Skip to content

Commit

Permalink
feat: mark chapter as read from ViewerFragment
Browse files Browse the repository at this point in the history
  • Loading branch information
mytlogos committed Dec 21, 2021
1 parent a67d653 commit 9963220
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import kotlinx.coroutines.withContext
open class TextViewerFragment : ViewerFragment<TextViewerFragment.ReadableEpisode>() {
private lateinit var textDisplay: TextView
private lateinit var scrollView: ScrollView

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?,
Expand Down Expand Up @@ -108,6 +109,7 @@ open class TextViewerFragment : ViewerFragment<TextViewerFragment.ReadableEpisod
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.font) {
changeFont()
return true
}
return super.onOptionsItemSelected(item)
}
Expand Down
17 changes: 14 additions & 3 deletions app/src/main/java/com/mytlogos/enterprise/ui/ViewerFragment.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.mytlogos.enterprise.ui

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.*
import android.widget.ScrollView
import android.widget.TextView
import androidx.annotation.IdRes
Expand Down Expand Up @@ -83,6 +81,19 @@ abstract class ViewerFragment<T> : BaseFragment() {
return view
}

override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.viewer_menu, menu)
super.onCreateOptionsMenu(menu, inflater)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.read) {
this.updateProgress(1.0f)
return true
}
return super.onOptionsItemSelected(item)
}

open fun onScroll(scrollX: Int, scrollY: Int, oldScrollX: Int, oldScrollY: Int) {
if (scrollY != oldScrollY) {
scrollHideHelper.hideGroups(
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/menu/viewer_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/read"
android:title="@string/mark_read" />
</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,5 @@
<string name="name_of_the_list">Name of the List</string>
<string name="name_of_the_medium">Name of the Medium</string>
<string name="scroll_helper">Scroll helper</string>
<string name="mark_read">Mark read</string>
</resources>

0 comments on commit 9963220

Please sign in to comment.