[PK Setting] add keyboard review under keyboard selection page
Demo video as attached in bug. Add new image view for keyboard layout review. Reuse NewKeyboardLayoutPickerController under NewKeyboardLayoutPickerFragment when get update for keyboard layout, get preview image from inputManager and set to the view. This feature will be guided with keyboard_layout_preview_flag, if the flag is off, preview image from InputManager will be null. Bug: 305588594 Test: Verified on device Change-Id: Ic6f8e469d3cf7114dab6935304706ad42bf83608
This commit is contained in:
@@ -59,6 +59,7 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
|
||||
private String mFinalSelectedLayout;
|
||||
private String mLayout;
|
||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private KeyboardLayoutSelectedCallback mKeyboardLayoutSelectedCallback;
|
||||
|
||||
public NewKeyboardLayoutPickerController(Context context, String key) {
|
||||
super(context, key);
|
||||
@@ -100,7 +101,7 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
if (!mLayout.equals(mFinalSelectedLayout)) {
|
||||
if (mLayout != null && !mLayout.equals(mFinalSelectedLayout)) {
|
||||
String change = "From:" + mLayout + ", to:" + mFinalSelectedLayout;
|
||||
mMetricsFeatureProvider.action(
|
||||
mContext, SettingsEnums.ACTION_PK_LAYOUT_CHANGED, change);
|
||||
@@ -121,6 +122,14 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers {@link KeyboardLayoutSelectedCallback} and get updated.
|
||||
*/
|
||||
public void registerKeyboardSelectedCallback(KeyboardLayoutSelectedCallback
|
||||
keyboardLayoutSelectedCallback) {
|
||||
this.mKeyboardLayoutSelectedCallback = keyboardLayoutSelectedCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (!(preference instanceof TickButtonPreference)) {
|
||||
@@ -128,6 +137,9 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
|
||||
}
|
||||
|
||||
final TickButtonPreference pref = (TickButtonPreference) preference;
|
||||
if (mKeyboardLayoutSelectedCallback != null && mPreferenceMap.containsKey(preference)) {
|
||||
mKeyboardLayoutSelectedCallback.onSelected(mPreferenceMap.get(preference));
|
||||
}
|
||||
pref.setSelected(true);
|
||||
if (mPreviousSelection != null && !mPreviousSelection.equals(preference.getKey())) {
|
||||
TickButtonPreference preSelectedPref = mScreen.findPreference(mPreviousSelection);
|
||||
@@ -166,6 +178,9 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
|
||||
pref.setTitle(layout.getLabel());
|
||||
|
||||
if (mLayout.equals(layout.getLabel())) {
|
||||
if (mKeyboardLayoutSelectedCallback != null) {
|
||||
mKeyboardLayoutSelectedCallback.onSelected(layout);
|
||||
}
|
||||
pref.setSelected(true);
|
||||
mPreviousSelection = layout.getDescriptor();
|
||||
}
|
||||
@@ -200,4 +215,11 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
public interface KeyboardLayoutSelectedCallback {
|
||||
/**
|
||||
* Called when KeyboardLayout been selected.
|
||||
*/
|
||||
void onSelected(KeyboardLayout keyboardLayout);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user