|
|
@ -33,10 +33,6 @@ public class GtasksPreferenceService {
|
|
|
|
this.preferences = preferences;
|
|
|
|
this.preferences = preferences;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getIdentifier() {
|
|
|
|
|
|
|
|
return IDENTIFIER;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getDefaultList() {
|
|
|
|
public String getDefaultList() {
|
|
|
|
return preferences.getStringValue(PREF_DEFAULT_LIST);
|
|
|
|
return preferences.getStringValue(PREF_DEFAULT_LIST);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -57,74 +53,52 @@ public class GtasksPreferenceService {
|
|
|
|
|
|
|
|
|
|
|
|
protected static final String PREF_LAST_SYNC = "_last_sync"; //$NON-NLS-1$
|
|
|
|
protected static final String PREF_LAST_SYNC = "_last_sync"; //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
|
|
protected static final String PREF_LAST_ATTEMPTED_SYNC = "_last_attempted"; //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static final String PREF_LAST_ERROR = "_last_err"; //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static final String PREF_ONGOING = "_ongoing"; //$NON-NLS-1$
|
|
|
|
protected static final String PREF_ONGOING = "_ongoing"; //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @return true if we have a token for this user, false otherwise
|
|
|
|
* @return true if we have a token for this user, false otherwise
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public boolean isLoggedIn() {
|
|
|
|
public boolean isLoggedIn() {
|
|
|
|
return preferences.getStringValue(getIdentifier() + PREF_TOKEN) != null;
|
|
|
|
return preferences.getStringValue(IDENTIFIER + PREF_TOKEN) != null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** authentication token, or null if doesn't exist */
|
|
|
|
/** authentication token, or null if doesn't exist */
|
|
|
|
public String getToken() {
|
|
|
|
public String getToken() {
|
|
|
|
return preferences.getStringValue(getIdentifier() + PREF_TOKEN);
|
|
|
|
return preferences.getStringValue(IDENTIFIER + PREF_TOKEN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Sets the authentication token. Set to null to clear. */
|
|
|
|
/** Sets the authentication token. Set to null to clear. */
|
|
|
|
public void setToken(String setting) {
|
|
|
|
public void setToken(String setting) {
|
|
|
|
preferences.setString(getIdentifier() + PREF_TOKEN, setting);
|
|
|
|
preferences.setString(IDENTIFIER + PREF_TOKEN, setting);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @return Last Successful Sync Date, or 0 */
|
|
|
|
/** @return Last Successful Sync Date, or 0 */
|
|
|
|
public long getLastSyncDate() {
|
|
|
|
public long getLastSyncDate() {
|
|
|
|
return preferences.getLong(getIdentifier() + PREF_LAST_SYNC, 0);
|
|
|
|
return preferences.getLong(IDENTIFIER + PREF_LAST_SYNC, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @return Last Attempted Sync Date, or 0 if it was successful */
|
|
|
|
|
|
|
|
public long getLastAttemptedSyncDate() {
|
|
|
|
|
|
|
|
return preferences.getLong(getIdentifier() + PREF_LAST_ATTEMPTED_SYNC, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @return Last Error, or null if no last error */
|
|
|
|
|
|
|
|
public String getLastError() {
|
|
|
|
|
|
|
|
return preferences.getStringValue(getIdentifier() + PREF_LAST_ERROR);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @return Last Error, or null if no last error */
|
|
|
|
/** @return Last Error, or null if no last error */
|
|
|
|
public boolean isOngoing() {
|
|
|
|
public boolean isOngoing() {
|
|
|
|
return preferences.getBoolean(getIdentifier() + PREF_ONGOING, false);
|
|
|
|
return preferences.getBoolean(IDENTIFIER + PREF_ONGOING, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Deletes Last Successful Sync Date */
|
|
|
|
/** Deletes Last Successful Sync Date */
|
|
|
|
public void clearLastSyncDate() {
|
|
|
|
public void clearLastSyncDate() {
|
|
|
|
preferences.clear(getIdentifier() + PREF_LAST_SYNC);
|
|
|
|
preferences.clear(IDENTIFIER + PREF_LAST_SYNC);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Set Last Error */
|
|
|
|
|
|
|
|
public void setLastError(String error) {
|
|
|
|
|
|
|
|
preferences.setString(getIdentifier() + PREF_LAST_ERROR, error);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Set Ongoing */
|
|
|
|
/** Set Ongoing */
|
|
|
|
public void stopOngoing() {
|
|
|
|
public void stopOngoing() {
|
|
|
|
preferences.setBoolean(getIdentifier() + PREF_ONGOING, false);
|
|
|
|
preferences.setBoolean(IDENTIFIER + PREF_ONGOING, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Set Last Successful Sync Date */
|
|
|
|
/** Set Last Successful Sync Date */
|
|
|
|
public void recordSuccessfulSync() {
|
|
|
|
public void recordSuccessfulSync() {
|
|
|
|
preferences.setLong(getIdentifier() + PREF_LAST_SYNC, DateUtilities.now() + 1000);
|
|
|
|
preferences.setLong(IDENTIFIER + PREF_LAST_SYNC, DateUtilities.now() + 1000);
|
|
|
|
preferences.setLong(getIdentifier() + PREF_LAST_ATTEMPTED_SYNC, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Set Last Attempted Sync Date */
|
|
|
|
/** Set Last Attempted Sync Date */
|
|
|
|
public void recordSyncStart() {
|
|
|
|
public void recordSyncStart() {
|
|
|
|
preferences.setLong(getIdentifier() + PREF_LAST_ATTEMPTED_SYNC, DateUtilities.now());
|
|
|
|
preferences.setBoolean(IDENTIFIER + PREF_ONGOING, true);
|
|
|
|
preferences.clear(getIdentifier() + PREF_LAST_ERROR);
|
|
|
|
|
|
|
|
preferences.setBoolean(getIdentifier() + PREF_ONGOING, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|