From ca8c626febe70f51236dadd0cfb1bb72589c4783 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Mon, 27 Oct 2014 16:53:18 +0100 Subject: [PATCH] Tune spacing in navigation bar for small and big devices Bug: 18032228 Change-Id: Ia187fa3c108b93f4ca74e109d3fa76e625b711e3 --- .../SystemUI/res/layout/navigation_bar.xml | 50 +++++++++++-------- .../SystemUI/res/values-sw360dp/dimens.xml | 30 +++++++++++ .../SystemUI/res/values-sw400dp/dimens.xml | 27 ++++++++++ packages/SystemUI/res/values/dimens.xml | 10 ++-- .../statusbar/phone/NavigationBarView.java | 18 +++++++ 5 files changed, 111 insertions(+), 24 deletions(-) create mode 100644 packages/SystemUI/res/values-sw360dp/dimens.xml create mode 100644 packages/SystemUI/res/values-sw400dp/dimens.xml diff --git a/packages/SystemUI/res/layout/navigation_bar.xml b/packages/SystemUI/res/layout/navigation_bar.xml index 16027d96f0c06..2e38b2026112c 100644 --- a/packages/SystemUI/res/layout/navigation_bar.xml +++ b/packages/SystemUI/res/layout/navigation_bar.xml @@ -43,7 +43,7 @@ + android:visibility="invisible" + android:layout_gravity="end" /> @@ -119,9 +123,9 @@ android:visibility="gone" > + android:layout_height="@dimen/navigation_side_padding" > @@ -223,9 +230,10 @@ android:visibility="invisible" /> + + + + + 80dip + + + 40dip + + + 40dip + + + diff --git a/packages/SystemUI/res/values-sw400dp/dimens.xml b/packages/SystemUI/res/values-sw400dp/dimens.xml new file mode 100644 index 0000000000000..80e82c4fd5946 --- /dev/null +++ b/packages/SystemUI/res/values-sw400dp/dimens.xml @@ -0,0 +1,27 @@ + + + + + + 80dip + + + 50dp + + + diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 07573e0754360..6e6f3025545f6 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -103,11 +103,15 @@ 20dp - - 80dip + + 70dp - 40dip + 36dp + + + 36dp 40dip diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 88e71e2cee74e..9bb52e71ddd7c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -33,12 +33,14 @@ import android.os.Message; import android.util.AttributeSet; import android.util.Log; import android.view.Display; +import android.view.Gravity; import android.view.MotionEvent; import android.view.Surface; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import com.android.systemui.R; @@ -503,15 +505,31 @@ public class NavigationBarView extends LinearLayout { // We swap all children of the 90 and 270 degree layouts, since they are vertical View rotation90 = mRotatedViews[Surface.ROTATION_90]; swapChildrenOrderIfVertical(rotation90.findViewById(R.id.nav_buttons)); + adjustExtraKeyGravity(rotation90, isLayoutRtl); View rotation270 = mRotatedViews[Surface.ROTATION_270]; if (rotation90 != rotation270) { swapChildrenOrderIfVertical(rotation270.findViewById(R.id.nav_buttons)); + adjustExtraKeyGravity(rotation270, isLayoutRtl); } mIsLayoutRtl = isLayoutRtl; } } + private void adjustExtraKeyGravity(View navBar, boolean isLayoutRtl) { + View menu = navBar.findViewById(R.id.menu); + View imeSwitcher = navBar.findViewById(R.id.ime_switcher); + if (menu != null) { + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) menu.getLayoutParams(); + lp.gravity = isLayoutRtl ? Gravity.BOTTOM : Gravity.TOP; + menu.setLayoutParams(lp); + } + if (imeSwitcher != null) { + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) imeSwitcher.getLayoutParams(); + lp.gravity = isLayoutRtl ? Gravity.BOTTOM : Gravity.TOP; + imeSwitcher.setLayoutParams(lp); + } + } /** * Swaps the children order of a LinearLayout if it's orientation is Vertical