mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 09:38:52 -06:00
Sync: Improve encryption and preferences API
This commit is contained in:
@@ -319,30 +319,29 @@ public class Preferences
|
||||
return storage.getString("pref_sync_key", "");
|
||||
}
|
||||
|
||||
public void setSyncKey(String key)
|
||||
{
|
||||
storage.putString("pref_sync_key", key);
|
||||
}
|
||||
|
||||
public String getEncryptionKey()
|
||||
{
|
||||
return storage.getString("pref_encryption_key", "");
|
||||
}
|
||||
|
||||
public void setEncryptionKey(String key)
|
||||
{
|
||||
storage.putString("pref_encryption_key", key);
|
||||
}
|
||||
|
||||
public boolean isSyncEnabled()
|
||||
{
|
||||
return storage.getBoolean("pref_sync_enabled", false);
|
||||
}
|
||||
|
||||
public void setSyncEnabled(boolean enabled)
|
||||
public void enableSync(String syncKey, String encKey)
|
||||
{
|
||||
storage.putBoolean("pref_sync_enabled", enabled);
|
||||
if(enabled) for (Listener l : listeners) l.onSyncEnabled();
|
||||
storage.putBoolean("pref_sync_enabled", true);
|
||||
storage.putString("pref_sync_key", syncKey);
|
||||
storage.putString("pref_encryption_key", encKey);
|
||||
for (Listener l : listeners) l.onSyncEnabled();
|
||||
}
|
||||
|
||||
public void disableSync()
|
||||
{
|
||||
storage.putBoolean("pref_sync_enabled", false);
|
||||
storage.putString("pref_sync_key", "");
|
||||
storage.putString("pref_encryption_key", "");
|
||||
}
|
||||
|
||||
public boolean areQuestionMarksEnabled()
|
||||
|
||||
@@ -165,9 +165,7 @@ public class ListHabitsBehavior
|
||||
return;
|
||||
}
|
||||
screen.showConfirmInstallSyncKey(() -> {
|
||||
prefs.setSyncKey(syncKey);
|
||||
prefs.setEncryptionKey(encryptionKey);
|
||||
prefs.setSyncEnabled(true);
|
||||
prefs.enableSync(syncKey, encryptionKey);
|
||||
screen.showMessage(Message.SYNC_ENABLED);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user