mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
ecd6ed4a2e
========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.
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);
|
|
}
|
|
}
|