Java Code Examples for android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION

The following examples show how to use android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION . 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 File: Util.java    From DMusic with Apache License 2.0 6 votes vote down vote up
/**
 * 隐藏状态栏&&导航栏
 */
public static void hideSystemUI(Activity activity, View... views) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        // 4.1 above API level 16
        int uist = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LOW_PROFILE
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            uist |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        }
        View decorView = activity.getWindow().getDecorView();
        decorView.setSystemUiVisibility(uist);
        // Some views can setFitsSystemWindows(true), setPadding()
        setFitsPadding(0, getStatusBarHeight(activity), getNavigationBarHeight(activity), 0, views);
    } else {
        WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
        attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        activity.getWindow().setAttributes(attrs);
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    }
}
 
Example 2
Source File: CordovaActivity.java    From xmall with MIT License 6 votes vote down vote up
/**
 * Called when view focus is changed
 */
@SuppressLint("InlinedApi")
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus && immersiveMode) {
        final int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

        getWindow().getDecorView().setSystemUiVisibility(uiOptions);
    }
}
 
Example 3
Source File: ImmersionBar.java    From a with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Hide bar.
 * 隐藏或显示状态栏和导航栏。
 *
 * @param uiFlags the ui flags
 * @return the int
 */

@SuppressLint("ObsoleteSdkInt")
private int hideBar(int uiFlags) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        switch (mBarParams.barHide) {
            case FLAG_HIDE_BAR:
                uiFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.INVISIBLE;
                break;
            case FLAG_HIDE_STATUS_BAR:
                uiFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.INVISIBLE;
                break;
            case FLAG_HIDE_NAVIGATION_BAR:
                uiFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
                break;
            case FLAG_SHOW_BAR:
                uiFlags |= View.SYSTEM_UI_FLAG_VISIBLE;
                break;
        }
    }
    return uiFlags | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
}
 
Example 4
Source File: DisplayUtils.java    From GeometricWeather with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void setSystemBarStyle(Context context, Window window, boolean miniAlpha,
                                     boolean statusShader, boolean lightStatus,
                                     boolean navigationShader, boolean lightNavigation) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return;
    }

    // statusShader &= Build.VERSION.SDK_INT < Build.VERSION_CODES.Q;
    lightStatus &= Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
    navigationShader &= Build.VERSION.SDK_INT < Build.VERSION_CODES.Q;
    lightNavigation &= Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;

    int visibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
    if (lightStatus) {
        visibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    }
    if (lightNavigation) {
        visibility |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
    }
    window.getDecorView().setSystemUiVisibility(visibility);

    setSystemBarColor(context, window, miniAlpha, statusShader, lightStatus, navigationShader, lightNavigation);
}
 
Example 5
Source File: VerticalReaderActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    MobclickAgent.onResume(this);

    // set navigation bar status, remember to disable "setNavigationBarTintEnabled"
    final int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    // This work only for android 4.4+
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        getWindow().getDecorView().setSystemUiVisibility(flags);

        // Code below is to handle presses of Volume up or Volume down.
        // Without this, after pressing volume buttons, the navigation bar will
        // show up and won't hide
        final View decorView = getWindow().getDecorView();
        decorView.setOnSystemUiVisibilityChangeListener(visibility -> {
            if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                decorView.setSystemUiVisibility(flags);
            }
        });
    }
}
 
Example 6
Source File: AndroidUtil.java    From Alite with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("InlinedApi")
public static void setImmersion(View view) {
	if (view == null || Settings.navButtonsVisible) {
		return;
	}
	int flags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
		flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
	} 
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
		flags |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
				View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
				View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
				View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
				View.SYSTEM_UI_FLAG_FULLSCREEN;					
	}
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
		flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;	
	}
	if (flags != 0) {
		view.setSystemUiVisibility(flags);
	}
}
 
Example 7
Source File: DisplayUtils.java    From Mysplash with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void setSystemBarStyle(MysplashActivity activity, boolean miniAlpha,
                                     boolean statusShader, boolean lightStatus,
                                     boolean navigationShader, boolean lightNavigation) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return;
    }

    statusShader &= Build.VERSION.SDK_INT < Build.VERSION_CODES.Q;
    lightStatus &= Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
    navigationShader &= Build.VERSION.SDK_INT < Build.VERSION_CODES.Q;
    lightNavigation &= Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;

    int visibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
    if (lightStatus) {
        visibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    }
    if (lightNavigation) {
        visibility |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
    }
    activity.getWindow().getDecorView().setSystemUiVisibility(visibility);

    setSystemBarColor(activity, miniAlpha, statusShader, lightStatus, navigationShader, lightNavigation);
}
 
Example 8
Source File: InitActivity.java    From Rucky with GNU General Public License v3.0 6 votes vote down vote up
public void hideNavigationBar() {
    final View decorView = this.getWindow().getDecorView();
    final int uiOptions =
            View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_IMMERSIVE
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

    Timer timer = new Timer();
    TimerTask task = new TimerTask() {
        @Override
        public void run() {
            InitActivity.this.runOnUiThread(() -> decorView.setSystemUiVisibility(uiOptions));
        }
    };
    timer.scheduleAtFixedRate(task, 1, 2);

}
 
Example 9
Source File: CordovaActivity.java    From keemob with MIT License 6 votes vote down vote up
/**
 * Called when view focus is changed
 */
@SuppressLint("InlinedApi")
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus && immersiveMode) {
        final int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

        getWindow().getDecorView().setSystemUiVisibility(uiOptions);
    }
}
 
Example 10
Source File: BarUtils.java    From DevUtils with Apache License 2.0 6 votes vote down vote up
/**
 * 设置 Navigation Bar 是否可见
 * @param window    {@link Window}
 * @param isVisible 是否显示 Navigation Bar
 * @return {@code true} success, {@code false} fail
 */
public static boolean setNavBarVisibility(final Window window, final boolean isVisible) {
    if (window != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        final ViewGroup decorView = (ViewGroup) window.getDecorView();
        for (int i = 0, count = decorView.getChildCount(); i < count; i++) {
            final View child = decorView.getChildAt(i);
            final int id = child.getId();
            if (id != View.NO_ID) {
                String resourceEntryName = Resources.getSystem().getResourceEntryName(id);
                if ("navigationBarBackground".equals(resourceEntryName)) {
                    child.setVisibility(isVisible ? View.VISIBLE : View.INVISIBLE);
                }
            }
        }
        final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        if (isVisible) {
            decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() & ~uiOptions);
        } else {
            decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() | uiOptions);
        }
        return true;
    }
    return false;
}
 
Example 11
Source File: StatusBarUtil.java    From Android-Architecture with Apache License 2.0 6 votes vote down vote up
/**
 * 设置状态栏颜色
 *
 * @param activity
 * @param color
 */
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static void setColor(Activity activity, int color) {
    View decorView = activity.getWindow().getDecorView();
    int option = View.SYSTEM_UI_FLAG_LAYOUT_STABLE //
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN//全屏,显示状态栏
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;//隐藏虚拟按键
    decorView.setSystemUiVisibility(option);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        //添加flag来设置状态栏颜色
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().setStatusBarColor(color);//设置状态栏颜色
        if (NavigationBarUtil.hasNavigationBar(activity)) {//若有虚拟按键
            activity.getWindow().setNavigationBarColor(color);//设置虚拟按键颜色
        }
    } else {//处理4.4
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }
}
 
Example 12
Source File: ViewUtils.java    From HgLauncher with GNU General Public License v3.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static int setWindowbarMode(String mode) {
    int baseLayout;
    if (Utils.sdkIsAround(19)) {
        baseLayout = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    } else {
        baseLayout = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
    }
    int noStatusLayout = baseLayout
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_FULLSCREEN;
    int noNavLayout = baseLayout
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

    switch (mode) {
        case "status":
            return noStatusLayout;
        case "nav":
            return noNavLayout;
        case "both":
            return noStatusLayout | noNavLayout;
        case "none":
        default:
            return View.SYSTEM_UI_LAYOUT_FLAGS;
    }
}
 
Example 13
Source File: VideoRecordActivity.java    From PLDroidShortVideo with Apache License 2.0 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    if (Build.VERSION.SDK_INT >= 19 && Utils.checkDeviceHasNavigationBar(this)) {
        int flag = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide
                | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        mDecorView.setSystemUiVisibility(flag);
    }
}
 
Example 14
Source File: ImmersiveModeFragment.java    From SkyTube with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Change the navigation bar's visibility status.
 */
private void changeNavigationBarVisibility(boolean setBarToVisible) {
	try {
		int newUiOptions = getActivity().getWindow().getDecorView().getSystemUiVisibility();

		// navigation bar hiding:  backwards compatible to ICS.
		if (Build.VERSION.SDK_INT >= 14) {
			newUiOptions = setBarToVisible
					? newUiOptions & ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
					: newUiOptions | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
		}

		// status bar hiding:  backwards compatible to Jellybean
		if (Build.VERSION.SDK_INT >= 16) {
			newUiOptions = setBarToVisible
					? newUiOptions & ~View.SYSTEM_UI_FLAG_FULLSCREEN & ~View.SYSTEM_UI_FLAG_LAYOUT_STABLE & ~View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION & ~View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
					: newUiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
		}

		// immersive mode:  backward compatible to KitKat
		if (Build.VERSION.SDK_INT >= 19) {
			newUiOptions = setBarToVisible
					? newUiOptions & ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
					: newUiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
		}

		getActivity().getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
	} catch (Throwable tr) {
		Logger.e(this, "Exception caught while trying to change the nav bar visibility...", tr);
	}
}
 
Example 15
Source File: ExoVideoControlsMobile.java    From v9porn with MIT License 5 votes vote down vote up
/**
 * Correctly sets up the fullscreen flags to avoid popping when we switch
 * between fullscreen and not
 */
private void initUiFlags() {
    int flags = View.SYSTEM_UI_FLAG_VISIBLE;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        flags |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
    }
    View decorView = ActivityUtils.getWindow(getContext()).getDecorView();
    if (decorView != null) {
        decorView.setSystemUiVisibility(flags);
        decorView.setOnSystemUiVisibilityChangeListener(fullScreenListener);
    }
}
 
Example 16
Source File: BaseActivity.java    From Android-Application-ZJB with Apache License 2.0 5 votes vote down vote up
/**
 * If the Android version is higher than KitKat(API>=19) <br> use this call to show & hide
 *
 * @param enable
 */
@SuppressLint("NewApi")
public final void makeFullScreenAfterKitKat(boolean enable) {
    try {
        View decorView = getWindow().getDecorView();
        if (enable) {
            int uiOptionsEnable = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
            decorView.setSystemUiVisibility(uiOptionsEnable);

        } else {
            int uiOptionsDisable = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
            decorView.setSystemUiVisibility(uiOptionsDisable);
        }

    } catch (Exception e) {
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        if (enable) {
            lp.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        } else {
            lp.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }
        getWindow().setAttributes(lp);
    }
}
 
Example 17
Source File: CordovaActivity.java    From ultimate-cordova-webview-app with MIT License 5 votes vote down vote up
/**
 * Called when view focus is changed
 */
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus && immersiveMode) {
        final int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

        getWindow().getDecorView().setSystemUiVisibility(uiOptions);
    }
}
 
Example 18
Source File: SystemUiHelperImplJB.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
@Override
protected int createShowFlags() {
    int flag = super.createShowFlags();

    if (mLevel >= SystemUiHelper.LEVEL_HIDE_STATUS_BAR) {
        flag |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;

        if (mLevel >= SystemUiHelper.LEVEL_LEAN_BACK) {
            flag |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        }
    }

    return flag;
}
 
Example 19
Source File: Utils.java    From Musicoco with Apache License 2.0 5 votes vote down vote up
@Deprecated
    public static void hideSystemNavigationBar(Activity activity) {
        if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) {
            View view = activity.getWindow().getDecorView();
            view.setSystemUiVisibility(View.GONE);
        } else if (Build.VERSION.SDK_INT >= 19) {
            View decorView = activity.getWindow().getDecorView();
            int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
//            | View.SYSTEM_UI_FLAG_FULLSCREEN;
            decorView.setSystemUiVisibility(uiOptions);
        }
    }
 
Example 20
Source File: ModExpandedDesktop.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
    if (DEBUG_LAYOUT) log("getContentInsetHintLw");
    try {
        if (!isImmersiveModeActive()) {
            return XposedBridge.invokeOriginalMethod(param.method, param.thisObject, param.args);
        }

        WindowManager.LayoutParams attrs = (WindowManager.LayoutParams) param.args[0];
        final int displayRotation = (int) param.args[1];
        Rect contentInset = (Rect) param.args[2];
        Rect stableInset = (Rect) param.args[3];
        Rect outOutsets = (Rect) param.args[4];

        final int fl = updateWindowManagerVisibilityFlagsForExpandedDesktop(attrs.flags);
        final int systemUiVisibility = updateSystemUiVisibilityFlagsForExpandedDesktop(attrs.systemUiVisibility |
                XposedHelpers.getIntField(attrs, "subtreeSystemUiVisibility"));

        final boolean useOutsets = outOutsets != null &&
                (boolean) mShouldUseOutsets.invoke(param.thisObject, attrs, fl);
        if (useOutsets) {
            int outset = (int) XposedHelpers.callStaticMethod(mClsScreenShapeHelper,
                    "getWindowOutsetBottomPx", mContext.getResources());
            if (outset > 0) {
                if (displayRotation == Surface.ROTATION_0) {
                    outOutsets.bottom += outset;
                } else if (displayRotation == Surface.ROTATION_90) {
                    outOutsets.right += outset;
                } else if (displayRotation == Surface.ROTATION_180) {
                    outOutsets.top += outset;
                } else if (displayRotation == Surface.ROTATION_270) {
                    outOutsets.left += outset;
                }
            }
        }

        if ((fl & (WmLp.FLAG_LAYOUT_IN_SCREEN | WmLp.FLAG_LAYOUT_INSET_DECOR))
                == (WmLp.FLAG_LAYOUT_IN_SCREEN | WmLp.FLAG_LAYOUT_INSET_DECOR)) {
            int availRight, availBottom;
            if ((Boolean) mCanHideNavigationBar.invoke(param.thisObject) &&
                    (systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0) {
                availRight = getInt("mUnrestrictedScreenLeft") + getInt("mUnrestrictedScreenWidth");
                availBottom = getInt("mUnrestrictedScreenTop") + getInt("mUnrestrictedScreenHeight");
            } else {
                availRight = getInt("mRestrictedScreenLeft") + getInt("mRestrictedScreenWidth");
                availBottom = getInt("mRestrictedScreenTop") + getInt("mRestrictedScreenHeight");
            }
            if ((systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) {
                if ((fl & WmLp.FLAG_FULLSCREEN) != 0) {
                    contentInset.set(getInt("mStableFullscreenLeft"), getInt("mStableFullscreenTop"),
                            availRight - getInt("mStableFullscreenRight"),
                            availBottom - getInt("mStableFullscreenBottom"));
                } else {
                    contentInset.set(getInt("mStableLeft"), getInt("mStableTop"),
                            availRight - getInt("mStableRight"), availBottom - getInt("mStableBottom"));
                }
            } else if ((fl & WmLp.FLAG_FULLSCREEN) != 0 || (fl & WmLp.FLAG_LAYOUT_IN_OVERSCAN) != 0) {
                contentInset.setEmpty();
            } else if ((systemUiVisibility & (View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)) == 0) {
                contentInset.set(getInt("mCurLeft"), getInt("mCurTop"),
                        availRight - getInt("mCurRight"), availBottom - getInt("mCurBottom"));
            } else {
                contentInset.set(getInt("mCurLeft"), getInt("mCurTop"),
                        availRight - getInt("mCurRight"), availBottom - getInt("mCurBottom"));
            }

            if (stableInset != null) {
                stableInset.set(getInt("mStableLeft"), getInt("mStableTop"),
                        availRight - getInt("mStableRight"),
                        availBottom - getInt("mStableBottom"));
            }

            return null;
        }
        contentInset.setEmpty();
        if (stableInset != null) {
            stableInset.setEmpty();
        }
        return null;
    } catch (Throwable t) {
        logAndMute(param.method.getName(), t);
        return XposedBridge.invokeOriginalMethod(param.method, param.thisObject, param.args);
    }
}