summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael W <baddaemon87@gmail.com>2020-05-23 16:51:33 +0200
committerMichael W <baddaemon87@gmail.com>2020-05-25 22:10:56 +0200
commit07c937e7011fd20e456fc1b397dee33ff8c5b367 (patch)
treeef3da1b5da67b5312a523ea89aff92894b2a49f7
parent50ae60707defd1e7ba1be9d033946e8c46bf39c2 (diff)
LatinIME: Fix back-arrow finishing activity
* When going to a sub setting menu and pressing the action bar up arrow instead of the device's back key, the settings are closed instead of going one level up as expected * Call "onBackPressed" instead of "finish" to fix that * For InputMethodSettings create a new flag to alter the behaviour for our use case but to keep existing behaviour for other callers Test: - Open the keyboard settings from Settings app and navigate between menus -> action bar back icon only goes one levelup - Open keyboard settings directly from keyboard: behaviour is the same, last "up" action takes you back to where you came from Change-Id: I4f01e80e7f35ddbd2af1baae899d689f1144a5a1
-rw-r--r--java/src/com/android/inputmethod/latin/settings/SettingsActivity.java2
-rw-r--r--java/src/com/android/inputmethodcommon/InputMethodSettingsFragment.java1
-rw-r--r--java/src/com/android/inputmethodcommon/InputMethodSettingsImpl.java13
3 files changed, 12 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsActivity.java b/java/src/com/android/inputmethod/latin/settings/SettingsActivity.java
index ac1657762..43467a05a 100644
--- a/java/src/com/android/inputmethod/latin/settings/SettingsActivity.java
+++ b/java/src/com/android/inputmethod/latin/settings/SettingsActivity.java
@@ -59,7 +59,7 @@ public final class SettingsActivity extends PreferenceActivity
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
if (mShowHomeAsUp && item.getItemId() == android.R.id.home) {
- finish();
+ onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
diff --git a/java/src/com/android/inputmethodcommon/InputMethodSettingsFragment.java b/java/src/com/android/inputmethodcommon/InputMethodSettingsFragment.java
index 8c5bae2cb..8d05f8383 100644
--- a/java/src/com/android/inputmethodcommon/InputMethodSettingsFragment.java
+++ b/java/src/com/android/inputmethodcommon/InputMethodSettingsFragment.java
@@ -34,6 +34,7 @@ public abstract class InputMethodSettingsFragment extends CustomPreferenceFragme
super.onCreate(savedInstanceState);
final Context context = getActivity();
setPreferenceScreen(getPreferenceManager().createPreferenceScreen(context));
+ mSettings.setSpawnAsNewActivity(false);
mSettings.init(context, getPreferenceScreen());
}
diff --git a/java/src/com/android/inputmethodcommon/InputMethodSettingsImpl.java b/java/src/com/android/inputmethodcommon/InputMethodSettingsImpl.java
index cfa1a6596..e56c97578 100644
--- a/java/src/com/android/inputmethodcommon/InputMethodSettingsImpl.java
+++ b/java/src/com/android/inputmethodcommon/InputMethodSettingsImpl.java
@@ -40,6 +40,7 @@ import java.util.List;
private Drawable mSubtypeEnablerIcon;
private InputMethodManager mImm;
private InputMethodInfo mImi;
+ private boolean mSpawnAsNewActivity = true;
/**
* Initialize internal states of this object.
@@ -55,9 +56,11 @@ import java.util.List;
}
final Intent intent = new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID, mImi.getId());
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
- | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ if (mSpawnAsNewActivity) {
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
+ | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ }
mSubtypeEnablerPreference = new Preference(context);
mSubtypeEnablerPreference.setIntent(intent);
prefScreen.addPreference(mSubtypeEnablerPreference);
@@ -176,4 +179,8 @@ import java.util.List;
pref.setIcon(mSubtypeEnablerIcon);
}
}
+
+ public void setSpawnAsNewActivity(boolean spawnAsNew) {
+ mSpawnAsNewActivity = spawnAsNew;
+ }
}