Fixed viewer flickering
Added moving with volume button Added nomedia Added help link to error snackbar
This commit is contained in:
@@ -206,10 +206,10 @@ class MainActivity : AppCompatActivity() {
|
||||
val maxPage = ceil(totalItems / perPage.toDouble()).roundToInt()
|
||||
|
||||
return when(keyCode) {
|
||||
KeyEvent.KEYCODE_VOLUME_DOWN -> {
|
||||
if (currentPage < maxPage) {
|
||||
KeyEvent.KEYCODE_VOLUME_UP -> {
|
||||
if (currentPage > 0) {
|
||||
runOnUiThread {
|
||||
currentPage++
|
||||
currentPage--
|
||||
|
||||
cancelFetch()
|
||||
clearGalleries()
|
||||
@@ -220,10 +220,10 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
true
|
||||
}
|
||||
KeyEvent.KEYCODE_VOLUME_UP -> {
|
||||
if (currentPage > 0) {
|
||||
KeyEvent.KEYCODE_VOLUME_DOWN -> {
|
||||
if (currentPage < maxPage) {
|
||||
runOnUiThread {
|
||||
currentPage--
|
||||
currentPage++
|
||||
|
||||
cancelFetch()
|
||||
clearGalleries()
|
||||
@@ -796,7 +796,7 @@ class MainActivity : AppCompatActivity() {
|
||||
s ?: return
|
||||
|
||||
if (s.any { it.isUpperCase() })
|
||||
s.replace(0, s.length, s.toString().toLowerCase())
|
||||
s.replace(0, s.length, s.toString().toLowerCase(Locale.getDefault()))
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.Manifest
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Animatable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
@@ -45,10 +46,7 @@ import kotlinx.serialization.ImplicitReflectionSerializer
|
||||
import xyz.quaver.pupil.Pupil
|
||||
import xyz.quaver.pupil.R
|
||||
import xyz.quaver.pupil.adapters.ReaderAdapter
|
||||
import xyz.quaver.pupil.util.GalleryDownloader
|
||||
import xyz.quaver.pupil.util.Histories
|
||||
import xyz.quaver.pupil.util.ItemClickSupport
|
||||
import xyz.quaver.pupil.util.hasPermission
|
||||
import xyz.quaver.pupil.util.*
|
||||
|
||||
class ReaderActivity : AppCompatActivity() {
|
||||
|
||||
@@ -220,6 +218,23 @@ class ReaderActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
//currentPage is 1-based
|
||||
return when(keyCode) {
|
||||
KeyEvent.KEYCODE_VOLUME_UP -> {
|
||||
(reader_recyclerview.layoutManager as LinearLayoutManager?)?.scrollToPositionWithOffset(currentPage-2, 0)
|
||||
|
||||
true
|
||||
}
|
||||
KeyEvent.KEYCODE_VOLUME_DOWN -> {
|
||||
(reader_recyclerview.layoutManager as LinearLayoutManager?)?.scrollToPositionWithOffset(currentPage, 0)
|
||||
|
||||
true
|
||||
}
|
||||
else -> super.onKeyDown(keyCode, event)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initDownloader() {
|
||||
var d: GalleryDownloader? = GalleryDownloader.get(galleryID)
|
||||
|
||||
@@ -262,7 +277,12 @@ class ReaderActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
onErrorHandler = {
|
||||
Snackbar.make(reader_layout, it.message ?: it.javaClass.name, Snackbar.LENGTH_INDEFINITE).show()
|
||||
Snackbar
|
||||
.make(reader_layout, it.message ?: it.javaClass.name, Snackbar.LENGTH_INDEFINITE)
|
||||
.setAction(R.string.reader_help) { view ->
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.error_help))))
|
||||
}
|
||||
.show()
|
||||
downloader.download = false
|
||||
}
|
||||
onCompleteHandler = {
|
||||
@@ -340,7 +360,7 @@ class ReaderActivity : AppCompatActivity() {
|
||||
scrollMode(false)
|
||||
fullscreen(true)
|
||||
} else {
|
||||
(reader_recyclerview.layoutManager as LinearLayoutManager?)?.scrollToPosition(currentPage)
|
||||
(reader_recyclerview.layoutManager as LinearLayoutManager?)?.scrollToPosition(currentPage) //Moves to next page because currentPage is 1-based indexing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import xyz.quaver.pupil.util.Lock
|
||||
import xyz.quaver.pupil.util.LockManager
|
||||
import xyz.quaver.pupil.util.getDownloadDirectory
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
class SettingsActivity : AppCompatActivity() {
|
||||
|
||||
@@ -278,7 +279,7 @@ class SettingsActivity : AppCompatActivity() {
|
||||
s ?: return
|
||||
|
||||
if (s.any { it.isUpperCase() })
|
||||
s.replace(0, s.length, s.toString().toLowerCase())
|
||||
s.replace(0, s.length, s.toString().toLowerCase(Locale.getDefault()))
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -352,6 +353,38 @@ class SettingsActivity : AppCompatActivity() {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
with(findPreference<Preference>("nomedia")) {
|
||||
this!!
|
||||
|
||||
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||
val directories = listOf(
|
||||
context.cacheDir,
|
||||
getDownloadDirectory(context)
|
||||
)
|
||||
|
||||
when (newValue as Boolean) {
|
||||
true -> {
|
||||
directories.forEach {
|
||||
it ?: return@forEach
|
||||
|
||||
if (it.exists())
|
||||
File(it, ".nomedia").createNewFile()
|
||||
}
|
||||
}
|
||||
false -> {
|
||||
directories.forEach {
|
||||
it ?: return@forEach
|
||||
|
||||
if (it.exists())
|
||||
File(it, ".nomedia").delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user