Merge "Directly show the layout selection screen."
This commit is contained in:
committed by
Android (Google) Code Review
commit
ed46e1a5fa
@@ -572,10 +572,13 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showKeyboardLayoutDialog(InputDeviceIdentifier inputDeviceIdentifier) {
|
private void showKeyboardLayoutDialog(InputDeviceIdentifier inputDeviceIdentifier) {
|
||||||
KeyboardLayoutDialogFragment fragment = new KeyboardLayoutDialogFragment(
|
KeyboardLayoutDialogFragment fragment = (KeyboardLayoutDialogFragment)
|
||||||
inputDeviceIdentifier);
|
getFragmentManager().findFragmentByTag("keyboardLayout");
|
||||||
fragment.setTargetFragment(this, 0);
|
if (fragment == null) {
|
||||||
fragment.show(getActivity().getFragmentManager(), "keyboardLayout");
|
fragment = new KeyboardLayoutDialogFragment(inputDeviceIdentifier);
|
||||||
|
fragment.setTargetFragment(this, 0);
|
||||||
|
fragment.show(getActivity().getFragmentManager(), "keyboardLayout");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -53,6 +53,7 @@ public class KeyboardLayoutDialogFragment extends DialogFragment
|
|||||||
private int mInputDeviceId = -1;
|
private int mInputDeviceId = -1;
|
||||||
private InputManager mIm;
|
private InputManager mIm;
|
||||||
private KeyboardLayoutAdapter mAdapter;
|
private KeyboardLayoutAdapter mAdapter;
|
||||||
|
private boolean mHasShownLayoutSelectionScreen;
|
||||||
|
|
||||||
public KeyboardLayoutDialogFragment() {
|
public KeyboardLayoutDialogFragment() {
|
||||||
}
|
}
|
||||||
@@ -178,6 +179,7 @@ public class KeyboardLayoutDialogFragment extends DialogFragment
|
|||||||
dialog.getListView().setItemChecked(data.current, true);
|
dialog.getListView().setItemChecked(data.current, true);
|
||||||
}
|
}
|
||||||
updateSwitchHintVisibility();
|
updateSwitchHintVisibility();
|
||||||
|
showSetupKeyboardLayoutsIfNecessary();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -212,6 +214,17 @@ public class KeyboardLayoutDialogFragment extends DialogFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showSetupKeyboardLayoutsIfNecessary() {
|
||||||
|
AlertDialog dialog = (AlertDialog)getDialog();
|
||||||
|
if (dialog != null
|
||||||
|
&& mAdapter.getCount() == 1 && mAdapter.getItem(0) == null
|
||||||
|
&& !mHasShownLayoutSelectionScreen) {
|
||||||
|
mHasShownLayoutSelectionScreen = true;
|
||||||
|
((OnSetupKeyboardLayoutsListener)getTargetFragment()).onSetupKeyboardLayouts(
|
||||||
|
mInputDeviceIdentifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final class KeyboardLayoutAdapter extends ArrayAdapter<KeyboardLayout> {
|
private static final class KeyboardLayoutAdapter extends ArrayAdapter<KeyboardLayout> {
|
||||||
private final LayoutInflater mInflater;
|
private final LayoutInflater mInflater;
|
||||||
private int mCheckedItem = -1;
|
private int mCheckedItem = -1;
|
||||||
@@ -300,7 +313,7 @@ public class KeyboardLayoutDialogFragment extends DialogFragment
|
|||||||
public Keyboards loadInBackground() {
|
public Keyboards loadInBackground() {
|
||||||
Keyboards keyboards = new Keyboards();
|
Keyboards keyboards = new Keyboards();
|
||||||
InputManager im = (InputManager)getContext().getSystemService(Context.INPUT_SERVICE);
|
InputManager im = (InputManager)getContext().getSystemService(Context.INPUT_SERVICE);
|
||||||
String[] keyboardLayoutDescriptors = im.getKeyboardLayoutsForInputDevice(
|
String[] keyboardLayoutDescriptors = im.getEnabledKeyboardLayoutsForInputDevice(
|
||||||
mInputDeviceIdentifier);
|
mInputDeviceIdentifier);
|
||||||
for (String keyboardLayoutDescriptor : keyboardLayoutDescriptors) {
|
for (String keyboardLayoutDescriptor : keyboardLayoutDescriptors) {
|
||||||
KeyboardLayout keyboardLayout = im.getKeyboardLayout(keyboardLayoutDescriptor);
|
KeyboardLayout keyboardLayout = im.getKeyboardLayout(keyboardLayoutDescriptor);
|
||||||
@@ -351,4 +364,4 @@ public class KeyboardLayoutDialogFragment extends DialogFragment
|
|||||||
public interface OnSetupKeyboardLayoutsListener {
|
public interface OnSetupKeyboardLayoutsListener {
|
||||||
public void onSetupKeyboardLayouts(InputDeviceIdentifier mInputDeviceIdentifier);
|
public void onSetupKeyboardLayouts(InputDeviceIdentifier mInputDeviceIdentifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -65,7 +65,7 @@ public class KeyboardLayoutPickerFragment extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
mIm = (InputManager)getSystemService(Context.INPUT_SERVICE);
|
mIm = (InputManager)getSystemService(Context.INPUT_SERVICE);
|
||||||
mKeyboardLayouts = mIm.getKeyboardLayouts();
|
mKeyboardLayouts = mIm.getKeyboardLayoutsForInputDevice(mInputDeviceIdentifier);
|
||||||
Arrays.sort(mKeyboardLayouts);
|
Arrays.sort(mKeyboardLayouts);
|
||||||
setPreferenceScreen(createPreferenceHierarchy());
|
setPreferenceScreen(createPreferenceHierarchy());
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ public class KeyboardLayoutPickerFragment extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateCheckedState() {
|
private void updateCheckedState() {
|
||||||
String[] enabledKeyboardLayouts = mIm.getKeyboardLayoutsForInputDevice(
|
String[] enabledKeyboardLayouts = mIm.getEnabledKeyboardLayoutsForInputDevice(
|
||||||
mInputDeviceIdentifier);
|
mInputDeviceIdentifier);
|
||||||
Arrays.sort(enabledKeyboardLayouts);
|
Arrays.sort(enabledKeyboardLayouts);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user