From 3b3f1f521a6a7a097c996955d11c075a32fecea8 Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Wed, 28 Jun 2017 10:45:13 -0400 Subject: [PATCH] Shrink the nav buttons some Test: visual Bug: 37115488 Change-Id: Ie013f1644ac9782c10000dc4e4019d99c91680f8 --- packages/SystemUI/res/layout/back.xml | 4 ++- packages/SystemUI/res/layout/home.xml | 4 ++- packages/SystemUI/res/layout/recent_apps.xml | 4 ++- .../phone/NavigationBarInflaterView.java | 3 +- .../statusbar/phone/ReverseLinearLayout.java | 35 ++++++++++++++++--- 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/res/layout/back.xml b/packages/SystemUI/res/layout/back.xml index 4e8726b3a6340..43bec91ad053c 100644 --- a/packages/SystemUI/res/layout/back.xml +++ b/packages/SystemUI/res/layout/back.xml @@ -22,8 +22,10 @@ android:layout_height="match_parent" android:layout_weight="0" systemui:keyCode="4" - android:scaleType="center" + android:scaleType="fitCenter" android:contentDescription="@string/accessibility_back" + android:paddingTop="15dp" + android:paddingBottom="15dp" android:paddingStart="@dimen/navigation_key_padding" android:paddingEnd="@dimen/navigation_key_padding" /> diff --git a/packages/SystemUI/res/layout/home.xml b/packages/SystemUI/res/layout/home.xml index 95863272b9bf7..53ef2ab247e76 100644 --- a/packages/SystemUI/res/layout/home.xml +++ b/packages/SystemUI/res/layout/home.xml @@ -21,8 +21,10 @@ android:layout_height="match_parent" android:layout_weight="0" systemui:keyCode="3" - android:scaleType="center" + android:scaleType="fitCenter" android:contentDescription="@string/accessibility_home" + android:paddingTop="13dp" + android:paddingBottom="13dp" android:paddingStart="@dimen/navigation_key_padding" android:paddingEnd="@dimen/navigation_key_padding" /> diff --git a/packages/SystemUI/res/layout/recent_apps.xml b/packages/SystemUI/res/layout/recent_apps.xml index 870bcf7547a70..c84d28051286a 100644 --- a/packages/SystemUI/res/layout/recent_apps.xml +++ b/packages/SystemUI/res/layout/recent_apps.xml @@ -21,8 +21,10 @@ android:layout_width="@dimen/navigation_key_width" android:layout_height="match_parent" android:layout_weight="0" - android:scaleType="center" + android:scaleType="fitCenter" android:contentDescription="@string/accessibility_recent" + android:paddingTop="15dp" + android:paddingBottom="15dp" android:paddingStart="@dimen/navigation_key_padding" android:paddingEnd="@dimen/navigation_key_padding" /> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java index a14d1bc564ffe..09ae521ceb2b6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java @@ -37,6 +37,7 @@ import com.android.systemui.R; import com.android.systemui.plugins.PluginListener; import com.android.systemui.plugins.PluginManager; import com.android.systemui.plugins.statusbar.phone.NavBarButtonProvider; +import com.android.systemui.statusbar.phone.ReverseLinearLayout.ReverseFrameLayout; import com.android.systemui.statusbar.policy.KeyButtonView; import com.android.systemui.tuner.TunerService; import com.android.systemui.tuner.TunerService.Tunable; @@ -285,7 +286,7 @@ public class NavigationBarInflaterView extends FrameLayout if (sizeStr.contains(WEIGHT_SUFFIX)) { float weight = Float.parseFloat(sizeStr.substring(0, sizeStr.indexOf(WEIGHT_SUFFIX))); - FrameLayout frame = new FrameLayout(mContext); + FrameLayout frame = new ReverseFrameLayout(mContext); LayoutParams childParams = new LayoutParams(v.getLayoutParams()); if (sizeStr.endsWith(WEIGHT_CENTERED_SUFFIX)) { childParams.gravity = Gravity.CENTER; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ReverseLinearLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ReverseLinearLayout.java index f45967a0a0a6e..bcbc3457a2e29 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ReverseLinearLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ReverseLinearLayout.java @@ -16,10 +16,10 @@ package com.android.systemui.statusbar.phone; import android.annotation.Nullable; import android.content.Context; -import android.content.res.Configuration; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; +import android.widget.FrameLayout; import android.widget.LinearLayout; import java.util.ArrayList; @@ -48,7 +48,7 @@ public class ReverseLinearLayout extends LinearLayout { @Override public void addView(View child) { - reversParams(child.getLayoutParams()); + reverseParams(child.getLayoutParams(), child); if (mIsLayoutReverse) { super.addView(child, 0); } else { @@ -58,7 +58,7 @@ public class ReverseLinearLayout extends LinearLayout { @Override public void addView(View child, ViewGroup.LayoutParams params) { - reversParams(params); + reverseParams(params, child); if (mIsLayoutReverse) { super.addView(child, 0, params); } else { @@ -100,7 +100,15 @@ public class ReverseLinearLayout extends LinearLayout { } } - private void reversParams(ViewGroup.LayoutParams params) { + private static void reverseParams(ViewGroup.LayoutParams params, View child) { + if (child instanceof Reversable) { + ((Reversable) child).reverse(); + } + if (child.getPaddingLeft() == child.getPaddingRight() + && child.getPaddingTop() == child.getPaddingBottom()) { + child.setPadding(child.getPaddingTop(), child.getPaddingLeft(), + child.getPaddingTop(), child.getPaddingLeft()); + } if (params == null) { return; } @@ -109,4 +117,23 @@ public class ReverseLinearLayout extends LinearLayout { params.height = width; } + public interface Reversable { + void reverse(); + } + + public static class ReverseFrameLayout extends FrameLayout implements Reversable { + + public ReverseFrameLayout(Context context) { + super(context); + } + + @Override + public void reverse() { + for (int i = 0; i < getChildCount(); i++) { + View child = getChildAt(i); + reverseParams(child.getLayoutParams(), child); + } + } + } + }