android.view.View#SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR源码实例Demo

下面列出了android.view.View#SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: GeometricWeather   文件: DisplayUtils.java
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);
}
 
源代码2 项目: SimplicityBrowser   文件: StaticUtils.java
public static void clearNavigationBar(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        int flags = activity.getWindow().getDecorView().getSystemUiVisibility(); // get current flag
        flags &= ~ View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; // use XOR here for remove LIGHT_STATUS_BAR from flags_settings
        activity.getWindow().getDecorView().setSystemUiVisibility(flags);
    }
}
 
源代码3 项目: Android-utils   文件: BarUtils.java
/**
 * Set the nav bar's light mode.
 *
 * @param window      The window.
 * @param isLightMode True to set nav bar light mode, false otherwise.
 */
public static void setNavBarLightMode(@NonNull final Window window,
                                      final boolean isLightMode) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        View decorView = window.getDecorView();
        int vis = decorView.getSystemUiVisibility();
        if (isLightMode) {
            vis |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        } else {
            vis &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        }
        decorView.setSystemUiVisibility(vis);
    }
}
 
源代码4 项目: Notepad   文件: NotepadBaseActivity.java
@Override
protected void onResume() {
    super.onResume();

    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
        SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", MODE_PRIVATE);
        String theme = pref.getString("theme", "light-sans");

        int navbarColorId = -1;
        int navbarDividerColorId = -1;
        int sysUiVisibility = -1;

        if(theme.contains("light")) {
            navbarColorId = R.color.navbar_color_light;
            navbarDividerColorId = R.color.navbar_divider_color_light;
            sysUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        }

        if(theme.contains("dark")) {
            navbarColorId = R.color.navbar_color_dark;
            navbarDividerColorId = R.color.navbar_divider_color_dark;
            sysUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE;
        }

        getWindow().setNavigationBarColor(ContextCompat.getColor(this, navbarColorId));
        findViewById(Window.ID_ANDROID_CONTENT).setSystemUiVisibility(sysUiVisibility);

        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
            getWindow().setNavigationBarDividerColor(ContextCompat.getColor(this, navbarDividerColorId));
    }
}
 
源代码5 项目: DevUtils   文件: BarUtils.java
/**
 * 设置 Navigation Bar 是否高亮模式
 * @param window      {@link Window}
 * @param isLightMode 是否高亮模式
 * @return {@code true} success, {@code false} fail
 */
public static boolean setNavBarLightMode(final Window window, final boolean isLightMode) {
    if (window != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        View decorView = window.getDecorView();
        int vis = decorView.getSystemUiVisibility();
        if (isLightMode) {
            vis |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        } else {
            vis &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        }
        decorView.setSystemUiVisibility(vis);
        return true;
    }
    return false;
}
 
源代码6 项目: DevUtils   文件: BarUtils.java
/**
 * 获取 Navigation Bar 是否高亮模式
 * @param window {@link Window}
 * @return {@code true} yes, {@code false} no
 */
public static boolean isNavBarLightMode(final Window window) {
    if (window != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        View decorView = window.getDecorView();
        int vis = decorView.getSystemUiVisibility();
        return (vis & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) != 0;
    }
    return false;
}
 
源代码7 项目: AndroidBarUtils   文件: AndroidBarUtils.java
/**
     * Android 6.0使用原始的主题适配
     *
     * @param activity Activity
     * @param darkMode 是否是黑色模式
     */
    public static void setBarDarkMode(Activity activity, boolean darkMode) {
        Window window = activity.getWindow();
        if (window == null) {
            return;
        }
        //设置StatusBar模式
        if (darkMode) {//黑色模式
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {//设置statusBar和navigationBar为黑色
                    window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
                } else {//设置statusBar为黑色
                    window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
                }
            }
        } else {//白色模式
            int statusBarFlag = View.SYSTEM_UI_FLAG_VISIBLE;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                statusBarFlag = window.getDecorView().getSystemUiVisibility()
                        & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
            }
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {//设置statusBar为白色,navigationBar为灰色
//                int navBarFlag = window.getDecorView().getSystemUiVisibility()
//                        & ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;//如果想让navigationBar为白色,那么就使用这个代码。
                int navBarFlag = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
                window.getDecorView().setSystemUiVisibility(navBarFlag | statusBarFlag);
            } else {
                window.getDecorView().setSystemUiVisibility(statusBarFlag);
            }
        }
        setHuaWeiStatusBar(darkMode, window);
    }
 
源代码8 项目: AndroidNavigation   文件: AppUtils.java
public static void setNavigationBarStyle(Window window, boolean dark) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        View decorView = window.getDecorView();
        int systemUi = decorView.getSystemUiVisibility();
        if (dark) {
            systemUi |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        } else {
            systemUi &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        }
        decorView.setSystemUiVisibility(systemUi);
    }
}
 
源代码9 项目: MyBookshelf   文件: ImmersionBar.java
/**
 * 设置暗色导航栏按钮
 */
private int setNavigationBarLightFont(int uiFlags) {
    if (canNavigationBarDarkFont() && mBarParams.navigationBarDarkFont) {
        return uiFlags | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
    } else {
        return uiFlags;
    }
}
 
源代码10 项目: Telegram-FOSS   文件: AndroidUtilities.java
public static void setLightNavigationBar(Window window, boolean enable) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        final View decorView = window.getDecorView();
        int flags = decorView.getSystemUiVisibility();
        if (enable) {
            flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        } else {
            flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        }
        decorView.setSystemUiVisibility(flags);
    }
}
 
源代码11 项目: LaunchEnr   文件: WidgetsBottomSheet.java
public void populateAndShow(ItemInfo itemInfo) {
    mOriginalItemInfo = itemInfo;
    ((TextView) findViewById(R.id.title)).setText(getContext().getString(
            R.string.widgets_bottom_sheet_title, mOriginalItemInfo.title));

    onWidgetsBound();

    mWasNavBarLight = (mLauncher.getWindow().getDecorView().getSystemUiVisibility()
            & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) != 0;
    mLauncher.getDragLayer().addView(this);
    measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    setTranslationY(mTranslationYClosed);
    mIsOpen = false;
    open(true);
}
 
源代码12 项目: Telegram   文件: AndroidUtilities.java
public static void setLightNavigationBar(Window window, boolean enable) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        final View decorView = window.getDecorView();
        int flags = decorView.getSystemUiVisibility();
        if (enable) {
            flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        } else {
            flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        }
        decorView.setSystemUiVisibility(flags);
    }
}
 
源代码13 项目: ImmersionBar   文件: ImmersionBar.java
/**
 * 设置导航栏图标亮色与暗色
 * Sets dark navigation icon.
 */
private int setNavigationIconDark(int uiFlags) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && mBarParams.navigationBarDarkIcon) {
        return uiFlags | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
    } else {
        return uiFlags;
    }
}
 
源代码14 项目: dynamic-utils   文件: DynamicViewUtils.java
/**
 * Set light navigation bar if we are using light primary color on API 26 and above devices.
 *
 * @param view The view to get the system ui flags.
 * @param light {@code true} to set the light navigation bar.
 */
@TargetApi(Build.VERSION_CODES.O)
public static void setLightNavigationBar(@NonNull View view, boolean light) {
    if (DynamicSdkUtils.is26()) {
        int flags = view.getSystemUiVisibility();
        if (light) {
            flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        } else {
            flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        }

        view.setSystemUiVisibility(flags);
    }
}
 
源代码15 项目: MNImageBrowser   文件: ImmersionBar.java
/**
 * 设置导航栏图标亮色与暗色
 * Sets dark navigation icon.
 */
private int setNavigationIconDark(int uiFlags) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && mBarParams.navigationBarDarkIcon) {
        return uiFlags | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
    } else {
        return uiFlags;
    }
}
 
源代码16 项目: AndroidUtilCode   文件: BarUtils.java
/**
 * Set the nav bar's light mode.
 *
 * @param window      The window.
 * @param isLightMode True to set nav bar light mode, false otherwise.
 */
public static void setNavBarLightMode(@NonNull final Window window,
                                      final boolean isLightMode) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        View decorView = window.getDecorView();
        int vis = decorView.getSystemUiVisibility();
        if (isLightMode) {
            vis |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        } else {
            vis &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        }
        decorView.setSystemUiVisibility(vis);
    }
}
 
源代码17 项目: AndroidUtilCode   文件: BarUtils.java
/**
 * Is the nav bar light mode.
 *
 * @param window The window.
 * @return {@code true}: yes<br>{@code false}: no
 */
public static boolean isNavBarLightMode(@NonNull final Window window) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        View decorView = window.getDecorView();
        int vis = decorView.getSystemUiVisibility();
        return (vis & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) != 0;
    }
    return false;
}
 
源代码18 项目: react-native-navigation   文件: Presenter.java
private void setNavigationBarButtonsColor(int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        View decorView = activity.getWindow().getDecorView();
        int flags = decorView.getSystemUiVisibility();
        if (isColorLight(color)) {
            flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        } else {
            flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        }
        decorView.setSystemUiVisibility(flags);
    }
}
 
源代码19 项目: candybar   文件: CandyBarMainActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.setTheme(Preferences.get(this).isDarkTheme() ?
            R.style.AppThemeDark : R.style.AppTheme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ColorHelper.setupStatusBarIconColor(this);
    ColorHelper.setNavigationBarColor(this, ContextCompat.getColor(this,
            Preferences.get(this).isDarkTheme() ?
                    R.color.navigationBarDark : R.color.navigationBar));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !Preferences.get(this).isDarkTheme()) {
        int flags = 0;
        if (ColorHelper.isLightColor(ContextCompat.getColor(this, R.color.navigationBar)))
            flags = flags | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        if (ColorHelper.isLightColor(ContextCompat.getColor(this, R.color.colorPrimaryDark)))
            flags = flags | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        if (flags != 0) {
            this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            this.getWindow().getDecorView().setSystemUiVisibility(flags);
            this.getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
        }
    }

    registerBroadcastReceiver();
    startService(new Intent(this, CandyBarService.class));

    //Todo: wait until google fix the issue, then enable wallpaper crop again on API 26+
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        Preferences.get(this).setCropWallpaper(false);
    }

    mConfig = onInit();
    InAppBillingProcessor.get(this).init(mConfig.getLicenseKey());

    mDrawerLayout = findViewById(R.id.drawer_layout);
    mNavigationView = findViewById(R.id.navigation_view);
    Toolbar toolbar = findViewById(R.id.toolbar);
    mToolbarTitle = findViewById(R.id.toolbar_title);

    toolbar.setPopupTheme(Preferences.get(this).isDarkTheme() ?
            R.style.AppThemeDark : R.style.AppTheme);
    toolbar.setTitle("");
    setSupportActionBar(toolbar);

    mFragManager = getSupportFragmentManager();

    initNavigationView(toolbar);
    initNavigationViewHeader();

    mPosition = mLastPosition = 0;
    if (savedInstanceState != null) {
        mPosition = mLastPosition = savedInstanceState.getInt(Extras.EXTRA_POSITION, 0);
        onSearchExpanded(false);
    }

    Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        int position = bundle.getInt(Extras.EXTRA_POSITION, -1);
        if (position >= 0 && position < 5) {
            mPosition = mLastPosition = position;
        }
    }

    IntentHelper.sAction = IntentHelper.getAction(getIntent());
    if (IntentHelper.sAction == IntentHelper.ACTION_DEFAULT) {
        setFragment(getFragment(mPosition));
    } else {
        setFragment(getActionFragment(IntentHelper.sAction));
    }

    checkWallpapers();
    IconRequestTask.start(this, AsyncTask.THREAD_POOL_EXECUTOR);
    IconsLoaderTask.start(this);

    new PlaystoreCheckHelper(this).run();

    if (Preferences.get(this).isFirstRun() && mConfig.isLicenseCheckerEnabled()) {
        mLicenseHelper = new LicenseHelper(this);
        mLicenseHelper.run(mConfig.getLicenseKey(), mConfig.getRandomString(), new LicenseCallbackHelper(this));
        return;
    }

    if (!Preferences.get(this).isPlaystoreCheckEnabled() && !mConfig.isLicenseCheckerEnabled()) {
        if (Preferences.get(this).isNewVersion()) {
            ChangelogFragment.showChangelog(mFragManager);
            File cache = this.getCacheDir();
            FileHelper.clearDirectory(cache);
        }
    }

    if (mConfig.isLicenseCheckerEnabled() && !Preferences.get(this).isLicensed()) {
        finish();
    }
}
 
源代码20 项目: AndroidNavigation   文件: AppUtils.java
public static boolean isDarNavigationBarStyle(Window window) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        return (window.getDecorView().getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) != 0;
    }
    return false;
}
 
 方法所在类
 同类方法