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

Commit d3fab05e authored by Michael W's avatar Michael W Committed by Michael Bestas
Browse files

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
parent 1c575ade
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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());
    }

+10 −3
Original line number Diff line number Diff line
@@ -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());
        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;
    }
}