Bug 1263726 - Settings title remains as "Language" after switching locale and returning to "General Settings". r=grisha
MozReview-Commit-ID: L4hPzJ7kRc5
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
@@ -109,16 +109,17 @@ OnPreferenceChangeListener,
OnSharedPreferenceChangeListener
{
private static final String LOGTAG = "GeckoPreferences";
// We have a white background, which makes transitions on
// some devices look bad. Don't use transitions on those
// devices.
private static final boolean NO_TRANSITIONS = HardwareUtils.IS_KINDLE_DEVICE;
+ private static final int NO_SUCH_ID = 0;
public static final String NON_PREF_PREFIX = "android.not_a_preference.";
public static final String INTENT_EXTRA_RESOURCES = "resource";
public static final String PREFS_TRACKING_PROTECTION_PROMPT_SHOWN = NON_PREF_PREFIX + "trackingProtectionPromptShown";
public static String PREFS_HEALTHREPORT_UPLOAD_ENABLED = NON_PREF_PREFIX + "healthreport.uploadEnabled";
public static final String PREFS_SYNC = NON_PREF_PREFIX + "sync";
private static boolean sIsCharEncodingEnabled;
@@ -276,17 +277,22 @@ OnSharedPreferenceChangeListener
// Because Android just rebuilt the activity itself with the
// old language, we need to update the top title and other
// wording again.
if (onIsMultiPane()) {
updateActionBarTitle(R.string.settings_title);
}
// Update the title to for the preference pane that we're currently showing.
- setTitle(R.string.pref_category_language);
+ final int titleId = getIntent().getExtras().getInt(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE);
+ if (titleId != NO_SUCH_ID) {
+ setTitle(titleId);
+ } else {
+ throw new IllegalStateException("Title id not found in intent bundle extras");
+ }
// Don't finish the activity -- we just reloaded all of the
// individual parts! -- but when it returns, make sure that the
// caller knows the locale changed.
setResult(RESULT_CODE_LOCALE_DID_CHANGE);
return;
}
@@ -423,16 +429,18 @@ OnSharedPreferenceChangeListener
} else {
fragmentArgs.putString(INTENT_EXTRA_RESOURCES, "preferences_general_tablet");
}
}
// Build fragment intent.
intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, GeckoPreferenceFragment.class.getName());
intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs);
+ // Used to get fragment title when locale changes (see onLocaleChanged method above)
+ intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE, R.string.settings_title);
}
@Override
public boolean isValidFragment(String fragmentName) {
return GeckoPreferenceFragment.class.getName().equals(fragmentName);
}
@TargetApi(11)
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/UITest.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/UITest.java
@@ -1,32 +1,25 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.tests;
import org.mozilla.gecko.Actions;
import org.mozilla.gecko.Assert;
-import org.mozilla.gecko.BrowserApp;
import org.mozilla.gecko.Driver;
-import org.mozilla.gecko.GeckoAppShell;
-import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.tests.components.AboutHomeComponent;
import org.mozilla.gecko.tests.components.AppMenuComponent;
import org.mozilla.gecko.tests.components.BaseComponent;
import org.mozilla.gecko.tests.components.GeckoViewComponent;
import org.mozilla.gecko.tests.components.TabStripComponent;
import org.mozilla.gecko.tests.components.ToolbarComponent;
import org.mozilla.gecko.tests.helpers.HelperInitializer;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.text.TextUtils;
-
import com.robotium.solo.Solo;
/**
* A base test class for Robocop (UI-centric) tests. This and the related classes attempt to
* provide a framework to improve upon the issues discovered with the previous BaseTest
* implementation by providing simple test authorship and framework extension, consistency,
* and reliability.
*