Skip to content

Commit

Permalink
FWB:Add a Switch to Enable Disable Dynamic 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 .

- Using tuner settings

Change-Id: I7e4695d6c7970078d17890c9061aa52510e541c8
Signed-off-by: Varun Date <[email protected]>
Signed-off-by: AKabhishek <[email protected]>
  • Loading branch information
varund7726 authored and DarkKnight6499 committed Jun 25, 2017
1 parent 45bd147 commit 8df6304
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 @@ -3950,6 +3950,12 @@ public boolean validate(String value) {
*/
public static final String QUICK_SETTINGS_TILES_VIBRATE = "quick_settings_vibrate";

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

/**
* Settings to backup. This is here so that it's in the same place as the settings
* keys and easy to update.
Expand Down
24 changes: 20 additions & 4 deletions core/java/com/android/internal/policy/DecorView.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.RemoteException;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
Expand Down Expand Up @@ -1264,6 +1265,8 @@ private void updateColorViewTranslations() {

private WindowInsets updateStatusGuard(WindowInsets insets) {
boolean showStatusGuard = false;
boolean isDynamic = 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 @@ -1287,8 +1290,13 @@ private WindowInsets updateStatusGuard(WindowInsets insets) {

if (mStatusGuard == null) {
mStatusGuard = new View(mContext);
mStatusGuard.setBackgroundColor(mContext.getColor(
R.color.input_method_navigation_guard));
if (!isDynamic) {
mStatusGuard.setBackgroundColor(mContext.getColor(
R.color.input_method_navigation_guard));
} else {
mStatusGuard.setBackgroundColor(mContext.getColor(
R.color.input_method_navigation_guard_dynamic));
}
addView(mStatusGuard, indexOfChild(mStatusColorViewState.view),
new LayoutParams(LayoutParams.MATCH_PARENT,
mlp.topMargin, Gravity.START | Gravity.TOP));
Expand Down Expand Up @@ -1333,10 +1341,13 @@ private WindowInsets updateStatusGuard(WindowInsets insets) {
}

private WindowInsets updateNavigationGuard(WindowInsets insets) {
boolean isDynamic = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.NAV_BAR_DYNAMIC, 0) == 1;
// IME windows lay out below the nav bar, but the content view must not (for back compat)
// Only make this adjustment if the window is not requesting layout in overscan
if (mWindow.getAttributes().type == WindowManager.LayoutParams.TYPE_INPUT_METHOD
&& (mWindow.getAttributes().flags & FLAG_LAYOUT_IN_OVERSCAN) == 0) {

// prevent the content view from including the nav bar height
if (mWindow.mContentParent != null) {
if (mWindow.mContentParent.getLayoutParams() instanceof MarginLayoutParams) {
Expand All @@ -1349,8 +1360,13 @@ private WindowInsets 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 (!isDynamic) {
mNavigationGuard.setBackgroundColor(mContext.getColor(
R.color.input_method_navigation_guard));
} else {
mNavigationGuard.setBackgroundColor(mContext.getColor(
R.color.input_method_navigation_guard_dynamic));
}
addView(mNavigationGuard, indexOfChild(mNavigationColorViewState.view),
new LayoutParams(LayoutParams.MATCH_PARENT,
insets.getSystemWindowInsetBottom(),
Expand Down
9 changes: 8 additions & 1 deletion core/java/com/android/internal/policy/PhoneWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import android.app.ActivityManagerNative;
import android.app.SearchManager;
import android.database.ContentObserver;
import android.os.UserHandle;

import android.text.TextUtils;
Expand Down Expand Up @@ -2407,7 +2408,13 @@ protected ViewGroup generateLayout(DecorView decor) {
mStatusBarColor = a.getColor(R.styleable.Window_statusBarColor, 0xFF000000);
}
if (!mForcedNavigationBarColor) {
mNavigationBarColor = a.getColor(R.styleable.Window_navigationBarColor, 0xFF000000);
boolean isDynamic = Settings.System.getInt(getContext().getContentResolver(),
Settings.System.NAV_BAR_DYNAMIC, 0) == 1;
if (!isDynamic) {
mNavigationBarColor = a.getColor(R.styleable.Window_navigationBarColor, 0xFF000000);
} else {
mNavigationBarColor = a.getColor(R.styleable.Window_navigationBarColordynamic, 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#setNavigationBarColordynamic(int)}. -->
<attr name="navigationBarColordynamic" 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
1 change: 1 addition & 0 deletions core/res/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@

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

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

Expand Down
3 changes: 3 additions & 0 deletions core/res/res/values/dnd_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permdesc_restartUI">Restart SystemUIService so that system bars can load themed resources</string>

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

</resources>
1 change: 1 addition & 0 deletions core/res/res/values/themes_device_defaults.xml
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,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="navigationBarColordynamic">@android:color/transparent</item>
</style>

<!-- Variant of {@link #Theme_DeviceDefault_Light} with no action bar and no status bar.
Expand Down
2 changes: 2 additions & 0 deletions core/res/res/values/themes_material.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ please see themes_device_defaults.xml.
<item name="windowActionBarFullscreenDecorLayout">@layout/screen_toolbar</item>
<item name="statusBarColor">?attr/colorPrimaryDark</item>
<item name="navigationBarColor">@color/black</item>
<item name="navigationBarColordynamic">?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 @@ -532,6 +533,7 @@ please see themes_device_defaults.xml.
<item name="windowActionBarFullscreenDecorLayout">@layout/screen_toolbar</item>
<item name="statusBarColor">?attr/colorPrimaryDark</item>
<item name="navigationBarColor">@color/black</item>
<item name="navigationBarColordynamic">?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:navigationBarColordynamic">@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 @@ -333,6 +333,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
Settings.Secure.QS_COLUMNS;
private static final String STATUS_BAR_SHOW_CARRIER =
"system:" + Settings.System.STATUS_BAR_SHOW_CARRIER;
private static final String NAV_BAR_DYNAMIC =
"system:" + Settings.System.NAV_BAR_DYNAMIC;

static {
boolean onlyCoreApps;
Expand Down Expand Up @@ -811,7 +813,8 @@ public void start() {
QS_ROWS_PORTRAIT,
QS_ROWS_LANDSCAPE,
QS_COLUMNS,
STATUS_BAR_SHOW_CARRIER);
STATUS_BAR_SHOW_CARRIER,
NAV_BAR_DYNAMIC);

// Lastly, call to the icon policy to install/update all the icons.
mIconPolicy = new PhoneStatusBarPolicy(mContext, mIconController, mCastController,
Expand Down Expand Up @@ -5541,6 +5544,11 @@ public void onTuningChanged(String key, String newValue) {
newValue == null ? 1 : Integer.parseInt(newValue);
updateCarrier();
break;
case NAV_BAR_DYNAMIC:
if (mNavigationController != null) {
mNavigationController.updateNavbarOverlay(mContext.getResources());
}
break;
default:
break;
}
Expand Down

0 comments on commit 8df6304

Please sign in to comment.