// Path: common-android-utils/src/main/java/com/common/android/utils/device/Dimension.java
// @Deprecated
// public class Dimension {
// 
//     public final int width, height;
// 
//     public Dimension(final int width, final int height) {
//         this.width = width;
//         this.height = height;
//     }
// 
//     public static String getDisplayCountry(@NonNull final Context context) {
//         return context.getResources().getConfiguration().locale.getDisplayCountry();
//     }
// 
//     @NonNull
//     @Override
//     public String toString() {
//         return "Dimension{" +
//                 "width=" + width +
//                 ", height=" + height +
//                 '}';
//     }
// 
//     @Override
//     public boolean equals(@Nullable final Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         final Dimension dimension = (Dimension) o;
// 
//         if (width != dimension.width) return false;
//         return height == dimension.height;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = width;
//         result = 31 * result + height;
//         return result;
//     }
// }
// 
// Path: common-android-utils/src/main/java/com/common/android/utils/ContextHelper.java
// @Nullable
// public static Activity getActivity() {
//     if (context == null)
//         return null;
// 
//     return context.get() instanceof Activity
//             ? (Activity) context.get()
//             : null;
// }
// 
// Path: common-android-utils/src/main/java/com/common/android/utils/ContextHelper.java
// @Nullable
// public static Context getContext() {
//     return context != null
//             ? context.get()
//             : null;
// }
// 
// Path: common-android-utils/src/main/java/com/common/android/utils/extensions/ViewExtensions.java
// public static View getContentRoot() {
//     return getActivity()
//             .getWindow()
//             .getDecorView()
//             .findViewById(android.R.id.content);
// }


import android.app.Service;
import android.content.Context;
import android.graphics.Point;
import android.support.annotation.NonNull;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import com.common.android.utils.device.Dimension;
import static android.os.Build.VERSION.SDK_INT;
import static com.common.android.utils.ContextHelper.getActivity;
import static com.common.android.utils.ContextHelper.getContext;
import static com.common.android.utils.extensions.ViewExtensions.getContentRoot;
package com.common.android.utils.extensions;




/**
 * Created by Jan Rabe on 24/09/15.
 */
final public class DeviceExtensions {

    private DeviceExtensions() throws IllegalAccessException {
        throw new IllegalAccessException();
    }

    @NonNull
    public static Dimension getScreenDimension() {
        final WindowManager w = getActivity().getWindowManager();
        final Display d = w.getDefaultDisplay();
        final DisplayMetrics metrics = new DisplayMetrics();
        d.getMetrics(metrics);
        // since SDK_INT = 1;
        Dimension dimension = new Dimension(metrics.widthPixels, metrics.heightPixels);
        // includes window decorations (statusbar bar/menu bar)
        if (SDK_INT >= 14 && SDK_INT < 17)
            try {
                dimension = new Dimension((Integer) Display.class.getMethod("getRawWidth").invoke(d), (Integer) Display.class.getMethod("getRawHeight").invoke(d));
            } catch (@NonNull final Exception ignored) {
            }
        // includes window decorations (statusbar bar/menu bar)
        if (SDK_INT >= 17)
            try {
                final Point realSize = new Point();
                Display.class.getMethod("getRealSize", Point.class).invoke(d, realSize);
                dimension = new Dimension(realSize.x, realSize.y);
            } catch (@NonNull final Exception ignored) {
            }
        return dimension;
    }

// Path: common-android-utils/src/main/java/com/common/android/utils/device/Dimension.java
// @Deprecated
// public class Dimension {
// 
//     public final int width, height;
// 
//     public Dimension(final int width, final int height) {
//         this.width = width;
//         this.height = height;
//     }
// 
//     public static String getDisplayCountry(@NonNull final Context context) {
//         return context.getResources().getConfiguration().locale.getDisplayCountry();
//     }
// 
//     @NonNull
//     @Override
//     public String toString() {
//         return "Dimension{" +
//                 "width=" + width +
//                 ", height=" + height +
//                 '}';
//     }
// 
//     @Override
//     public boolean equals(@Nullable final Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         final Dimension dimension = (Dimension) o;
// 
//         if (width != dimension.width) return false;
//         return height == dimension.height;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = width;
//         result = 31 * result + height;
//         return result;
//     }
// }
// 
// Path: common-android-utils/src/main/java/com/common/android/utils/ContextHelper.java
// @Nullable
// public static Activity getActivity() {
//     if (context == null)
//         return null;
// 
//     return context.get() instanceof Activity
//             ? (Activity) context.get()
//             : null;
// }
// 
// Path: common-android-utils/src/main/java/com/common/android/utils/ContextHelper.java
// @Nullable
// public static Context getContext() {
//     return context != null
//             ? context.get()
//             : null;
// }
// 
// Path: common-android-utils/src/main/java/com/common/android/utils/extensions/ViewExtensions.java
// public static View getContentRoot() {
//     return getActivity()
//             .getWindow()
//             .getDecorView()
//             .findViewById(android.R.id.content);
// }


// Path: common-android-utils/src/main/java/com/common/android/utils/extensions/DeviceExtensions.java
import android.app.Service;
import android.content.Context;
import android.graphics.Point;
import android.support.annotation.NonNull;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import com.common.android.utils.device.Dimension;
import static android.os.Build.VERSION.SDK_INT;
import static com.common.android.utils.ContextHelper.getActivity;
import static com.common.android.utils.ContextHelper.getContext;
import static com.common.android.utils.extensions.ViewExtensions.getContentRoot;

package com.common.android.utils.extensions;




/**
 * Created by Jan Rabe on 24/09/15.
 */
final public class DeviceExtensions {

    private DeviceExtensions() throws IllegalAccessException {
        throw new IllegalAccessException();
    }

    @NonNull
    public static Dimension getScreenDimension() {
        final WindowManager w = getActivity().getWindowManager();
        final Display d = w.getDefaultDisplay();
        final DisplayMetrics metrics = new DisplayMetrics();
        d.getMetrics(metrics);
        // since SDK_INT = 1;
        Dimension dimension = new Dimension(metrics.widthPixels, metrics.heightPixels);
        // includes window decorations (statusbar bar/menu bar)
        if (SDK_INT >= 14 && SDK_INT < 17)
            try {
                dimension = new Dimension((Integer) Display.class.getMethod("getRawWidth").invoke(d), (Integer) Display.class.getMethod("getRawHeight").invoke(d));
            } catch (@NonNull final Exception ignored) {
            }
        // includes window decorations (statusbar bar/menu bar)
        if (SDK_INT >= 17)
            try {
                final Point realSize = new Point();
                Display.class.getMethod("getRealSize", Point.class).invoke(d, realSize);
                dimension = new Dimension(realSize.x, realSize.y);
            } catch (@NonNull final Exception ignored) {
            }
        return dimension;
    }

    public static void showKeyboard() {