diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2014-06-09 12:52:24 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2014-06-09 13:01:39 -0700 |
commit | a9e77993d1f82a230ff381134d4a22eff4a907cd (patch) | |
tree | f60d4c0ccd21ddd8ed63e24e049014a23f5d7a98 /src/com/android/settings | |
parent | d407f2a05c8f8a81d5ea7bf9ad34bd491dc2d742 (diff) | |
download | packages_apps_Settings-a9e77993d1f82a230ff381134d4a22eff4a907cd.tar.gz packages_apps_Settings-a9e77993d1f82a230ff381134d4a22eff4a907cd.tar.bz2 packages_apps_Settings-a9e77993d1f82a230ff381134d4a22eff4a907cd.zip |
Fix bug #14499324 Label of the "Language & input " page doesn't get updated
...as per the newly selected language
- use also title resource id when possible
Change-Id: Ibeb95d605cd79910c18f4529b749645c9ed0fc17
Diffstat (limited to 'src/com/android/settings')
4 files changed, 56 insertions, 35 deletions
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index ad7d47305..12dee4a05 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -175,10 +175,11 @@ public class SettingsActivity extends Activity /** * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT}, - * this extra can also be specify to supply the title to be shown for + * those extra can also be specify to supply the title or title res id to be shown for * that fragment. */ public static final String EXTRA_SHOW_FRAGMENT_TITLE = ":settings:show_fragment_title"; + public static final String EXTRA_SHOW_FRAGMENT_TITLE_RESID = ":settings:show_fragment_title_resid"; private static final String META_DATA_KEY_FRAGMENT_CLASS = "com.android.settings.FRAGMENT_CLASS"; @@ -192,6 +193,7 @@ public class SettingsActivity extends Activity private String mFragmentClass; private CharSequence mInitialTitle; + private int mInitialTitleResId; // Show only these settings for restricted users private int[] SETTINGS_FOR_RESTRICTED = { @@ -478,9 +480,7 @@ public class SettingsActivity extends Activity mSearchMenuItemExpanded = savedState.getBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED); mSearchQuery = savedState.getString(SAVE_KEY_SEARCH_QUERY); - final String initialTitle = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT_TITLE); - mInitialTitle = (initialTitle != null) ? initialTitle : getTitle(); - setTitle(mInitialTitle); + setTitleFromIntent(getIntent()); ArrayList<DashboardCategory> categories = savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES); @@ -500,19 +500,17 @@ public class SettingsActivity extends Activity mDisplayHomeAsUpEnabled = false; mDisplaySearch = false; } - final String initialTitle = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT_TITLE); - mInitialTitle = (initialTitle != null) ? initialTitle : getTitle(); - setTitle(mInitialTitle); + setTitleFromIntent(getIntent()); Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); - switchToFragment( initialFragmentName, initialArguments, true, false, - mInitialTitle, false); + switchToFragment(initialFragmentName, initialArguments, true, false, + mInitialTitleResId, mInitialTitle, false); } else { // No UP if we are displaying the main Dashboard mDisplayHomeAsUpEnabled = false; - mInitialTitle = getText(R.string.dashboard_title); + mInitialTitleResId = R.string.dashboard_title; switchToFragment(DashboardSummary.class.getName(), null, false, false, - mInitialTitle, false); + mInitialTitleResId, mInitialTitle, false); } } @@ -579,6 +577,20 @@ public class SettingsActivity extends Activity } } + private void setTitleFromIntent(Intent intent) { + final int initialTitleResId = intent.getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1); + if (initialTitleResId > 0) { + mInitialTitle = null; + mInitialTitleResId = initialTitleResId; + setTitle(mInitialTitleResId); + } else { + mInitialTitleResId = -1; + final String initialTitle = intent.getStringExtra(EXTRA_SHOW_FRAGMENT_TITLE); + mInitialTitle = (initialTitle != null) ? initialTitle : getTitle(); + setTitle(mInitialTitle); + } + } + @Override public void onBackStackChanged() { setTitleFromBackStack(); @@ -588,7 +600,11 @@ public class SettingsActivity extends Activity final int count = getFragmentManager().getBackStackEntryCount(); if (count == 0) { - setTitle(mInitialTitle); + if (mInitialTitleResId > 0) { + setTitle(mInitialTitleResId); + } else { + setTitle(mInitialTitle); + } return 0; } @@ -753,16 +769,17 @@ public class SettingsActivity extends Activity */ public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes, CharSequence titleText, Fragment resultTo, int resultRequestCode) { - String title; - if (titleRes > 0) { - title = getString(titleRes); - } else if (titleText != null) { - title = titleText.toString(); - } else { - // There not much we can do in that case - title = ""; + String title = null; + if (titleRes < 0) { + if (titleText != null) { + title = titleText.toString(); + } else { + // There not much we can do in that case + title = ""; + } } - Utils.startWithFragment(this, fragmentClass, args, resultTo, resultRequestCode, title); + Utils.startWithFragment(this, fragmentClass, args, resultTo, resultRequestCode, + titleRes, title); } /** @@ -801,7 +818,7 @@ public class SettingsActivity extends Activity * Switch to a specific Fragment with taking care of validation, Title and BackStack */ private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate, - boolean addToBackStack, CharSequence title, boolean withTransition) { + boolean addToBackStack, int titleResId, CharSequence title, boolean withTransition) { if (validate && !isValidFragment(fragmentName)) { throw new IllegalArgumentException("Invalid fragment for this activity: " + fragmentName); @@ -815,7 +832,9 @@ public class SettingsActivity extends Activity if (addToBackStack) { transaction.addToBackStack(SettingsActivity.BACK_STACK_PREFS); } - if (title != null) { + if (titleResId > 0) { + transaction.setBreadCrumbTitle(titleResId); + } else if (title != null) { transaction.setBreadCrumbTitle(title); } transaction.commitAllowingStateLoss(); @@ -1270,10 +1289,9 @@ public class SettingsActivity extends Activity if (current != null && current instanceof SearchResultsSummary) { mSearchResultsFragment = (SearchResultsSummary) current; } else { - String title = getString(R.string.search_results_title); mSearchResultsFragment = (SearchResultsSummary) switchToFragment( - SearchResultsSummary.class.getName(), null, false, true, title, - true); + SearchResultsSummary.class.getName(), null, false, true, + R.string.search_results_title, null, true); } mSearchResultsFragment.setSearchView(mSearchView); mSearchMenuItemExpanded = true; diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index 1b640642f..59a137e80 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -519,15 +519,16 @@ public class Utils { * @param context The context. * @param fragmentName The name of the fragment to display. * @param args Optional arguments to supply to the fragment. - * @param resultTo Option fragment that should receive the result of - * the activity launch. - * @param resultRequestCode If resultTo is non-null, this is the request - * code in which to report the result. + * @param resultTo Option fragment that should receive the result of the activity launch. + * @param resultRequestCode If resultTo is non-null, this is the request code in which + * to report the result. + * @param titleResId resource id for the String to display for the title of this set + * of preferences. * @param title String to display for the title of this set of preferences. */ public static void startWithFragment(Context context, String fragmentName, Bundle args, - Fragment resultTo, int resultRequestCode, CharSequence title) { - Intent intent = onBuildStartFragmentIntent(context, fragmentName, args, title); + Fragment resultTo, int resultRequestCode, int titleResId, CharSequence title) { + Intent intent = onBuildStartFragmentIntent(context, fragmentName, args, titleResId, title); if (resultTo == null) { context.startActivity(intent); } else { @@ -543,16 +544,18 @@ public class Utils { * @param context The Context. * @param fragmentName The name of the fragment to display. * @param args Optional arguments to supply to the fragment. + * @param titleResId Optional title resource id to show for this item. * @param title Optional title to show for this item. * @return Returns an Intent that can be launched to display the given * fragment. */ public static Intent onBuildStartFragmentIntent(Context context, String fragmentName, - Bundle args, CharSequence title) { + Bundle args, int titleResId, CharSequence title) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClass(context, SubSettings.class); intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, fragmentName); intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, args); + intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, titleResId); intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE, title); return intent; } diff --git a/src/com/android/settings/dashboard/DashboardTileView.java b/src/com/android/settings/dashboard/DashboardTileView.java index a114f7030..099459c18 100644 --- a/src/com/android/settings/dashboard/DashboardTileView.java +++ b/src/com/android/settings/dashboard/DashboardTileView.java @@ -85,7 +85,7 @@ public class DashboardTileView extends FrameLayout implements View.OnClickListen public void onClick(View v) { if (mTile.fragment != null) { Utils.startWithFragment(getContext(), mTile.fragment, mTile.fragmentArguments, null, 0, - mTile.getTitle(getResources())); + mTile.titleRes, mTile.getTitle(getResources())); } else if (mTile.intent != null) { getContext().startActivity(mTile.intent); } diff --git a/src/com/android/settings/dashboard/SearchResultsSummary.java b/src/com/android/settings/dashboard/SearchResultsSummary.java index 910d66156..c31a89331 100644 --- a/src/com/android/settings/dashboard/SearchResultsSummary.java +++ b/src/com/android/settings/dashboard/SearchResultsSummary.java @@ -181,7 +181,7 @@ public class SearchResultsSummary extends Fragment { Bundle args = new Bundle(); args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key); - Utils.startWithFragment(sa, className, args, null, 0, screenTitle); + Utils.startWithFragment(sa, className, args, null, 0, -1, screenTitle); } else { final Intent intent = new Intent(action); |