summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/res/layout-ldrtl/navigation_bar.xml328
-rw-r--r--packages/SystemUI/res/layout-sw600dp/navigation_bar.xml8
-rw-r--r--packages/SystemUI/res/layout/navigation_bar.xml7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java63
4 files changed, 58 insertions, 348 deletions
diff --git a/packages/SystemUI/res/layout-ldrtl/navigation_bar.xml b/packages/SystemUI/res/layout-ldrtl/navigation_bar.xml
deleted file mode 100644
index 35414bca419f..000000000000
--- a/packages/SystemUI/res/layout-ldrtl/navigation_bar.xml
+++ /dev/null
@@ -1,328 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/* apps/common/assets/default/default/skins/StatusBar.xml
-**
-** Copyright 2011, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
--->
-
-<com.android.systemui.statusbar.phone.NavigationBarView
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:background="@drawable/system_bar_background"
- >
-
- <FrameLayout android:id="@+id/rot0"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- >
-
- <LinearLayout
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:orientation="horizontal"
- android:clipChildren="false"
- android:clipToPadding="false"
- android:id="@+id/nav_buttons"
- android:animateLayoutChanges="true"
- >
-
- <!-- navigation controls -->
- <View
- android:layout_width="@dimen/navigation_extra_key_width"
- android:layout_height="match_parent"
- android:layout_weight="0"
- android:visibility="invisible"
- />
- <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/back"
- android:layout_width="@dimen/navigation_key_width"
- android:layout_height="match_parent"
- android:src="@drawable/ic_sysbar_back"
- systemui:keyCode="4"
- android:layout_weight="0"
- android:scaleType="center"
- android:background="@drawable/ripple_drawable"
- android:contentDescription="@string/accessibility_back"
- />
- <View
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:visibility="invisible"
- />
- <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/home"
- android:layout_width="@dimen/navigation_key_width"
- android:layout_height="match_parent"
- android:src="@drawable/ic_sysbar_home"
- systemui:keyCode="3"
- systemui:keyRepeat="false"
- android:layout_weight="0"
- android:background="@drawable/ripple_drawable"
- android:contentDescription="@string/accessibility_home"
- />
- <View
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:visibility="invisible"
- />
- <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/recent_apps"
- android:layout_width="@dimen/navigation_key_width"
- android:layout_height="match_parent"
- android:src="@drawable/ic_sysbar_recent"
- android:layout_weight="0"
- android:background="@drawable/ripple_drawable"
- android:contentDescription="@string/accessibility_recent"
- />
- <FrameLayout
- android:layout_width="@dimen/navigation_extra_key_width"
- android:layout_height="match_parent"
- android:layout_weight="0" >
- <com.android.systemui.statusbar.policy.KeyButtonView
- android:id="@+id/menu"
- android:layout_width="@dimen/navigation_extra_key_width"
- android:layout_height="match_parent"
- android:contentDescription="@string/accessibility_menu"
- android:src="@drawable/ic_sysbar_menu"
- android:visibility="invisible"
- android:background="@drawable/ripple_drawable"
- systemui:keyCode="82" />
- <com.android.systemui.statusbar.policy.KeyButtonView
- android:id="@+id/ime_switcher"
- android:layout_width="@dimen/navigation_extra_key_width"
- android:layout_height="match_parent"
- android:contentDescription="@string/accessibility_ime_switch_button"
- android:scaleType="centerInside"
- android:src="@drawable/ic_ime_switcher_default"
- android:visibility="invisible"
- android:background="@drawable/ripple_drawable" />
- </FrameLayout>
- </LinearLayout>
-
- <!-- lights out layout to match exactly -->
- <LinearLayout
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:orientation="horizontal"
- android:id="@+id/lights_out"
- android:visibility="gone"
- >
- <ImageView
- android:layout_width="80dp"
- android:layout_height="match_parent"
- android:layout_marginStart="40dp"
- android:src="@drawable/ic_sysbar_lights_out_dot_small"
- android:scaleType="center"
- android:layout_weight="0"
- />
- <View
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:visibility="invisible"
- />
- <ImageView
- android:layout_width="80dp"
- android:layout_height="match_parent"
- android:src="@drawable/ic_sysbar_lights_out_dot_large"
- android:scaleType="center"
- android:layout_weight="0"
- />
- <View
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:visibility="invisible"
- />
- <ImageView
- android:layout_width="80dp"
- android:layout_marginEnd="40dp"
- android:layout_height="match_parent"
- android:src="@drawable/ic_sysbar_lights_out_dot_small"
- android:scaleType="center"
- android:layout_weight="0"
- />
- </LinearLayout>
-
- <com.android.systemui.statusbar.policy.DeadZone
- android:id="@+id/deadzone"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- systemui:minSize="@dimen/navigation_bar_deadzone_size"
- systemui:maxSize="@dimen/navigation_bar_deadzone_size_max"
- systemui:holdTime="@integer/navigation_bar_deadzone_hold"
- systemui:decayTime="@integer/navigation_bar_deadzone_decay"
- systemui:orientation="horizontal"
- android:layout_gravity="top"
- />
- </FrameLayout>
-
- <FrameLayout android:id="@+id/rot90"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:visibility="gone"
- android:paddingTop="0dp"
- >
-
- <LinearLayout
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:orientation="vertical"
- android:clipChildren="false"
- android:clipToPadding="false"
- android:id="@+id/nav_buttons"
- android:animateLayoutChanges="true"
- >
-
- <!-- navigation controls -->
- <FrameLayout
- android:layout_width="@dimen/navigation_extra_key_width"
- android:layout_height="40dp"
- android:layout_weight="0" >
- <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/menu"
- android:layout_height="@dimen/navigation_extra_key_width"
- android:layout_width="match_parent"
- android:src="@drawable/ic_sysbar_menu_land"
- systemui:keyCode="82"
- android:layout_weight="0"
- android:visibility="invisible"
- android:contentDescription="@string/accessibility_menu"
- android:background="@drawable/ripple_drawable" />
- <com.android.systemui.statusbar.policy.KeyButtonView
- android:id="@+id/ime_switcher"
- android:layout_height="@dimen/navigation_extra_key_width"
- android:layout_width="match_parent"
- android:contentDescription="@string/accessibility_ime_switch_button"
- android:scaleType="centerInside"
- android:src="@drawable/ic_ime_switcher_default"
- android:visibility="invisible"
- android:background="@drawable/ripple_drawable" />
- </FrameLayout>
- <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/back"
- android:layout_height="80dp"
- android:layout_width="match_parent"
- android:src="@drawable/ic_sysbar_back_land"
- android:scaleType="center"
- systemui:keyCode="4"
- android:layout_weight="0"
- android:contentDescription="@string/accessibility_back"
- android:background="@drawable/ripple_drawable"
- />
- <View
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:layout_weight="1"
- android:visibility="invisible"
- />
- <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/home"
- android:layout_height="80dp"
- android:layout_width="match_parent"
- android:src="@drawable/ic_sysbar_home_land"
- systemui:keyCode="3"
- systemui:keyRepeat="false"
- android:layout_weight="0"
- android:contentDescription="@string/accessibility_home"
- android:background="@drawable/ripple_drawable"
- />
- <View
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:layout_weight="1"
- android:visibility="invisible"
- />
- <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/recent_apps"
- android:layout_height="80dp"
- android:layout_width="match_parent"
- android:src="@drawable/ic_sysbar_recent_land"
- android:layout_weight="0"
- android:contentDescription="@string/accessibility_recent"
- android:background="@drawable/ripple_drawable"
- />
- <View
- android:layout_height="40dp"
- android:layout_width="match_parent"
- android:layout_weight="0"
- android:visibility="invisible"
- />
- </LinearLayout>
-
- <!-- lights out layout to match exactly -->
- <LinearLayout
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:orientation="vertical"
- android:id="@+id/lights_out"
- android:visibility="gone"
- >
- <ImageView
- android:layout_height="80dp"
- android:layout_marginTop="40dp"
- android:layout_width="match_parent"
- android:src="@drawable/ic_sysbar_lights_out_dot_small"
- android:scaleType="center"
- android:layout_weight="0"
- />
- <View
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:layout_weight="1"
- android:visibility="invisible"
- />
- <ImageView
- android:layout_height="80dp"
- android:layout_width="match_parent"
- android:src="@drawable/ic_sysbar_lights_out_dot_large"
- android:scaleType="center"
- android:layout_weight="0"
- />
- <View
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:layout_weight="1"
- android:visibility="invisible"
- />
- <ImageView
- android:layout_height="80dp"
- android:layout_marginBottom="40dp"
- android:layout_width="match_parent"
- android:src="@drawable/ic_sysbar_lights_out_dot_small"
- android:scaleType="center"
- android:layout_weight="0"
- />
- </LinearLayout>
-
- <com.android.systemui.statusbar.policy.DeadZone
- android:id="@+id/deadzone"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- systemui:minSize="@dimen/navigation_bar_deadzone_size"
- systemui:maxSize="@dimen/navigation_bar_deadzone_size_max"
- systemui:holdTime="@integer/navigation_bar_deadzone_hold"
- systemui:decayTime="@integer/navigation_bar_deadzone_decay"
- systemui:orientation="vertical"
- android:layout_gravity="top"
- />
- </FrameLayout>
-
- <!-- not used -->
- <View android:id="@+id/rot270"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:visibility="gone"
- />
-
-</com.android.systemui.statusbar.phone.NavigationBarView>
diff --git a/packages/SystemUI/res/layout-sw600dp/navigation_bar.xml b/packages/SystemUI/res/layout-sw600dp/navigation_bar.xml
index f8b7bae8681c..b5983bb8cd95 100644
--- a/packages/SystemUI/res/layout-sw600dp/navigation_bar.xml
+++ b/packages/SystemUI/res/layout-sw600dp/navigation_bar.xml
@@ -314,12 +314,4 @@
android:layout_gravity="top"
/>
</FrameLayout>
-
- <!-- not used -->
- <View android:id="@+id/rot270"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:visibility="gone"
- />
-
</com.android.systemui.statusbar.phone.NavigationBarView>
diff --git a/packages/SystemUI/res/layout/navigation_bar.xml b/packages/SystemUI/res/layout/navigation_bar.xml
index 7616cb1f85ba..a165940616ba 100644
--- a/packages/SystemUI/res/layout/navigation_bar.xml
+++ b/packages/SystemUI/res/layout/navigation_bar.xml
@@ -322,11 +322,4 @@
/>
</FrameLayout>
- <!-- not used -->
- <View android:id="@+id/rot270"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:visibility="gone"
- />
-
</com.android.systemui.statusbar.phone.NavigationBarView>
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 35929716c243..3bb403d209a8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -23,6 +23,7 @@ import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.app.StatusBarManager;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Rect;
@@ -48,13 +49,12 @@ import com.android.systemui.statusbar.policy.KeyButtonView;
import java.io.FileDescriptor;
import java.io.PrintWriter;
+import java.util.ArrayList;
public class NavigationBarView extends LinearLayout {
final static boolean DEBUG = false;
final static String TAG = "PhoneStatusBar/NavigationBarView";
- final static boolean NAVBAR_ALWAYS_AT_RIGHT = true;
-
// slippery nav bar when everything is disabled, e.g. during setup
final static boolean SLIPPERY_WHEN_DISABLED = true;
@@ -87,6 +87,7 @@ public class NavigationBarView extends LinearLayout {
private final NavTransitionListener mTransitionListener = new NavTransitionListener();
private OnVerticalChangedListener mOnVerticalChangedListener;
+ private boolean mIsLtr;
private class NavTransitionListener implements TransitionListener {
private boolean mBackTransitioning;
@@ -387,13 +388,13 @@ public class NavigationBarView extends LinearLayout {
mRotatedViews[Surface.ROTATION_90] = findViewById(R.id.rot90);
- mRotatedViews[Surface.ROTATION_270] = NAVBAR_ALWAYS_AT_RIGHT
- ? findViewById(R.id.rot90)
- : findViewById(R.id.rot270);
+ mRotatedViews[Surface.ROTATION_270] = mRotatedViews[Surface.ROTATION_90];
mCurrentView = mRotatedViews[Surface.ROTATION_0];
getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener);
+
+ updateLTROrder();
}
public boolean isVertical() {
@@ -456,6 +457,58 @@ public class NavigationBarView extends LinearLayout {
super.onSizeChanged(w, h, oldw, oldh);
}
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ updateLTROrder();
+ }
+
+ /**
+ * In landscape, the LinearLayout is not auto mirrored since it is vertical. Therefore we
+ * have to do it manually
+ */
+ private void updateLTROrder() {
+ boolean isLtr = getResources().getConfiguration()
+ .getLayoutDirection() == LAYOUT_DIRECTION_RTL;
+ if (mIsLtr != isLtr) {
+
+ // 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));
+
+ View rotation270 = mRotatedViews[Surface.ROTATION_270];
+ if (rotation90 != rotation270) {
+ swapChildrenOrderIfVertical(rotation270.findViewById(R.id.nav_buttons));
+ }
+ mIsLtr = isLtr;
+ }
+ }
+
+
+ /**
+ * Swaps the children order of a LinearLayout if it's orientation is Vertical
+ *
+ * @param group The LinearLayout to swap the children from.
+ */
+ private void swapChildrenOrderIfVertical(View group) {
+ if (group instanceof LinearLayout) {
+ LinearLayout linearLayout = (LinearLayout) group;
+ if (linearLayout.getOrientation() == VERTICAL) {
+ int childCount = linearLayout.getChildCount();
+ ArrayList<View> childList = new ArrayList<>(childCount);
+ for (int i = 0; i < childCount; i++) {
+ childList.add(linearLayout.getChildAt(i));
+ }
+ linearLayout.removeAllViews();
+ for (int i = childCount - 1; i >= 0; i--) {
+ linearLayout.addView(childList.get(i));
+ }
+ }
+ }
+ }
+
+
+
/*
@Override
protected void onLayout (boolean changed, int left, int top, int right, int bottom) {