Change key name "Meta" to "Action key"

1. In the modifier key remapping page, the string "Meta" should be changed to "Action"
2. We should add the default focus effect when users go into this page first time.

Demo: https://screencast.googleplex.com/cast/NTA2NjA2MzEyMjI2ODE2MHw2YjRjOTljMi0xMQ

Bug: 269981968
Test: manual
Change-Id: I481be0370166a8831bedc721751e23cee3b39703
This commit is contained in:
danielwbhuang
2023-02-23 17:58:29 +08:00
parent 4951384ba2
commit b8e1799527
2 changed files with 19 additions and 9 deletions

View File

@@ -3916,8 +3916,8 @@
<string name="modifier_keys_caps_lock" translatable="false">Caps lock</string>
<!-- Title for the button to trigger the 'modifier keys ctrl'. [CHAR LIMIT=15] -->
<string name="modifier_keys_ctrl" translatable="false">Ctrl</string>
<!-- Title for the button to trigger the 'modifier keys meta'. [CHAR LIMIT=15] -->
<string name="modifier_keys_meta" translatable="false">Meta</string>
<!-- Title for the button to trigger the 'modifier keys action key'. [CHAR LIMIT=15] -->
<string name="modifier_keys_meta" translatable="false">Action key</string>
<!-- Title for the button to trigger the 'modifier keys alt'. [CHAR LIMIT=15] -->
<string name="modifier_keys_alt" translatable="false">Alt</string>

View File

@@ -54,6 +54,7 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
private Preference mPreference;
private String mKeyDefaultName;
private String mKeyFocus;
private Context mContext;
private InputManager mIm;
@@ -72,6 +73,7 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
public ModifierKeysPickerDialogFragment(Preference preference, InputManager inputManager) {
mPreference = preference;
mKeyDefaultName = preference.getTitle().toString();
mKeyFocus = preference.getSummary().toString();
mIm = inputManager;
}
@@ -101,11 +103,11 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
ModifierKeyAdapter adapter = new ModifierKeyAdapter(modifierKeys);
ListView listView = dialoglayout.findViewById(R.id.modifier_key_picker);
listView.setAdapter(adapter);
setInitialFocusItem(modifierKeys, adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
adapter.setCurrentItem(i);
adapter.setClick(true);
adapter.notifyDataSetChanged();
}
});
@@ -165,13 +167,22 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
return modifierKeyDialog;
}
private void setInitialFocusItem(
List<String> modifierKeys, ModifierKeyAdapter adapter) {
if (modifierKeys.indexOf(mKeyFocus) == -1) {
adapter.setCurrentItem(modifierKeys.indexOf(mKeyDefaultName));
} else {
adapter.setCurrentItem(modifierKeys.indexOf(mKeyFocus));
}
adapter.notifyDataSetChanged();
}
private static boolean isKeyCapsLock(Context context, String key) {
return key.equals(context.getString(R.string.modifier_keys_caps_lock));
}
class ModifierKeyAdapter extends BaseAdapter {
private int mCurrentItem = 0;
private boolean mIsClick = false;
private List<String> mList;
ModifierKeyAdapter(List<String> list) {
@@ -201,12 +212,15 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
TextView textView = view.findViewById(R.id.modifier_key_text);
ImageView checkIcon = view.findViewById(R.id.modifier_key_check_icon);
textView.setText(mList.get(i));
if (mCurrentItem == i && mIsClick) {
if (mCurrentItem == i) {
textView.setTextColor(getColorOfColorAccentPrimaryVariant());
checkIcon.setImageAlpha(255);
view.setBackground(
mContext.getDrawable(R.drawable.modifier_key_lisetview_background));
} else {
textView.setTextColor(getColorOfTextColorPrimary());
checkIcon.setImageAlpha(0);
view.setBackground(null);
}
return view;
}
@@ -218,10 +232,6 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
public int getCurrentItem() {
return this.mCurrentItem;
}
public void setClick(boolean click) {
this.mIsClick = click;
}
}
private int getColorOfTextColorPrimary() {