Bug 788688 - Allow setting client's device name in FxAccountStatusActivity. r=rnewman

========

8c7b253142
Author: Nick Alexander <nalexander@mozilla.com>
Date:   Tue Jun 3 15:48:40 2014 -0700

    Bug 788688 - Review comment: Include timestamp in setClientName.

========

b53b9092c2
Author: Nick Alexander <nalexander@mozilla.com>
Date:   Thu May 29 16:05:25 2014 -0700

    Bug 788688 - Post: PII client data to ease debugging.

========

fd59f3c984
Author: Nick Alexander <nalexander@mozilla.com>
Date:   Wed Jun 4 15:01:12 2014 -0700

    Bug 788688 - Part 4: Work around Android DialogPreference caching bug.

========

87d10bc16a
Author: Nick Alexander <nalexander@mozilla.com>
Date:   Thu May 29 14:44:24 2014 -0700

    Bug 788688 - Part 3: Add "Device name" pref to Status activity.

    In the edge case where what the user has entered (empty text) and what
    is persisted (default client name) differ, Android does not update the
    contents of the dialog's EditText correctly.  Removing and re-creating
    all preferences is the only way I found to work around this; that's in
    the next commit.

========

7af72f6c2f
Author: Nick Alexander <nalexander@mozilla.com>
Date:   Thu May 29 16:05:59 2014 -0700

    Bug 788688 - Part 2: Upload clients and tabs records when client name changes.

========

0e99eae1b5
Author: Nick Alexander <nalexander@mozilla.com>
Date:   Thu May 29 15:28:36 2014 -0700

    Bug 788688 - Part 1: Add setClientName with timestamp to ClientsDataDelegate.

========

1999e263db
Author: Nick Alexander <nalexander@mozilla.com>
Date:   Thu May 29 14:10:40 2014 -0700

    Bug 788688 - Pre: Clean some imports.
This commit is contained in:
Nick Alexander
2014-06-04 16:37:25 -07:00
parent 9e68fd2c17
commit 5680daa86a
15 changed files with 171 additions and 27 deletions

View File

@@ -30,12 +30,33 @@ public class SharedPreferencesClientsDataDelegate implements ClientsDataDelegate
return accountGUID;
}
/**
* Set client name.
*
* @param clientName to change to.
*/
@Override
public synchronized void setClientName(String clientName, long now) {
sharedPreferences
.edit()
.putString(SyncConfiguration.PREF_CLIENT_NAME, clientName)
.putLong(SyncConfiguration.PREF_CLIENT_DATA_TIMESTAMP, now)
.commit();
}
@Override
public String getDefaultClientName() {
// Bug 1019719: localize this string!
return GlobalConstants.MOZ_APP_DISPLAYNAME + " on " + android.os.Build.MODEL;
}
@Override
public synchronized String getClientName() {
String clientName = sharedPreferences.getString(SyncConfiguration.PREF_CLIENT_NAME, null);
if (clientName == null) {
clientName = GlobalConstants.MOZ_APP_DISPLAYNAME + " on " + android.os.Build.MODEL;
sharedPreferences.edit().putString(SyncConfiguration.PREF_CLIENT_NAME, clientName).commit();
clientName = getDefaultClientName();
long now = System.currentTimeMillis();
setClientName(clientName, now);
}
return clientName;
}
@@ -54,4 +75,9 @@ public class SharedPreferencesClientsDataDelegate implements ClientsDataDelegate
public synchronized int getClientsCount() {
return (int) sharedPreferences.getLong(SyncConfiguration.PREF_NUM_CLIENTS, 0);
}
@Override
public long getLastModifiedTimestamp() {
return sharedPreferences.getLong(SyncConfiguration.PREF_CLIENT_DATA_TIMESTAMP, 0);
}
}