diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-03-29 13:39:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-29 13:39:19 +0100 |
commit | f9dd837362921df3fbcea424f9e064ecc696f367 (patch) | |
tree | 95cc951dab32ff976a328fbea9897304ee000367 | |
parent | 8f553f08f0347b73b34c80dddef228302cdf5977 (diff) | |
download | AntennaPod-f9dd837362921df3fbcea424f9e064ecc696f367.zip |
Remove ClientConfig class (#7038)
20 files changed, 49 insertions, 144 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/PodcastApp.java b/app/src/main/java/de/danoeh/antennapod/PodcastApp.java index d39015834..34672141c 100644 --- a/app/src/main/java/de/danoeh/antennapod/PodcastApp.java +++ b/app/src/main/java/de/danoeh/antennapod/PodcastApp.java @@ -5,9 +5,7 @@ import android.os.StrictMode; import com.google.android.material.color.DynamicColors; -import de.danoeh.antennapod.config.ApplicationCallbacksImpl; import de.danoeh.antennapod.core.ApCoreEventBusIndex; -import de.danoeh.antennapod.core.ClientConfig; import de.danoeh.antennapod.core.ClientConfigurator; import de.danoeh.antennapod.error.CrashReportWriter; import de.danoeh.antennapod.error.RxJavaErrorHandlerSetup; @@ -17,18 +15,9 @@ import org.greenrobot.eventbus.EventBus; /** Main application class. */ public class PodcastApp extends Application { - - private static PodcastApp singleton; - - public static PodcastApp getInstance() { - return singleton; - } - @Override public void onCreate() { super.onCreate(); - ClientConfig.applicationCallbacks = new ApplicationCallbacksImpl(); - Thread.setDefaultUncaughtExceptionHandler(new CrashReportWriter()); RxJavaErrorHandlerSetup.setupRxJavaErrorHandler(); @@ -43,8 +32,6 @@ public class PodcastApp extends Application { StrictMode.setVmPolicy(builder.build()); } - singleton = this; - ClientConfigurator.initialize(this); PreferenceUpgrader.checkUpgrades(this); diff --git a/app/src/main/java/de/danoeh/antennapod/config/ApplicationCallbacksImpl.java b/app/src/main/java/de/danoeh/antennapod/config/ApplicationCallbacksImpl.java deleted file mode 100644 index e9dfd66e0..000000000 --- a/app/src/main/java/de/danoeh/antennapod/config/ApplicationCallbacksImpl.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.danoeh.antennapod.config; - - -import android.app.Application; - -import de.danoeh.antennapod.PodcastApp; -import de.danoeh.antennapod.core.ApplicationCallbacks; - -public class ApplicationCallbacksImpl implements ApplicationCallbacks { - - @Override - public Application getApplicationInstance() { - return PodcastApp.getInstance(); - } -} diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java index 4ffc72699..b4b6112ff 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java @@ -20,7 +20,7 @@ import de.danoeh.antennapod.storage.preferences.PlaybackPreferences; import de.danoeh.antennapod.core.util.FeedUtil; import de.danoeh.antennapod.core.service.playback.PlaybackServiceInterface; import de.danoeh.antennapod.core.storage.DBWriter; -import de.danoeh.antennapod.core.sync.SynchronizationSettings; +import de.danoeh.antennapod.storage.preferences.SynchronizationSettings; import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink; import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.IntentUtils; diff --git a/core/src/main/java/de/danoeh/antennapod/core/ApplicationCallbacks.java b/core/src/main/java/de/danoeh/antennapod/core/ApplicationCallbacks.java deleted file mode 100644 index 3b591363f..000000000 --- a/core/src/main/java/de/danoeh/antennapod/core/ApplicationCallbacks.java +++ /dev/null @@ -1,14 +0,0 @@ -package de.danoeh.antennapod.core; - -import android.app.Application; - -/** - * Callbacks related to the application in general - */ -public interface ApplicationCallbacks { - - /** - * Returns a non-null instance of the application class - */ - Application getApplicationInstance(); -} diff --git a/core/src/main/java/de/danoeh/antennapod/core/ClientConfig.java b/core/src/main/java/de/danoeh/antennapod/core/ClientConfig.java deleted file mode 100644 index 69abcee93..000000000 --- a/core/src/main/java/de/danoeh/antennapod/core/ClientConfig.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.danoeh.antennapod.core; - -/** - * Stores callbacks for core classes like Services, DB classes etc. and other configuration variables. - * Apps using the core module of AntennaPod should register implementations of all interfaces here. - */ -public class ClientConfig { - public static ApplicationCallbacks applicationCallbacks; -} diff --git a/core/src/main/java/de/danoeh/antennapod/core/ClientConfigurator.java b/core/src/main/java/de/danoeh/antennapod/core/ClientConfigurator.java index b50a1b2ab..48d937266 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/ClientConfigurator.java +++ b/core/src/main/java/de/danoeh/antennapod/core/ClientConfigurator.java @@ -3,6 +3,7 @@ package de.danoeh.antennapod.core; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import de.danoeh.antennapod.storage.preferences.SynchronizationSettings; import de.danoeh.antennapod.storage.preferences.SynchronizationCredentials; import de.danoeh.antennapod.storage.preferences.PlaybackPreferences; import de.danoeh.antennapod.storage.preferences.SleepTimerPreferences; @@ -38,6 +39,7 @@ public class ClientConfigurator { PodDBAdapter.init(context); UserPreferences.init(context); SynchronizationCredentials.init(context); + SynchronizationSettings.init(context); UsageStatistics.init(context); PlaybackPreferences.init(context); SslProviderInstaller.install(context); diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java index d1334190a..7010d61ba 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java @@ -1,13 +1,10 @@ package de.danoeh.antennapod.core.service.download; -import android.content.Context; -import android.net.wifi.WifiManager; import androidx.annotation.NonNull; import java.util.Date; import java.util.concurrent.Callable; -import de.danoeh.antennapod.core.ClientConfig; import de.danoeh.antennapod.core.R; import de.danoeh.antennapod.model.download.DownloadResult; import de.danoeh.antennapod.model.download.DownloadRequest; @@ -39,20 +36,7 @@ public abstract class Downloader implements Callable<Downloader> { protected abstract void download(); public final Downloader call() { - WifiManager wifiManager = (WifiManager) - ClientConfig.applicationCallbacks.getApplicationInstance().getApplicationContext().getSystemService(Context.WIFI_SERVICE); - WifiManager.WifiLock wifiLock = null; - if (wifiManager != null) { - wifiLock = wifiManager.createWifiLock(TAG); - wifiLock.acquire(); - } - download(); - - if (wifiLock != null) { - wifiLock.release(); - } - finished = true; return this; } diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/EpisodeDownloadWorker.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/EpisodeDownloadWorker.java index 4f9c7a190..9c073713f 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/EpisodeDownloadWorker.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/EpisodeDownloadWorker.java @@ -7,6 +7,7 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; +import android.net.wifi.WifiManager; import android.os.Build; import android.util.Log; import androidx.annotation.NonNull; @@ -160,12 +161,22 @@ public class EpisodeDownloadWorker extends Worker { return Result.failure(); } + WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); + WifiManager.WifiLock wifiLock = null; + if (wifiManager != null) { + wifiLock = wifiManager.createWifiLock(TAG); + wifiLock.acquire(); + } try { downloader.call(); } catch (Exception e) { DBWriter.addDownloadStatus(downloader.getResult()); sendErrorNotification(request.getTitle()); return Result.failure(); + } finally { + if (wifiLock != null) { + wifiLock.release(); + } } if (downloader.cancelled) { diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java index d9399420c..30178edf9 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java @@ -29,6 +29,7 @@ import de.danoeh.antennapod.event.MessageEvent; import de.danoeh.antennapod.model.feed.FeedItemFilter; import de.danoeh.antennapod.model.feed.SortOrder; import de.danoeh.antennapod.storage.preferences.SynchronizationCredentials; +import de.danoeh.antennapod.storage.preferences.SynchronizationSettings; import de.danoeh.antennapod.ui.notifications.NotificationUtils; import org.apache.commons.lang3.StringUtils; import org.greenrobot.eventbus.EventBus; diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/queue/SynchronizationQueueSink.java b/core/src/main/java/de/danoeh/antennapod/core/sync/queue/SynchronizationQueueSink.java index cfe3798a7..8d59c9146 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/sync/queue/SynchronizationQueueSink.java +++ b/core/src/main/java/de/danoeh/antennapod/core/sync/queue/SynchronizationQueueSink.java @@ -3,7 +3,7 @@ package de.danoeh.antennapod.core.sync.queue; import android.content.Context; import de.danoeh.antennapod.core.sync.LockingAsyncExecutor; -import de.danoeh.antennapod.core.sync.SynchronizationSettings; +import de.danoeh.antennapod.storage.preferences.SynchronizationSettings; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.net.sync.model.EpisodeAction; diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/queue/SynchronizationQueueStorage.java b/core/src/main/java/de/danoeh/antennapod/core/sync/queue/SynchronizationQueueStorage.java index e1e373953..407d69fd6 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/sync/queue/SynchronizationQueueStorage.java +++ b/core/src/main/java/de/danoeh/antennapod/core/sync/queue/SynchronizationQueueStorage.java @@ -8,7 +8,7 @@ import org.json.JSONException; import java.util.ArrayList; -import de.danoeh.antennapod.core.sync.SynchronizationSettings; +import de.danoeh.antennapod.storage.preferences.SynchronizationSettings; import de.danoeh.antennapod.net.sync.model.EpisodeAction; public class SynchronizationQueueStorage { diff --git a/core/src/test/java/de/danoeh/antennapod/core/feed/LocalFeedUpdaterTest.java b/core/src/test/java/de/danoeh/antennapod/core/feed/LocalFeedUpdaterTest.java index ad340314d..12256264a 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/feed/LocalFeedUpdaterTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/feed/LocalFeedUpdaterTest.java @@ -1,6 +1,5 @@ package de.danoeh.antennapod.core.feed; -import android.app.Application; import android.content.Context; import android.media.MediaMetadataRetriever; import android.net.Uri; @@ -16,6 +15,7 @@ import de.danoeh.antennapod.core.util.FastDocumentFile; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.storage.database.PodDBAdapter; +import de.danoeh.antennapod.storage.preferences.SynchronizationSettings; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -33,8 +33,6 @@ import java.util.Collections; import java.util.List; import java.util.Objects; -import de.danoeh.antennapod.core.ApplicationCallbacks; -import de.danoeh.antennapod.core.ClientConfig; import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; @@ -46,8 +44,6 @@ import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import static org.robolectric.Shadows.shadowOf; /** @@ -74,10 +70,7 @@ public class LocalFeedUpdaterTest { context = InstrumentationRegistry.getInstrumentation().getContext(); UserPreferences.init(context); PlaybackPreferences.init(context); - - Application app = (Application) context; - ClientConfig.applicationCallbacks = mock(ApplicationCallbacks.class); - when(ClientConfig.applicationCallbacks.getApplicationInstance()).thenReturn(app); + SynchronizationSettings.init(context); DownloadServiceInterface.setImpl(new DownloadServiceInterfaceStub()); // Initialize database diff --git a/core/src/test/java/de/danoeh/antennapod/core/storage/DbCleanupTests.java b/core/src/test/java/de/danoeh/antennapod/core/storage/DbCleanupTests.java index a0632b345..a7d435aed 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/storage/DbCleanupTests.java +++ b/core/src/test/java/de/danoeh/antennapod/core/storage/DbCleanupTests.java @@ -1,6 +1,5 @@ package de.danoeh.antennapod.core.storage; -import android.app.Application; import android.content.Context; import android.content.SharedPreferences; import androidx.preference.PreferenceManager; @@ -13,12 +12,11 @@ import java.util.List; import androidx.test.platform.app.InstrumentationRegistry; -import de.danoeh.antennapod.core.ApplicationCallbacks; -import de.danoeh.antennapod.core.ClientConfig; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.storage.preferences.PlaybackPreferences; +import de.danoeh.antennapod.storage.preferences.SynchronizationSettings; import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.storage.database.PodDBAdapter; @@ -32,8 +30,6 @@ import static de.danoeh.antennapod.core.storage.DbTestUtils.saveFeedlist; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; /** * Test class for DBTasks. @@ -83,10 +79,7 @@ public class DbCleanupTests { UserPreferences.init(context); PlaybackPreferences.init(context); - - Application app = (Application) context; - ClientConfig.applicationCallbacks = mock(ApplicationCallbacks.class); - when(ClientConfig.applicationCallbacks.getApplicationInstance()).thenReturn(app); + SynchronizationSettings.init(context); } @After diff --git a/core/src/test/java/de/danoeh/antennapod/core/storage/DbTasksTest.java b/core/src/test/java/de/danoeh/antennapod/core/storage/DbTasksTest.java index 1357f4d4e..075e7a559 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/storage/DbTasksTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/storage/DbTasksTest.java @@ -1,6 +1,5 @@ package de.danoeh.antennapod.core.storage; -import android.app.Application; import android.content.Context; import androidx.test.platform.app.InstrumentationRegistry; @@ -18,8 +17,6 @@ import java.util.Collections; import java.util.Date; import java.util.List; -import de.danoeh.antennapod.core.ApplicationCallbacks; -import de.danoeh.antennapod.core.ClientConfig; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; @@ -33,8 +30,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; /** * Test class for {@link FeedDatabaseWriter}. @@ -49,10 +44,6 @@ public class DbTasksTest { UserPreferences.init(context); PlaybackPreferences.init(context); - Application app = (Application) context; - ClientConfig.applicationCallbacks = mock(ApplicationCallbacks.class); - when(ClientConfig.applicationCallbacks.getApplicationInstance()).thenReturn(app); - // create new database PodDBAdapter.init(context); PodDBAdapter.deleteDatabase(); diff --git a/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java b/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java index 32c0fd2cd..4fea67f79 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java @@ -1,6 +1,5 @@ package de.danoeh.antennapod.core.storage; -import android.app.Application; import android.content.Context; import android.content.SharedPreferences; import android.database.Cursor; @@ -29,8 +28,6 @@ import java.util.Locale; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; -import de.danoeh.antennapod.core.ApplicationCallbacks; -import de.danoeh.antennapod.core.ClientConfig; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; @@ -44,8 +41,6 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; /** * Test class for {@link DBWriter}. @@ -64,10 +59,6 @@ public class DbWriterTest { context = InstrumentationRegistry.getInstrumentation().getTargetContext(); UserPreferences.init(context); PlaybackPreferences.init(context); - - Application app = (Application) context; - ClientConfig.applicationCallbacks = mock(ApplicationCallbacks.class); - when(ClientConfig.applicationCallbacks.getApplicationInstance()).thenReturn(app); DownloadServiceInterface.setImpl(new DownloadServiceInterfaceStub()); // create new database diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/SynchronizationSettings.java b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/SynchronizationSettings.java index 1a53ac0fb..dbd015972 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/sync/SynchronizationSettings.java +++ b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/SynchronizationSettings.java @@ -1,25 +1,28 @@ -package de.danoeh.antennapod.core.sync; +package de.danoeh.antennapod.storage.preferences; import android.content.Context; import android.content.SharedPreferences; -import de.danoeh.antennapod.core.ClientConfig; - public class SynchronizationSettings { - public static final String LAST_SYNC_ATTEMPT_TIMESTAMP = "last_sync_attempt_timestamp"; - private static final String NAME = "synchronization"; + private static final String PREF_NAME = "synchronization"; private static final String SELECTED_SYNC_PROVIDER = "selected_sync_provider"; private static final String LAST_SYNC_ATTEMPT_SUCCESS = "last_sync_attempt_success"; private static final String LAST_EPISODE_ACTIONS_SYNC_TIMESTAMP = "last_episode_actions_sync_timestamp"; private static final String LAST_SUBSCRIPTION_SYNC_TIMESTAMP = "last_sync_timestamp"; + private static SharedPreferences prefs; + + public static void init(Context context) { + prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); + } + public static boolean isProviderConnected() { return getSelectedSyncProviderKey() != null; } public static void resetTimestamps() { - getSharedPreferences().edit() + prefs.edit() .putLong(LAST_SUBSCRIPTION_SYNC_TIMESTAMP, 0) .putLong(LAST_EPISODE_ACTIONS_SYNC_TIMESTAMP, 0) .putLong(LAST_SYNC_ATTEMPT_TIMESTAMP, 0) @@ -27,57 +30,42 @@ public class SynchronizationSettings { } public static boolean isLastSyncSuccessful() { - return getSharedPreferences().getBoolean(LAST_SYNC_ATTEMPT_SUCCESS, false); + return prefs.getBoolean(LAST_SYNC_ATTEMPT_SUCCESS, false); } public static long getLastSyncAttempt() { - return getSharedPreferences().getLong(LAST_SYNC_ATTEMPT_TIMESTAMP, 0); + return prefs.getLong(LAST_SYNC_ATTEMPT_TIMESTAMP, 0); } - public static void setSelectedSyncProvider(SynchronizationProviderViewData provider) { - getSharedPreferences() - .edit() - .putString(SELECTED_SYNC_PROVIDER, provider == null ? null : provider.getIdentifier()) - .apply(); + public static void setSelectedSyncProvider(String providerIdentifier) { + prefs.edit().putString(SELECTED_SYNC_PROVIDER, providerIdentifier).apply(); } public static String getSelectedSyncProviderKey() { - return getSharedPreferences().getString(SELECTED_SYNC_PROVIDER, null); + return prefs.getString(SELECTED_SYNC_PROVIDER, null); } public static void updateLastSynchronizationAttempt() { - getSharedPreferences().edit() - .putLong(LAST_SYNC_ATTEMPT_TIMESTAMP, System.currentTimeMillis()) - .apply(); + prefs.edit().putLong(LAST_SYNC_ATTEMPT_TIMESTAMP, System.currentTimeMillis()).apply(); } public static void setLastSynchronizationAttemptSuccess(boolean isSuccess) { - getSharedPreferences().edit() - .putBoolean(LAST_SYNC_ATTEMPT_SUCCESS, isSuccess) - .apply(); + prefs.edit().putBoolean(LAST_SYNC_ATTEMPT_SUCCESS, isSuccess).apply(); } public static long getLastSubscriptionSynchronizationTimestamp() { - return getSharedPreferences().getLong(LAST_SUBSCRIPTION_SYNC_TIMESTAMP, 0); + return prefs.getLong(LAST_SUBSCRIPTION_SYNC_TIMESTAMP, 0); } public static void setLastSubscriptionSynchronizationAttemptTimestamp(long newTimeStamp) { - getSharedPreferences().edit() - .putLong(LAST_SUBSCRIPTION_SYNC_TIMESTAMP, newTimeStamp).apply(); + prefs.edit().putLong(LAST_SUBSCRIPTION_SYNC_TIMESTAMP, newTimeStamp).apply(); } public static long getLastEpisodeActionSynchronizationTimestamp() { - return getSharedPreferences() - .getLong(LAST_EPISODE_ACTIONS_SYNC_TIMESTAMP, 0); + return prefs.getLong(LAST_EPISODE_ACTIONS_SYNC_TIMESTAMP, 0); } public static void setLastEpisodeActionSynchronizationAttemptTimestamp(long timestamp) { - getSharedPreferences().edit() - .putLong(LAST_EPISODE_ACTIONS_SYNC_TIMESTAMP, timestamp).apply(); - } - - private static SharedPreferences getSharedPreferences() { - return ClientConfig.applicationCallbacks.getApplicationInstance() - .getSharedPreferences(NAME, Context.MODE_PRIVATE); + prefs.edit().putLong(LAST_EPISODE_ACTIONS_SYNC_TIMESTAMP, timestamp).apply(); } } diff --git a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/NotificationPreferencesFragment.java b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/NotificationPreferencesFragment.java index 221ea5da1..d33646571 100644 --- a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/NotificationPreferencesFragment.java +++ b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/NotificationPreferencesFragment.java @@ -3,7 +3,7 @@ package de.danoeh.antennapod.ui.preferences.screen; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; import androidx.preference.PreferenceFragmentCompat; -import de.danoeh.antennapod.core.sync.SynchronizationSettings; +import de.danoeh.antennapod.storage.preferences.SynchronizationSettings; import de.danoeh.antennapod.ui.preferences.R; public class NotificationPreferencesFragment extends PreferenceFragmentCompat { diff --git a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/GpodderAuthenticationFragment.java b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/GpodderAuthenticationFragment.java index 388359e3d..6328bc61e 100644 --- a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/GpodderAuthenticationFragment.java +++ b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/GpodderAuthenticationFragment.java @@ -23,7 +23,7 @@ import de.danoeh.antennapod.net.common.AntennapodHttpClient; import de.danoeh.antennapod.core.sync.SyncService; import de.danoeh.antennapod.storage.preferences.SynchronizationCredentials; import de.danoeh.antennapod.core.sync.SynchronizationProviderViewData; -import de.danoeh.antennapod.core.sync.SynchronizationSettings; +import de.danoeh.antennapod.storage.preferences.SynchronizationSettings; import de.danoeh.antennapod.core.util.FileNameGenerator; import de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService; import de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetDevice; @@ -257,7 +257,8 @@ public class GpodderAuthenticationFragment extends DialogFragment { if (selectedDevice == null) { throw new IllegalStateException("Device must not be null here"); } else { - SynchronizationSettings.setSelectedSyncProvider(SynchronizationProviderViewData.GPODDER_NET); + SynchronizationSettings.setSelectedSyncProvider( + SynchronizationProviderViewData.GPODDER_NET.getIdentifier()); SynchronizationCredentials.setUsername(username); SynchronizationCredentials.setPassword(password); SynchronizationCredentials.setDeviceId(selectedDevice.getId()); diff --git a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/NextcloudAuthenticationFragment.java b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/NextcloudAuthenticationFragment.java index 5c0f22d88..d0ecb8a24 100644 --- a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/NextcloudAuthenticationFragment.java +++ b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/NextcloudAuthenticationFragment.java @@ -13,7 +13,7 @@ import de.danoeh.antennapod.net.common.AntennapodHttpClient; import de.danoeh.antennapod.core.sync.SyncService; import de.danoeh.antennapod.storage.preferences.SynchronizationCredentials; import de.danoeh.antennapod.core.sync.SynchronizationProviderViewData; -import de.danoeh.antennapod.core.sync.SynchronizationSettings; +import de.danoeh.antennapod.storage.preferences.SynchronizationSettings; import de.danoeh.antennapod.net.sync.nextcloud.NextcloudLoginFlow; import de.danoeh.antennapod.ui.preferences.R; import de.danoeh.antennapod.ui.preferences.databinding.NextcloudAuthDialogBinding; @@ -88,7 +88,8 @@ public class NextcloudAuthenticationFragment extends DialogFragment @Override public void onNextcloudAuthenticated(String server, String username, String password) { - SynchronizationSettings.setSelectedSyncProvider(SynchronizationProviderViewData.NEXTCLOUD_GPODDER); + SynchronizationSettings.setSelectedSyncProvider( + SynchronizationProviderViewData.NEXTCLOUD_GPODDER.getIdentifier()); SynchronizationCredentials.clear(); SynchronizationQueueSink.clearQueue(getContext()); SynchronizationCredentials.setPassword(password); diff --git a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/SynchronizationPreferencesFragment.java b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/SynchronizationPreferencesFragment.java index e8428dd5c..d4c8bee72 100644 --- a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/SynchronizationPreferencesFragment.java +++ b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/SynchronizationPreferencesFragment.java @@ -31,7 +31,7 @@ import de.danoeh.antennapod.event.SyncServiceEvent; import de.danoeh.antennapod.storage.preferences.SynchronizationCredentials; import de.danoeh.antennapod.core.sync.SyncService; import de.danoeh.antennapod.core.sync.SynchronizationProviderViewData; -import de.danoeh.antennapod.core.sync.SynchronizationSettings; +import de.danoeh.antennapod.storage.preferences.SynchronizationSettings; public class SynchronizationPreferencesFragment extends PreferenceFragmentCompat { private static final String PREFERENCE_SYNCHRONIZATION_DESCRIPTION = "preference_synchronization_description"; |