mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-26 21:50:42 -10:00
======== https://github.com/mozilla-services/android-sync/commit/8c7b2531420892398d6b86eef52b0b472908e53e Author: Nick Alexander <[email protected]> Date: Tue Jun 3 15:48:40 2014 -0700 Bug 788688 - Review comment: Include timestamp in setClientName. ======== https://github.com/mozilla-services/android-sync/commit/b53b9092c20a317b0ebb4eef0d3618c12d4c6407 Author: Nick Alexander <[email protected]> Date: Thu May 29 16:05:25 2014 -0700 Bug 788688 - Post: PII client data to ease debugging. ======== https://github.com/mozilla-services/android-sync/commit/fd59f3c984b4a6c480cf045ca810e298ced826d5 Author: Nick Alexander <[email protected]> Date: Wed Jun 4 15:01:12 2014 -0700 Bug 788688 - Part 4: Work around Android DialogPreference caching bug. ======== https://github.com/mozilla-services/android-sync/commit/87d10bc16aaf59d463e187bb5879728152367cfc Author: Nick Alexander <[email protected]> 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. ======== https://github.com/mozilla-services/android-sync/commit/7af72f6c2ff9099b957cc562cc3f71ee3cb1f49b Author: Nick Alexander <[email protected]> Date: Thu May 29 16:05:59 2014 -0700 Bug 788688 - Part 2: Upload clients and tabs records when client name changes. ======== https://github.com/mozilla-services/android-sync/commit/0e99eae1b5fe5e79dd3a8030bfca4aef64e22703 Author: Nick Alexander <[email protected]> Date: Thu May 29 15:28:36 2014 -0700 Bug 788688 - Part 1: Add setClientName with timestamp to ClientsDataDelegate. ======== https://github.com/mozilla-services/android-sync/commit/1999e263dbee7340c1f2ad312813561520805700 Author: Nick Alexander <[email protected]> Date: Thu May 29 14:10:40 2014 -0700 Bug 788688 - Pre: Clean some imports.
84 lines
2.6 KiB
Java
84 lines
2.6 KiB
Java
/* 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.sync;
|
|
|
|
import org.mozilla.gecko.background.common.GlobalConstants;
|
|
import org.mozilla.gecko.sync.delegates.ClientsDataDelegate;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
/**
|
|
* A <code>ClientsDataDelegate</code> implementation that persists to a
|
|
* <code>SharedPreferences</code> instance.
|
|
*/
|
|
public class SharedPreferencesClientsDataDelegate implements ClientsDataDelegate {
|
|
protected final SharedPreferences sharedPreferences;
|
|
|
|
public SharedPreferencesClientsDataDelegate(SharedPreferences sharedPreferences) {
|
|
this.sharedPreferences = sharedPreferences;
|
|
}
|
|
|
|
@Override
|
|
public synchronized String getAccountGUID() {
|
|
String accountGUID = sharedPreferences.getString(SyncConfiguration.PREF_ACCOUNT_GUID, null);
|
|
if (accountGUID == null) {
|
|
accountGUID = Utils.generateGuid();
|
|
sharedPreferences.edit().putString(SyncConfiguration.PREF_ACCOUNT_GUID, accountGUID).commit();
|
|
}
|
|
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 = getDefaultClientName();
|
|
long now = System.currentTimeMillis();
|
|
setClientName(clientName, now);
|
|
}
|
|
return clientName;
|
|
}
|
|
|
|
@Override
|
|
public synchronized void setClientsCount(int clientsCount) {
|
|
sharedPreferences.edit().putLong(SyncConfiguration.PREF_NUM_CLIENTS, (long) clientsCount).commit();
|
|
}
|
|
|
|
@Override
|
|
public boolean isLocalGUID(String guid) {
|
|
return getAccountGUID().equals(guid);
|
|
}
|
|
|
|
@Override
|
|
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);
|
|
}
|
|
}
|