Add sync preferences to settings screen

This commit is contained in:
2020-11-22 15:39:08 -06:00
parent a2400172e2
commit 23f2978a64
9 changed files with 101 additions and 121 deletions

View File

@@ -29,10 +29,6 @@ import java.util.*;
public class Preferences
{
public static final String DEFAULT_SYNC_SERVER =
"https://sync.loophabits.org";
@NonNull
private final Storage storage;
@@ -130,16 +126,6 @@ public class Preferences
else return new Timestamp(unixTime);
}
public long getLastSync()
{
return storage.getLong("last_sync", 0);
}
public void setLastSync(long timestamp)
{
storage.putLong("last_sync", timestamp);
}
public boolean getShowArchived()
{
return storage.getBoolean("pref_show_archived", false);
@@ -170,39 +156,6 @@ public class Preferences
storage.putString("pref_snooze_interval", String.valueOf(interval));
}
public String getSyncAddress()
{
return storage.getString("pref_sync_address", DEFAULT_SYNC_SERVER);
}
public void setSyncAddress(String address)
{
storage.putString("pref_sync_address", address);
for (Listener l : listeners) l.onSyncFeatureChanged();
}
public String getSyncClientId()
{
String id = storage.getString("pref_sync_client_id", "");
if (!id.isEmpty()) return id;
id = UUID.randomUUID().toString();
storage.putString("pref_sync_client_id", id);
return id;
}
public String getSyncKey()
{
return storage.getString("pref_sync_key", "");
}
public void setSyncKey(String key)
{
storage.putString("pref_sync_key", key);
for (Listener l : listeners) l.onSyncFeatureChanged();
}
public int getTheme()
{
return storage.getInt("pref_theme", ThemeSwitcher.THEME_AUTOMATIC);
@@ -263,17 +216,6 @@ public class Preferences
storage.putBoolean("pref_short_toggle", enabled);
}
public boolean isSyncEnabled()
{
return storage.getBoolean("pref_feature_sync", false);
}
public void setSyncEnabled(boolean isEnabled)
{
storage.putBoolean("pref_feature_sync", isEnabled);
for (Listener l : listeners) l.onSyncFeatureChanged();
}
public boolean isWidgetStackEnabled()
{
return storage.getBoolean("pref_feature_widget_stack", false);
@@ -367,6 +309,26 @@ public class Preferences
storage.putBoolean("pref_skip_enabled", value);
}
public String getSyncBaseURL()
{
return storage.getString("pref_sync_base_url", "");
}
public String getSyncKey()
{
return storage.getString("pref_sync_key", "");
}
public void setSyncKey(String key)
{
storage.putString("pref_sync_key", key);
}
public boolean isSyncEnabled()
{
return storage.getBoolean("pref_sync_enabled", false);
}
/**
* @return An integer representing the first day of the week. Sunday
@@ -390,10 +352,6 @@ public class Preferences
default void onNotificationsChanged()
{
}
default void onSyncFeatureChanged()
{
}
}
public interface Storage