diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-03-29 11:23:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-29 11:23:33 +0100 |
commit | 5ede21d676af8d879ec8f5d695255ccbf4398e76 (patch) | |
tree | e4f23895d32ff6946b57887880b084a6759bc5dc /storage/preferences | |
parent | 13a985ca1e6fae65682c97ee523dec96b2fdeedf (diff) | |
download | AntennaPod-5ede21d676af8d879ec8f5d695255ccbf4398e76.zip |
Remove dependency of :net:discovery and :ui:echo on :core (#7036)
Moves the common icon files to :ui:common
Diffstat (limited to 'storage/preferences')
-rw-r--r-- | storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/SynchronizationCredentials.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/SynchronizationCredentials.java b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/SynchronizationCredentials.java new file mode 100644 index 000000000..a5613b4ec --- /dev/null +++ b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/SynchronizationCredentials.java @@ -0,0 +1,60 @@ +package de.danoeh.antennapod.storage.preferences; + +import android.content.Context; +import android.content.SharedPreferences; + +/** + * Manages preferences for accessing gpodder.net service and other sync providers + */ +public abstract class SynchronizationCredentials { + private static final String PREF_NAME = "gpodder.net"; + private static final String PREF_USERNAME = "de.danoeh.antennapod.preferences.gpoddernet.username"; + private static final String PREF_PASSWORD = "de.danoeh.antennapod.preferences.gpoddernet.password"; + private static final String PREF_DEVICEID = "de.danoeh.antennapod.preferences.gpoddernet.deviceID"; + private static final String PREF_HOSTNAME = "prefGpodnetHostname"; + + private static SharedPreferences prefs; + + public static void init(Context context) { + prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); + } + + public static String getUsername() { + return prefs.getString(PREF_USERNAME, null); + } + + public static void setUsername(String username) { + prefs.edit().putString(PREF_USERNAME, username).apply(); + } + + public static String getPassword() { + return prefs.getString(PREF_PASSWORD, null); + } + + public static void setPassword(String password) { + prefs.edit().putString(PREF_PASSWORD, password).apply(); + } + + public static String getDeviceId() { + return prefs.getString(PREF_DEVICEID, null); + } + + public static void setDeviceId(String deviceId) { + prefs.edit().putString(PREF_DEVICEID, deviceId).apply(); + } + + public static String getHosturl() { + return prefs.getString(PREF_HOSTNAME, null); + } + + public static void setHosturl(String value) { + prefs.edit().putString(PREF_HOSTNAME, value).apply(); + } + + public static synchronized void clear() { + setUsername(null); + setPassword(null); + setDeviceId(null); + UserPreferences.setGpodnetNotificationsEnabled(); + } +} |