Skip to content

Commit

Permalink
FWB:Add a Switch to Enable Disable Dyanamic Navbar[1/2]
Browse files Browse the repository at this point in the history
Everything works as it should. To see changes within the app after enabling/disabling this switch, app must be restarted everytime switch is toggled .

Signed-off-by: Varun Date <date.varun123@gmail.com>
  • Loading branch information
varund7726 committed Dec 14, 2016
1 parent 3e498b9 commit ab8fa40
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 6 deletions.
6 changes: 6 additions & 0 deletions core/java/android/provider/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -4530,6 +4530,12 @@ public boolean validate(String value) {
*/
public static final String STATUS_BAR_WEATHER_COLOR = "status_bar_weather_color";

/*
* Dyanamic Navbar Switch
* @hide
*/
public static final String NAV_BAR_DYNAMIC = "nav_bar_dynamic";

/*
* Whether to show the weather info on the lock screen
* @hide
Expand Down
20 changes: 18 additions & 2 deletions core/java/com/android/internal/policy/DecorView.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import android.animation.ObjectAnimator;
import android.app.ActivityManager;
import android.content.Context;
import android.content.ContentResolver;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Canvas;
Expand Down Expand Up @@ -78,6 +79,7 @@
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
import android.widget.PopupWindow;
import android.provider.Settings;

import static android.app.ActivityManager.StackId;
import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
Expand Down Expand Up @@ -1261,6 +1263,8 @@ private void updateColorViewTranslations() {

private WindowInsets updateStatusGuard(WindowInsets insets) {
boolean showStatusGuard = false;
boolean isDyanamic = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.NAV_BAR_DYNAMIC, 0) == 1;
// Show the status guard when the non-overlay contextual action bar is showing
if (mPrimaryActionModeView != null) {
if (mPrimaryActionModeView.getLayoutParams() instanceof MarginLayoutParams) {
Expand All @@ -1284,8 +1288,13 @@ private WindowInsets updateStatusGuard(WindowInsets insets) {

if (mStatusGuard == null) {
mStatusGuard = new View(mContext);
if (!isDyanamic) {
mStatusGuard.setBackgroundColor(mContext.getColor(
R.color.input_method_navigation_guard));
} else {
mStatusGuard.setBackgroundColor(mContext.getColor(
R.color.input_method_navigation_guard_dyanamic));
}
addView(mStatusGuard, indexOfChild(mStatusColorViewState.view),
new LayoutParams(LayoutParams.MATCH_PARENT,
mlp.topMargin, Gravity.START | Gravity.TOP));
Expand Down Expand Up @@ -1330,6 +1339,8 @@ private WindowInsets updateStatusGuard(WindowInsets insets) {
}

private void updateNavigationGuard(WindowInsets insets) {
boolean isDyanamic = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.NAV_BAR_DYNAMIC, 0) == 1;
// IMEs lay out below the nav bar, but the content view must not (for back compat)
if (mWindow.getAttributes().type == WindowManager.LayoutParams.TYPE_INPUT_METHOD) {
// prevent the content view from including the nav bar height
Expand All @@ -1344,8 +1355,13 @@ private void updateNavigationGuard(WindowInsets insets) {
// position the navigation guard view, creating it if necessary
if (mNavigationGuard == null) {
mNavigationGuard = new View(mContext);
mNavigationGuard.setBackgroundColor(mContext.getColor(
R.color.input_method_navigation_guard));
if (!isDyanamic) {
mNavigationGuard.setBackgroundColor(mContext.getColor(
R.color.input_method_navigation_guard));
} else {
mNavigationGuard.setBackgroundColor(mContext.getColor(
R.color.input_method_navigation_guard_dyanamic));
}
addView(mNavigationGuard, indexOfChild(mNavigationColorViewState.view),
new LayoutParams(LayoutParams.MATCH_PARENT,
insets.getSystemWindowInsetBottom(),
Expand Down
8 changes: 8 additions & 0 deletions core/java/com/android/internal/policy/PhoneWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.app.ActivityManagerNative;
import android.app.SearchManager;
import android.os.UserHandle;
import android.database.ContentObserver;

import android.text.TextUtils;
import android.view.ContextThemeWrapper;
Expand Down Expand Up @@ -330,6 +331,7 @@ public final void setContainer(Window container) {
super.setContainer(container);
}


@Override
public boolean requestFeature(int featureId) {
if (mContentParentExplicitlySet) {
Expand Down Expand Up @@ -2407,7 +2409,13 @@ protected ViewGroup generateLayout(DecorView decor) {
mStatusBarColor = a.getColor(R.styleable.Window_statusBarColor, 0xFF000000);
}
if (!mForcedNavigationBarColor) {
boolean isDyanamic = Settings.System.getInt(getContext().getContentResolver(),
Settings.System.NAV_BAR_DYNAMIC, 0) == 1;
if (!isDyanamic) {
mNavigationBarColor = a.getColor(R.styleable.Window_navigationBarColor, 0xFF000000);
} else {
mNavigationBarColor = a.getColor(R.styleable.Window_navigationBarColordyanamic, 0xFF000000);
}
}

WindowManager.LayoutParams params = getAttributes();
Expand Down
10 changes: 10 additions & 0 deletions core/res/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,16 @@ i
Corresponds to {@link android.view.Window#setNavigationBarColor(int)}. -->
<attr name="navigationBarColor" format="color" />

<!-- The dyanamic color for the navigation bar. If the color is not opaque, consider setting
{@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
{@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.
For this to take effect, the window must be drawing the system bar backgrounds with
{@link android.R.attr#windowDrawsSystemBarBackgrounds} and the navigation bar must not
have been requested to be translucent with
{@link android.R.attr#windowTranslucentNavigation}.
Corresponds to {@link android.view.Window#setNavigationBarColor(int)}. -->
<attr name="navigationBarColordyanamic" format="color" />

<!-- The duration, in milliseconds, of the window background fade duration
when transitioning into or away from an Activity when called with an
Activity Transition. Corresponds to
Expand Down
3 changes: 2 additions & 1 deletion core/res/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
<drawable name="editbox_dropdown_light_frame">@drawable/editbox_dropdown_background</drawable>

<drawable name="input_method_fullscreen_background">#fff9f9f9</drawable>
<color name="input_method_navigation_guard">#00000000</color>
<color name="input_method_navigation_guard">#ff000000</color>
<color name="input_method_navigation_guard_dyanamic">#00000000</color><!--Dyanamic Navbar-->

<color name="system_error">#fff4511e</color> <!-- deep orange 600 -->

Expand Down
3 changes: 3 additions & 0 deletions core/res/res/values/rr_symbols.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,7 @@
<!-- Quick settings tiles columns and rows config -->
<java-symbol type="integer" name="config_qs_num_rows_landscape_default"/>

<!-- Dyanamic Navbar -->
<java-symbol type="color" name="input_method_navigation_guard_dyanamic" />

</resources>
2 changes: 2 additions & 0 deletions core/res/res/values/themes_device_defaults.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ easier.
<item name="colorPrimary">@color/primary_device_default_light</item>
<item name="colorPrimaryDark">@color/primary_dark_device_default_light</item>
<item name="colorAccent">@color/accent_device_default_light</item>
<item name="navigationBarColordyanamic">@android:color/transparent</item>
</style>

<!-- Variant of {@link #Theme_DeviceDefault_Light} with no action bar and no status bar.
Expand All @@ -577,6 +578,7 @@ easier.
<item name="colorPrimary">@color/primary_device_default_light</item>
<item name="colorPrimaryDark">@color/primary_dark_device_default_light</item>
<item name="colorAccent">@color/accent_device_default_light</item>
<item name="navigationBarColordyanamic">@android:color/transparent</item>
</style>

<!-- Variant of {@link #Theme_DeviceDefault_Light} with no action bar and no status bar
Expand Down
6 changes: 4 additions & 2 deletions core/res/res/values/themes_material.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ please see themes_device_defaults.xml.
<item name="windowDrawsSystemBarBackgrounds">true</item>
<item name="windowActionBarFullscreenDecorLayout">@layout/screen_toolbar</item>
<item name="statusBarColor">?attr/colorPrimaryDark</item>
<item name="navigationBarColor">?attr/colorPrimaryDark</item>
<item name="navigationBarColor">@color/black</item>
<item name="navigationBarColordyanamic">?attr/colorPrimaryDark</item>
<item name="windowEnterTransition">@transition/fade</item>
<item name="windowSharedElementEnterTransition">@transition/move</item>
<item name="windowSharedElementExitTransition">@transition/move</item>
Expand Down Expand Up @@ -530,7 +531,8 @@ please see themes_device_defaults.xml.
<item name="windowDrawsSystemBarBackgrounds">true</item>
<item name="windowActionBarFullscreenDecorLayout">@layout/screen_toolbar</item>
<item name="statusBarColor">?attr/colorPrimaryDark</item>
<item name="navigationBarColor">?attr/colorPrimaryDark</item>
<item name="navigationBarColor">@color/black</item>
<item name="navigationBarColordyanamic">?attr/colorPrimaryDark</item>
<item name="windowEnterTransition">@transition/fade</item>
<item name="windowSharedElementEnterTransition">@transition/move</item>
<item name="windowSharedElementExitTransition">@transition/move</item>
Expand Down
1 change: 1 addition & 0 deletions packages/SystemUI/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<!-- Misc -->
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="@*android:navigationBarColordyanamic">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowAnimationStyle">@null</item>
<item name="android:ambientShadowAlpha">0.35</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,10 @@ protected void observe() {
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.BATTERY_LARGE_TEXT),
false, this, UserHandle.USER_ALL);
update();
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.NAV_BAR_DYNAMIC),
false, this, UserHandle.USER_ALL);
update();
}

@Override
Expand Down Expand Up @@ -776,6 +779,9 @@ public void onChange(boolean selfChange, Uri uri) {
} else if (uri.equals(Settings.System.getUriFor(
Settings.System.NAVBAR_BUTTON_COLOR))) {
mNavigationController.updateNavbarOverlay(mContext.getResources());
} else if (uri.equals(Settings.System.getUriFor(
Settings.System.NAV_BAR_DYNAMIC))) {
mNavigationController.updateNavbarOverlay(mContext.getResources());
}
update();
}
Expand Down

0 comments on commit ab8fa40

Please sign in to comment.