From 5ede21d676af8d879ec8f5d695255ccbf4398e76 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 29 Mar 2024 11:23:33 +0100 Subject: Remove dependency of :net:discovery and :ui:echo on :core (#7036) Moves the common icon files to :ui:common --- .../preferences/SynchronizationCredentials.java | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/SynchronizationCredentials.java (limited to 'storage/preferences/src') 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(); + } +} -- cgit v1.2.3