Bläddra i källkod

Clean up some companion object usages

arkon 3 år sedan
förälder
incheckning
ec4e631760
24 ändrade filer med 82 tillägg och 133 borttagningar
  1. 2 4
      app/src/main/java/eu/kanade/tachiyomi/App.kt
  2. 2 4
      app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallActivity.kt
  3. 3 5
      app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionTrustDialog.kt
  4. 3 6
      app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt
  5. 3 5
      app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesController.kt
  6. 2 4
      app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchController.kt
  7. 2 4
      app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchAdapter.kt
  8. 2 4
      app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryRenameDialog.kt
  9. 3 5
      app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/DownloadCustomChaptersDialog.kt
  10. 2 4
      app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/SetChapterSettingsDialog.kt
  11. 2 4
      app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackChaptersDialog.kt
  12. 2 4
      app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackScoreDialog.kt
  13. 2 4
      app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackStatusDialog.kt
  14. 3 5
      app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt
  15. 2 4
      app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSheet.kt
  16. 3 5
      app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt
  17. 8 10
      app/src/main/java/eu/kanade/tachiyomi/ui/reader/PageIndicatorTextView.kt
  18. 9 11
      app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderColorFilterSettings.kt
  19. 9 11
      app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt
  20. 5 7
      app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt
  21. 2 4
      app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt
  22. 7 11
      app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt
  23. 2 4
      app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt
  24. 2 4
      app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchAdapter.kt

+ 2 - 4
app/src/main/java/eu/kanade/tachiyomi/App.kt

@@ -178,8 +178,6 @@ open class App : Application(), LifecycleObserver, ImageLoaderFactory {
             }
         }
     }
-
-    companion object {
-        private const val ACTION_DISABLE_INCOGNITO_MODE = "tachi.action.DISABLE_INCOGNITO_MODE"
-    }
 }
+
+private const val ACTION_DISABLE_INCOGNITO_MODE = "tachi.action.DISABLE_INCOGNITO_MODE"

+ 2 - 4
app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallActivity.kt

@@ -45,8 +45,6 @@ class ExtensionInstallActivity : Activity() {
         val extensionManager = Injekt.get<ExtensionManager>()
         extensionManager.setInstallationResult(downloadId, success)
     }
-
-    private companion object {
-        const val INSTALL_REQUEST_CODE = 500
-    }
 }
+
+private const val INSTALL_REQUEST_CODE = 500

+ 3 - 5
app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionTrustDialog.kt

@@ -33,13 +33,11 @@ class ExtensionTrustDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
             .create()
     }
 
-    private companion object {
-        const val SIGNATURE_KEY = "signature_key"
-        const val PKGNAME_KEY = "pkgname_key"
-    }
-
     interface Listener {
         fun trustSignature(signatureHash: String)
         fun uninstallExtension(pkgName: String)
     }
 }
+
+private const val SIGNATURE_KEY = "signature_key"
+private const val PKGNAME_KEY = "pkgname_key"

+ 3 - 6
app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt

@@ -235,10 +235,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
         activity!!.theme.resolveAttribute(R.attr.preferenceTheme, tv, true)
         return ContextThemeWrapper(activity, tv.resourceId)
     }
-
-    private companion object {
-        const val PKGNAME_KEY = "pkg_name"
-
-        private const val URL_EXTENSION_COMMITS = "https://github.com/tachiyomiorg/tachiyomi-extensions/commits/master"
-    }
 }
+
+private const val PKGNAME_KEY = "pkg_name"
+private const val URL_EXTENSION_COMMITS = "https://github.com/tachiyomiorg/tachiyomi-extensions/commits/master"

+ 3 - 5
app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesController.kt

@@ -167,9 +167,7 @@ class SourcePreferencesController(bundle: Bundle? = null) :
         // [key] isn't useful since there may be duplicates
         return preferenceScreen!!.getPreference(lastOpenPreferencePosition!!) as T
     }
-
-    private companion object {
-        const val SOURCE_ID = "source_id"
-        const val LASTOPENPREFERENCE_KEY = "last_open_preference"
-    }
 }
+
+private const val SOURCE_ID = "source_id"
+private const val LASTOPENPREFERENCE_KEY = "last_open_preference"

+ 2 - 4
app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchController.kt

@@ -37,8 +37,6 @@ class SourceSearchController(
     override fun onItemLongClick(position: Int) {
         view?.let { super.onItemClick(it, position) }
     }
-
-    private companion object {
-        const val MANGA_KEY = "oldManga"
-    }
 }
+
+private const val MANGA_KEY = "oldManga"

+ 2 - 4
app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchAdapter.kt

@@ -74,8 +74,6 @@ class GlobalSearchAdapter(val controller: GlobalSearchController) :
     interface OnTitleClickListener {
         fun onTitleClick(source: CatalogueSource)
     }
-
-    private companion object {
-        const val HOLDER_BUNDLE_KEY = "holder_bundle"
-    }
 }
+
+private const val HOLDER_BUNDLE_KEY = "holder_bundle"

+ 2 - 4
app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryRenameDialog.kt

@@ -78,8 +78,6 @@ class CategoryRenameDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
     interface Listener {
         fun renameCategory(category: Category, name: String)
     }
-
-    private companion object {
-        const val CATEGORY_KEY = "CategoryRenameDialog.category"
-    }
 }
+
+private const val CATEGORY_KEY = "CategoryRenameDialog.category"

+ 3 - 5
app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/DownloadCustomChaptersDialog.kt

@@ -69,9 +69,7 @@ class DownloadCustomChaptersDialog<T> : DialogController
     interface Listener {
         fun downloadCustomChapters(amount: Int)
     }
-
-    private companion object {
-        // Key to retrieve max chapters from bundle on process death.
-        const val KEY_ITEM_MAX = "DownloadCustomChaptersDialog.int.maxChapters"
-    }
 }
+
+// Key to retrieve max chapters from bundle on process death.
+private const val KEY_ITEM_MAX = "DownloadCustomChaptersDialog.int.maxChapters"

+ 2 - 4
app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/SetChapterSettingsDialog.kt

@@ -37,8 +37,6 @@ class SetChapterSettingsDialog(bundle: Bundle? = null) : DialogController(bundle
             .setNegativeButton(android.R.string.cancel, null)
             .create()
     }
-
-    private companion object {
-        const val MANGA_KEY = "manga"
-    }
 }
+
+private const val MANGA_KEY = "manga"

+ 2 - 4
app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackChaptersDialog.kt

@@ -65,8 +65,6 @@ class SetTrackChaptersDialog<T> : DialogController
     interface Listener {
         fun setChaptersRead(item: TrackItem, chaptersRead: Int)
     }
-
-    private companion object {
-        const val KEY_ITEM_TRACK = "SetTrackChaptersDialog.item.track"
-    }
 }
+
+private const val KEY_ITEM_TRACK = "SetTrackChaptersDialog.item.track"

+ 2 - 4
app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackScoreDialog.kt

@@ -65,8 +65,6 @@ class SetTrackScoreDialog<T> : DialogController
     interface Listener {
         fun setScore(item: TrackItem, score: Int)
     }
-
-    private companion object {
-        const val KEY_ITEM_TRACK = "SetTrackScoreDialog.item.track"
-    }
 }
+
+private const val KEY_ITEM_TRACK = "SetTrackScoreDialog.item.track"

+ 2 - 4
app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackStatusDialog.kt

@@ -54,8 +54,6 @@ class SetTrackStatusDialog<T> : DialogController
     interface Listener {
         fun setStatus(item: TrackItem, selection: Int)
     }
-
-    private companion object {
-        const val KEY_ITEM_TRACK = "SetTrackStatusDialog.item.track"
-    }
 }
+
+private const val KEY_ITEM_TRACK = "SetTrackStatusDialog.item.track"

+ 3 - 5
app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt

@@ -189,9 +189,7 @@ class TrackSearchDialog : DialogController {
         binding.message.text = message ?: binding.message.context.getString(R.string.unknown_error)
         adapter?.items = emptyList()
     }
-
-    private companion object {
-        const val KEY_SERVICE = "service_id"
-        const val KEY_CURRENT_URL = "current_url"
-    }
 }
+
+private const val KEY_SERVICE = "service_id"
+private const val KEY_CURRENT_URL = "current_url"

+ 2 - 4
app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSheet.kt

@@ -226,8 +226,6 @@ class TrackSheet(
     fun getSearchDialog(): TrackSearchDialog? {
         return controller.router.getControllerWithTag(TAG_SEARCH_CONTROLLER) as? TrackSearchDialog
     }
-
-    private companion object {
-        const val TAG_SEARCH_CONTROLLER = "track_search_controller"
-    }
 }
+
+private const val TAG_SEARCH_CONTROLLER = "track_search_controller"

+ 3 - 5
app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt

@@ -30,9 +30,7 @@ class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundl
             .setNegativeButton(R.string.update_check_ignore, null)
             .create()
     }
-
-    private companion object {
-        const val BODY_KEY = "NewUpdateDialogController.body"
-        const val URL_KEY = "NewUpdateDialogController.key"
-    }
 }
+
+private const val BODY_KEY = "NewUpdateDialogController.body"
+private const val URL_KEY = "NewUpdateDialogController.key"

+ 8 - 10
app/src/main/java/eu/kanade/tachiyomi/ui/reader/PageIndicatorTextView.kt

@@ -40,15 +40,13 @@ class PageIndicatorTextView(
 
         super.setText(finalText, BufferType.SPANNABLE)
     }
+}
 
-    private companion object {
-        private val fillColor = Color.rgb(235, 235, 235)
-        private val strokeColor = Color.rgb(45, 45, 45)
+private val fillColor = Color.rgb(235, 235, 235)
+private val strokeColor = Color.rgb(45, 45, 45)
 
-        // A span object with text outlining properties
-        val spanOutline = OutlineSpan(
-            strokeColor = strokeColor,
-            strokeWidth = 4f
-        )
-    }
-}
+// A span object with text outlining properties
+private val spanOutline = OutlineSpan(
+    strokeColor = strokeColor,
+    strokeWidth = 4f
+)

+ 9 - 11
app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderColorFilterSettings.kt

@@ -219,18 +219,16 @@ class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attr
         val updatedColor = (color shl bitShift) or (currentColor and mask.inv().toInt())
         preferences.colorFilterValue().set(updatedColor)
     }
+}
 
-    private companion object {
-        /** Integer mask of alpha value **/
-        const val ALPHA_MASK: Long = 0xFF000000
+/** Integer mask of alpha value **/
+private const val ALPHA_MASK: Long = 0xFF000000
 
-        /** Integer mask of red value **/
-        const val RED_MASK: Long = 0x00FF0000
+/** Integer mask of red value **/
+private const val RED_MASK: Long = 0x00FF0000
 
-        /** Integer mask of green value **/
-        const val GREEN_MASK: Long = 0x0000FF00
+/** Integer mask of green value **/
+private const val GREEN_MASK: Long = 0x0000FF00
 
-        /** Integer mask of blue value **/
-        const val BLUE_MASK: Long = 0x000000FF
-    }
-}
+/** Integer mask of blue value **/
+private const val BLUE_MASK: Long = 0x000000FF

+ 9 - 11
app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt

@@ -183,16 +183,14 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter<RecyclerV
             return newItems.size
         }
     }
+}
 
-    private companion object {
-        /**
-         * View holder type of a chapter page view.
-         */
-        const val PAGE_VIEW = 0
+/**
+ * View holder type of a chapter page view.
+ */
+private const val PAGE_VIEW = 0
 
-        /**
-         * View holder type of a chapter transition view.
-         */
-        const val TRANSITION_VIEW = 1
-    }
-}
+/**
+ * View holder type of a chapter transition view.
+ */
+private const val TRANSITION_VIEW = 1

+ 5 - 7
app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt

@@ -314,11 +314,9 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
             return super.onTouchEvent(ev)
         }
     }
-
-    private companion object {
-        const val ANIMATOR_DURATION_TIME = 200
-        const val MIN_RATE = 0.5f
-        const val DEFAULT_RATE = 1f
-        const val MAX_SCALE_RATE = 3f
-    }
 }
+
+private const val ANIMATOR_DURATION_TIME = 200
+private const val MIN_RATE = 0.5f
+private const val DEFAULT_RATE = 1f
+private const val MAX_SCALE_RATE = 3f

+ 2 - 4
app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt

@@ -243,8 +243,6 @@ class SettingsAdvancedController : SettingsController() {
         db.deleteHistoryNoLastRead().executeAsBlocking()
         activity?.toast(R.string.clear_database_completed)
     }
-
-    private companion object {
-        const val CLEAR_CACHE_KEY = "pref_clear_cache_key"
-    }
 }
+
+private const val CLEAR_CACHE_KEY = "pref_clear_cache_key"

+ 7 - 11
app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt

@@ -329,16 +329,12 @@ class SettingsBackupController : SettingsController() {
                     .create()
             }
         }
-
-        private companion object {
-            const val KEY_URI = "RestoreBackupDialog.uri"
-            const val KEY_TYPE = "RestoreBackupDialog.type"
-        }
-    }
-
-    private companion object {
-        const val CODE_BACKUP_DIR = 503
-        const val CODE_BACKUP_CREATE = 504
-        const val CODE_BACKUP_RESTORE = 505
     }
 }
+
+private const val KEY_URI = "RestoreBackupDialog.uri"
+private const val KEY_TYPE = "RestoreBackupDialog.type"
+
+private const val CODE_BACKUP_DIR = 503
+private const val CODE_BACKUP_CREATE = 504
+private const val CODE_BACKUP_RESTORE = 505

+ 2 - 4
app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt

@@ -269,8 +269,6 @@ class SettingsDownloadController : SettingsController() {
                 .create()
         }
     }
-
-    private companion object {
-        const val DOWNLOAD_DIR = 104
-    }
 }
+
+private const val DOWNLOAD_DIR = 104

+ 2 - 4
app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchAdapter.kt

@@ -77,8 +77,6 @@ class SettingsSearchAdapter(val controller: SettingsSearchController) :
     interface OnTitleClickListener {
         fun onTitleClick(ctrl: SettingsController)
     }
-
-    private companion object {
-        const val HOLDER_BUNDLE_KEY = "holder_bundle"
-    }
 }
+
+private const val HOLDER_BUNDLE_KEY = "holder_bundle"