Fix Multiple UI issues
1. Use edge-to-edge UI 2. Use new color token 3. Put text in the middle of the button Bug:279163958 Bug:278504911 Test: manual Change-Id: I189e9da2251f7d204ddc18680d3d1ec4638fa2db
This commit is contained in:
committed by
Daniel Huang
parent
2b44fc26d1
commit
55a3d089f9
32
res/drawable/trackpad_bordered.xml
Normal file
32
res/drawable/trackpad_bordered.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2023 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<inset
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
||||||
|
<ripple
|
||||||
|
android:color="?android:attr/colorControlHighlight">
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<corners android:radius="24dp" />
|
||||||
|
<solid android:color="@android:color/transparent"/>
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="?androidprv:attr/materialColorPrimary"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</ripple>
|
||||||
|
</inset>
|
29
res/drawable/trackpad_button_done_colored.xml
Normal file
29
res/drawable/trackpad_button_done_colored.xml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2022 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<inset
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
||||||
|
<ripple
|
||||||
|
android:color="?android:attr/colorControlHighlight">
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<corners android:radius="24dp"/>
|
||||||
|
<solid android:color="?androidprv:attr/materialColorPrimary"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</ripple>
|
||||||
|
</inset>
|
@@ -29,11 +29,11 @@
|
|||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dip"
|
android:layout_marginStart="8dip"
|
||||||
android:layout_marginEnd="8dip"
|
android:layout_marginEnd="8dip"
|
||||||
android:layout_marginTop="6dip"
|
android:layout_marginTop="6dip"
|
||||||
android:layout_marginBottom="6dip"
|
android:layout_marginBottom="48dip"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:paddingVertical="14dp"
|
android:paddingVertical="14dp"
|
||||||
android:drawablePadding="9dp"
|
android:drawablePadding="9dp"
|
||||||
style="@style/ModifierKeyButtonCancel"
|
style="@style/TrackpadButtonCancel"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:text="@string/gesture_button_skip"/>
|
android:text="@string/gesture_button_skip"/>
|
||||||
|
|
||||||
@@ -60,15 +60,16 @@
|
|||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:paddingVertical="14dp"
|
android:paddingVertical="14dp"
|
||||||
android:drawablePadding="9dp"
|
android:drawablePadding="9dp"
|
||||||
style="@style/ModifierKeyButtonCancel"
|
style="@style/TrackpadButtonCancel"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:text="@string/gesture_button_restart"/>
|
android:text="@string/gesture_button_restart"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/viewGroup"
|
android:id="@+id/viewGroup"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="48dp"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"/>
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_centerHorizontal="true"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button_next"
|
android:id="@+id/button_next"
|
||||||
@@ -80,7 +81,7 @@
|
|||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:paddingVertical="14dp"
|
android:paddingVertical="14dp"
|
||||||
android:drawablePadding="9dp"
|
android:drawablePadding="9dp"
|
||||||
style="@style/ModifierKeyButtonDone"
|
style="@style/TrackpadButtonDone"
|
||||||
android:textColor="?androidprv:attr/materialColorOnPrimary"
|
android:textColor="?androidprv:attr/materialColorOnPrimary"
|
||||||
android:text="@string/gesture_button_next"/>
|
android:text="@string/gesture_button_next"/>
|
||||||
|
|
||||||
@@ -94,7 +95,7 @@
|
|||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:paddingVertical="14dp"
|
android:paddingVertical="14dp"
|
||||||
android:drawablePadding="9dp"
|
android:drawablePadding="9dp"
|
||||||
style="@style/ModifierKeyButtonDone"
|
style="@style/TrackpadButtonDone"
|
||||||
android:textColor="?androidprv:attr/materialColorOnPrimary"
|
android:textColor="?androidprv:attr/materialColorOnPrimary"
|
||||||
android:text="@string/gesture_button_done"/>
|
android:text="@string/gesture_button_done"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@@ -380,6 +380,20 @@
|
|||||||
<item name="android:padding">4dp</item>
|
<item name="android:padding">4dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="TrackpadButtonDone" parent="@android:style/Widget.Material.Button">
|
||||||
|
<item name="android:background">@drawable/trackpad_button_done_colored</item>
|
||||||
|
<item name="android:stateListAnimator">@null</item>
|
||||||
|
<item name="android:textSize">16sp</item>
|
||||||
|
<item name="android:padding">4dp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="TrackpadButtonCancel" parent="@android:style/Widget.Material.Button">
|
||||||
|
<item name="android:background">@drawable/trackpad_bordered</item>
|
||||||
|
<item name="android:stateListAnimator">@null</item>
|
||||||
|
<item name="android:textSize">16sp</item>
|
||||||
|
<item name="android:padding">4dp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="LockPatternContainerStyle">
|
<style name="LockPatternContainerStyle">
|
||||||
<item name="android:gravity">center</item>
|
<item name="android:gravity">center</item>
|
||||||
<item name="android:maxHeight">@dimen/biometric_auth_pattern_view_max_size</item>
|
<item name="android:maxHeight">@dimen/biometric_auth_pattern_view_max_size</item>
|
||||||
|
@@ -17,17 +17,21 @@
|
|||||||
package com.android.settings.inputmethod;
|
package com.android.settings.inputmethod;
|
||||||
|
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
|
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
import android.view.WindowInsets;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
@@ -87,21 +91,36 @@ public class TrackpadGestureDialogFragment extends BottomSheetDialogFragment {
|
|||||||
if (window == null) {
|
if (window == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setLayoutEdgeToEdge(window);
|
||||||
final Point size = getScreenSize();
|
final Point size = getScreenSize();
|
||||||
final WindowManager.LayoutParams attributes = window.getAttributes();
|
final WindowManager.LayoutParams attributes = window.getAttributes();
|
||||||
attributes.width = (int) (size.x * 0.75);
|
attributes.width = (int) (size.x * 0.75);
|
||||||
window.setAttributes(attributes);
|
window.setAttributes(attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setLayoutEdgeToEdge(Window window) {
|
||||||
|
View windowDecorView = window.getDecorView();
|
||||||
|
windowDecorView.setSystemUiVisibility(
|
||||||
|
windowDecorView.getSystemUiVisibility()
|
||||||
|
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||||
|
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
|
||||||
|
window.setNavigationBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(final Bundle savedInstanceState) {
|
public Dialog onCreateDialog(final Bundle savedInstanceState) {
|
||||||
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
||||||
|
|
||||||
mInflater = mContext.getSystemService(LayoutInflater.class);
|
mInflater = mContext.getSystemService(LayoutInflater.class);
|
||||||
|
View contentView = mInflater.inflate(R.layout.trackpad_gesture_preview, null);
|
||||||
View gestureEducationView = mInflater.inflate(R.layout.trackpad_gesture_preview, null);
|
addViewPager(contentView);
|
||||||
addViewPager(gestureEducationView);
|
dialog.setContentView(contentView);
|
||||||
dialog.setContentView(gestureEducationView);
|
|
||||||
|
|
||||||
Window gestureDialogWindow = dialog.getWindow();
|
Window gestureDialogWindow = dialog.getWindow();
|
||||||
gestureDialogWindow.setType(TYPE_SYSTEM_DIALOG);
|
gestureDialogWindow.setType(TYPE_SYSTEM_DIALOG);
|
||||||
|
|
||||||
@@ -109,8 +128,40 @@ public class TrackpadGestureDialogFragment extends BottomSheetDialogFragment {
|
|||||||
FrameLayout bottomSheet = (FrameLayout)
|
FrameLayout bottomSheet = (FrameLayout)
|
||||||
dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet);
|
dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet);
|
||||||
bottomSheet.setBackgroundResource(android.R.color.transparent);
|
bottomSheet.setBackgroundResource(android.R.color.transparent);
|
||||||
BottomSheetBehavior.from(bottomSheet)
|
BottomSheetBehavior<FrameLayout> behavior = BottomSheetBehavior.from(bottomSheet);
|
||||||
.setState(BottomSheetBehavior.STATE_EXPANDED);
|
if (!isGestureNavigationEnabled()) {
|
||||||
|
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||||
|
}
|
||||||
|
ViewTreeObserver observer = contentView.getViewTreeObserver();
|
||||||
|
observer.addOnGlobalLayoutListener(
|
||||||
|
new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
contentView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
|
int contentViewHeight = contentView.getMeasuredHeight();
|
||||||
|
int navigationBarHeight = getNavigationBarHeight();
|
||||||
|
behavior.setPeekHeight(contentViewHeight - navigationBarHeight);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// The gesture education view shouldn't be draggable."
|
||||||
|
behavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
|
||||||
|
@Override
|
||||||
|
public void onStateChanged(View bottomSheet, int newState) {
|
||||||
|
if (newState == BottomSheetBehavior.STATE_DRAGGING) {
|
||||||
|
if (isGestureNavigationEnabled()) {
|
||||||
|
behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||||
|
} else {
|
||||||
|
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSlide(View bottomSheet, float slideOffset) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
@@ -263,4 +314,16 @@ public class TrackpadGestureDialogFragment extends BottomSheetDialogFragment {
|
|||||||
display.getSize(size);
|
display.getSize(size);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getNavigationBarHeight() {
|
||||||
|
final Activity activity = (Activity) mContext;
|
||||||
|
WindowInsets insets =
|
||||||
|
activity.getWindowManager().getCurrentWindowMetrics().getWindowInsets();
|
||||||
|
return insets.getInsets(WindowInsets.Type.navigationBars()).bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isGestureNavigationEnabled() {
|
||||||
|
return NAV_BAR_MODE_GESTURAL == mContext.getResources().getInteger(
|
||||||
|
com.android.internal.R.integer.config_navBarInteractionMode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user