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:
@@ -3916,8 +3916,8 @@
|
|||||||
<string name="modifier_keys_caps_lock" translatable="false">Caps lock</string>
|
<string name="modifier_keys_caps_lock" translatable="false">Caps lock</string>
|
||||||
<!-- Title for the button to trigger the 'modifier keys ctrl'. [CHAR LIMIT=15] -->
|
<!-- Title for the button to trigger the 'modifier keys ctrl'. [CHAR LIMIT=15] -->
|
||||||
<string name="modifier_keys_ctrl" translatable="false">Ctrl</string>
|
<string name="modifier_keys_ctrl" translatable="false">Ctrl</string>
|
||||||
<!-- Title for the button to trigger the 'modifier keys meta'. [CHAR LIMIT=15] -->
|
<!-- Title for the button to trigger the 'modifier keys action key'. [CHAR LIMIT=15] -->
|
||||||
<string name="modifier_keys_meta" translatable="false">Meta</string>
|
<string name="modifier_keys_meta" translatable="false">Action key</string>
|
||||||
<!-- Title for the button to trigger the 'modifier keys alt'. [CHAR LIMIT=15] -->
|
<!-- Title for the button to trigger the 'modifier keys alt'. [CHAR LIMIT=15] -->
|
||||||
<string name="modifier_keys_alt" translatable="false">Alt</string>
|
<string name="modifier_keys_alt" translatable="false">Alt</string>
|
||||||
|
|
||||||
|
@@ -54,6 +54,7 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
|
|||||||
|
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
private String mKeyDefaultName;
|
private String mKeyDefaultName;
|
||||||
|
private String mKeyFocus;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private InputManager mIm;
|
private InputManager mIm;
|
||||||
|
|
||||||
@@ -72,6 +73,7 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
|
|||||||
public ModifierKeysPickerDialogFragment(Preference preference, InputManager inputManager) {
|
public ModifierKeysPickerDialogFragment(Preference preference, InputManager inputManager) {
|
||||||
mPreference = preference;
|
mPreference = preference;
|
||||||
mKeyDefaultName = preference.getTitle().toString();
|
mKeyDefaultName = preference.getTitle().toString();
|
||||||
|
mKeyFocus = preference.getSummary().toString();
|
||||||
mIm = inputManager;
|
mIm = inputManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,11 +103,11 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
|
|||||||
ModifierKeyAdapter adapter = new ModifierKeyAdapter(modifierKeys);
|
ModifierKeyAdapter adapter = new ModifierKeyAdapter(modifierKeys);
|
||||||
ListView listView = dialoglayout.findViewById(R.id.modifier_key_picker);
|
ListView listView = dialoglayout.findViewById(R.id.modifier_key_picker);
|
||||||
listView.setAdapter(adapter);
|
listView.setAdapter(adapter);
|
||||||
|
setInitialFocusItem(modifierKeys, adapter);
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
adapter.setCurrentItem(i);
|
adapter.setCurrentItem(i);
|
||||||
adapter.setClick(true);
|
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -165,13 +167,22 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
|
|||||||
return modifierKeyDialog;
|
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) {
|
private static boolean isKeyCapsLock(Context context, String key) {
|
||||||
return key.equals(context.getString(R.string.modifier_keys_caps_lock));
|
return key.equals(context.getString(R.string.modifier_keys_caps_lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
class ModifierKeyAdapter extends BaseAdapter {
|
class ModifierKeyAdapter extends BaseAdapter {
|
||||||
private int mCurrentItem = 0;
|
private int mCurrentItem = 0;
|
||||||
private boolean mIsClick = false;
|
|
||||||
private List<String> mList;
|
private List<String> mList;
|
||||||
|
|
||||||
ModifierKeyAdapter(List<String> list) {
|
ModifierKeyAdapter(List<String> list) {
|
||||||
@@ -201,12 +212,15 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
|
|||||||
TextView textView = view.findViewById(R.id.modifier_key_text);
|
TextView textView = view.findViewById(R.id.modifier_key_text);
|
||||||
ImageView checkIcon = view.findViewById(R.id.modifier_key_check_icon);
|
ImageView checkIcon = view.findViewById(R.id.modifier_key_check_icon);
|
||||||
textView.setText(mList.get(i));
|
textView.setText(mList.get(i));
|
||||||
if (mCurrentItem == i && mIsClick) {
|
if (mCurrentItem == i) {
|
||||||
textView.setTextColor(getColorOfColorAccentPrimaryVariant());
|
textView.setTextColor(getColorOfColorAccentPrimaryVariant());
|
||||||
checkIcon.setImageAlpha(255);
|
checkIcon.setImageAlpha(255);
|
||||||
|
view.setBackground(
|
||||||
|
mContext.getDrawable(R.drawable.modifier_key_lisetview_background));
|
||||||
} else {
|
} else {
|
||||||
textView.setTextColor(getColorOfTextColorPrimary());
|
textView.setTextColor(getColorOfTextColorPrimary());
|
||||||
checkIcon.setImageAlpha(0);
|
checkIcon.setImageAlpha(0);
|
||||||
|
view.setBackground(null);
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@@ -218,10 +232,6 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
|
|||||||
public int getCurrentItem() {
|
public int getCurrentItem() {
|
||||||
return this.mCurrentItem;
|
return this.mCurrentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClick(boolean click) {
|
|
||||||
this.mIsClick = click;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getColorOfTextColorPrimary() {
|
private int getColorOfTextColorPrimary() {
|
||||||
|
Reference in New Issue
Block a user