Save page button in reader
This commit is contained in:
@@ -4,7 +4,7 @@ import java.util.EnumSet
|
||||
|
||||
enum class ReaderControl {
|
||||
|
||||
PREV_CHAPTER, NEXT_CHAPTER, SLIDER, PAGES_SHEET, SCREEN_ROTATION;
|
||||
PREV_CHAPTER, NEXT_CHAPTER, SLIDER, PAGES_SHEET, SCREEN_ROTATION, SAVE_PAGE;
|
||||
|
||||
companion object {
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ class ReaderActivity :
|
||||
}
|
||||
addMenuProvider(ReaderMenuTopProvider(viewModel))
|
||||
viewBinding.toolbarBottom.addMenuProvider(
|
||||
ReaderMenuBottomProvider(this, readerManager, screenOrientationHelper, viewModel),
|
||||
ReaderMenuBottomProvider(this, readerManager, screenOrientationHelper, this, viewModel),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,13 @@ import androidx.fragment.app.FragmentActivity
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.nav.router
|
||||
import org.koitharu.kotatsu.core.prefs.ReaderControl
|
||||
import org.koitharu.kotatsu.reader.ui.config.ReaderConfigSheet
|
||||
|
||||
class ReaderMenuBottomProvider(
|
||||
private val activity: FragmentActivity,
|
||||
private val readerManager: ReaderManager,
|
||||
private val screenOrientationHelper: ScreenOrientationHelper,
|
||||
private val configCallback: ReaderConfigSheet.Callback,
|
||||
private val viewModel: ReaderViewModel,
|
||||
) : MenuProvider {
|
||||
|
||||
@@ -24,8 +26,8 @@ class ReaderMenuBottomProvider(
|
||||
|
||||
override fun onPrepareMenu(menu: Menu) {
|
||||
val readerControls = viewModel.readerControls.value
|
||||
val isPagesSheetEnabled = viewModel.content.value.pages.isNotEmpty() &&
|
||||
ReaderControl.PAGES_SHEET in readerControls
|
||||
val hasPages = viewModel.content.value.pages.isNotEmpty()
|
||||
val isPagesSheetEnabled = hasPages && ReaderControl.PAGES_SHEET in readerControls
|
||||
menu.findItem(R.id.action_pages_thumbs).run {
|
||||
isVisible = isPagesSheetEnabled
|
||||
if (isPagesSheetEnabled) {
|
||||
@@ -47,6 +49,9 @@ class ReaderMenuBottomProvider(
|
||||
}
|
||||
}
|
||||
}
|
||||
menu.findItem(R.id.action_save_page)?.run {
|
||||
isVisible = hasPages && ReaderControl.SAVE_PAGE in readerControls
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||
@@ -56,6 +61,11 @@ class ReaderMenuBottomProvider(
|
||||
true
|
||||
}
|
||||
|
||||
R.id.action_save_page -> {
|
||||
configCallback.onSavePageClick()
|
||||
true
|
||||
}
|
||||
|
||||
R.id.action_pages_thumbs -> {
|
||||
activity.router.showChapterPagesSheet()
|
||||
true
|
||||
|
||||
@@ -5,6 +5,14 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:ignore="AlwaysShowAction">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_save_page"
|
||||
android:icon="@drawable/ic_save"
|
||||
android:title="@string/save_page"
|
||||
android:visible="false"
|
||||
app:showAsAction="always"
|
||||
tools:visible="true" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_screen_rotation"
|
||||
android:icon="@drawable/ic_screen_rotation"
|
||||
|
||||
@@ -130,5 +130,6 @@
|
||||
<item>@string/pages_slider</item>
|
||||
<item>@string/chapters_and_pages</item>
|
||||
<item>@string/screen_orientation</item>
|
||||
<item>@string/save_page</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -23,6 +23,12 @@
|
||||
app:allowDividerAbove="true"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="reader_zoom_buttons"
|
||||
android:summary="@string/reader_zoom_buttons_summary"
|
||||
android:title="@string/reader_zoom_buttons" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="webtoon_zoom"
|
||||
@@ -39,24 +45,23 @@
|
||||
app:defaultValue="0"
|
||||
app:tickVisible="true" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="reader_zoom_buttons"
|
||||
android:summary="@string/reader_zoom_buttons_summary"
|
||||
android:title="@string/reader_zoom_buttons" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="webtoon_gaps"
|
||||
android:summary="@string/webtoon_gaps_summary"
|
||||
android:title="@string/webtoon_gaps" />
|
||||
|
||||
<MultiSelectListPreference
|
||||
android:entries="@array/reader_controls"
|
||||
android:key="reader_controls"
|
||||
android:title="@string/reader_controls_in_bottom_bar"
|
||||
app:allowDividerAbove="true" />
|
||||
|
||||
<Preference
|
||||
android:key="reader_tap_actions"
|
||||
android:persistent="false"
|
||||
android:summary="@string/reader_actions_summary"
|
||||
android:title="@string/reader_actions"
|
||||
app:allowDividerAbove="true" />
|
||||
android:title="@string/reader_actions" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
@@ -140,11 +145,6 @@
|
||||
android:summary="@string/show_pages_numbers_summary"
|
||||
android:title="@string/show_pages_numbers" />
|
||||
|
||||
<MultiSelectListPreference
|
||||
android:entries="@array/reader_controls"
|
||||
android:key="reader_controls"
|
||||
android:title="@string/reader_controls_in_bottom_bar" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="2"
|
||||
android:entries="@array/network_policy"
|
||||
|
||||
Reference in New Issue
Block a user