Skip to content

Commit

Permalink
Improve system bars color
Browse files Browse the repository at this point in the history
Navigation bar now uses dark primary color to distinguish it from
the bottom navigation components as shown in the Google I/O 2018
app.
  • Loading branch information
pranavpandey committed May 9, 2018
1 parent acd0413 commit bff2b72
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public abstract class DynamicSystemActivity extends AppCompatActivity implements
* etc.
*/
protected static final @ColorInt int ADS_DEFAULT_SYSTEM_UI_COLOR =
Color.parseColor("#FFFFFF");
Color.parseColor("#F5F5F5");

/**
* Default background color for the system UI elements like
Expand Down Expand Up @@ -143,7 +143,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

mStatusBarColor = DynamicTheme.getInstance().getPrimaryColorDark();
mNavigationBarColor = DynamicTheme.getInstance().getPrimaryColor();
mNavigationBarColor = DynamicTheme.getInstance().getPrimaryColorDark();
}

@Override
Expand Down Expand Up @@ -249,7 +249,7 @@ protected boolean setNavigationBarThemeInLandscape() {

/**
* @return {@code true} to register a
* {@link android.content.SharedPreferences.OnSharedPreferenceChangeListener}
* {@link SharedPreferences.OnSharedPreferenceChangeListener}
* to receive preference change callback.
*/
protected boolean setSharedPreferenceChangeListener() {
Expand Down Expand Up @@ -329,8 +329,8 @@ public void setTranslucentStatusBar() {
protected void updateStatusBar() {
if (!DynamicColorUtils.isColorDark(mStatusBarColor)) {
if (!DynamicVersionUtils.isMarshmallow()) {
mStatusBarColor = DynamicColorUtils.getContrastColor(mStatusBarColor,
ADS_DEFAULT_SYSTEM_UI_COLOR);
mStatusBarColor = DynamicColorUtils.getContrastColor(
mStatusBarColor, ADS_DEFAULT_SYSTEM_UI_COLOR);
}
}

Expand Down Expand Up @@ -495,9 +495,7 @@ private void updateTaskDescription() {
@ColorInt int color = mStatusBarColor;
color = Color.rgb(Color.red(color), Color.green(color), Color.blue(color));

ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
null, null, color);
setTaskDescription(td);
setTaskDescription(new ActivityManager.TaskDescription(null, null, color));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ private void setViewPagerAdapter() {
* @param color The activity color to be applied.
*/
private void setColor(int position, @ColorInt int color) {
setStatusBarColor(DynamicColorUtils.shiftColor(
color, DynamicTheme.ADS_COLOR_SHIFT_DARK_DEFAULT));
setStatusBarColor(color);
setNavigationBarColor(color);
mCoordinatorLayout.setBackgroundColor(color);
mCoordinatorLayout.setStatusBarBackgroundColor(getStatusBarColor());
Expand Down
2 changes: 1 addition & 1 deletion dynamic-support/src/main/res/values/bools.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<!-- Activity -->
<bool name="ads_translucent_navigation">true</bool>
<bool name="ads_navigation_bar_theme_landscape">false</bool>
<bool name="ads_navigation_bar_theme_landscape">true</bool>
<bool name="ads_persistent_drawer">false</bool>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,9 @@ class BottomNavigationActivity : DynamicActivity() {
*/
private fun themeBottomNavigationView() {
if (mBottomNavigationView != null) {
if (isNavigationBarTheme
&& mAppliedNavigationBarColor != ADS_DEFAULT_SYSTEM_BG_COLOR) {
mBottomNavigationView!!.color = mNavigationBarColor
mBottomNavigationView!!.textColor =
DynamicColorUtils.getTintColor(mNavigationBarColor)
} else {
mBottomNavigationView!!.color = DynamicTheme.getInstance().primaryColor
mBottomNavigationView!!.textColor = DynamicColorUtils.getTintColor(
DynamicTheme.getInstance().primaryColor)
}
mBottomNavigationView!!.color = DynamicTheme.getInstance().primaryColor
mBottomNavigationView!!.textColor = DynamicColorUtils.getTintColor(
DynamicTheme.getInstance().primaryColor)
}
}

Expand Down

0 comments on commit bff2b72

Please sign in to comment.