mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 19:25:10 +01:00
Move ReaderBottomButton to its own file
This commit is contained in:
parent
47f6c54412
commit
b7b2c9ab64
@ -12,7 +12,7 @@ import com.tfcporciuncula.flow.FlowSharedPreferences
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.track.TrackService
|
import eu.kanade.tachiyomi.data.track.TrackService
|
||||||
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
|
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBottomButton
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PageLayout
|
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PageLayout
|
||||||
import eu.kanade.tachiyomi.ui.recents.RecentMangaAdapter
|
import eu.kanade.tachiyomi.ui.recents.RecentMangaAdapter
|
||||||
@ -190,7 +190,7 @@ class PreferencesHelper(val context: Context) {
|
|||||||
|
|
||||||
fun readerBottomButtons() = flowPrefs.getStringSet(
|
fun readerBottomButtons() = flowPrefs.getStringSet(
|
||||||
Keys.readerBottomButtons,
|
Keys.readerBottomButtons,
|
||||||
ReaderActivity.BUTTONS_DEFAULTS
|
ReaderBottomButton.BUTTONS_DEFAULTS
|
||||||
)
|
)
|
||||||
|
|
||||||
fun showNavigationOverlayNewUser() = flowPrefs.getBoolean(Keys.showNavigationOverlayNewUser, true)
|
fun showNavigationOverlayNewUser() = flowPrefs.getBoolean(Keys.showNavigationOverlayNewUser, true)
|
||||||
|
@ -44,7 +44,6 @@ import eu.kanade.tachiyomi.data.download.DownloadServiceListener
|
|||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
||||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.data.updater.UpdateChecker
|
import eu.kanade.tachiyomi.data.updater.UpdateChecker
|
||||||
@ -82,7 +81,6 @@ import eu.kanade.tachiyomi.widget.EndAnimatorListener
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.launchIn
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
@ -22,7 +22,6 @@ import android.view.WindowManager
|
|||||||
import android.view.animation.Animation
|
import android.view.animation.Animation
|
||||||
import android.view.animation.AnimationUtils
|
import android.view.animation.AnimationUtils
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
import androidx.annotation.StringRes
|
|
||||||
import androidx.appcompat.view.menu.MenuBuilder
|
import androidx.appcompat.view.menu.MenuBuilder
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
@ -56,6 +55,7 @@ import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.Success
|
|||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBottomButton
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.settings.ReadingModeType
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.TabbedReaderSettingsSheet
|
import eu.kanade.tachiyomi.ui.reader.settings.TabbedReaderSettingsSheet
|
||||||
@ -207,13 +207,6 @@ class ReaderActivity :
|
|||||||
const val SHIFTED_PAGE_INDEX = "shiftedPageIndex"
|
const val SHIFTED_PAGE_INDEX = "shiftedPageIndex"
|
||||||
const val SHIFTED_CHAP_INDEX = "shiftedChapterIndex"
|
const val SHIFTED_CHAP_INDEX = "shiftedChapterIndex"
|
||||||
|
|
||||||
val BUTTONS_DEFAULTS = setOf(
|
|
||||||
BottomButton.ViewChapters,
|
|
||||||
BottomButton.WebView,
|
|
||||||
BottomButton.PageLayout,
|
|
||||||
BottomButton.CropBordersWebtoon
|
|
||||||
).map { it.value }.toSet()
|
|
||||||
|
|
||||||
fun newIntent(context: Context, manga: Manga, chapter: Chapter): Intent {
|
fun newIntent(context: Context, manga: Manga, chapter: Chapter): Intent {
|
||||||
val intent = Intent(context, ReaderActivity::class.java)
|
val intent = Intent(context, ReaderActivity::class.java)
|
||||||
intent.putExtra("manga", manga.id)
|
intent.putExtra("manga", manga.id)
|
||||||
@ -223,17 +216,6 @@ class ReaderActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class BottomButton(val value: String, @StringRes val stringRes: Int) {
|
|
||||||
ViewChapters("vc", R.string.view_chapters),
|
|
||||||
WebView("wb", R.string.open_in_webview),
|
|
||||||
ReadingMode("rm", R.string.reading_mode),
|
|
||||||
Rotation("rot", R.string.rotation),
|
|
||||||
CropBordersPaged("cbp", R.string.crop_borders_paged),
|
|
||||||
CropBordersWebtoon("cbw", R.string.crop_borders_webtoon),
|
|
||||||
PageLayout("pl", R.string.page_layout),
|
|
||||||
ShiftDoublePage("sdp", R.string.shift_double_pages)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the activity is created. Initializes the presenter and configuration.
|
* Called when the activity is created. Initializes the presenter and configuration.
|
||||||
*/
|
*/
|
||||||
@ -379,7 +361,7 @@ class ReaderActivity :
|
|||||||
return if (preferences.readerBottomButtons().isNotSet()) {
|
return if (preferences.readerBottomButtons().isNotSet()) {
|
||||||
isTablet()
|
isTablet()
|
||||||
} else {
|
} else {
|
||||||
BottomButton.ShiftDoublePage.value in preferences.readerBottomButtons().get()
|
ReaderBottomButton.ShiftDoublePage.isIn(preferences.readerBottomButtons().get())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,21 +428,21 @@ class ReaderActivity :
|
|||||||
with(binding.chaptersSheet) {
|
with(binding.chaptersSheet) {
|
||||||
readingMode.isVisible =
|
readingMode.isVisible =
|
||||||
presenter?.manga?.isLongStrip() != true &&
|
presenter?.manga?.isLongStrip() != true &&
|
||||||
BottomButton.ReadingMode.value in enabledButtons
|
ReaderBottomButton.ReadingMode.isIn(enabledButtons)
|
||||||
rotationSheetButton.isVisible =
|
rotationSheetButton.isVisible =
|
||||||
BottomButton.Rotation.value in enabledButtons
|
ReaderBottomButton.Rotation.isIn(enabledButtons)
|
||||||
doublePage.isVisible = viewer is PagerViewer &&
|
doublePage.isVisible = viewer is PagerViewer &&
|
||||||
BottomButton.PageLayout.value in enabledButtons
|
ReaderBottomButton.PageLayout.isIn(enabledButtons)
|
||||||
cropBordersSheetButton.isVisible =
|
cropBordersSheetButton.isVisible =
|
||||||
if (viewer is PagerViewer) {
|
if (viewer is PagerViewer) {
|
||||||
BottomButton.CropBordersPaged.value in enabledButtons
|
ReaderBottomButton.CropBordersPaged.isIn(enabledButtons)
|
||||||
} else {
|
} else {
|
||||||
BottomButton.CropBordersWebtoon.value in enabledButtons
|
ReaderBottomButton.CropBordersWebtoon.isIn(enabledButtons)
|
||||||
}
|
}
|
||||||
webviewButton.isVisible =
|
webviewButton.isVisible =
|
||||||
BottomButton.WebView.value in enabledButtons
|
ReaderBottomButton.WebView.isIn(enabledButtons)
|
||||||
chaptersButton.isVisible =
|
chaptersButton.isVisible =
|
||||||
BottomButton.ViewChapters.value in enabledButtons
|
ReaderBottomButton.ViewChapters.isIn(enabledButtons)
|
||||||
shiftPageButton.isVisible =
|
shiftPageButton.isVisible =
|
||||||
((viewer as? PagerViewer)?.config?.doublePages ?: false) && canShowSplitAtBottom()
|
((viewer as? PagerViewer)?.config?.doublePages ?: false) && canShowSplitAtBottom()
|
||||||
binding.toolbar.menu.findItem(R.id.action_shift_double_page)?.isVisible =
|
binding.toolbar.menu.findItem(R.id.action_shift_double_page)?.isVisible =
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package eu.kanade.tachiyomi.ui.reader.settings
|
||||||
|
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import eu.kanade.tachiyomi.R
|
||||||
|
|
||||||
|
enum class ReaderBottomButton(val value: String, @StringRes val stringRes: Int) {
|
||||||
|
ViewChapters("vc", R.string.view_chapters),
|
||||||
|
WebView("wb", R.string.open_in_webview),
|
||||||
|
ReadingMode("rm", R.string.reading_mode),
|
||||||
|
Rotation("rot", R.string.rotation),
|
||||||
|
CropBordersPaged("cbp", R.string.crop_borders_paged),
|
||||||
|
CropBordersWebtoon("cbw", R.string.crop_borders_webtoon),
|
||||||
|
PageLayout("pl", R.string.page_layout),
|
||||||
|
ShiftDoublePage("sdp", R.string.shift_double_pages)
|
||||||
|
;
|
||||||
|
|
||||||
|
fun isIn(buttons: Collection<String>) = value in buttons
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val BUTTONS_DEFAULTS = setOf(
|
||||||
|
ViewChapters,
|
||||||
|
WebView,
|
||||||
|
PageLayout,
|
||||||
|
CropBordersWebtoon
|
||||||
|
).map { it.value }.toSet()
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@ import androidx.preference.PreferenceScreen
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBottomButton
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PageLayout
|
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PageLayout
|
||||||
@ -73,15 +73,15 @@ class SettingsReaderController : SettingsController() {
|
|||||||
multiSelectListPreferenceMat(activity) {
|
multiSelectListPreferenceMat(activity) {
|
||||||
key = Keys.readerBottomButtons
|
key = Keys.readerBottomButtons
|
||||||
titleRes = R.string.display_buttons_bottom_reader
|
titleRes = R.string.display_buttons_bottom_reader
|
||||||
val enumConstants = ReaderActivity.BottomButton::class.java.enumConstants
|
val enumConstants = ReaderBottomButton.values()
|
||||||
entriesRes = enumConstants?.map { it.stringRes }.orEmpty().toTypedArray()
|
entriesRes = ReaderBottomButton.values().map { it.stringRes }.toTypedArray()
|
||||||
entryValues = enumConstants?.map { it.value }.orEmpty()
|
entryValues = enumConstants.map { it.value }
|
||||||
allSelectionRes = R.string.display_options
|
allSelectionRes = R.string.display_options
|
||||||
allIsAlwaysSelected = true
|
allIsAlwaysSelected = true
|
||||||
showAllLast = true
|
showAllLast = true
|
||||||
val defaults = ReaderActivity.BUTTONS_DEFAULTS.toMutableList()
|
val defaults = ReaderBottomButton.BUTTONS_DEFAULTS.toMutableList()
|
||||||
if (context.isTablet()) {
|
if (context.isTablet()) {
|
||||||
defaults.add(ReaderActivity.BottomButton.ShiftDoublePage.value)
|
defaults.add(ReaderBottomButton.ShiftDoublePage.value)
|
||||||
}
|
}
|
||||||
defaultValue = defaults
|
defaultValue = defaults
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user