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:com.hufeiya.SignIn.activity.QuizActivity.java

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

From source file:com.adkdevelopment.rssreader.ui.DetailFragment.java

@Override
public void showData(NewsObject newsItem) {

    //ImageView backdrop = ButterKnife.findById(getActivity(), R.id.backdrop);
    if (mBackdrop != null) {
        Picasso.with(getContext()).load(newsItem.getThumbnail()).into(mBackdrop, new Callback() {
            @Override/*from  w w w .ja va 2 s  .c o  m*/
            public void onSuccess() {
                // makes detail view colored according to the image palette
                if (mBackdrop != null) {
                    BitmapDrawable drawable = (BitmapDrawable) mBackdrop.getDrawable();

                    int[] palette = Utilities.getPalette(drawable);
                    mNestedScroll.setBackgroundColor(palette[0]);
                    CollapsingToolbarLayout toolbarLayout = ButterKnife.findById(getActivity(),
                            R.id.collapsing_toolbar);
                    if (toolbarLayout != null) {
                        toolbarLayout.setContentScrimColor(palette[1]);
                    }

                    Toolbar toolbar = ButterKnife.findById(getActivity(), R.id.toolbar);
                    toolbar.setBackgroundColor(palette[2]);

                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        Window window = getActivity().getWindow();
                        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                        window.setStatusBarColor(palette[2]);
                    }
                }
            }

            @Override
            public void onError() {
                Log.e(TAG, "onError: no image");
            }
        });
    }

    mTextDate.setText(Utilities.getFormattedDate(newsItem.getPubDate()));
    mTextTitle.setText(newsItem.getTitle());
    mTextDescription.setText(newsItem.getDescription());
    String learMore = getString(R.string.learn_more) + " " + newsItem.getLink();
    mTextLink.setText(learMore);
}

From source file:com.qasp.diego.arsp.MainActivity.java

@SuppressWarnings("unchecked")
@Override/* w ww  . jav a2 s  .  c  o  m*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
        // Activity was brought to front and not created,
        // Thus finishing this will get us to the last viewed activity
        finish();
        return;
    }

    // Opcoes padrao para Preferencias.
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    setContentView(R.layout.activity_main);

    // Salva dados se nao for mais visivel
    if (savedInstanceState != null) {
        Global.estacoes = (ArrayList<Estacao>) savedInstanceState.getSerializable(ESTADO_ESTACOES);
        Global.GPS = (Coordenada) savedInstanceState.getSerializable(ESTADO_GPS);
    } else
        InicializaEstacoesValidas(Global.estacoes);

    // Colorizao da barra de servios.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.parseColor("#202020"));
    }

    // PERMISSOES
    verifyStoragePermissions(this);
    if (PermissaodoGPS(this)) {
        // Se a permisso ja foi aprovada anterioremente.
        Intent intent = new Intent(this, LocalizacaoGPSService.class);
        startService(intent);
    }

    // Action bar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // TABS.
    tablayout = (TabLayout) findViewById(R.id.tab_layout);
    tablayout.addTab(tablayout.newTab().setText("Lista Estaes"));
    tablayout.addTab(tablayout.newTab().setText("Indice Local"));
    tablayout.addTab(tablayout.newTab().setText("Feedback"));
    tablayout.setTabGravity(TabLayout.GRAVITY_FILL);

    // PAGER (Deslize) e Funcionamento das Tabs
    viewPager = (ViewPager) findViewById(R.id.pager);
    adapter = new PagerAdapter(getSupportFragmentManager(), tablayout.getTabCount());
    viewPager.setAdapter(adapter);
    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tablayout));
    tablayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            // Notificar eventuais mudanas ao mudar de aba.
            Global.tabSelecionado = tab.getPosition();
            viewPager.setCurrentItem(tab.getPosition());
            viewPager.getAdapter().notifyDataSetChanged();
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
            // vazio de proposito
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
            // Vazio de proposito
        }
    });
}

From source file:com.grarak.kerneladiutor.FileBrowserActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    fileBrowserActivity = this;
    boolean dark = Utils.getBoolean("darktheme", false, this);
    if (dark)/*from ww  w  . j  ava  2s .c  o m*/
        super.setTheme(R.style.AppThemeDark);
    setContentView(R.layout.activity_filebrowser);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    ActionBar actionBar;
    if ((actionBar = getSupportActionBar()) != null)
        actionBar.setDisplayHomeAsUpEnabled(true);

    String fileType = getIntent().getExtras().getString(FILE_TYPE_ARG);
    String externalStorage = Utils.getExternalStorage();

    LinkedHashMap<String, Fragment> fragments = new LinkedHashMap<>();
    internalStorage = StorageFragment.newInstance(Environment.getExternalStorageDirectory().getPath(),
            fileType);
    fragments.put(getString(R.string.internal_storage), internalStorage);
    if (externalStorage != null) {
        this.externalStorage = StorageFragment.newInstance(externalStorage, fileType);
        fragments.put(getString(R.string.external_storage), this.externalStorage);
    }

    mViewPager = (ViewPager) findViewById(R.id.view_pager);
    mViewPager.setAdapter(new Adapter(getSupportFragmentManager(), fragments));
    if (dark)
        mViewPager.setBackgroundColor(getResources().getColor(R.color.card_background_dark));

    final SlidingTabLayout mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
    mSlidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);
    for (int i = 0; i < fragments.keySet().toArray().length; i++)
        mSlidingTabLayout.setContentDescription(i, (String) fragments.keySet().toArray()[i]);
    mSlidingTabLayout.setSelectedIndicatorColors(
            getResources().getColor(fragments.size() > 1 ? R.color.white : R.color.color_primary));
    mSlidingTabLayout.setDistributeEvenly(true);
    mSlidingTabLayout.setViewPager(mViewPager);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(getResources().getColor(R.color.color_primary_dark));
    }
}

From source file:com.yanzhenjie.durban.DurbanActivity.java

private void initFrameViews() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final Window window = getWindow();
        if (window != null) {
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(mStatusColor);
            window.setNavigationBarColor(mNavigationColor);
        }// w  w w .  j av a  2s  .  c om
    }

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setBackgroundColor(mToolbarColor);
    setSupportActionBar(toolbar);

    final ActionBar actionBar = getSupportActionBar();
    assert actionBar != null;
    actionBar.setDefaultDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(mTitle);
}

From source file:com.jun.elephant.ui.user.info.UserInfoActivity.java

@Override
public void initView() {
    setToolbar(mToolBar, "");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
    }//from w  ww.  j  av  a2  s  . c om

    mToolBar.inflateMenu(R.menu.menu_user_info);
    alphaView(mPageTitleTv, 200, 4);

    mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            float f = ((float) Math.abs(verticalOffset)) / (float) (mAppBarLayout.getTotalScrollRange());

            appBarScrollChange(f);
        }
    });

}

From source file:com.bilibili.magicasakurademo.MainActivity.java

@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= 21) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(ThemeUtils.getColorById(this, R.color.theme_color_primary_dark));
        ActivityManager.TaskDescription description = new ActivityManager.TaskDescription(null, null,
                ThemeUtils.getThemeAttrColor(this, android.R.attr.colorPrimary));
        setTaskDescription(description);
    }/*  w w  w  .  ja  v  a 2  s . c  o m*/
}

From source file:com.experiments.whereapp.application.home.activities.HomeActivity.java

@TargetApi(Build.VERSION_CODES.KITKAT)
@Override/*from   www  .j av  a 2s .  co m*/
public void makeStatusBarTransparent() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
        return;
    Window window = getWindow();
    window.getDecorView()
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        window.setStatusBarColor(Color.TRANSPARENT);
    } else {
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
}

From source file:com.breadwallet.presenter.activities.IntroActivity.java

private void setStatusBarColor(int mode) {
    if (mode == 0) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(getColor(R.color.intro_status_bar));
    } else {/* w  w  w.  jav a2  s  . co  m*/
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(getColor(R.color.warning_status_bar));
    }
}

From source file:ir.isilearning.lmsapp.activity.QuizActivity.java

@SuppressLint("NewApi")
private void populate(String categoryId) {
    if (null == categoryId) {
        Log.w(TAG, "Didn't find a category. Finishing");
        finish();/*  w w  w.j  a va 2s.  c  o  m*/
    }
    mCategory = LMSAppDatabaseHelper.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);
}