Merge "Update nav bar layout for universal grid" into oc-dr1-dev

am: bf15050a0c

Change-Id: Ifbdae7b95603c76f6cc49e5cc3a28a3dfac46a4f
This commit is contained in:
Jason Monk
2017-06-27 22:57:51 +00:00
committed by android-build-merger
6 changed files with 93 additions and 40 deletions

View File

@@ -18,7 +18,11 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:layout_marginStart="@dimen/rounded_corner_content_padding"
android:layout_marginEnd="@dimen/rounded_corner_content_padding"
android:paddingStart="8dp"
android:paddingEnd="8dp">
<FrameLayout
android:id="@+id/nav_buttons"

View File

@@ -18,7 +18,11 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:layout_marginTop="@dimen/rounded_corner_content_padding"
android:layout_marginBottom="@dimen/rounded_corner_content_padding"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<FrameLayout
android:id="@+id/nav_buttons"

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2017, 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.
*/
-->
<!-- These resources are around just to allow their values to be customized
for different hardware and product builds. -->
<resources>
<!-- Nav bar button default ordering/layout -->
<string name="config_navBarLayout" translatable="false">left[.25W],back[.5WC];home;recent[.5WC],right[.25W]</string>
</resources>

View File

@@ -293,7 +293,7 @@
<string name="config_systemUIFactoryComponent" translatable="false">com.android.systemui.SystemUIFactory</string>
<!-- Nav bar button default ordering/layout -->
<string name="config_navBarLayout" translatable="false">left,back;home;recent,right</string>
<string name="config_navBarLayout" translatable="false">left[.5W],back[1WC];home;recent[1WC],right[.5W]</string>
<bool name="quick_settings_show_full_alarm">false</bool>

View File

@@ -98,14 +98,6 @@ public class RoundedCorners extends SystemUI implements Tunable {
TunablePadding.addTunablePadding(statusBar.findViewById(R.id.keyguard_header), PADDING,
padding, FLAG_END);
View navigationBarWindow = sb.getNavigationBarWindow();
// Not all devices have on screen navigation bars.
if (navigationBarWindow != null) {
FragmentHostManager.get(navigationBarWindow).addTagListener(
NavigationBarFragment.TAG,
new TunablePaddingTagListener(padding, 0));
}
FragmentHostManager fragmentHostManager = FragmentHostManager.get(statusBar);
fragmentHostManager.addTagListener(CollapsedStatusBarFragment.TAG,
new TunablePaddingTagListener(padding, R.id.status_bar));

View File

@@ -19,9 +19,11 @@ import android.content.Context;
import android.content.res.Configuration;
import android.graphics.drawable.Icon;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.Display;
import android.view.Display.Mode;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -43,6 +45,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
public class NavigationBarInflaterView extends FrameLayout
implements Tunable, PluginListener<NavBarButtonProvider> {
@@ -71,6 +75,8 @@ public class NavigationBarInflaterView extends FrameLayout
public static final String KEY_CODE_START = "(";
public static final String KEY_IMAGE_DELIM = ":";
public static final String KEY_CODE_END = ")";
private static final String WEIGHT_SUFFIX = "W";
private static final String WEIGHT_CENTERED_SUFFIX = "WC";
private final List<NavBarButtonProvider> mPlugins = new ArrayList<>();
@@ -219,26 +225,27 @@ public class NavigationBarInflaterView extends FrameLayout
String[] center = sets[1].split(BUTTON_SEPARATOR);
String[] end = sets[2].split(BUTTON_SEPARATOR);
// Inflate these in start to end order or accessibility traversal will be messed up.
inflateButtons(start, (ViewGroup) mRot0.findViewById(R.id.ends_group), isRot0Landscape);
inflateButtons(start, (ViewGroup) mRot90.findViewById(R.id.ends_group), !isRot0Landscape);
inflateButtons(start, mRot0.findViewById(R.id.ends_group), isRot0Landscape, true);
inflateButtons(start, mRot90.findViewById(R.id.ends_group), !isRot0Landscape, true);
inflateButtons(center, (ViewGroup) mRot0.findViewById(R.id.center_group), isRot0Landscape);
inflateButtons(center, (ViewGroup) mRot90.findViewById(R.id.center_group), !isRot0Landscape);
inflateButtons(center, mRot0.findViewById(R.id.center_group), isRot0Landscape, false);
inflateButtons(center, mRot90.findViewById(R.id.center_group), !isRot0Landscape, false);
addGravitySpacer((LinearLayout) mRot0.findViewById(R.id.ends_group));
addGravitySpacer((LinearLayout) mRot90.findViewById(R.id.ends_group));
addGravitySpacer(mRot0.findViewById(R.id.ends_group));
addGravitySpacer(mRot90.findViewById(R.id.ends_group));
inflateButtons(end, (ViewGroup) mRot0.findViewById(R.id.ends_group), isRot0Landscape);
inflateButtons(end, (ViewGroup) mRot90.findViewById(R.id.ends_group), !isRot0Landscape);
inflateButtons(end, mRot0.findViewById(R.id.ends_group), isRot0Landscape, false);
inflateButtons(end, mRot90.findViewById(R.id.ends_group), !isRot0Landscape, false);
}
private void addGravitySpacer(LinearLayout layout) {
layout.addView(new Space(mContext), new LinearLayout.LayoutParams(0, 0, 1));
}
private void inflateButtons(String[] buttons, ViewGroup parent, boolean landscape) {
private void inflateButtons(String[] buttons, ViewGroup parent, boolean landscape,
boolean start) {
for (int i = 0; i < buttons.length; i++) {
inflateButton(buttons[i], parent, landscape);
inflateButton(buttons[i], parent, landscape, start);
}
}
@@ -251,16 +258,13 @@ public class NavigationBarInflaterView extends FrameLayout
}
@Nullable
protected View inflateButton(String buttonSpec, ViewGroup parent, boolean landscape) {
protected View inflateButton(String buttonSpec, ViewGroup parent, boolean landscape,
boolean start) {
LayoutInflater inflater = landscape ? mLandscapeInflater : mLayoutInflater;
float size = extractSize(buttonSpec);
View v = createView(buttonSpec, parent, inflater, landscape);
View v = createView(buttonSpec, parent, inflater);
if (v == null) return null;
if (size != 0) {
ViewGroup.LayoutParams params = v.getLayoutParams();
params.width = (int) (params.width * size);
}
v = applySize(v, buttonSpec, landscape, start);
parent.addView(v);
addToDispatchers(v);
View lastView = landscape ? mLastLandscape : mLastPortrait;
@@ -275,16 +279,41 @@ public class NavigationBarInflaterView extends FrameLayout
return v;
}
private View createView(String buttonSpec, ViewGroup parent, LayoutInflater inflater,
boolean landscape) {
private View applySize(View v, String buttonSpec, boolean landscape, boolean start) {
String sizeStr = extractSize(buttonSpec);
if (sizeStr == null) return v;
if (sizeStr.contains(WEIGHT_SUFFIX)) {
float weight = Float.parseFloat(sizeStr.substring(0, sizeStr.indexOf(WEIGHT_SUFFIX)));
FrameLayout frame = new FrameLayout(mContext);
LayoutParams childParams = new LayoutParams(v.getLayoutParams());
if (sizeStr.endsWith(WEIGHT_CENTERED_SUFFIX)) {
childParams.gravity = Gravity.CENTER;
} else {
childParams.gravity = landscape ? (start ? Gravity.BOTTOM : Gravity.TOP)
: (start ? Gravity.START : Gravity.END);
}
frame.addView(v, childParams);
frame.setLayoutParams(new LinearLayout.LayoutParams(0, MATCH_PARENT, weight));
frame.setClipChildren(false);
frame.setClipToPadding(false);
return frame;
}
float size = Float.parseFloat(sizeStr);
ViewGroup.LayoutParams params = v.getLayoutParams();
params.width = (int) (params.width * size);
return v;
}
private View createView(String buttonSpec, ViewGroup parent, LayoutInflater inflater) {
View v = null;
String button = extractButton(buttonSpec);
if (LEFT.equals(button)) {
buttonSpec = Dependency.get(TunerService.class).getValue(NAV_BAR_LEFT, NAVSPACE);
button = extractButton(buttonSpec);
String s = Dependency.get(TunerService.class).getValue(NAV_BAR_LEFT, NAVSPACE);
button = extractButton(s);
} else if (RIGHT.equals(button)) {
buttonSpec = Dependency.get(TunerService.class).getValue(NAV_BAR_RIGHT, MENU_IME);
button = extractButton(buttonSpec);
String s = Dependency.get(TunerService.class).getValue(NAV_BAR_RIGHT, MENU_IME);
button = extractButton(s);
}
// Let plugins go first so they can override a standard view if they want.
for (NavBarButtonProvider provider : mPlugins) {
@@ -340,13 +369,12 @@ public class NavigationBarInflaterView extends FrameLayout
return Integer.parseInt(subStr);
}
public static float extractSize(String buttonSpec) {
public static String extractSize(String buttonSpec) {
if (!buttonSpec.contains(SIZE_MOD_START)) {
return 1;
return null;
}
final int sizeStart = buttonSpec.indexOf(SIZE_MOD_START);
String sizeStr = buttonSpec.substring(sizeStart + 1, buttonSpec.indexOf(SIZE_MOD_END));
return Float.parseFloat(sizeStr);
return buttonSpec.substring(sizeStart + 1, buttonSpec.indexOf(SIZE_MOD_END));
}
public static String extractButton(String buttonSpec) {
@@ -379,8 +407,8 @@ public class NavigationBarInflaterView extends FrameLayout
mButtonDispatchers.valueAt(i).clear();
}
}
clearAllChildren((ViewGroup) mRot0.findViewById(R.id.nav_buttons));
clearAllChildren((ViewGroup) mRot90.findViewById(R.id.nav_buttons));
clearAllChildren(mRot0.findViewById(R.id.nav_buttons));
clearAllChildren(mRot90.findViewById(R.id.nav_buttons));
}
private void clearAllChildren(ViewGroup group) {