Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b17ff677 authored by Michael Wright's avatar Michael Wright Committed by Android Git Automerger
Browse files

am 57bb094b: am 233bbabf: Merge "Specify a device identifier for keyboard...

am 57bb094b: am 233bbabf: Merge "Specify a device identifier for keyboard layout notification." into lmp-dev

* commit '57bb094b818d0e215cd987738078e5c181c26fac':
  Specify a device identifier for keyboard layout notification.
parents aa047467 e27380ac
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -977,6 +977,19 @@ public final class Settings {

    public static final String EXTRA_INPUT_METHOD_ID = "input_method_id";

    /**
     * Activity Extra: The device identifier to act upon.
     * <p>
     * This can be passed as an extra field in an Activity Intent with a single
     * InputDeviceIdentifier. This field is used by some activities to jump straight into the
     * settings for the given device.
     * <p>
     * Example: The {@link #INPUT_METHOD_SETTINGS} intent opens the keyboard layout dialog for the
     * given device.
     * @hide
     */
    public static final String EXTRA_INPUT_DEVICE_IDENTIFIER = "input_device_identifier";

    /**
     * @hide
     * Activity Extra: Enable or disable Airplane Mode.
+25 −10
Original line number Diff line number Diff line
@@ -695,6 +695,8 @@ public class InputManagerService extends IInputManager.Stub
            final int numFullKeyboards = mTempFullKeyboards.size();
            boolean missingLayoutForExternalKeyboard = false;
            boolean missingLayoutForExternalKeyboardAdded = false;
            boolean multipleMissingLayoutsForExternalKeyboardsAdded = false;
            InputDevice keyboardMissingLayout = null;
            synchronized (mDataStore) {
                for (int i = 0; i < numFullKeyboards; i++) {
                    final InputDevice inputDevice = mTempFullKeyboards.get(i);
@@ -704,13 +706,25 @@ public class InputManagerService extends IInputManager.Stub
                        missingLayoutForExternalKeyboard = true;
                        if (i < numFullKeyboardsAdded) {
                            missingLayoutForExternalKeyboardAdded = true;
                            if (keyboardMissingLayout == null) {
                                keyboardMissingLayout = inputDevice;
                            } else {
                                multipleMissingLayoutsForExternalKeyboardsAdded = true;
                            }
                        }
                    }
                }
            }
            if (missingLayoutForExternalKeyboard) {
                if (missingLayoutForExternalKeyboardAdded) {
                    showMissingKeyboardLayoutNotification();
                    if (multipleMissingLayoutsForExternalKeyboardsAdded) {
                        // We have more than one keyboard missing a layout, so drop the
                        // user at the generic input methods page so they can pick which
                        // one to set.
                        showMissingKeyboardLayoutNotification(null);
                    } else {
                        showMissingKeyboardLayoutNotification(keyboardMissingLayout);
                    }
                }
            } else if (mKeyboardLayoutNotificationShown) {
                hideMissingKeyboardLayoutNotification();
@@ -761,16 +775,17 @@ public class InputManagerService extends IInputManager.Stub
    }

    // Must be called on handler.
    private void showMissingKeyboardLayoutNotification() {
    private void showMissingKeyboardLayoutNotification(InputDevice device) {
        if (!mKeyboardLayoutNotificationShown) {
            if (mKeyboardLayoutIntent == null) {
                final Intent intent = new Intent("android.settings.INPUT_METHOD_SETTINGS");
            final Intent intent = new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS);
            if (device != null) {
                intent.putExtra(Settings.EXTRA_INPUT_DEVICE_IDENTIFIER, device.getIdentifier());
            }
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                    | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                    | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                mKeyboardLayoutIntent = PendingIntent.getActivityAsUser(mContext, 0,
            final PendingIntent keyboardLayoutIntent = PendingIntent.getActivityAsUser(mContext, 0,
                    intent, 0, null, UserHandle.CURRENT);
            }

            Resources r = mContext.getResources();
            Notification notification = new Notification.Builder(mContext)
@@ -778,7 +793,7 @@ public class InputManagerService extends IInputManager.Stub
                            R.string.select_keyboard_layout_notification_title))
                    .setContentText(r.getString(
                            R.string.select_keyboard_layout_notification_message))
                    .setContentIntent(mKeyboardLayoutIntent)
                    .setContentIntent(keyboardLayoutIntent)
                    .setSmallIcon(R.drawable.ic_settings_language)
                    .setPriority(Notification.PRIORITY_LOW)
                    .setColor(mContext.getResources().getColor(