Example usage for android.view Window setStatusBarColor

List of usage examples for android.view Window setStatusBarColor

Introduction

In this page you can find the example usage for android.view Window setStatusBarColor.

Prototype

public abstract void setStatusBarColor(@ColorInt int color);

Source Link

Document

Sets the color of the status bar to color .

Usage

From source file:org.dalol.orthodoxmezmurmedia.basic.base.BaseActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    int contentRes = getContentView();
    if (contentRes > 0) {
        setContentView(contentRes);/*from  www .  j ava 2  s .  c o m*/
    }
    ButterKnife.bind(this);

    if (mToolbar != null) {
        setSupportActionBar(mToolbar);
        int statusBarColor = getStatusBarColor();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && statusBarColor > 0) {
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(ContextCompat.getColor(this, statusBarColor));
        }
    }

    resolveDependency();
    onViewReady(savedInstanceState, getIntent());

    //showRateDialog();
    //getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}

From source file:sg.fxl.topekaport.QuizActivity.java

@SuppressLint("NewApi")
private void populate(Quiz quiz) {
    this.quiz = quiz;
    setTheme(this.quiz.getTheme().getStyleId());
    if (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.LOLLIPOP)) {
        Window window = getWindow();
        window.setStatusBarColor(ContextCompat.getColor(this, this.quiz.getTheme().getPrimaryDarkColor()));
    }//from   ww w.  j  a va 2s .c o  m
    initLayout();
    initToolbar(this.quiz);
}

From source file:com.bottomsheetbehavior.ScrollingAppBarLayoutBehavior.java

private void setStatusBarBackgroundVisible(boolean visible) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mStatusBarColor != 0) {
        if (visible) {
            Window window = ((ThemedReactContext) mContext).getCurrentActivity().getWindow();
            window.getDecorView().setSystemUiVisibility(mBarStyle);
            window.setStatusBarColor(mStatusBarColor);
        } else {//from  w w w  .j av  a  2s.c om
            Window window = ((ThemedReactContext) mContext).getCurrentActivity().getWindow();
            window.getDecorView().setSystemUiVisibility(mBarStyleTransparent);
            window.setStatusBarColor(ContextCompat.getColor(mContext, android.R.color.transparent));
        }
    }
}

From source file:com.google.samples.apps.topeka.activity.QuizActivity.java

@SuppressLint("NewApi")
private void populate(String categoryId) {
    if (null == categoryId) {
        Log.w(TAG, "Didn't find a category. Finishing");
        finish();//from w  w w . j a  v  a2  s .  c o  m
    }
    mCategory = TopekaDatabaseHelper.getCategoryWith(this, categoryId);
    setTheme(mCategory.getTheme().getStyleId());
    if (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.LOLLIPOP)) {
        Window window = getWindow();
        window.setStatusBarColor(ContextCompat.getColor(this, mCategory.getTheme().getPrimaryDarkColor()));
    }
    initLayout(mCategory.getId());
    initToolbar(mCategory);
}

From source file:dg.shenm233.mmaps.ui.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Window window = getWindow();
    window.getDecorView()/*from w  w w  .j  av a 2 s  .  c o  m*/
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(getResources().getColor(R.color.status_bar_color));

    setContentView(R.layout.activity_main);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    initNavigationView();

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.main_content, getMapsFragment(), MapsFragment.class.getName());
    ft.commit();
}

From source file:com.igniva.filemanager.activities.Preferences.java

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);//  w w w  .  ja  v  a  2s  . com
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Filemanager",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin));
        setTaskDescription(taskDescription);
    }
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_HOME_AS_UP
            | android.support.v7.app.ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setBackgroundDrawable(
            new ColorDrawable(Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin)));
    int sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin));

        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.preferences)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        boolean colourednavigation = Sp.getBoolean("colorednavigation", true);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(
                (PreferenceUtils.getStatusColor(MainActivity.currentTab == 1 ? skinTwo : skin)));
        if (colourednavigation)
            window.setNavigationBarColor(
                    (PreferenceUtils.getStatusColor(MainActivity.currentTab == 1 ? skinTwo : skin)));

    }
    selectItem(0);
}

From source file:com.amaze.carbonfilemanager.activities.PreferencesActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);//from  ww  w .  j  ava 2s  .c o  m
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));
        setTaskDescription(taskDescription);
    }
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_HOME_AS_UP
            | android.support.v7.app.ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setBackgroundDrawable(
            getColorPreference().getDrawable(ColorUsage.getPrimary(MainActivity.currentTab)));

    if (SDK_INT == 20 || SDK_INT == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(
                getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));

        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.preferences)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (SDK_INT >= 21) {
        boolean colourednavigation = Sp.getBoolean("colorednavigation", true);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(PreferenceUtils.getStatusColor(
                getColorPreference().getColorAsString(ColorUsage.getPrimary(MainActivity.currentTab))));
        if (colourednavigation)
            window.setNavigationBarColor(PreferenceUtils.getStatusColor(
                    getColorPreference().getColorAsString(ColorUsage.getPrimary(MainActivity.currentTab))));

    }
    if (savedInstanceState != null) {
        selectedItem = savedInstanceState.getInt(KEY_CURRENT_FRAG_OPEN, 0);
    }
    selectItem(selectedItem);
}

From source file:com.google.samples.apps.topeka.view.quiz.QuizActivity.java

@Override
public void initLayout(ThemeEntity theme) {
    final Theme androidTheme = Theme.values()[theme.ordinal()];
    setTheme(androidTheme.getStyleId());
    setContentView(R.layout.activity_quiz);

    setTheme(androidTheme.getStyleId());
    if (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.LOLLIPOP)) {
        Window window = getWindow();
        window.setStatusBarColor(ContextCompat.getColor(this, androidTheme.getPrimaryDarkColor()));
    }/*from  w  ww  . j  av a 2  s . c o m*/
}

From source file:com.example.locale.MainActivity.java

private void showDefaultLocale() {
    Locale locale = Locale.getDefault();
    setTitle(locale.getDisplayName());//from   w ww  . j  ava2 s .c  om
    BitmapDrawable d = (BitmapDrawable) ImageUtil.getFlagIcon(this, locale.getCountry());
    if (d != null) {
        final Bitmap bitmap = d.getBitmap();
        mPaletteTask = new Palette.Builder(bitmap).generate(new Palette.PaletteAsyncListener() {
            @Override
            public void onGenerated(Palette palette) {
                mPaletteTask = null;
                int color = palette.getDarkVibrantColor(0);
                mToolbar.setBackgroundColor(color);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    Window window = getWindow();
                    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                    window.setStatusBarColor(getDarkerColor(color));
                }
            }
        });
    }
}

From source file:com.ycdyng.onemulti.MultiFragment.java

public void setStatusBarColor() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mColorPrimaryDark != 0) {
        Window window = mActivity.getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(mColorPrimaryDark);
    }// w ww.j  a  v a2s.c om
}