Example usage for android.view Window setNavigationBarColor

List of usage examples for android.view Window setNavigationBarColor

Introduction

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

Prototype

public abstract void setNavigationBarColor(@ColorInt int color);

Source Link

Document

Sets the color of the navigation bar to color .

Usage

From source file:Main.java

@TargetApi(19)
public static void transparencyBar(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = activity.getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
        window.setNavigationBarColor(Color.TRANSPARENT);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window window = activity.getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }//from   w ww  . j a va  2  s .com
}

From source file:com.sanchez.fmf.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    setSupportActionBar(mToolbar);/* ww w.  j  av a  2s .c  o  m*/

    // color nav and status bar with app color
    Window w = getWindow();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        w.setNavigationBarColor(getResources().getColor(R.color.primary_dark));
    }

    FragmentManager fm = getSupportFragmentManager();
    Fragment mainFragment = fm.findFragmentById(R.id.container_main_activity);

    if (mainFragment == null) {
        mainFragment = MainFragment.newInstance();
        fm.beginTransaction().add(R.id.container_main_activity, mainFragment).commit();
    }
}

From source file:com.geecko.QuickLyric.MainActivity.java

@TargetApi(21)
public static void setNavBarColor(Window window, Resources.Theme theme, Integer color) {
    if (Build.VERSION.SDK_INT >= 21) {
        if (color == null) {
            TypedValue typedValue = new TypedValue();
            theme.resolveAttribute(android.R.attr.navigationBarColor, typedValue, true);
            color = typedValue.data;/*from  w  w w. j a  v  a2  s  .  c o m*/
        }
        window.setNavigationBarColor(color);
    }
}

From source file:com.filemanager.free.activities.DbViewer.java

@Override
public void onCreate(Bundle savedInstanceState) {
    this.checkStorage = false;
    super.onCreate(savedInstanceState);

    if (theme1 == 1) {
        setTheme(R.style.appCompatDark);
        getWindow().getDecorView()/*from w  w  w  .  ja v a 2  s  .  c o m*/
                .setBackgroundColor(ContextCompat.getColor(getBaseContext(), R.color.holo_dark_background));
    }
    setContentView(R.layout.activity_db_viewer);
    toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    skin = PreferenceUtils.getPrimaryColorString(Sp);
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("File Manager",
                ((BitmapDrawable) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }
    skinStatusBar = PreferenceUtils.getStatusColor(skin);
    assert (getSupportActionBar()) != null;
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if (Build.VERSION.SDK_INT == 20 || Build.VERSION.SDK_INT == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.parentdb)
                .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(skin)));
        if (colourednavigation)
            window.setNavigationBarColor((PreferenceUtils.getStatusColor(skin)));

    }

    String path = getIntent().getStringExtra("path");
    pathFile = new File(path);
    listView = (ListView) findViewById(R.id.listView);

    load(pathFile);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
            DbViewerFragment fragment = new DbViewerFragment();
            Bundle bundle = new Bundle();
            bundle.putString("table", arrayList.get(position));
            fragment.setArguments(bundle);
            fragmentTransaction.add(R.id.content_frame, fragment);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        }
    });

}

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

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);//from www  .  ja v a  2s  .co m
    mHandler = new Handler();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    skin = PreferenceUtils.getSkinColor(Sp.getInt("skin_color_position", 9));
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("File Manager",
                ((BitmapDrawable) ContextCompat.getDrawable(getBaseContext(), R.mipmap.ic_launcher))
                        .getBitmap(),
                Color.parseColor(skin));
        setTaskDescription(taskDescription);
    }
    skinStatusBar = PreferenceUtils.getStatusColor(skin);
    setSupportActionBar(toolbar);
    assert (getSupportActionBar()) != null;
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));
    int sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(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(skin)));
        if (colourednavigation)
            window.setNavigationBarColor((PreferenceUtils.getStatusColor(skin)));

    }
    selectItem(0);
}

From source file:com.amaze.filemanager.activities.DbViewer.java

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

    Sp = PreferenceManager.getDefaultSharedPreferences(this);
    theme = Integer.parseInt(Sp.getString("theme", "0"));

    theme1 = theme == 2 ? PreferenceUtils.hourOfDay() : theme;

    if (theme1 == 1) {
        setTheme(R.style.appCompatDark);
        getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.holo_dark_background));
    }/*  www .  j  a  va 2 s  . co m*/
    setContentView(R.layout.activity_db_viewer);
    toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    skin = PreferenceUtils.getPrimaryColorString(Sp);
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }
    skinStatusBar = PreferenceUtils.getStatusColor(skin);
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    rootMode = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("rootmode", false);
    int sdk = Build.VERSION.SDK_INT;
    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.parentdb)
                .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(skin)));
        if (colourednavigation)
            window.setNavigationBarColor((PreferenceUtils.getStatusColor(skin)));

    }

    path = getIntent().getStringExtra("path");
    pathFile = new File(path);
    listView = (ListView) findViewById(R.id.listView);

    load(pathFile);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
            DbViewerFragment fragment = new DbViewerFragment();
            Bundle bundle = new Bundle();
            bundle.putString("table", arrayList.get(position));
            fragment.setArguments(bundle);
            fragmentTransaction.add(R.id.content_frame, fragment);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.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  ww .j ava 2  s  .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.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);
        }/*from  w w  w . j  av  a2  s.  c o m*/
    }

    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.amaze.filemanager.activities.DatabaseViewerActivity.java

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

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);

    if (getAppTheme().equals(AppTheme.DARK)) {
        setTheme(R.style.appCompatDark);
        getWindow().getDecorView().setBackgroundColor(Utils.getColor(this, R.color.holo_dark_background));
    } else if (getAppTheme().equals(AppTheme.BLACK)) {
        setTheme(R.style.appCompatBlack);
        getWindow().getDecorView().setBackgroundColor(Utils.getColor(this, android.R.color.black));
    }//from w  ww . j a  v a  2  s  .  c o  m
    setContentView(R.layout.activity_db_viewer);
    toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    @ColorInt
    int primaryColor = ColorPreferenceHelper.getPrimary(getCurrentColorPreference(), MainActivity.currentTab);

    if (SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)).getBitmap(),
                primaryColor);
        setTaskDescription(taskDescription);
    }

    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(primaryColor));

    boolean useNewStack = sharedPref.getBoolean(PreferencesConstants.PREFERENCE_TEXTEDITOR_NEWSTACK, false);

    getSupportActionBar().setDisplayHomeAsUpEnabled(!useNewStack);

    if (SDK_INT == 20 || SDK_INT == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(
                ColorPreferenceHelper.getPrimary(getCurrentColorPreference(), MainActivity.currentTab));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.parentdb)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (SDK_INT >= 21) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(PreferenceUtils.getStatusColor(primaryColor));
        if (getBoolean(PREFERENCE_COLORED_NAVIGATION))
            window.setNavigationBarColor(PreferenceUtils.getStatusColor(primaryColor));

    }

    path = getIntent().getStringExtra("path");
    pathFile = new File(path);
    listView = findViewById(R.id.listView);

    load(pathFile);
    listView.setOnItemClickListener((parent, view, position, id) -> {
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        DbViewerFragment fragment = new DbViewerFragment();
        Bundle bundle = new Bundle();
        bundle.putString("table", arrayList.get(position));
        fragment.setArguments(bundle);
        fragmentTransaction.add(R.id.content_frame, fragment);
        fragmentTransaction.addToBackStack(null);
        fragmentTransaction.commit();
    });

}

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

@Override
public void onCreate(Bundle savedInstanceState) {
    this.checkStorage = false;
    super.onCreate(savedInstanceState);

    if (theme1 == 1) {
        setTheme(R.style.appCompatDark);
        getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.holo_dark_background));
    }/*from   www .j av a2s .c om*/
    setContentView(R.layout.activity_db_viewer);
    toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Filemanager",
                ((BitmapDrawable) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }
    getSupportActionBar().setBackgroundDrawable(
            new ColorDrawable(Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin)));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    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.parentdb)
                .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)));

    }

    path = getIntent().getStringExtra("path");
    pathFile = new File(path);
    listView = (ListView) findViewById(R.id.listView);

    load(pathFile);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
            DbViewerFragment fragment = new DbViewerFragment();
            Bundle bundle = new Bundle();
            bundle.putString("table", arrayList.get(position));
            fragment.setArguments(bundle);
            fragmentTransaction.add(R.id.content_frame, fragment);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        }
    });

}