Skip to content

Commit

Permalink
Fix bug #20: Back arrow closes app
Browse files Browse the repository at this point in the history
  • Loading branch information
dslul committed Jan 18, 2020
1 parent 33fc7b1 commit 2437d84
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1828,7 +1828,7 @@ private void startActivityOnTheSameDisplay(Intent intent) {
ActivityOptions.makeBasic().setLaunchDisplayId(currentDisplayId).toBundle());
}

void launchSettings(final String extraEntryValue) {
void launchSettings() {
mInputLogic.commitTyped(mSettings.getCurrent(), LastComposedWord.NOT_A_SEPARATOR);
requestHideSelf(0);
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
Expand All @@ -1840,8 +1840,6 @@ void launchSettings(final String extraEntryValue) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(SettingsActivity.EXTRA_SHOW_HOME_AS_UP, false);
intent.putExtra(SettingsActivity.EXTRA_ENTRY_KEY, extraEntryValue);
startActivityOnTheSameDisplay(intent);
}

Expand Down Expand Up @@ -1869,7 +1867,7 @@ public void onClick(DialogInterface di, int position) {
startActivityOnTheSameDisplay(intent);
break;
case 1:
launchSettings(SettingsActivity.EXTRA_ENTRY_VALUE_LONG_PRESS_COMMA);
launchSettings();
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public final class SettingsActivity extends PreferenceActivity
implements ActivityCompat.OnRequestPermissionsResultCallback {
private static final String DEFAULT_FRAGMENT = SettingsFragment.class.getName();

public static final String EXTRA_SHOW_HOME_AS_UP = "show_home_as_up";
public static final String EXTRA_ENTRY_KEY = "entry";
public static final String EXTRA_ENTRY_VALUE_LONG_PRESS_COMMA = "long_press_comma";
public static final String EXTRA_ENTRY_VALUE_APP_ICON = "app_icon";
Expand All @@ -45,24 +44,10 @@ public final class SettingsActivity extends PreferenceActivity
protected void onCreate(final Bundle savedState) {
super.onCreate(savedState);
final ActionBar actionBar = getActionBar();
final Intent intent = getIntent();
if (actionBar != null) {
mShowHomeAsUp = intent.getBooleanExtra(EXTRA_SHOW_HOME_AS_UP, true);
actionBar.setDisplayHomeAsUpEnabled(mShowHomeAsUp);
actionBar.setHomeButtonEnabled(mShowHomeAsUp);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
}
StatsUtils.onSettingsActivity(
intent.hasExtra(EXTRA_ENTRY_KEY) ? intent.getStringExtra(EXTRA_ENTRY_KEY)
: EXTRA_ENTRY_VALUE_SYSTEM_SETTINGS);
}

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
if (mShowHomeAsUp && item.getItemId() == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}

@Override
Expand Down

0 comments on commit 2437d84

Please sign in to comment.