Show "navigate up" icon on settings activity

Bug: 15813742
Change-Id: I8b1feb5c35377e62199e5a909640d9c50f970654
main
Tadashi G. Takaoka 2014-07-23 14:12:27 -07:00
parent 8ca3eb67d2
commit 76cffec788
2 changed files with 34 additions and 11 deletions

View File

@ -20,7 +20,6 @@ import static com.android.inputmethod.latin.Constants.ImeOption.FORCE_ASCII;
import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE;
import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE_COMPAT;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -1621,24 +1620,22 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (mainKeyboardView != null) {
mainKeyboardView.closing();
}
launchSubActivity(SettingsActivity.class);
}
private void launchSubActivity(final Class<? extends Activity> activityClass) {
Intent intent = new Intent();
intent.setClass(LatinIME.this, activityClass);
final Intent intent = new Intent();
intent.setClass(LatinIME.this, SettingsActivity.class);
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);
startActivity(intent);
}
private void showSubtypeSelectorAndSettings() {
final CharSequence title = getString(R.string.english_ime_input_options);
// TODO: Should use new string "Select active input modes".
final CharSequence languageSelectionTitle = getString(R.string.language_selection_title);
final CharSequence[] items = new CharSequence[] {
// TODO: Should use new string "Select active input modes".
getString(R.string.language_selection_title),
getString(ApplicationUtils.getActivityTitleResId(this, SettingsActivity.class)),
languageSelectionTitle,
getString(ApplicationUtils.getActivityTitleResId(this, SettingsActivity.class))
};
final OnClickListener listener = new OnClickListener() {
@Override
@ -1651,6 +1648,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(Intent.EXTRA_TITLE, languageSelectionTitle);
startActivity(intent);
break;
case 1:

View File

@ -18,11 +18,36 @@ package com.android.inputmethod.latin.settings;
import com.android.inputmethod.latin.utils.FragmentUtils;
import android.app.ActionBar;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.MenuItem;
public final class SettingsActivity extends PreferenceActivity {
public static final String EXTRA_SHOW_HOME_AS_UP = "show_home_as_up";
private static final String DEFAULT_FRAGMENT = SettingsFragment.class.getName();
private boolean mShowHomeAsUp;
@Override
protected void onCreate(final Bundle savedState) {
super.onCreate(savedState);
final ActionBar actionBar = getActionBar();
if (actionBar != null) {
mShowHomeAsUp = getIntent().getBooleanExtra(EXTRA_SHOW_HOME_AS_UP, true);
actionBar.setDisplayHomeAsUpEnabled(mShowHomeAsUp);
actionBar.setHomeButtonEnabled(mShowHomeAsUp);
}
}
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
if (mShowHomeAsUp && item.getItemId() == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public Intent getIntent() {
@ -36,7 +61,7 @@ public final class SettingsActivity extends PreferenceActivity {
}
@Override
public boolean isValidFragment(String fragmentName) {
public boolean isValidFragment(final String fragmentName) {
return FragmentUtils.isValidFragment(fragmentName);
}
}