Bug 1019719 - Localize the Sync client name. r=nalexander

This commit is contained in:
Bryan Kok 2014-07-21 11:13:24 -07:00
parent 2e765e2232
commit a271a54f65
6 changed files with 27 additions and 8 deletions

View File

@ -348,7 +348,7 @@ public class FxAccountStatusFragment
}
this.fxAccount = fxAccount;
try {
this.clientsDataDelegate = new SharedPreferencesClientsDataDelegate(fxAccount.getSyncPrefs());
this.clientsDataDelegate = new SharedPreferencesClientsDataDelegate(fxAccount.getSyncPrefs(), getActivity().getApplicationContext());
} catch (Exception e) {
Logger.error(LOG_TAG, "Got exception fetching Sync prefs associated to Firefox Account; aborting.", e);
// Something is terribly wrong; best to get a stack trace rather than

View File

@ -357,7 +357,7 @@ public class FxAccountSyncAdapter extends AbstractThreadedSyncAdapter {
FxAccountGlobalSession globalSession = null;
try {
final ClientsDataDelegate clientsDataDelegate = new SharedPreferencesClientsDataDelegate(sharedPrefs);
final ClientsDataDelegate clientsDataDelegate = new SharedPreferencesClientsDataDelegate(sharedPrefs, getContext());
if (FxAccountConstants.LOG_PERSONAL_INFORMATION) {
FxAccountConstants.pii(LOG_TAG, "Client device name is: '" + clientsDataDelegate.getClientName() + "'.");
FxAccountConstants.pii(LOG_TAG, "Client device data last modified: " + clientsDataDelegate.getLastModifiedTimestamp());

View File

@ -34,7 +34,7 @@
<!ENTITY sync.input.key.label 'Recovery Key'>
<!ENTITY sync.checkbox.server.label 'Use custom server'>
<!ENTITY sync.input.server.label 'Server URL'>
<!-- Setup Fail -->
<!ENTITY sync.title.fail.label 'Cannot Set Up &syncBrand.shortName.label;'>
<!ENTITY sync.subtitle.fail.label '&syncBrand.fullName.label; could not connect to the server. Would you like to try again?'>
@ -43,7 +43,7 @@
<!ENTITY sync.subtitle.nointernet.label 'No internet connection available.'>
<!ENTITY sync.subtitle.failaccount.label 'Account creation on your device failed.'>
<!ENTITY sync.subtitle.failmultiple.label 'Do you have more than one Firefox installed? Currently, &syncBrand.fullName.label; only supports one Firefox installation at a time. Please uninstall other instances to use &syncBrand.shortName.label;.'>
<!-- Setup Success -->
<!ENTITY sync.title.success.label 'Setup Complete'>
<!ENTITY sync.subtitle.success.label1 'Your data is now being downloaded in the background. You can go to Settings to manage your account, or start browsing with &brandShortName;.'>
@ -74,6 +74,13 @@
<!-- Account strings -->
<!ENTITY sync.account.label '&syncBrand.fullName.label; (deprecated)'>
<!-- Localization note (sync.default.client.name): Default string of the "Device name" menu item upon setting up Firefox Sync.
The placeholder &formatS1 will be replaced by the name of the Firefox release channel and &formatS2 by the model name of the
Android device. Examples:
Aurora on GT-I1950
Fennec on MI 2S -->
<!ENTITY sync.default.client.name '&formatS1; on &formatS2;'>
<!-- Bookmark folder strings -->
<!ENTITY bookmarks.folder.menu.label 'Bookmarks Menu'>
<!ENTITY bookmarks.folder.places.label ''>

View File

@ -6,7 +6,9 @@ package org.mozilla.gecko.sync;
import org.mozilla.gecko.background.common.GlobalConstants;
import org.mozilla.gecko.sync.delegates.ClientsDataDelegate;
import org.mozilla.gecko.R;
import android.content.Context;
import android.content.SharedPreferences;
/**
@ -15,9 +17,11 @@ import android.content.SharedPreferences;
*/
public class SharedPreferencesClientsDataDelegate implements ClientsDataDelegate {
protected final SharedPreferences sharedPreferences;
protected final Context context;
public SharedPreferencesClientsDataDelegate(SharedPreferences sharedPreferences) {
public SharedPreferencesClientsDataDelegate(SharedPreferences sharedPreferences, Context context) {
this.sharedPreferences = sharedPreferences;
this.context = context;
}
@Override
@ -46,8 +50,15 @@ public class SharedPreferencesClientsDataDelegate implements ClientsDataDelegate
@Override
public String getDefaultClientName() {
// Bug 1019719: localize this string!
return GlobalConstants.MOZ_APP_DISPLAYNAME + " on " + android.os.Build.MODEL;
String name = GlobalConstants.MOZ_APP_DISPLAYNAME;
if (name.contains("Aurora")) {
name = "Aurora";
} else if (name.contains("Beta")) {
name = "Beta";
} else if (name.contains("Nightly")) {
name = "Nightly";
}
return context.getResources().getString(R.string.sync_default_client_name, name, android.os.Build.MODEL);
}
@Override

View File

@ -341,7 +341,7 @@ public class SyncAdapter extends AbstractThreadedSyncAdapter implements BaseGlob
final String profile = Constants.DEFAULT_PROFILE;
final long version = SyncConfiguration.CURRENT_PREFS_VERSION;
self.accountSharedPreferences = Utils.getSharedPreferences(mContext, product, username, serverURL, profile, version);
self.clientsDataDelegate = new SharedPreferencesClientsDataDelegate(accountSharedPreferences);
self.clientsDataDelegate = new SharedPreferencesClientsDataDelegate(accountSharedPreferences, mContext);
self.backoffHandler = new PrefsBackoffHandler(accountSharedPreferences, SyncConstants.BACKOFF_PREF_SUFFIX_11);
final String nodeWeaveURL = Utils.nodeWeaveURL(serverURL, username);
self.nodeAssignmentDelegate = new SharedPreferencesNodeAssignmentCallback(accountSharedPreferences, nodeWeaveURL);

View File

@ -97,6 +97,7 @@
<string name="sync_text_redirect_to_set_up_sync">&sync.text.redirect.to.set.up.sync.label;</string>
<string name="sync_text_tab_sent">&sync.text.tab.sent.label;</string>
<string name="sync_text_tab_not_sent">&sync.text.tab.not.sent.label;</string>
<string name="sync_default_client_name">&sync.default.client.name;</string>
<string name="browser_intent_package">@ANDROID_PACKAGE_NAME@</string>
<string name="browser_intent_class">@ANDROID_PACKAGE_NAME@.App</string>