|
4 | 4 | import android.app.FragmentTransaction; |
5 | 5 | import android.content.Intent; |
6 | 6 | import android.content.SharedPreferences; |
| 7 | +import android.graphics.drawable.ColorDrawable; |
| 8 | +import android.os.Build; |
7 | 9 | import android.os.Bundle; |
8 | 10 | import android.preference.PreferenceManager; |
9 | 11 | import android.support.design.widget.NavigationView; |
10 | 12 |
|
11 | 13 | import android.app.FragmentManager; |
| 14 | +import android.support.v4.content.ContextCompat; |
12 | 15 | import android.support.v4.view.GravityCompat; |
13 | 16 | import android.os.Handler; |
14 | 17 | import android.support.v4.widget.DrawerLayout; |
@@ -107,7 +110,7 @@ public boolean onNavigationItemSelected(MenuItem item) { |
107 | 110 | getSupportActionBar().setDisplayShowHomeEnabled(true); |
108 | 111 | getSupportActionBar().setDisplayShowTitleEnabled(true); |
109 | 112 | } |
110 | | - |
| 113 | + restoreColorScheme(); |
111 | 114 | switch(id){ |
112 | 115 | case R.id.nav_home: |
113 | 116 | smoothNavigationToggle.runWhenIdle(new Runnable() { |
@@ -199,6 +202,16 @@ public void run() { |
199 | 202 | return true; |
200 | 203 | } |
201 | 204 |
|
| 205 | + private void restoreColorScheme() { |
| 206 | + int primaryColor = ContextCompat.getColor(HomeActivity.this, R.color.color_primary); |
| 207 | + int primaryColorDark = ContextCompat.getColor(HomeActivity.this, R.color.color_primary_dark); |
| 208 | + getSupportActionBar().setBackgroundDrawable(new ColorDrawable(primaryColor)); |
| 209 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| 210 | + getWindow().setStatusBarColor(primaryColorDark); |
| 211 | + getWindow().setNavigationBarColor(primaryColor); |
| 212 | + } |
| 213 | + } |
| 214 | + |
202 | 215 | @Override |
203 | 216 | public void onBackPressed() { |
204 | 217 | FragmentManager fragmentManager = getFragmentManager(); |
|
0 commit comments