Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55a3d089 authored by danielwbhuang's avatar danielwbhuang Committed by Daniel Huang
Browse files

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
parent 2b44fc26
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
<?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>
 No newline at end of file
+29 −0
Original line number Diff line number Diff line
<?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>
 No newline at end of file
+10 −9
Original line number Diff line number Diff line
@@ -29,11 +29,11 @@

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dip"
        android:layout_marginEnd="8dip"
        android:layout_marginTop="6dip"
        android:layout_marginBottom="6dip"
        android:layout_marginBottom="48dip"
        android:layout_weight="1">

        <Button
@@ -46,7 +46,7 @@
            android:layout_alignParentStart="true"
            android:paddingVertical="14dp"
            android:drawablePadding="9dp"
            style="@style/ModifierKeyButtonCancel"
            style="@style/TrackpadButtonCancel"
            android:textColor="?android:attr/textColorPrimary"
            android:text="@string/gesture_button_skip"/>

@@ -60,15 +60,16 @@
            android:layout_alignParentStart="true"
            android:paddingVertical="14dp"
            android:drawablePadding="9dp"
            style="@style/ModifierKeyButtonCancel"
            style="@style/TrackpadButtonCancel"
            android:textColor="?android:attr/textColorPrimary"
            android:text="@string/gesture_button_restart"/>

        <LinearLayout
            android:id="@+id/viewGroup"
            android:layout_width="fill_parent"
            android:layout_height="48dp"
            android:gravity="center"/>
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true"/>

        <Button
            android:id="@+id/button_next"
@@ -80,7 +81,7 @@
            android:layout_alignParentEnd="true"
            android:paddingVertical="14dp"
            android:drawablePadding="9dp"
            style="@style/ModifierKeyButtonDone"
            style="@style/TrackpadButtonDone"
            android:textColor="?androidprv:attr/materialColorOnPrimary"
            android:text="@string/gesture_button_next"/>

@@ -94,7 +95,7 @@
            android:layout_alignParentEnd="true"
            android:paddingVertical="14dp"
            android:drawablePadding="9dp"
            style="@style/ModifierKeyButtonDone"
            style="@style/TrackpadButtonDone"
            android:textColor="?androidprv:attr/materialColorOnPrimary"
            android:text="@string/gesture_button_done"/>
    </RelativeLayout>
+14 −0
Original line number Diff line number Diff line
@@ -380,6 +380,20 @@
        <item name="android:padding">4dp</item>
    </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">
        <item name="android:gravity">center</item>
        <item name="android:maxHeight">@dimen/biometric_auth_pattern_view_max_size</item>
+70 −7
Original line number Diff line number Diff line
@@ -17,17 +17,21 @@
package com.android.settings.inputmethod;

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.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Point;
import android.os.Bundle;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
@@ -87,21 +91,36 @@ public class TrackpadGestureDialogFragment extends BottomSheetDialogFragment {
        if (window == null) {
            return;
        }
        setLayoutEdgeToEdge(window);
        final Point size = getScreenSize();
        final WindowManager.LayoutParams attributes = window.getAttributes();
        attributes.width = (int) (size.x * 0.75);
        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
    public Dialog onCreateDialog(final Bundle savedInstanceState) {
        Dialog dialog = super.onCreateDialog(savedInstanceState);
        mInflater = mContext.getSystemService(LayoutInflater.class);

        View gestureEducationView = mInflater.inflate(R.layout.trackpad_gesture_preview, null);
        addViewPager(gestureEducationView);
        dialog.setContentView(gestureEducationView);

        mInflater = mContext.getSystemService(LayoutInflater.class);
        View contentView = mInflater.inflate(R.layout.trackpad_gesture_preview, null);
        addViewPager(contentView);
        dialog.setContentView(contentView);
        Window gestureDialogWindow = dialog.getWindow();
        gestureDialogWindow.setType(TYPE_SYSTEM_DIALOG);

@@ -109,8 +128,40 @@ public class TrackpadGestureDialogFragment extends BottomSheetDialogFragment {
        FrameLayout bottomSheet = (FrameLayout)
                dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet);
        bottomSheet.setBackgroundResource(android.R.color.transparent);
        BottomSheetBehavior.from(bottomSheet)
                .setState(BottomSheetBehavior.STATE_EXPANDED);
        BottomSheetBehavior<FrameLayout> behavior = BottomSheetBehavior.from(bottomSheet);
        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;
    }
@@ -263,4 +314,16 @@ public class TrackpadGestureDialogFragment extends BottomSheetDialogFragment {
        display.getSize(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);
    }
}