Java Code Examples for android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR

The following are Jave code examples for showing how to use SYSTEM_UI_FLAG_LIGHT_STATUS_BAR of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: BilibiliClient   File: StatusBarUtil.java   Source Code and License Vote up 7 votes
@TargetApi(Build.VERSION_CODES.M)
private void processM() {

  if (current < Build.VERSION_CODES.M) {
    return;
  }
  int flag = window.getDecorView().getSystemUiVisibility();
  if (lightStatusBar) {
    /**
     * 改变字体颜色
     * see {@link <a href="https://developer.android.com/reference/android/R.attr.html#windowLightStatusBar"></a>}
     */
    flag |= (WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
        | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    window.setStatusBarColor(Color.TRANSPARENT);
  }
  if (transparentStatusBar) {
    flag |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
    window.setStatusBarColor(Color.TRANSPARENT);
  }
  if (transparentNavigationbar) {
    flag |= (View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    window.setNavigationBarColor(Color.TRANSPARENT);
  }
  window.getDecorView().setSystemUiVisibility(flag);
}
 
Example 2
Project: SimpleUILauncher   File: Launcher.java   Source Code and License Vote up 6 votes
/**
 * Sets the status bar to be light or not. Light status bar means dark icons.
 * @param activate if true, make sure the status bar is light, otherwise base on wallpaper.
 */
public void activateLightStatusBar(boolean activate) {
    boolean lightStatusBar = activate || (FeatureFlags.LIGHT_STATUS_BAR
            && mExtractedColors.getColor(ExtractedColors.STATUS_BAR_INDEX,
            ExtractedColors.DEFAULT_DARK) == ExtractedColors.DEFAULT_LIGHT);
    int oldSystemUiFlags = getWindow().getDecorView().getSystemUiVisibility();
    int newSystemUiFlags = oldSystemUiFlags;
    if (lightStatusBar) {
        newSystemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    } else {
        newSystemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    }
    if (newSystemUiFlags != oldSystemUiFlags) {
        getWindow().getDecorView().setSystemUiVisibility(newSystemUiFlags);
    }
}
 
Example 3
Project: LaunchEnr   File: Launcher.java   Source Code and License Vote up 6 votes
/**
 * Sets the status and/or nav bar to be light or not. Light status bar means dark icons.
 * @param isLight make sure the system bar is light.
 * @param statusBar if true, make the status bar theme match the isLight param.
 * @param navBar if true, make the nav bar theme match the isLight param.
 */
@TargetApi(23)
public void activateLightSystemBars(boolean isLight, boolean statusBar, boolean navBar) {
    int oldSystemUiFlags = getWindow().getDecorView().getSystemUiVisibility();
    int newSystemUiFlags = oldSystemUiFlags;
    if (isLight) {
        if (statusBar) {
            newSystemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        }
        if (navBar && AndroidVersion.isAtLeastOreo()) {
            newSystemUiFlags |= SYSTEM_UI_FLAG_LIGHT_NAV_BAR;
        }
    } else {
        if (statusBar) {
            newSystemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }
        if (navBar && AndroidVersion.isAtLeastOreo()) {
            newSystemUiFlags &= ~(SYSTEM_UI_FLAG_LIGHT_NAV_BAR);
        }
    }

    if (newSystemUiFlags != oldSystemUiFlags) {
        getWindow().getDecorView().setSystemUiVisibility(newSystemUiFlags);
    }
}
 
Example 4
Project: FastAndroid   File: UIStatusBarController.java   Source Code and License Vote up 6 votes
/**
 * OPPO低版本系统(处理白色状态栏黑色字体兼容问题)
 * 详细问题请参照OPPO开放平台:https://open.oppomobile.com/wiki/index#id=73494
 * @param darkMode
 * @param activity
 */
public void setOPPOStatusBar(boolean darkMode,Activity activity) {
    final int SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT = 0x00000010;
    Window window = activity.getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    int vis = window.getDecorView().getSystemUiVisibility();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (darkMode) {
            vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        } else {
            vis |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        }
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES. KITKAT) {
        if (darkMode) {
            vis &= ~SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT;
        } else {
            vis |= SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT;
        }
    }
    window.getDecorView().setSystemUiVisibility(vis);
}
 
Example 5
Project: GitHub   File: DeliveryStyleActivity.java   Source Code and License Vote up 5 votes
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    switch (Item.values()[position]) {
        case 默认主题:
            mToolbar.setBackgroundResource(android.R.color.white);
            mToolbar.setTitleTextColor(0xffbbbbbb);
            mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_gray_24dp);
            mRefreshLayout.setPrimaryColors(0xfff0f0f0, 0xffffffff);
            if (Build.VERSION.SDK_INT >= 21) {
                getWindow().setStatusBarColor(0xfff0f0f0);
            }
            if (Build.VERSION.SDK_INT >= 23) {
                Window window = getWindow();
                int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
                systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
                window.getDecorView().setSystemUiVisibility(systemUiVisibility);
            }
            break;
        case 蓝色主题:
            setThemeColor(R.color.colorPrimary, R.color.colorPrimaryDark);
            break;
        case 绿色主题:
            setThemeColor(android.R.color.holo_green_light, android.R.color.holo_green_dark);
            break;
        case 红色主题:
            setThemeColor(android.R.color.holo_red_light, android.R.color.holo_red_dark);
            break;
        case 橙色主题:
            setThemeColor(android.R.color.holo_orange_light, android.R.color.holo_orange_dark);
            break;
    }
    mRefreshLayout.autoRefresh();
}
 
Example 6
Project: GitHub   File: DeliveryStyleActivity.java   Source Code and License Vote up 5 votes
private void setThemeColor(int colorPrimary, int colorPrimaryDark) {
    mToolbar.setBackgroundResource(colorPrimary);
    mToolbar.setTitleTextColor(ContextCompat.getColor(this, android.R.color.white));
    mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
    mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white);
    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark));
    }
    if (Build.VERSION.SDK_INT >= 23) {
        Window window = getWindow();
        int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
        systemUiVisibility &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        window.getDecorView().setSystemUiVisibility(systemUiVisibility);
    }
}
 
Example 7
Project: GitHub   File: StatusBarUtil.java   Source Code and License Vote up 5 votes
/** android 6.0设置字体颜色 */
    @RequiresApi(Build.VERSION_CODES.M)
    private static void darkModeForM(Window window, boolean dark) {
//        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
//        window.setStatusBarColor(Color.TRANSPARENT);

        int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
        if (dark) {
            systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        } else {
            systemUiVisibility &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        }
        window.getDecorView().setSystemUiVisibility(systemUiVisibility);
    }
 
Example 8
Project: BrotherWeather   File: StatusBarTextColorUtils.java   Source Code and License Vote up 5 votes
public static void setWindowLightStatusBar(Activity activity, Boolean lightStatusBar) {
  Window window = activity.getWindow();
  View decor = window.getDecorView();
  //取消设置透明状态栏,使 ContentView 内容不再覆盖状态栏
  window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  //需要设置这个 flag 才能调用 setStatusBarColor 来设置状态栏颜色
  window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  int ui = decor.getSystemUiVisibility();
  if (lightStatusBar) {
    ui |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
  } else {
    ui &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
  }
  decor.setSystemUiVisibility(ui);
}
 
Example 9
Project: BilibiliClient   File: SystemBarHelper.java   Source Code and License Vote up 5 votes
/**
 * android 6.0设置字体颜色
 */
@TargetApi(Build.VERSION_CODES.M)
public static void setStatusBarDarkModeForM(Window window) {

  window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  window.setStatusBarColor(Color.TRANSPARENT);

  int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
  systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
  window.getDecorView().setSystemUiVisibility(systemUiVisibility);
}
 
Example 10
Project: BilibiliClient   File: SystemBarHelper.java   Source Code and License Vote up 5 votes
/**
 * android 6.0设置字体颜色
 */
@TargetApi(Build.VERSION_CODES.M)
public static void setStatusBarDarkModeForM(Window window) {

  window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  window.setStatusBarColor(Color.TRANSPARENT);

  int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
  systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
  window.getDecorView().setSystemUiVisibility(systemUiVisibility);
}
 
Example 11
Project: QMUI_Android   File: QMUIStatusBarHelper.java   Source Code and License Vote up 5 votes
/**
 * 设置状态栏字体图标为深色,Android 6
 *
 * @param window 需要设置的窗口
 * @param light  是否把状态栏字体及图标颜色设置为深色
 * @return boolean 成功执行返回true
 */
@TargetApi(23)
private static boolean Android6SetStatusBarLightMode(Window window, boolean light) {
    View decorView = window.getDecorView();
    int systemUi = light ? View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR : View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
    systemUi = changeStatusBarModeRetainFlag(window, systemUi);
    decorView.setSystemUiVisibility(systemUi);
    return true;
}
 
Example 12
Project: music-player   File: ViewUtils.java   Source Code and License Vote up 5 votes
public static void clearLightStatusBar(@NonNull View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int flags = view.getSystemUiVisibility();
        flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
    }
}
 
Example 13
Project: Farmacias   File: Utils.java   Source Code and License Vote up 5 votes
public static void setLightStatusBar(View view, Activity activity) {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            View decor = activity.getWindow().getDecorView();
            oldStatusBarFlags = decor.getSystemUiVisibility();
            int flags = view.getSystemUiVisibility();
            flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
            view.setSystemUiVisibility(flags);
            activity.getWindow().setStatusBarColor(Color.WHITE);
        }


    }
 
Example 14
Project: AmenEye   File: ViewUtil.java   Source Code and License Vote up 5 votes
public static void setLightStatusBar(@NonNull View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int flags = view.getSystemUiVisibility();
        flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
    }
}
 
Example 15
Project: SmartRefreshLayout   File: DeliveryStyleActivity.java   Source Code and License Vote up 5 votes
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    switch (Item.values()[position]) {
        case 默认主题:
            mToolbar.setBackgroundResource(android.R.color.white);
            mToolbar.setTitleTextColor(0xffbbbbbb);
            mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_gray_24dp);
            mRefreshLayout.setPrimaryColors(0xfff0f0f0, 0xffffffff);
            if (Build.VERSION.SDK_INT >= 21) {
                getWindow().setStatusBarColor(0xfff0f0f0);
            }
            if (Build.VERSION.SDK_INT >= 23) {
                Window window = getWindow();
                int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
                systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
                window.getDecorView().setSystemUiVisibility(systemUiVisibility);
            }
            break;
        case 蓝色主题:
            setThemeColor(R.color.colorPrimary, R.color.colorPrimaryDark);
            break;
        case 绿色主题:
            setThemeColor(android.R.color.holo_green_light, android.R.color.holo_green_dark);
            break;
        case 红色主题:
            setThemeColor(android.R.color.holo_red_light, android.R.color.holo_red_dark);
            break;
        case 橙色主题:
            setThemeColor(android.R.color.holo_orange_light, android.R.color.holo_orange_dark);
            break;
    }
    mRefreshLayout.autoRefresh();
}
 
Example 16
Project: SmartChart   File: StatusBarUtil.java   Source Code and License Vote up 5 votes
/** android 6.0设置字体颜色 */
    @RequiresApi(Build.VERSION_CODES.M)
    private static void darkModeForM(Window window, boolean dark) {
//        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
//        window.setStatusBarColor(Color.TRANSPARENT);

        int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
        if (dark) {
            systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        } else {
            systemUiVisibility &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        }
        window.getDecorView().setSystemUiVisibility(systemUiVisibility);
    }
 
Example 17
Project: Paper-Launcher   File: SystemBarUtil.java   Source Code and License Vote up 5 votes
public static void enableLightStatusBar(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        View view = activity.getWindow().getDecorView();

        int flags = view.getSystemUiVisibility();
        flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
    }
}
 
Example 18
Project: Paper-Launcher   File: SystemBarUtil.java   Source Code and License Vote up 5 votes
public static void clearLightStatusBar(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        View view = activity.getWindow().getDecorView();

        int flags = view.getSystemUiVisibility();
        flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
    }
}
 
Example 19
Project: SmartRefreshLayout   File: DeliveryStyleActivity.java   Source Code and License Vote up 5 votes
private void setThemeColor(int colorPrimary, int colorPrimaryDark) {
    mToolbar.setBackgroundResource(colorPrimary);
    mToolbar.setTitleTextColor(ContextCompat.getColor(this, android.R.color.white));
    mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
    mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white);
    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark));
    }
    if (Build.VERSION.SDK_INT >= 23) {
        Window window = getWindow();
        int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
        systemUiVisibility &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        window.getDecorView().setSystemUiVisibility(systemUiVisibility);
    }
}
 
Example 20
Project: TravelJournal   File: BaseActivity.java   Source Code and License Vote up 5 votes
public static void setLightStatusBar(View view, Activity activity){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

        int flags = view.getSystemUiVisibility();
        flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
        activity.getWindow().setStatusBarColor(Color.WHITE);
    }
}