Merge 2024-06 Release (ab/AP2A.240605.024) to aosp-main-future
Bug: 343100748 Merged-In: Id3d79805bb2289b84ad34ac05a97e50f0410502f Change-Id: I70f531e800ed5f3765a100b5b5cecb99664c1dbc
This commit is contained in:
@@ -22,6 +22,7 @@ import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
@@ -47,7 +48,7 @@ import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
|
||||
/**
|
||||
* A preference controller to turn on/off keyboard vibration state with a single toggle.
|
||||
* A preference controller to turn on/off keyboard vibration state with a single toggle.
|
||||
*/
|
||||
public class KeyboardVibrationTogglePreferenceController extends TogglePreferenceController
|
||||
implements DefaultLifecycleObserver {
|
||||
@@ -110,7 +111,9 @@ public class KeyboardVibrationTogglePreferenceController extends TogglePreferenc
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (Flags.keyboardCategoryEnabled()
|
||||
&& mContext.getResources().getBoolean(R.bool.config_keyboard_vibration_supported)) {
|
||||
&& mContext.getResources().getBoolean(R.bool.config_keyboard_vibration_supported)
|
||||
&& mContext.getResources().getFloat(
|
||||
com.android.internal.R.dimen.config_keyboardHapticFeedbackFixedAmplitude) > 0) {
|
||||
return AVAILABLE;
|
||||
}
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
@@ -157,8 +160,11 @@ public class KeyboardVibrationTogglePreferenceController extends TogglePreferenc
|
||||
}
|
||||
|
||||
private boolean updateKeyboardVibrationSetting(boolean enable) {
|
||||
final boolean success = Settings.System.putInt(mContext.getContentResolver(),
|
||||
KEYBOARD_VIBRATION_ENABLED, enable ? ON : OFF);
|
||||
final ContentResolver contentResolver = mContext.getContentResolver();
|
||||
final boolean success = Settings.System.putInt(contentResolver,
|
||||
KEYBOARD_VIBRATION_ENABLED, enable ? ON : OFF);
|
||||
contentResolver.notifyChange(Settings.System.getUriFor(KEYBOARD_VIBRATION_ENABLED),
|
||||
null /* observer */, ContentResolver.NOTIFY_NO_DELAY);
|
||||
if (!success) {
|
||||
Log.w(TAG, "Update settings database error!");
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
@@ -68,6 +69,11 @@ public class DatePreferenceController extends BasePreferenceController
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
|
||||
if (preference instanceof RestrictedPreference
|
||||
&& ((RestrictedPreference) preference).isDisabledByAdmin()) {
|
||||
return;
|
||||
}
|
||||
preference.setEnabled(isEnabled());
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.widget.TimePicker;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
@@ -66,6 +67,11 @@ public class TimePreferenceController extends BasePreferenceController
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
|
||||
if (preference instanceof RestrictedPreference
|
||||
&& ((RestrictedPreference) preference).isDisabledByAdmin()) {
|
||||
return;
|
||||
}
|
||||
preference.setEnabled(isEnabled());
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.hardware.input.InputDeviceIdentifier;
|
||||
import android.hardware.input.InputManager;
|
||||
import android.hardware.input.KeyboardLayout;
|
||||
import android.hardware.input.KeyboardLayoutSelectionResult;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -180,7 +181,7 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
||||
mapLanguageWithLayout(info, subtype);
|
||||
}
|
||||
}
|
||||
updatePreferenceLayout(preferenceScreen, info);
|
||||
updatePreferenceLayout(preferenceScreen, info, infoList.size() > 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,14 +190,15 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
||||
KeyboardLayout[] keyboardLayouts =
|
||||
NewKeyboardSettingsUtils.getKeyboardLayouts(
|
||||
mIm, mUserId, mInputDeviceIdentifier, info, subtype);
|
||||
String layout = NewKeyboardSettingsUtils.getKeyboardLayout(
|
||||
KeyboardLayoutSelectionResult result = NewKeyboardSettingsUtils.getKeyboardLayout(
|
||||
mIm, mUserId, mInputDeviceIdentifier, info, subtype);
|
||||
if (layout != null) {
|
||||
if (result.getLayoutDescriptor() != null) {
|
||||
for (int i = 0; i < keyboardLayouts.length; i++) {
|
||||
if (keyboardLayouts[i].getDescriptor().equals(layout)) {
|
||||
if (keyboardLayouts[i].getDescriptor().equals(result.getLayoutDescriptor())) {
|
||||
KeyboardInfo keyboardInfo = new KeyboardInfo(
|
||||
subtypeLabel,
|
||||
keyboardLayouts[i].getLabel(),
|
||||
result.getSelectionCriteria(),
|
||||
info,
|
||||
subtype);
|
||||
mKeyboardInfoList.add(keyboardInfo);
|
||||
@@ -208,18 +210,22 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
||||
KeyboardInfo keyboardInfo = new KeyboardInfo(
|
||||
subtypeLabel,
|
||||
mContext.getString(R.string.keyboard_default_layout),
|
||||
KeyboardLayoutSelectionResult.LAYOUT_SELECTION_CRITERIA_UNSPECIFIED,
|
||||
info,
|
||||
subtype);
|
||||
mKeyboardInfoList.add(keyboardInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePreferenceLayout(PreferenceScreen preferenceScreen, InputMethodInfo info) {
|
||||
private void updatePreferenceLayout(PreferenceScreen preferenceScreen, InputMethodInfo info,
|
||||
boolean hasMultipleImes) {
|
||||
if (mKeyboardInfoList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
PreferenceCategory preferenceCategory = new PreferenceCategory(mContext);
|
||||
preferenceCategory.setTitle(info.loadLabel(mContext.getPackageManager()));
|
||||
preferenceCategory.setTitle(hasMultipleImes ? mContext.getString(R.string.ime_label_title,
|
||||
info.loadLabel(mContext.getPackageManager()))
|
||||
: mContext.getString(R.string.enabled_locales_keyboard_layout));
|
||||
preferenceCategory.setKey(info.getPackageName());
|
||||
preferenceScreen.addPreference(preferenceCategory);
|
||||
Collections.sort(mKeyboardInfoList, new Comparator<KeyboardInfo>() {
|
||||
@@ -234,7 +240,7 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
||||
final Preference pref = new Preference(mContext);
|
||||
pref.setKey(keyboardInfo.getPrefId());
|
||||
pref.setTitle(keyboardInfo.getSubtypeLabel());
|
||||
pref.setSummary(keyboardInfo.getLayout());
|
||||
pref.setSummary(keyboardInfo.getLayoutSummaryText(mContext));
|
||||
pref.setOnPreferenceClickListener(
|
||||
preference -> {
|
||||
showKeyboardLayoutPicker(
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.hardware.input.InputDeviceIdentifier;
|
||||
import android.hardware.input.InputManager;
|
||||
import android.hardware.input.KeyboardLayout;
|
||||
import android.hardware.input.KeyboardLayoutSelectionResult;
|
||||
import android.os.Bundle;
|
||||
import android.view.inputmethod.InputMethodInfo;
|
||||
import android.view.inputmethod.InputMethodSubtype;
|
||||
@@ -201,13 +202,13 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
|
||||
|
||||
private String getSelectedLayoutLabel() {
|
||||
String label = mContext.getString(R.string.keyboard_default_layout);
|
||||
String layout = NewKeyboardSettingsUtils.getKeyboardLayout(
|
||||
KeyboardLayoutSelectionResult result = NewKeyboardSettingsUtils.getKeyboardLayout(
|
||||
mIm, mUserId, mInputDeviceIdentifier, mInputMethodInfo, mInputMethodSubtype);
|
||||
KeyboardLayout[] keyboardLayouts = NewKeyboardSettingsUtils.getKeyboardLayouts(
|
||||
mIm, mUserId, mInputDeviceIdentifier, mInputMethodInfo, mInputMethodSubtype);
|
||||
if (layout != null) {
|
||||
if (result.getLayoutDescriptor() != null) {
|
||||
for (KeyboardLayout keyboardLayout : keyboardLayouts) {
|
||||
if (keyboardLayout.getDescriptor().equals(layout)) {
|
||||
if (keyboardLayout.getDescriptor().equals(result.getLayoutDescriptor())) {
|
||||
label = keyboardLayout.getLabel();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -16,20 +16,30 @@
|
||||
|
||||
package com.android.settings.inputmethod;
|
||||
|
||||
import static android.hardware.input.KeyboardLayoutSelectionResult.LAYOUT_SELECTION_CRITERIA_USER;
|
||||
import static android.hardware.input.KeyboardLayoutSelectionResult.LAYOUT_SELECTION_CRITERIA_DEVICE;
|
||||
import static android.hardware.input.KeyboardLayoutSelectionResult.LAYOUT_SELECTION_CRITERIA_VIRTUAL_KEYBOARD;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.UserIdInt;
|
||||
import android.content.Context;
|
||||
import android.hardware.input.InputDeviceIdentifier;
|
||||
import android.hardware.input.InputManager;
|
||||
import android.hardware.input.KeyboardLayout;
|
||||
import android.hardware.input.KeyboardLayoutSelectionResult;
|
||||
import android.hardware.input.KeyboardLayoutSelectionResult.LayoutSelectionCriteria;
|
||||
import android.os.UserHandle;
|
||||
import android.view.InputDevice;
|
||||
import android.view.inputmethod.InputMethodInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.inputmethod.InputMethodSubtype;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.android.settings.R;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Utilities of keyboard settings
|
||||
@@ -56,36 +66,47 @@ public class NewKeyboardSettingsUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
static List<String> getSuitableImeLabels(Context context, InputMethodManager imm, int userId) {
|
||||
List<String> suitableInputMethodInfoLabels = new ArrayList<>();
|
||||
List<InputMethodInfo> infoList = imm.getEnabledInputMethodListAsUser(UserHandle.of(userId));
|
||||
for (InputMethodInfo info : infoList) {
|
||||
List<InputMethodSubtype> subtypes =
|
||||
imm.getEnabledInputMethodSubtypeList(info, true);
|
||||
for (InputMethodSubtype subtype : subtypes) {
|
||||
if (subtype.isSuitableForPhysicalKeyboardLayoutMapping()) {
|
||||
suitableInputMethodInfoLabels.add(
|
||||
info.loadLabel(context.getPackageManager()).toString());
|
||||
break;
|
||||
@SuppressLint("MissingPermission")
|
||||
@Nullable
|
||||
static String getSelectedKeyboardLayoutLabelForUser(Context context, @UserIdInt int userId,
|
||||
InputDeviceIdentifier inputDeviceIdentifier) {
|
||||
InputMethodManager imm = context.getSystemService(InputMethodManager.class);
|
||||
InputManager im = context.getSystemService(InputManager.class);
|
||||
if (imm == null || im == null) {
|
||||
return null;
|
||||
}
|
||||
InputMethodInfo imeInfo = imm.getCurrentInputMethodInfoAsUser(UserHandle.of(userId));
|
||||
InputMethodSubtype subtype = imm.getCurrentInputMethodSubtype();
|
||||
KeyboardLayout[] keyboardLayouts = getKeyboardLayouts(im, userId, inputDeviceIdentifier,
|
||||
imeInfo, subtype);
|
||||
KeyboardLayoutSelectionResult result = getKeyboardLayout(im, userId, inputDeviceIdentifier,
|
||||
imeInfo, subtype);
|
||||
if (result != null) {
|
||||
for (KeyboardLayout keyboardLayout : keyboardLayouts) {
|
||||
if (keyboardLayout.getDescriptor().equals(result.getLayoutDescriptor())) {
|
||||
return keyboardLayout.getLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
return suitableInputMethodInfoLabels;
|
||||
return null;
|
||||
}
|
||||
|
||||
static class KeyboardInfo {
|
||||
CharSequence mSubtypeLabel;
|
||||
String mLayout;
|
||||
@LayoutSelectionCriteria int mSelectionCriteria;
|
||||
InputMethodInfo mInputMethodInfo;
|
||||
InputMethodSubtype mInputMethodSubtype;
|
||||
|
||||
KeyboardInfo(
|
||||
CharSequence subtypeLabel,
|
||||
String layout,
|
||||
@LayoutSelectionCriteria int selectionCriteria,
|
||||
InputMethodInfo inputMethodInfo,
|
||||
InputMethodSubtype inputMethodSubtype) {
|
||||
mSubtypeLabel = subtypeLabel;
|
||||
mLayout = layout;
|
||||
mSelectionCriteria = selectionCriteria;
|
||||
mInputMethodInfo = inputMethodInfo;
|
||||
mInputMethodSubtype = inputMethodSubtype;
|
||||
}
|
||||
@@ -102,6 +123,17 @@ public class NewKeyboardSettingsUtils {
|
||||
return mLayout;
|
||||
}
|
||||
|
||||
String getLayoutSummaryText(Context context) {
|
||||
if (isAutomaticSelection(mSelectionCriteria)) {
|
||||
return context.getResources().getString(R.string.automatic_keyboard_layout_label,
|
||||
mLayout);
|
||||
} else if (isUserSelection(mSelectionCriteria)) {
|
||||
return context.getResources().getString(
|
||||
R.string.user_selected_keyboard_layout_label, mLayout);
|
||||
}
|
||||
return mLayout;
|
||||
}
|
||||
|
||||
InputMethodInfo getInputMethodInfo() {
|
||||
return mInputMethodInfo;
|
||||
}
|
||||
@@ -121,11 +153,21 @@ public class NewKeyboardSettingsUtils {
|
||||
return inputManager.getKeyboardLayoutListForInputDevice(identifier, userId, info, subtype);
|
||||
}
|
||||
|
||||
static String getKeyboardLayout(InputManager inputManager, int userId,
|
||||
@NonNull
|
||||
static KeyboardLayoutSelectionResult getKeyboardLayout(InputManager inputManager, int userId,
|
||||
InputDeviceIdentifier identifier, InputMethodInfo info, InputMethodSubtype subtype) {
|
||||
return inputManager.getKeyboardLayoutForInputDevice(identifier, userId, info, subtype);
|
||||
}
|
||||
|
||||
static boolean isAutomaticSelection(@LayoutSelectionCriteria int criteria) {
|
||||
return criteria == LAYOUT_SELECTION_CRITERIA_DEVICE
|
||||
|| criteria == LAYOUT_SELECTION_CRITERIA_VIRTUAL_KEYBOARD;
|
||||
}
|
||||
|
||||
static boolean isUserSelection(@LayoutSelectionCriteria int criteria) {
|
||||
return criteria == LAYOUT_SELECTION_CRITERIA_USER;
|
||||
}
|
||||
|
||||
static void sortKeyboardLayoutsByLabel(KeyboardLayout[] keyboardLayouts) {
|
||||
Arrays.sort(
|
||||
keyboardLayouts,
|
||||
|
||||
@@ -288,19 +288,11 @@ public final class PhysicalKeyboardFragment extends SettingsPreferenceFragment
|
||||
final Preference pref = new Preference(getPrefContext());
|
||||
pref.setTitle(hardKeyboardDeviceInfo.mDeviceName);
|
||||
if (mIsNewKeyboardSettings) {
|
||||
List<String> suitableImes = new ArrayList<>();
|
||||
suitableImes.addAll(
|
||||
NewKeyboardSettingsUtils.getSuitableImeLabels(
|
||||
getContext(), mImm, UserHandle.myUserId()));
|
||||
if (!suitableImes.isEmpty()) {
|
||||
String summary = suitableImes.get(0);
|
||||
StringBuilder result = new StringBuilder(summary);
|
||||
for (int i = 1; i < suitableImes.size(); i++) {
|
||||
result.append(", ").append(suitableImes.get(i));
|
||||
}
|
||||
pref.setSummary(result.toString());
|
||||
} else {
|
||||
pref.setSummary(hardKeyboardDeviceInfo.mLayoutLabel);
|
||||
String currentLayout =
|
||||
NewKeyboardSettingsUtils.getSelectedKeyboardLayoutLabelForUser(getContext(),
|
||||
UserHandle.myUserId(), hardKeyboardDeviceInfo.mDeviceIdentifier);
|
||||
if (currentLayout != null) {
|
||||
pref.setSummary(currentLayout);
|
||||
}
|
||||
pref.setOnPreferenceClickListener(
|
||||
preference -> {
|
||||
|
||||
@@ -100,6 +100,7 @@ public interface SearchFeatureProvider {
|
||||
// and goes to the search UI. Also set the background to null so there's no ripple.
|
||||
final View navView = toolbar.getNavigationView();
|
||||
navView.setClickable(false);
|
||||
navView.setFocusable(false);
|
||||
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||
navView.setBackground(null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user