Java Code Examples for android.app.Activity#isInMultiWindowMode()

The following examples show how to use android.app.Activity#isInMultiWindowMode() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: SmartSwipe   File: Util.java    License: Apache License 2.0 6 votes vote down vote up
public static boolean setStatusBarTransparent(Activity activity, boolean darkStatusBar) {
    View decorView = activity.getWindow().getDecorView();
    boolean isInMultiWindowMode = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && activity.isInMultiWindowMode();
    if (isInMultiWindowMode || Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return false;
    } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    } else {
        int systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        if (darkStatusBar && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        }
        decorView.setSystemUiVisibility(systemUiVisibility);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
    }
    return true;
}
 
Example 2
Source Project: cafebar   File: CafeBar.java    License: Apache License 2.0 6 votes vote down vote up
public Builder fitSystemWindow() {
    Activity activity = (Activity) mContext;
    Window window = activity.getWindow();
    if (window == null) {
        LogUtil.d("fitSystemWindow() window is null");
        return this;
    }

    WindowManager.LayoutParams params = window.getAttributes();
    int navigationBarHeight = CafeBarUtil.getNavigationBarHeight(mContext);

    boolean isInMultiWindowMode = false;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        isInMultiWindowMode = activity.isInMultiWindowMode();
    }

    if ((params.flags & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) ==
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) {
        mFitSystemWindow = navigationBarHeight > 0 && !isInMultiWindowMode;
    }
    return this;
}
 
Example 3
Source Project: Slide   File: NewsView.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static int getNumColumns(final int orientation, Activity context) {
    final int numColumns;
    boolean singleColumnMultiWindow = false;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        singleColumnMultiWindow =
                context.isInMultiWindowMode() && SettingValues.singleColumnMultiWindow;
    }
    if (orientation == Configuration.ORIENTATION_LANDSCAPE
            && SettingValues.isPro
            && !singleColumnMultiWindow) {
        numColumns = Reddit.dpWidth;
    } else if (orientation == Configuration.ORIENTATION_PORTRAIT
            && SettingValues.dualPortrait) {
        numColumns = 2;
    } else {
        numColumns = 1;
    }
    return numColumns;
}
 
Example 4
public static int getNumColumns(final int orientation, Activity context) {
    final int numColumns;
    boolean singleColumnMultiWindow = false;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        singleColumnMultiWindow = context.isInMultiWindowMode() && SettingValues.singleColumnMultiWindow;
    }
    if (orientation == Configuration.ORIENTATION_LANDSCAPE && SettingValues.isPro && !singleColumnMultiWindow) {
        numColumns = Reddit.dpWidth;
    } else if (orientation == Configuration.ORIENTATION_PORTRAIT
            && SettingValues.dualPortrait) {
        numColumns = 2;
    } else {
        numColumns = 1;
    }
    return numColumns;
}
 
Example 5
/**
 * Gets a Rect representing the usable area of the screen
 *
 * @return A Rect representing the usable area of the screen
 */
public static Rect getScreenRect(Activity activity) {
    if (activity != null) {
        Display display = activity.getWindowManager().getDefaultDisplay();
        DisplayMetrics metrics = new DisplayMetrics();
        Point size = new Point();
        int width, height;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && activity.isInMultiWindowMode()) {
                display.getMetrics(metrics);
            } else {
                display.getRealMetrics(metrics);
            }

            width = metrics.widthPixels;
            height = metrics.heightPixels;
        } else {
            display.getSize(size);
            width = size.x;
            height = size.y;
        }

        return new Rect(0, 0, Math.min(width, height), Math.max(width, height) - totalVerticalInset);
    }

    return new Rect();
}
 
Example 6
/**
 * @param activity The {@link Activity} to check.
 * @return Whether or not {@code activity} is currently in Android N+ multi-window mode.
 */
public static boolean isInMultiWindowMode(Activity activity) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
        return false;
    }
    return activity.isInMultiWindowMode();
}
 
Example 7
/**
 * Finds and returns the TRUE width of the screen
 *
 * @return
 */
public static int getScreenWidth(Activity activity) {
    if (activity != null) {
        Display display = activity.getWindowManager().getDefaultDisplay();
        DisplayMetrics metrics = new DisplayMetrics();
        Point size = new Point();
        int width, height;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && activity.isInMultiWindowMode()) {
                display.getMetrics(metrics);
            } else {
                display.getRealMetrics(metrics);
            }

            width = metrics.widthPixels;
            height = metrics.heightPixels;
        } else {
            display.getSize(size);
            width = size.x;
            height = size.y;
        }

        return Math.max(width, height);
    }

    return 0;
}
 
Example 8
Source Project: materialistic   File: AppUtils.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressLint("InlinedApi")
public static Intent multiWindowIntent(Activity activity, Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && activity.isInMultiWindowMode()) {
        intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT |
                Intent.FLAG_ACTIVITY_NEW_TASK |
                Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    }
    return intent;
}
 
Example 9
Source Project: SmartFlasher   File: Utils.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static int getOrientation(Activity activity) {
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && activity.isInMultiWindowMode() ?
            Configuration.ORIENTATION_PORTRAIT : activity.getResources().getConfiguration().orientation;
}
 
Example 10
public static int getOrientation(Activity activity) {
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && activity.isInMultiWindowMode() ?
            Configuration.ORIENTATION_PORTRAIT : activity.getResources().getConfiguration().orientation;
}
 
Example 11
public static int getOrientation(Activity activity) {
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && activity.isInMultiWindowMode() ?
            Configuration.ORIENTATION_PORTRAIT : activity.getResources().getConfiguration().orientation;
}
 
Example 12
Source Project: deviceinfo   File: Factory.java    License: Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.N)
private static boolean getMultiWindow(Activity activity) {
   return activity.isInMultiWindowMode();
}
 
Example 13
public static int getOrientation(Activity activity) {
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && activity.isInMultiWindowMode() ?
            Configuration.ORIENTATION_PORTRAIT : activity.getResources().getConfiguration().orientation;
}
 
Example 14
Source Project: zapp   File: MultiWindowHelper.java    License: MIT License 2 votes vote down vote up
/**
 * This function can be used with any API level and will return
 * false if the multi window feature is not supported.
 *
 * @param activity to get access to multi window api
 * @return true if activity is currently displayed in multi window mode
 */
@TargetApi(24)
public static boolean isInsideMultiWindow(Activity activity) {
	return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N &&
		(activity.isInMultiWindowMode() || activity.isInPictureInPictureMode());
}
 
Example 15
Source Project: ProjectX   File: AMActivityCompat.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Returns true if the activity is currently in multi-window mode.
 *
 * @return True if the activity is in multi-window mode.
 * @see android.R.attr#resizeableActivity
 */
public static boolean isInMultiWindowMode(Activity activity) {
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N &&
            activity.isInMultiWindowMode();
}