Launch AOSP Keyboard Settings on the same display
This CL demonstrates how an IME can show an Activity on the display where the IME is shown. The key points are: * The current display ID can be obtained as follows. final int curentDisplayId = inputMethodService .getSystemService(WindowManager.class) .getDefaultDisplay() .getDisplayId(); * When launching an Activity, specify the target display ID as follows. inputMethodService.startActivity(intent, ActivityOptions .makeBasic() .setLaunchDisplayId(curentDisplayId) .toBundle()); Fix: 131718879 Test: Manually verified as follows. 1. Build aosp_blueline-userdebug and flash it. 2. adb shell settings put global force_desktop_mode_on_external_displays 1 3. adb shell settings put global overlay_display_devices 1920x1080/320 4. adb reboot 5. With a mouse, launch any application that has input field in the secondary display. 6. Click that input field to bring up AOSP Keyboard. 7. Long click the comma key then select the gear icon. 8. Select "Android Keyboard Settings (AOSP)" 9. Make sure that the AOSP Keyboard Settings is launched in the secondary display, not in the default display. 10. Go back to the step 7. 11. Select "Languages" 12. Subtype Enabler for AOSP Keyboard is shown in the secondary display, not in the default display. Change-Id: I9f89f371c38d9a7b5a06d018d4b41aa09815ea24main
parent
35cca31844
commit
d762841494
|
@ -21,6 +21,7 @@ import static com.android.inputmethod.latin.common.Constants.ImeOption.NO_MICROP
|
|||
import static com.android.inputmethod.latin.common.Constants.ImeOption.NO_MICROPHONE_COMPAT;
|
||||
|
||||
import android.Manifest.permission;
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
|
@ -1781,6 +1782,22 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts {@link android.app.Activity} on the same display where the IME is shown.
|
||||
*
|
||||
* @param intent {@link Intent} to be used to start {@link android.app.Activity}.
|
||||
*/
|
||||
private void startActivityOnTheSameDisplay(Intent intent) {
|
||||
// Note that WindowManager#getDefaultDisplay() returns the display ID associated with the
|
||||
// Context from which the WindowManager instance was obtained. Therefore the following code
|
||||
// returns the display ID for the window where the IME is shown.
|
||||
final int currentDisplayId = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
|
||||
.getDefaultDisplay().getDisplayId();
|
||||
|
||||
startActivity(intent,
|
||||
ActivityOptions.makeBasic().setLaunchDisplayId(currentDisplayId).toBundle());
|
||||
}
|
||||
|
||||
void launchSettings(final String extraEntryValue) {
|
||||
mInputLogic.commitTyped(mSettings.getCurrent(), LastComposedWord.NOT_A_SEPARATOR);
|
||||
requestHideSelf(0);
|
||||
|
@ -1795,7 +1812,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_HOME_AS_UP, false);
|
||||
intent.putExtra(SettingsActivity.EXTRA_ENTRY_KEY, extraEntryValue);
|
||||
startActivity(intent);
|
||||
startActivityOnTheSameDisplay(intent);
|
||||
}
|
||||
|
||||
private void showSubtypeSelectorAndSettings() {
|
||||
|
@ -1819,7 +1836,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.putExtra(Intent.EXTRA_TITLE, languageSelectionTitle);
|
||||
startActivity(intent);
|
||||
startActivityOnTheSameDisplay(intent);
|
||||
break;
|
||||
case 1:
|
||||
launchSettings(SettingsActivity.EXTRA_ENTRY_VALUE_LONG_PRESS_COMMA);
|
||||
|
|
Loading…
Reference in New Issue