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

Commit 16ae7436 authored by Yuhan Yang's avatar Yuhan Yang Committed by Android (Google) Code Review
Browse files

Merge changes I9f4b9492,Ib5c046e3 into main

* changes:
  Add reset button in mouse keys page
  Add title for keyboard diagrams
parents bd7c5fff 8e355796
Loading
Loading
Loading
Loading
+50 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
@@ -34,7 +35,7 @@
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@+id/mouse_keys_image_recycler_list">
        app:layout_constraintBottom_toTopOf="@+id/title_mouse_keys_image_recycler_list">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
@@ -43,6 +44,22 @@
            android:importantForAccessibility="no"/>
    </LinearLayout>

    <TextView
        android:id="@+id/title_mouse_keys_image_recycler_list"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="@string/mouse_keys_primary_keys_image_list_title"
        android:textSize="16sp"
        android:textColor="@androidprv:color/materialColorPrimary"
        android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
        android:paddingHorizontal="16dp"
        android:layout_marginBottom="8dp"
        android:visibility="gone"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/mouse_keys_info_icon"
        app:layout_constraintBottom_toTopOf="@+id/mouse_keys_image_recycler_list"/>

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/mouse_keys_image_recycler_list"
        android:layout_width="wrap_content"
@@ -52,7 +69,38 @@
        android:padding="12dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/mouse_keys_info_icon"
        app:layout_constraintTop_toBottomOf="@+id/title_mouse_keys_image_recycler_list"
        app:layout_constraintBottom_toTopOf="@+id/title_mouse_keys_numpad_image_recycler_list"/>

    <TextView
        android:id="@+id/title_mouse_keys_numpad_image_recycler_list"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="@string/mouse_keys_numpad_keys_image_list_title"
        android:textSize="16sp"
        android:textColor="@androidprv:color/materialColorPrimary"
        android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
        android:paddingHorizontal="16dp"
        android:layout_marginBottom="8dp"
        android:visibility="gone"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/mouse_keys_image_recycler_list"
        app:layout_constraintBottom_toTopOf="@+id/summary_mouse_keys_numpad_image_recycler_list"/>

    <TextView
        android:id="@+id/summary_mouse_keys_numpad_image_recycler_list"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="@string/mouse_keys_numpad_keys_image_list_summary"
        android:textSize="14sp"
        android:textColor="?android:attr/textColorSecondary"
        android:paddingHorizontal="16dp"
        android:layout_marginBottom="8dp"
        android:visibility="gone"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/title_mouse_keys_numpad_image_recycler_list"
        app:layout_constraintBottom_toTopOf="@+id/mouse_keys_numpad_image_recycler_list"/>

    <androidx.recyclerview.widget.RecyclerView
+8 −0
Original line number Diff line number Diff line
@@ -4950,6 +4950,14 @@
    <string name="mouse_reverse_vertical_scrolling">Reverse scrolling</string>
    <!-- Title for a toggle switch for 'Use primary keys' under mouse key main page, an accessibility setting that allows the user to use primary keyboard keys to control the cursor instead of using numpad keys. [CHAR LIMIT=35] -->
    <string name="mouse_keys_use_primary_keys_title">Use primary keys</string>
    <!-- Label for the reset settings button in mouse key main page, [CHAR LIMIT=35] -->
    <string name="mouse_keys_reset_button_label">Reset settings</string>
    <!-- Title for the primary keys keyboard diagrams in mouse key main page, [CHAR LIMIT=35] -->
    <string name="mouse_keys_primary_keys_image_list_title">How to use primary keys</string>
    <!-- Title for the numpad keys keyboard diagrams in mouse key main page. [CHAR LIMIT=35] -->
    <string name="mouse_keys_numpad_keys_image_list_title">How to use a numeric keypad</string>
    <!-- Summary text for the numpad keys keyboard diagrams in mouse key main page. [CHAR LIMIT=35] -->
    <string name="mouse_keys_numpad_keys_image_list_summary">Numeric keypad will always be used when Num Lock is on</string>
    <!-- Summary text for the 'Mouse reverse scrolling' preference switch indicating to users that when the setting is enabled that scrolling up with their mouse wheel will move the page content down. [CHAR LIMIT=NONE] -->
    <string name="mouse_reverse_vertical_scrolling_summary">Scroll up to move the page down</string>
    <!-- Title for the scrolling section of the mouse settings page. [CHAR LIMIT=60] -->
+9 −0
Original line number Diff line number Diff line
@@ -62,6 +62,15 @@
        android:defaultValue="true"
        settings:controller="com.android.settings.inputmethod.MouseKeysPrimaryKeysController"/>

    <com.android.settingslib.widget.ButtonPreference
        android:key="mouse_keys_reset_button"
        android:title="@string/mouse_keys_reset_button_label"
        settings:buttonPreferenceSize="normal"
        settings:buttonPreferenceType="filled"
        android:icon="@drawable/ic_history"
        android:persistent="false"
        settings:controller="com.android.settings.inputmethod.MouseKeysResetController" />

    <com.android.settingslib.widget.LayoutPreference
        android:key="mouse_keys_list"
        android:layout="@layout/mouse_keys_image_list"/>
+9 −0
Original line number Diff line number Diff line
@@ -168,6 +168,15 @@ public class MouseKeysMainPageFragment extends ShortcutFragment
            final View infoIcon = mMouseKeyImagesPreference.findViewById(
                    R.id.mouse_keys_info_icon);
            infoIcon.setVisibility(View.VISIBLE);

            mMouseKeyImagesPreference.findViewById(R.id.title_mouse_keys_image_recycler_list)
                    .setVisibility(View.VISIBLE);
            mMouseKeyImagesPreference
                    .findViewById(R.id.title_mouse_keys_numpad_image_recycler_list)
                    .setVisibility(View.VISIBLE);
            mMouseKeyImagesPreference
                    .findViewById(R.id.summary_mouse_keys_numpad_image_recycler_list)
                    .setVisibility(View.VISIBLE);
        }
    }

+60 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.
 */

package com.android.settings.inputmethod;

import android.content.Context;
import android.hardware.input.InputSettings;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceScreen;

import com.android.server.accessibility.Flags;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.widget.ButtonPreference;

/**
 * Controller for resetting mouse keys settings button.
 */
public class MouseKeysResetController extends BasePreferenceController {

    @Nullable
    public ButtonPreference mPreference;

    public MouseKeysResetController(@NonNull Context context, @NonNull String preferenceKey) {
        super(context, preferenceKey);
    }

    @Override
    public int getAvailabilityStatus() {
        return Flags.enableMouseKeyEnhancement() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
    }

    @Override
    public void displayPreference(@NonNull PreferenceScreen screen) {
        super.displayPreference(screen);
        mPreference = screen.findPreference(getPreferenceKey());
        if (mPreference != null) {
            mPreference.setOnClickListener(view -> {
                InputSettings.setAccessibilityMouseKeysMaxSpeed(
                        mContext, InputSettings.DEFAULT_MOUSE_KEYS_MAX_SPEED);
                InputSettings.setAccessibilityMouseKeysAcceleration(
                        mContext, InputSettings.DEFAULT_MOUSE_KEYS_ACCELERATION);
            });
        }
    }
}
Loading