Browse Source

Minor cleanup

Also add POST_NOTIFICATIONS permissions to make Android Studio stop complaining about it.
arkon 2 years ago
parent
commit
b37b3767f3

+ 2 - 0
app/src/main/AndroidManifest.xml

@@ -21,6 +21,8 @@
     <!-- To view extension packages in API 30+ -->
     <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
 
+    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
+
     <application
         android:name=".App"
         android:allowBackup="false"

+ 11 - 4
app/src/main/java/eu/kanade/domain/track/service/TrackPreferences.kt

@@ -1,7 +1,6 @@
 package eu.kanade.domain.track.service
 
 import eu.kanade.tachiyomi.core.preference.PreferenceStore
-import eu.kanade.tachiyomi.data.preference.PreferenceKeys
 import eu.kanade.tachiyomi.data.track.TrackService
 import eu.kanade.tachiyomi.data.track.anilist.Anilist
 
@@ -9,18 +8,26 @@ class TrackPreferences(
     private val preferenceStore: PreferenceStore,
 ) {
 
-    fun trackUsername(sync: TrackService) = preferenceStore.getString(PreferenceKeys.trackUsername(sync.id), "")
+    fun trackUsername(sync: TrackService) = preferenceStore.getString(trackUsername(sync.id), "")
 
-    fun trackPassword(sync: TrackService) = preferenceStore.getString(PreferenceKeys.trackPassword(sync.id), "")
+    fun trackPassword(sync: TrackService) = preferenceStore.getString(trackPassword(sync.id), "")
 
     fun setTrackCredentials(sync: TrackService, username: String, password: String) {
         trackUsername(sync).set(username)
         trackPassword(sync).set(password)
     }
 
-    fun trackToken(sync: TrackService) = preferenceStore.getString(PreferenceKeys.trackToken(sync.id), "")
+    fun trackToken(sync: TrackService) = preferenceStore.getString(trackToken(sync.id), "")
 
     fun anilistScoreType() = preferenceStore.getString("anilist_score_type", Anilist.POINT_10)
 
     fun autoUpdateTrack() = preferenceStore.getBoolean("pref_auto_update_manga_sync_key", true)
+
+    companion object {
+        fun trackUsername(syncId: Long) = "pref_mangasync_username_$syncId"
+
+        private fun trackPassword(syncId: Long) = "pref_mangasync_password_$syncId"
+
+        private fun trackToken(syncId: Long) = "track_token_$syncId"
+    }
 }

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/data/download/model/DownloadQueue.kt

@@ -71,7 +71,7 @@ class DownloadQueue(
         updatedRelay.call(Unit)
     }
 
-    fun getActiveDownloads(): Observable<Download> =
+    private fun getActiveDownloads(): Observable<Download> =
         Observable.from(this).filter { download -> download.status == Download.State.DOWNLOADING }
 
     @Deprecated("Use getStatusAsFlow instead")

+ 0 - 48
app/src/main/java/eu/kanade/tachiyomi/data/preference/EmptyPreferenceDataStore.kt

@@ -1,48 +0,0 @@
-package eu.kanade.tachiyomi.data.preference
-
-import androidx.preference.PreferenceDataStore
-
-class EmptyPreferenceDataStore : PreferenceDataStore() {
-
-    override fun getBoolean(key: String?, defValue: Boolean): Boolean {
-        return false
-    }
-
-    override fun putBoolean(key: String?, value: Boolean) {
-    }
-
-    override fun getInt(key: String?, defValue: Int): Int {
-        return 0
-    }
-
-    override fun putInt(key: String?, value: Int) {
-    }
-
-    override fun getLong(key: String?, defValue: Long): Long {
-        return 0
-    }
-
-    override fun putLong(key: String?, value: Long) {
-    }
-
-    override fun getFloat(key: String?, defValue: Float): Float {
-        return 0f
-    }
-
-    override fun putFloat(key: String?, value: Float) {
-    }
-
-    override fun getString(key: String?, defValue: String?): String? {
-        return null
-    }
-
-    override fun putString(key: String?, value: String?) {
-    }
-
-    override fun getStringSet(key: String?, defValues: Set<String>?): Set<String>? {
-        return null
-    }
-
-    override fun putStringSet(key: String?, values: Set<String>?) {
-    }
-}

+ 0 - 6
app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt

@@ -6,10 +6,4 @@ package eu.kanade.tachiyomi.data.preference
 object PreferenceKeys {
 
     const val dateFormat = "app_date_format"
-
-    fun trackUsername(syncId: Long) = "pref_mangasync_username_$syncId"
-
-    fun trackPassword(syncId: Long) = "pref_mangasync_password_$syncId"
-
-    fun trackToken(syncId: Long) = "track_token_$syncId"
 }

+ 0 - 1
app/src/main/java/eu/kanade/tachiyomi/extension/model/LoadResult.kt

@@ -1,7 +1,6 @@
 package eu.kanade.tachiyomi.extension.model
 
 sealed class LoadResult {
-
     class Success(val extension: Extension.Installed) : LoadResult()
     class Untrusted(val extension: Extension.Untrusted) : LoadResult()
     object Error : LoadResult()

+ 2 - 3
app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt

@@ -31,7 +31,6 @@ import eu.kanade.tachiyomi.util.system.openInBrowser
 import eu.kanade.tachiyomi.util.system.toast
 import eu.kanade.tachiyomi.widget.preference.TrackerPreference
 import uy.kohesive.injekt.injectLazy
-import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
 
 class SettingsTrackingController :
     SettingsController(),
@@ -104,7 +103,7 @@ class SettingsTrackingController :
     ): TrackerPreference {
         return add(
             TrackerPreference(context).apply {
-                key = Keys.trackUsername(service.id)
+                key = TrackPreferences.trackUsername(service.id)
                 titleRes = service.nameRes()
                 iconRes = service.getLogo()
                 iconColor = service.getLogoColor()
@@ -148,7 +147,7 @@ class SettingsTrackingController :
     }
 
     private fun updatePreference(id: Long) {
-        val pref = findPreference(Keys.trackUsername(id)) as? TrackerPreference
+        val pref = findPreference(TrackPreferences.trackUsername(id)) as? TrackerPreference
         pref?.notifyChanged()
     }