Java Code Examples for com.readystatesoftware.systembartint.SystemBarTintManager#setStatusBarTintColor()

The following examples show how to use com.readystatesoftware.systembartint.SystemBarTintManager#setStatusBarTintColor() . 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: SystemBarUtils.java    From likequanmintv with Apache License 2.0 6 votes vote down vote up
public static void setStatusBarTranslate(AppCompatActivity mActivity, int resId){

        SystemBarTintManager tintManager = new SystemBarTintManager(mActivity);
        if (resId== R.color.transparent){
            // enable status bar tint
            tintManager.setStatusBarTintEnabled(false);
            // enable navigation bar tint
            tintManager.setNavigationBarTintEnabled(false);
            //noinspection deprecation
        }else {
            // enable status bar tint
            tintManager.setStatusBarTintEnabled(true);
            // enable navigation bar tint
            tintManager.setNavigationBarTintEnabled(true);
            // enable navigation bar tint
        }
        tintManager.setStatusBarTintColor(mActivity.getResources().getColor(resId));

    }
 
Example 2
Source File: MainActivity.java    From TigerVideo with Apache License 2.0 6 votes vote down vote up
@TargetApi(19)
private void setTranslucentStatus(boolean on) {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
        Window win = getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if (on) {
            winParams.flags |= bits;
        } else {
            winParams.flags &= ~bits;
        }
        win.setAttributes(winParams);
    }
    SystemBarTintManager tintManager = new SystemBarTintManager(this);
    tintManager.setStatusBarTintColor(getResources().getColor(R.color.colorPrimary));
    tintManager.setStatusBarTintEnabled(true);
    tintManager.setNavigationBarTintEnabled(false);
}
 
Example 3
Source File: HomeActivity.java    From bleYan with GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(19)
public void setTranslucentStatus(Activity activity, boolean on) {
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
        Window win = activity.getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if (on) {
            winParams.flags |= bits;
        } else {
            winParams.flags &= ~bits;
        }
        win.setAttributes(winParams);

        SystemBarTintManager tintManager = new SystemBarTintManager(activity);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(false);
        tintManager.setStatusBarTintColor(activity.getResources().getColor(R.color.colorPrimary));
        //tintManager.setNavigationBarTintColor(activity.getResources().getColor(R.color.colorPrimary));
        //			tintManager.setStatusBarTintResource(R.color.colorPrimary);
    }
}
 
Example 4
Source File: BaseActivity.java    From bleYan with GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(19)
	public void setTranslucentStatus(Activity activity, boolean on) {
		if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
			Window win = activity.getWindow();
			WindowManager.LayoutParams winParams = win.getAttributes();
			final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
			if (on) {
				winParams.flags |= bits;
			} else {
				winParams.flags &= ~bits;
			}
			win.setAttributes(winParams);

			SystemBarTintManager tintManager = new SystemBarTintManager(activity);
			tintManager.setStatusBarTintEnabled(true);
			tintManager.setNavigationBarTintEnabled(false);
			tintManager.setStatusBarTintColor(activity.getResources().getColor(R.color.colorPrimary));
			//tintManager.setNavigationBarTintColor(activity.getResources().getColor(R.color.colorPrimary));
//			tintManager.setStatusBarTintResource(R.color.colorPrimary);
		}
	}
 
Example 5
Source File: BaseActivity.java    From Sky31Radio with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Timber.i("onCreate");
    AVAnalytics.trackAppOpened(getIntent());
    setContentView(provideContentViewId());
    ButterKnife.inject(this);
    if(toolbar!=null){
        setSupportActionBar(toolbar);
    }
    if(!TextUtils.isEmpty(NavUtils.getParentActivityName(this))){
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    if(Build.VERSION.SDK_INT <= 19){
        tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(true);
        tintManager.setStatusBarTintColor(getResources().getColor(R.color.primary_dark));
    }
}
 
Example 6
Source File: PreferencesActivity.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) getResources().getDrawable(R.drawable.ic_launcher)).getBitmap(),
                getColorPreference().getColor(ColorUsage.PRIMARY));
        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.PRIMARY));

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

        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.PRIMARY)));
        if (colourednavigation)
            window.setNavigationBarColor(PreferenceUtils.getStatusColor(getColorPreference().getColorAsString(ColorUsage.PRIMARY)));

    }
    if (savedInstanceState != null){
        selectedItem = savedInstanceState.getInt(KEY_CURRENT_FRAG_OPEN, 0);
    }
    selectItem(selectedItem);
}
 
Example 7
Source File: UiUtils.java    From STUer-client with MIT License 5 votes vote down vote up
@TargetApi(19)
public static void setTranslucentStatusBar(Activity activity, NavigationView navigationView) {
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT && navigationView != null) {
        // fix 天坑 4.4 + drawerlayout + navigationView
        tianKeng(activity, activity.getResources().getColor(R.color.primary), navigationView);
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            SystemBarTintManager tintManager = new SystemBarTintManager(activity);
            tintManager.setStatusBarTintEnabled(true);
            tintManager.setStatusBarTintColor(activity.getResources().getColor(R.color.primary));
        }
    }
}
 
Example 8
Source File: BaseActivity.java    From MemoryCleaner with Apache License 2.0 5 votes vote down vote up
@TargetApi(19) private void initWindow() {
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
        getWindow().addFlags(
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        getWindow().addFlags(
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintColor(getStatusBarColor());
        tintManager.setStatusBarTintEnabled(true);
    }
}
 
Example 9
Source File: CommonUtils.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public static void setStatusBarTint(Activity activity, int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return;
    setTranslucentStatus(activity, true);
    SystemBarTintManager tintManager = new SystemBarTintManager(activity);
    tintManager.setStatusBarTintEnabled(true);
    tintManager.setStatusBarTintColor(color);
}
 
Example 10
Source File: Utils.java    From android with Apache License 2.0 5 votes vote down vote up
@SuppressLint("NewApi")
public static void setStatusTint(Activity activity) {
    if (hasKitKat()) {
        Window w = activity.getWindow(); // in Activity's onCreate() for instance
        w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        SystemBarTintManager tintManager = new SystemBarTintManager(activity);
        tintManager.setStatusBarTintColor(Color.parseColor("#33b5e5"));
        tintManager.setStatusBarTintEnabled(true);
    }
}
 
Example 11
Source File: AppUtils.java    From android with Apache License 2.0 5 votes vote down vote up
@SuppressLint("NewApi")
public static void setStatusTint(Activity activity) {
    if (hasKitKat()) {
        Window w = activity.getWindow(); // in Activity's onCreate() for instance
        w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        SystemBarTintManager tintManager = new SystemBarTintManager(activity);
        tintManager.setStatusBarTintColor(Color.parseColor("#33b5e5"));
        tintManager.setStatusBarTintEnabled(true);
    }
}
 
Example 12
Source File: LocalPlayerActivity.java    From android with Apache License 2.0 5 votes vote down vote up
private void updateControlersVisibility(boolean show) {
    if (show) {

        mControllers.setVisibility(View.VISIBLE);
        if (mFull == 1) {
            mActionBar.show();
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
            if (AppUtils.hasKitKat()) {
                getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                tintManager = new SystemBarTintManager(LocalPlayerActivity.this);
                tintManager.setStatusBarTintColor(Color.parseColor("#5A33b5e5"));
                tintManager.setStatusBarTintEnabled(true);
            }
            mFull = 0;
        }
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            //getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
            //getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

        }
        mControllers.setVisibility(View.INVISIBLE);
        if (AppUtils.hasKitKat()) {
            tintManager.setStatusBarTintEnabled(false);
        }
    }
}
 
Example 13
Source File: BaseActivity.java    From githot with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); setContentView(provideContentViewId());
    if (Build.VERSION.SDK_INT <= 19) {
        tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(true);
        tintManager.setStatusBarTintColor(getResources().getColor(R.color.primary_dark));
    }

}
 
Example 14
Source File: MainActivity.java    From Netease with GNU General Public License v3.0 5 votes vote down vote up
@TargetApi(19)
private void initWindow() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintColor(getResources().getColor(R.color.tab_top_background));
        tintManager.setStatusBarTintEnabled(true);
    }
}
 
Example 15
Source File: NewsDisplayActivity.java    From Netease with GNU General Public License v3.0 5 votes vote down vote up
@TargetApi(19)
private void initWindow() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintColor(getResources().getColor(R.color.tab_top_background));
        tintManager.setStatusBarTintEnabled(true);
    }
}