From 9a71300c19a5b009699e823ca88acd34852fc48d Mon Sep 17 00:00:00 2001 From: Bryan Kok Date: Mon, 21 Jul 2014 11:13:24 -0700 Subject: [PATCH] Bug 1019719 - Localize the Sync client name. r=nalexander --- .../fxa/activities/FxAccountStatusFragment.java | 2 +- .../base/fxa/sync/FxAccountSyncAdapter.java | 2 +- .../android/base/locales/en-US/sync_strings.dtd | 11 +++++++++-- .../SharedPreferencesClientsDataDelegate.java | 17 ++++++++++++++--- .../base/sync/syncadapter/SyncAdapter.java | 2 +- mobile/android/services/strings.xml.in | 1 + 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/mobile/android/base/fxa/activities/FxAccountStatusFragment.java b/mobile/android/base/fxa/activities/FxAccountStatusFragment.java index e7c477274d6..6e250cce6fc 100644 --- a/mobile/android/base/fxa/activities/FxAccountStatusFragment.java +++ b/mobile/android/base/fxa/activities/FxAccountStatusFragment.java @@ -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 diff --git a/mobile/android/base/fxa/sync/FxAccountSyncAdapter.java b/mobile/android/base/fxa/sync/FxAccountSyncAdapter.java index d2ac7ea9de3..903c10d328c 100644 --- a/mobile/android/base/fxa/sync/FxAccountSyncAdapter.java +++ b/mobile/android/base/fxa/sync/FxAccountSyncAdapter.java @@ -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()); diff --git a/mobile/android/base/locales/en-US/sync_strings.dtd b/mobile/android/base/locales/en-US/sync_strings.dtd index ced43dcac0d..272bb46d313 100644 --- a/mobile/android/base/locales/en-US/sync_strings.dtd +++ b/mobile/android/base/locales/en-US/sync_strings.dtd @@ -34,7 +34,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -74,6 +74,13 @@ + + + diff --git a/mobile/android/base/sync/SharedPreferencesClientsDataDelegate.java b/mobile/android/base/sync/SharedPreferencesClientsDataDelegate.java index a96978afaf4..5f856319e53 100644 --- a/mobile/android/base/sync/SharedPreferencesClientsDataDelegate.java +++ b/mobile/android/base/sync/SharedPreferencesClientsDataDelegate.java @@ -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 diff --git a/mobile/android/base/sync/syncadapter/SyncAdapter.java b/mobile/android/base/sync/syncadapter/SyncAdapter.java index 3060b83f741..4e88bb7c56e 100644 --- a/mobile/android/base/sync/syncadapter/SyncAdapter.java +++ b/mobile/android/base/sync/syncadapter/SyncAdapter.java @@ -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); diff --git a/mobile/android/services/strings.xml.in b/mobile/android/services/strings.xml.in index 680591c7813..a8d9e64a946 100644 --- a/mobile/android/services/strings.xml.in +++ b/mobile/android/services/strings.xml.in @@ -97,6 +97,7 @@ &sync.text.redirect.to.set.up.sync.label; &sync.text.tab.sent.label; &sync.text.tab.not.sent.label; + &sync.default.client.name; @ANDROID_PACKAGE_NAME@ @ANDROID_PACKAGE_NAME@.App