Incognito mode indicator in reader
parent
d56fc674ab
commit
db1ddf539c
@ -0,0 +1,48 @@
|
|||||||
|
package org.koitharu.kotatsu.reader.ui
|
||||||
|
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
|
import androidx.core.view.MenuProvider
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.core.util.ext.DIALOG_THEME_CENTERED
|
||||||
|
|
||||||
|
class ReaderTopMenuProvider(
|
||||||
|
private val activity: ReaderActivity,
|
||||||
|
private val viewModel: ReaderViewModel,
|
||||||
|
) : MenuProvider {
|
||||||
|
|
||||||
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
||||||
|
menuInflater.inflate(R.menu.opt_reader_top, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPrepareMenu(menu: Menu) {
|
||||||
|
menu.findItem(R.id.action_incognito)?.isVisible = viewModel.incognitoMode.value
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||||
|
return when (menuItem.itemId) {
|
||||||
|
R.id.action_chapters -> {
|
||||||
|
ChaptersSheet.show(activity.supportFragmentManager)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
R.id.action_incognito -> {
|
||||||
|
showIncognitoModeDialog()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showIncognitoModeDialog() {
|
||||||
|
MaterialAlertDialogBuilder(activity, DIALOG_THEME_CENTERED)
|
||||||
|
.setIcon(R.drawable.ic_incognito)
|
||||||
|
.setTitle(R.string.incognito_mode)
|
||||||
|
.setMessage(R.string.incognito_mode_hint)
|
||||||
|
.setPositiveButton(R.string.got_it, null)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu
|
<menu
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
tools:ignore="AlwaysShowAction">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_chapters"
|
android:id="@+id/action_chapters"
|
||||||
android:icon="@drawable/ic_expand_more"
|
android:icon="@drawable/ic_expand_more"
|
||||||
android:title="@string/chapters"
|
|
||||||
android:orderInCategory="0"
|
android:orderInCategory="0"
|
||||||
|
android:title="@string/chapters"
|
||||||
|
app:showAsAction="always" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_incognito"
|
||||||
|
android:icon="@drawable/ic_incognito"
|
||||||
|
android:title="@string/incognito_mode"
|
||||||
|
android:visible="false"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="always" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
Loading…
Reference in New Issue