[Keyboard Setting] Rename KeyboardSettingUtils
rename KeyboardSettingUtils to match more about usage. Bug: 379594195 Test: atest SettingsRoboTests Flag: NONE, rename file. Change-Id: If978e7b56ecbdb0b571db5ff34553bbb20f976ee
This commit is contained in:
@@ -44,9 +44,9 @@ import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Utilities of keyboard settings
|
||||
* Utilities of input peripherals settings
|
||||
*/
|
||||
public class NewKeyboardSettingsUtils {
|
||||
public class InputPeripheralsSettingsUtils {
|
||||
|
||||
static final String EXTRA_TITLE = "keyboard_layout_picker_title";
|
||||
static final String EXTRA_USER_ID = "user_id";
|
@@ -308,7 +308,7 @@ public class KeyboardLayoutDialogFragment extends InstrumentedDialogFragment
|
||||
public Keyboards loadInBackground() {
|
||||
Keyboards keyboards = new Keyboards();
|
||||
InputManager im = (InputManager)getContext().getSystemService(Context.INPUT_SERVICE);
|
||||
if (mInputDeviceIdentifier == null || NewKeyboardSettingsUtils.getInputDevice(
|
||||
if (mInputDeviceIdentifier == null || InputPeripheralsSettingsUtils.getInputDevice(
|
||||
im, mInputDeviceIdentifier) == null) {
|
||||
keyboards.keyboardLayouts.add(null); // default layout
|
||||
keyboards.current = 0;
|
||||
|
@@ -68,11 +68,13 @@ public class KeyboardLayoutPickerController extends BasePreferenceController imp
|
||||
public void onStart() {
|
||||
mIm.registerInputDeviceListener(this, null);
|
||||
if (mInputDeviceIdentifier == null
|
||||
|| NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier) == null) {
|
||||
|| InputPeripheralsSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier)
|
||||
== null) {
|
||||
return;
|
||||
}
|
||||
mInputDeviceId =
|
||||
NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier).getId();
|
||||
InputPeripheralsSettingsUtils.getInputDevice(mIm,
|
||||
mInputDeviceIdentifier).getId();
|
||||
updateCheckedState();
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,7 @@ public class KeyboardLayoutPickerFragment extends DashboardFragment {
|
||||
final InputDeviceIdentifier inputDeviceIdentifier = getActivity().getIntent().
|
||||
getParcelableExtra(EXTRA_INPUT_DEVICE_IDENTIFIER);
|
||||
final InputManager im = context.getSystemService(InputManager.class);
|
||||
if (NewKeyboardSettingsUtils.getInputDevice(im, inputDeviceIdentifier) == null) {
|
||||
if (InputPeripheralsSettingsUtils.getInputDevice(im, inputDeviceIdentifier) == null) {
|
||||
return;
|
||||
}
|
||||
use(KeyboardLayoutPickerController.class).initialize(this /*parent*/,
|
||||
|
@@ -40,7 +40,7 @@ import com.android.settings.Utils;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
||||
import com.android.settings.inputmethod.NewKeyboardSettingsUtils.KeyboardInfo;
|
||||
import com.android.settings.inputmethod.InputPeripheralsSettingsUtils.KeyboardInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -117,14 +117,15 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
||||
return;
|
||||
}
|
||||
mInputDeviceIdentifier =
|
||||
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
|
||||
arguments.getParcelable(
|
||||
InputPeripheralsSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
|
||||
InputDeviceIdentifier.class);
|
||||
if (mInputDeviceIdentifier == null) {
|
||||
Log.e(TAG, "The inputDeviceIdentifier should not be null");
|
||||
return;
|
||||
}
|
||||
InputDevice inputDevice =
|
||||
NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier);
|
||||
InputPeripheralsSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier);
|
||||
if (inputDevice == null) {
|
||||
Log.e(TAG, "inputDevice is null");
|
||||
return;
|
||||
@@ -138,7 +139,7 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
||||
super.onStart();
|
||||
mIm.registerInputDeviceListener(this, null);
|
||||
InputDevice inputDevice =
|
||||
NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier);
|
||||
InputPeripheralsSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier);
|
||||
if (inputDevice == null) {
|
||||
Log.e(TAG, "Unable to start: input device is null");
|
||||
getActivity().finish();
|
||||
@@ -161,7 +162,7 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
||||
}
|
||||
|
||||
private void updateCheckedState() {
|
||||
if (NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier) == null) {
|
||||
if (InputPeripheralsSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier) == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -207,9 +208,9 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
||||
private void mapLanguageWithLayout(InputMethodInfo info, InputMethodSubtype subtype) {
|
||||
CharSequence subtypeLabel = getSubtypeLabel(mContext, info, subtype);
|
||||
KeyboardLayout[] keyboardLayouts =
|
||||
NewKeyboardSettingsUtils.getKeyboardLayouts(
|
||||
InputPeripheralsSettingsUtils.getKeyboardLayouts(
|
||||
mIm, mUserId, mInputDeviceIdentifier, info, subtype);
|
||||
KeyboardLayoutSelectionResult result = NewKeyboardSettingsUtils.getKeyboardLayout(
|
||||
KeyboardLayoutSelectionResult result = InputPeripheralsSettingsUtils.getKeyboardLayout(
|
||||
mIm, mUserId, mInputDeviceIdentifier, info, subtype);
|
||||
if (result.getLayoutDescriptor() != null) {
|
||||
for (int i = 0; i < keyboardLayouts.length; i++) {
|
||||
@@ -316,13 +317,14 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
||||
InputMethodSubtype inputMethodSubtype) {
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putParcelable(
|
||||
NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER, inputDeviceIdentifier);
|
||||
InputPeripheralsSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
|
||||
inputDeviceIdentifier);
|
||||
arguments.putParcelable(
|
||||
NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_INFO, inputMethodInfo);
|
||||
InputPeripheralsSettingsUtils.EXTRA_INPUT_METHOD_INFO, inputMethodInfo);
|
||||
arguments.putParcelable(
|
||||
NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE, inputMethodSubtype);
|
||||
arguments.putInt(NewKeyboardSettingsUtils.EXTRA_USER_ID, userId);
|
||||
arguments.putCharSequence(NewKeyboardSettingsUtils.EXTRA_TITLE, subtypeLabel);
|
||||
InputPeripheralsSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE, inputMethodSubtype);
|
||||
arguments.putInt(InputPeripheralsSettingsUtils.EXTRA_USER_ID, userId);
|
||||
arguments.putCharSequence(InputPeripheralsSettingsUtils.EXTRA_TITLE, subtypeLabel);
|
||||
new SubSettingLauncher(mContext)
|
||||
.setSourceMetricsCategory(getMetricsCategory())
|
||||
.setDestination(NewKeyboardLayoutPickerFragment.class.getName())
|
||||
|
@@ -48,9 +48,9 @@ public class NewKeyboardLayoutPickerContent extends DashboardFragment {
|
||||
InputManager im = getContext().getSystemService(InputManager.class);
|
||||
InputDeviceIdentifier identifier =
|
||||
getArguments().getParcelable(
|
||||
NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER);
|
||||
InputPeripheralsSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER);
|
||||
if (identifier == null
|
||||
|| NewKeyboardSettingsUtils.getInputDevice(im, identifier) == null) {
|
||||
|| InputPeripheralsSettingsUtils.getInputDevice(im, identifier) == null) {
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
|
@@ -73,19 +73,21 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
|
||||
public void initialize(Fragment parent) {
|
||||
mParent = parent;
|
||||
Bundle arguments = parent.getArguments();
|
||||
mTitle = arguments.getCharSequence(NewKeyboardSettingsUtils.EXTRA_TITLE);
|
||||
mUserId = arguments.getInt(NewKeyboardSettingsUtils.EXTRA_USER_ID);
|
||||
mTitle = arguments.getCharSequence(InputPeripheralsSettingsUtils.EXTRA_TITLE);
|
||||
mUserId = arguments.getInt(InputPeripheralsSettingsUtils.EXTRA_USER_ID);
|
||||
mInputDeviceIdentifier =
|
||||
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER);
|
||||
arguments.getParcelable(
|
||||
InputPeripheralsSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER);
|
||||
mInputMethodInfo =
|
||||
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_INFO);
|
||||
arguments.getParcelable(InputPeripheralsSettingsUtils.EXTRA_INPUT_METHOD_INFO);
|
||||
mInputMethodSubtype =
|
||||
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE);
|
||||
arguments.getParcelable(
|
||||
InputPeripheralsSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE);
|
||||
mLayout = getSelectedLayoutLabel();
|
||||
mFinalSelectedLayout = mLayout;
|
||||
mKeyboardLayouts = mIm.getKeyboardLayoutListForInputDevice(
|
||||
mInputDeviceIdentifier, mUserId, mInputMethodInfo, mInputMethodSubtype);
|
||||
NewKeyboardSettingsUtils.sortKeyboardLayoutsByLabel(mKeyboardLayouts);
|
||||
InputPeripheralsSettingsUtils.sortKeyboardLayoutsByLabel(mKeyboardLayouts);
|
||||
parent.getActivity().setTitle(mTitle);
|
||||
}
|
||||
|
||||
@@ -93,11 +95,13 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
|
||||
public void onStart() {
|
||||
mIm.registerInputDeviceListener(this, null);
|
||||
if (mInputDeviceIdentifier == null
|
||||
|| NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier) == null) {
|
||||
|| InputPeripheralsSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier)
|
||||
== null) {
|
||||
return;
|
||||
}
|
||||
mInputDeviceId =
|
||||
NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier).getId();
|
||||
InputPeripheralsSettingsUtils.getInputDevice(mIm,
|
||||
mInputDeviceIdentifier).getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -202,9 +206,9 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
|
||||
|
||||
private String getSelectedLayoutLabel() {
|
||||
String label = mContext.getString(R.string.keyboard_default_layout);
|
||||
KeyboardLayoutSelectionResult result = NewKeyboardSettingsUtils.getKeyboardLayout(
|
||||
KeyboardLayoutSelectionResult result = InputPeripheralsSettingsUtils.getKeyboardLayout(
|
||||
mIm, mUserId, mInputDeviceIdentifier, mInputMethodInfo, mInputMethodSubtype);
|
||||
KeyboardLayout[] keyboardLayouts = NewKeyboardSettingsUtils.getKeyboardLayouts(
|
||||
KeyboardLayout[] keyboardLayouts = InputPeripheralsSettingsUtils.getKeyboardLayouts(
|
||||
mIm, mUserId, mInputDeviceIdentifier, mInputMethodInfo, mInputMethodSubtype);
|
||||
if (result.getLayoutDescriptor() != null) {
|
||||
for (KeyboardLayout keyboardLayout : keyboardLayouts) {
|
||||
|
@@ -317,7 +317,7 @@ public final class PhysicalKeyboardFragment extends DashboardFragment
|
||||
final Preference pref = new Preference(getPrefContext());
|
||||
pref.setTitle(hardKeyboardDeviceInfo.mDeviceName);
|
||||
String currentLayout =
|
||||
NewKeyboardSettingsUtils.getSelectedKeyboardLayoutLabelForUser(context,
|
||||
InputPeripheralsSettingsUtils.getSelectedKeyboardLayoutLabelForUser(context,
|
||||
UserHandle.myUserId(), hardKeyboardDeviceInfo.mDeviceIdentifier);
|
||||
if (currentLayout != null) {
|
||||
pref.setSummary(currentLayout);
|
||||
@@ -369,7 +369,7 @@ public final class PhysicalKeyboardFragment extends DashboardFragment
|
||||
|
||||
private void showEnabledLocalesKeyboardLayoutList(InputDeviceIdentifier inputDeviceIdentifier) {
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
|
||||
arguments.putParcelable(InputPeripheralsSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
|
||||
inputDeviceIdentifier);
|
||||
new SubSettingLauncher(getContext())
|
||||
.setSourceMetricsCategory(getMetricsCategory())
|
||||
|
@@ -16,8 +16,8 @@
|
||||
|
||||
package com.android.settings.inputmethod;
|
||||
|
||||
import static com.android.settings.inputmethod.NewKeyboardSettingsUtils.isMouse;
|
||||
import static com.android.settings.inputmethod.NewKeyboardSettingsUtils.isTouchpad;
|
||||
import static com.android.settings.inputmethod.InputPeripheralsSettingsUtils.isMouse;
|
||||
import static com.android.settings.inputmethod.InputPeripheralsSettingsUtils.isTouchpad;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
@@ -16,8 +16,8 @@
|
||||
|
||||
package com.android.settings.inputmethod;
|
||||
|
||||
import static com.android.settings.inputmethod.NewKeyboardSettingsUtils.isMouse;
|
||||
import static com.android.settings.inputmethod.NewKeyboardSettingsUtils.isTouchpad;
|
||||
import static com.android.settings.inputmethod.InputPeripheralsSettingsUtils.isMouse;
|
||||
import static com.android.settings.inputmethod.InputPeripheralsSettingsUtils.isTouchpad;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
@@ -32,8 +32,8 @@ public class PointerTouchpadPreferenceController extends BasePreferenceControlle
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
|
||||
boolean isMouse = NewKeyboardSettingsUtils.isMouse();
|
||||
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
|
||||
boolean isMouse = InputPeripheralsSettingsUtils.isMouse();
|
||||
return (isTouchpad || isMouse) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
@@ -74,7 +74,7 @@ public class TouchGesturesButtonPreferenceController extends BasePreferenceContr
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
|
||||
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
|
||||
return isTouchpad ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
|
@@ -49,7 +49,7 @@ public class TrackpadBottomPreferenceController extends TogglePreferenceControll
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
|
||||
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
|
||||
return isTouchpad ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
|
@@ -49,7 +49,7 @@ public class TrackpadReverseScrollingPreferenceController extends TogglePreferen
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
|
||||
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
|
||||
return isTouchpad ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,7 @@ public class TrackpadSettings extends DashboardFragment {
|
||||
public void onCreate(@NonNull Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
getPreferenceScreen().setTitle(
|
||||
NewKeyboardSettingsUtils.getTouchpadAndMouseTitleTitleResId());
|
||||
InputPeripheralsSettingsUtils.getTouchpadAndMouseTitleTitleResId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,7 +67,7 @@ public class TrackpadSettings extends DashboardFragment {
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return FeatureFlagUtils
|
||||
.isEnabled(context, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_TRACKPAD)
|
||||
&& NewKeyboardSettingsUtils.isTouchpad();
|
||||
&& InputPeripheralsSettingsUtils.isTouchpad();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -77,17 +77,17 @@ public class TrackpadSettingsController extends BasePreferenceController
|
||||
return;
|
||||
}
|
||||
mPreference.setVisible(isAvailable());
|
||||
mPreference.setTitle(NewKeyboardSettingsUtils.getTouchpadAndMouseTitleTitleResId());
|
||||
mPreference.setTitle(InputPeripheralsSettingsUtils.getTouchpadAndMouseTitleTitleResId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
boolean isFeatureOn = FeatureFlagUtils
|
||||
.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_TRACKPAD);
|
||||
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
|
||||
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
|
||||
boolean isPointerCustomizationEnabled =
|
||||
android.view.flags.Flags.enableVectorCursorA11ySettings();
|
||||
boolean isMouse = NewKeyboardSettingsUtils.isMouse();
|
||||
boolean isMouse = InputPeripheralsSettingsUtils.isMouse();
|
||||
return (isFeatureOn && isTouchpad) || (isPointerCustomizationEnabled && isMouse) ? AVAILABLE
|
||||
: CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ public class TrackpadTapDraggingPreferenceController extends TogglePreferenceCon
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
|
||||
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
|
||||
return (InputSettings.isTouchpadTapDraggingFeatureFlagEnabled() && isTouchpad)
|
||||
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ public class TrackpadTapToClickPreferenceController extends TogglePreferenceCont
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
|
||||
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
|
||||
return isTouchpad ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
|
@@ -59,7 +59,7 @@ public class TrackpadTouchGestureSettings extends DashboardFragment {
|
||||
.isEnabled(
|
||||
context,
|
||||
FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_TRACKPAD_GESTURE)
|
||||
&& NewKeyboardSettingsUtils.isTouchpad();
|
||||
&& InputPeripheralsSettingsUtils.isTouchpad();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ public class TrackpadTouchGestureSettingsController extends BasePreferenceContro
|
||||
public int getAvailabilityStatus() {
|
||||
boolean isFeatureOn = FeatureFlagUtils
|
||||
.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_TRACKPAD_GESTURE);
|
||||
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
|
||||
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
|
||||
return (isFeatureOn && isTouchpad) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
@@ -72,7 +72,7 @@ public class TrackpadSettingsControllerTest {
|
||||
InputDevice.SOURCE_TOUCHPAD);
|
||||
ShadowInputDevice.addDevice(deviceId, device);
|
||||
String expectedTitle = mContext.getString(
|
||||
NewKeyboardSettingsUtils.getTouchpadAndMouseTitleTitleResId());
|
||||
InputPeripheralsSettingsUtils.getTouchpadAndMouseTitleTitleResId());
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
|
Reference in New Issue
Block a user