Skip to content

Commit

Permalink
Add banner for Incognito Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
arkon committed Oct 3, 2020
1 parent 7194f65 commit cf39ae0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class PreferencesHelper(val context: Context) {

fun sortChapterByAscendingOrDescending() = prefs.getInt(Keys.defaultChapterSortByAscendingOrDescending, Manga.SORT_DESC)

fun incognitoMode() = prefs.getBoolean(Keys.incognitoMode, false)
fun incognitoMode() = flowPrefs.getBoolean(Keys.incognitoMode, false)

fun setChapterSettingsDefault(manga: Manga) {
prefs.edit {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
preferences.downloadedOnly()
.asImmediateFlow { binding.downloadedOnly.isVisible = it }
.launchIn(scope)

preferences.incognitoMode()
.asImmediateFlow { binding.incognitoMode.isVisible = it }
.launchIn(scope)
}

override fun onNewIntent(intent: Intent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ class ReaderPresenter(
* Saves this [chapter] last read history.
*/
private fun saveChapterHistory(chapter: ReaderChapter) {
if (!preferences.incognitoMode()) {
if (!preferences.incognitoMode().get()) {
val history = History.create(chapter.chapter).apply { last_read = Date().time }
db.updateHistoryLastRead(history).asRxCompletable()
.onErrorComplete()
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/res/layout/main_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@

</FrameLayout>

<FrameLayout
android:id="@+id/incognito_mode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/md_grey_800"
android:visibility="gone"
tools:visibility="visible">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="4dp"
android:text="@string/pref_incognito_mode"
android:textColor="@color/md_white_1000" />

</FrameLayout>

</eu.kanade.tachiyomi.widget.ElevationAppBarLayout>

<com.bluelinelabs.conductor.ChangeHandlerFrameLayout
Expand Down

0 comments on commit cf39ae0

Please sign in to comment.