From ec4e631760607700481d453fef21f38bd4aebf49 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 5 Sep 2021 14:34:29 -0400 Subject: [PATCH] Clean up some companion object usages --- app/src/main/java/eu/kanade/tachiyomi/App.kt | 6 ++--- .../util/ExtensionInstallActivity.kt | 6 ++--- .../browse/extension/ExtensionTrustDialog.kt | 8 +++--- .../details/ExtensionDetailsController.kt | 9 +++---- .../details/SourcePreferencesController.kt | 8 +++--- .../search/SourceSearchController.kt | 6 ++--- .../globalsearch/GlobalSearchAdapter.kt | 6 ++--- .../ui/category/CategoryRenameDialog.kt | 6 ++--- .../chapter/DownloadCustomChaptersDialog.kt | 8 +++--- .../manga/chapter/SetChapterSettingsDialog.kt | 6 ++--- .../ui/manga/track/SetTrackChaptersDialog.kt | 6 ++--- .../ui/manga/track/SetTrackScoreDialog.kt | 6 ++--- .../ui/manga/track/SetTrackStatusDialog.kt | 6 ++--- .../ui/manga/track/TrackSearchDialog.kt | 8 +++--- .../tachiyomi/ui/manga/track/TrackSheet.kt | 6 ++--- .../ui/more/NewUpdateDialogController.kt | 8 +++--- .../ui/reader/PageIndicatorTextView.kt | 20 +++++++------- .../setting/ReaderColorFilterSettings.kt | 26 +++++++++---------- .../reader/viewer/webtoon/WebtoonAdapter.kt | 22 +++++++--------- .../viewer/webtoon/WebtoonRecyclerView.kt | 12 ++++----- .../ui/setting/SettingsAdvancedController.kt | 6 ++--- .../ui/setting/SettingsBackupController.kt | 18 +++++-------- .../ui/setting/SettingsDownloadController.kt | 6 ++--- .../setting/search/SettingsSearchAdapter.kt | 6 ++--- 24 files changed, 87 insertions(+), 138 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index 60da28c1e..6f5f488d5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallActivity.kt index 1623a5d7d..dd83bba99 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallActivity.kt @@ -45,8 +45,6 @@ class ExtensionInstallActivity : Activity() { val extensionManager = Injekt.get() extensionManager.setInstallationResult(downloadId, success) } - - private companion object { - const val INSTALL_REQUEST_CODE = 500 - } } + +private const val INSTALL_REQUEST_CODE = 500 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionTrustDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionTrustDialog.kt index 644ec9381..c1de2551d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionTrustDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionTrustDialog.kt @@ -33,13 +33,11 @@ class ExtensionTrustDialog(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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt index 6ff4ae4de..ea7a6daf1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt +++ b/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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesController.kt index d804e9658..0915a835b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesController.kt +++ b/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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchController.kt index bba217337..2b699b551 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchController.kt +++ b/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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchAdapter.kt index d9739a813..d0fc3e29c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchAdapter.kt +++ b/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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryRenameDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryRenameDialog.kt index 2910eb1e1..ae17260dd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryRenameDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryRenameDialog.kt @@ -78,8 +78,6 @@ class CategoryRenameDialog(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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/DownloadCustomChaptersDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/DownloadCustomChaptersDialog.kt index 903c1f85a..782a863fc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/DownloadCustomChaptersDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/DownloadCustomChaptersDialog.kt @@ -69,9 +69,7 @@ class DownloadCustomChaptersDialog : 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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/SetChapterSettingsDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/SetChapterSettingsDialog.kt index b86772639..9b3d4efd7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/SetChapterSettingsDialog.kt +++ b/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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackChaptersDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackChaptersDialog.kt index 67efe8ea4..9ae0b03c3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackChaptersDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackChaptersDialog.kt @@ -65,8 +65,6 @@ class SetTrackChaptersDialog : 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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackScoreDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackScoreDialog.kt index b70f1eb67..fd0d407d7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackScoreDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackScoreDialog.kt @@ -65,8 +65,6 @@ class SetTrackScoreDialog : 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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackStatusDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackStatusDialog.kt index 13aa209ce..0a760d1ea 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackStatusDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackStatusDialog.kt @@ -54,8 +54,6 @@ class SetTrackStatusDialog : 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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt index 00f8f6e7a..9cbff4f90 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt +++ b/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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSheet.kt index 2c6e91a24..a23dd4bca 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSheet.kt +++ b/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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt index 7a52904a9..cf99f4fab 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt +++ b/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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/PageIndicatorTextView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/PageIndicatorTextView.kt index d3f4db747..fa750a680 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/PageIndicatorTextView.kt +++ b/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) - - // A span object with text outlining properties - val spanOutline = OutlineSpan( - strokeColor = strokeColor, - strokeWidth = 4f - ) - } } + +private val fillColor = Color.rgb(235, 235, 235) +private val strokeColor = Color.rgb(45, 45, 45) + +// A span object with text outlining properties +private val spanOutline = OutlineSpan( + strokeColor = strokeColor, + strokeWidth = 4f +) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderColorFilterSettings.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderColorFilterSettings.kt index 9f978cd9a..2537e89ee 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderColorFilterSettings.kt +++ b/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 red value **/ - const val RED_MASK: Long = 0x00FF0000 - - /** Integer mask of green value **/ - const val GREEN_MASK: Long = 0x0000FF00 - - /** Integer mask of blue value **/ - const val BLUE_MASK: Long = 0x000000FF - } } + +/** Integer mask of alpha value **/ +private const val ALPHA_MASK: Long = 0xFF000000 + +/** Integer mask of red value **/ +private const val RED_MASK: Long = 0x00FF0000 + +/** Integer mask of green value **/ +private const val GREEN_MASK: Long = 0x0000FF00 + +/** Integer mask of blue value **/ +private const val BLUE_MASK: Long = 0x000000FF diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt index 5f17b4ce1..5379090dc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt @@ -183,16 +183,14 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter