Update dependencies and fix deprecations
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-android-extensions'
|
||||
id 'kotlin-kapt'
|
||||
}
|
||||
|
||||
def gitCommits = 'git rev-list --count HEAD'.execute([], rootDir).text.trim().toInteger()
|
||||
def gitBranch = 'git branch --show-current'.execute([], rootDir).text.trim()
|
||||
@@ -21,7 +23,7 @@ android {
|
||||
|
||||
kapt {
|
||||
arguments {
|
||||
arg('room.schemaLocation', "$projectDir/schemas".toString())
|
||||
arg 'room.schemaLocation', "$projectDir/schemas".toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,8 +64,10 @@ dependencies {
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5'
|
||||
|
||||
implementation 'androidx.core:core-ktx:1.3.0-rc01'
|
||||
implementation 'androidx.fragment:fragment-ktx:1.2.4'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
|
||||
implementation 'androidx.activity:activity-ktx:1.2.0-alpha04'
|
||||
implementation 'androidx.fragment:fragment-ktx:1.3.0-alpha04'
|
||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-alpha02'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta5'
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-rc01'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha03'
|
||||
@@ -91,9 +95,9 @@ dependencies {
|
||||
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0'
|
||||
implementation 'com.tomclaw.cache:cache:1.0'
|
||||
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.2'
|
||||
debugImplementation 'com.github.ChuckerTeam.Chucker:library:3.1.2'
|
||||
releaseImplementation 'com.github.ChuckerTeam.Chucker:library-no-op:3.1.2'
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.3'
|
||||
debugImplementation 'com.github.ChuckerTeam.Chucker:library:3.2.0'
|
||||
releaseImplementation 'com.github.ChuckerTeam.Chucker:library-no-op:3.2.0'
|
||||
|
||||
testImplementation 'junit:junit:4.13'
|
||||
testImplementation 'org.json:json:20190722'
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package org.koitharu.kotatsu.ui.common
|
||||
|
||||
import android.content.pm.PackageManager
|
||||
import android.view.KeyEvent
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import moxy.MvpAppCompatActivity
|
||||
import org.koin.core.KoinComponent
|
||||
import org.koitharu.kotatsu.BuildConfig
|
||||
@@ -14,8 +11,6 @@ import org.koitharu.kotatsu.R
|
||||
|
||||
abstract class BaseActivity : MvpAppCompatActivity(), KoinComponent {
|
||||
|
||||
private var permissionCallback: ((Boolean) -> Unit)? = null
|
||||
|
||||
override fun setContentView(layoutResID: Int) {
|
||||
super.setContentView(layoutResID)
|
||||
setupToolbar()
|
||||
@@ -35,47 +30,12 @@ abstract class BaseActivity : MvpAppCompatActivity(), KoinComponent {
|
||||
true
|
||||
} else super.onOptionsItemSelected(item)
|
||||
|
||||
fun requestPermission(permission: String, callback: (Boolean) -> Unit) {
|
||||
if (ContextCompat.checkSelfPermission(
|
||||
this,
|
||||
permission
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
callback(true)
|
||||
} else {
|
||||
permissionCallback = callback
|
||||
ActivityCompat.requestPermissions(this, arrayOf(permission), REQUEST_PERMISSION)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<out String>,
|
||||
grantResults: IntArray
|
||||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
if (requestCode == REQUEST_PERMISSION) {
|
||||
grantResults.singleOrNull()?.let {
|
||||
permissionCallback?.invoke(it == PackageManager.PERMISSION_GRANTED)
|
||||
}
|
||||
permissionCallback = null
|
||||
}
|
||||
}
|
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
//TODO remove. Just for testing
|
||||
if (BuildConfig.DEBUG && keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
|
||||
recreate()
|
||||
return true
|
||||
}
|
||||
if (BuildConfig.DEBUG && keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
throw StackOverflowError("test")
|
||||
}
|
||||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
const val REQUEST_PERMISSION = 30
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,9 @@ abstract class MangaListFragment<E> : BaseFragment(R.layout.fragment_list), Mang
|
||||
recyclerView_filter.addItemDecoration(ItemTypeDividerDecoration(view.context))
|
||||
recyclerView_filter.addItemDecoration(SectionItemDecoration(false, this))
|
||||
settings.subscribe(this)
|
||||
if (savedInstanceState?.containsKey(MvpDelegate.MOXY_DELEGATE_TAGS_KEY) != true) {
|
||||
onRequestMoreItems(0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
@@ -72,13 +75,6 @@ abstract class MangaListFragment<E> : BaseFragment(R.layout.fragment_list), Mang
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
if (savedInstanceState?.containsKey(MvpDelegate.MOXY_DELEGATE_TAGS_KEY) != true) {
|
||||
onRequestMoreItems(0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.opt_list, menu)
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
|
||||
@@ -57,6 +57,9 @@ abstract class MangaListSheet<E> : BaseBottomSheet(R.layout.sheet_list), MangaLi
|
||||
textView_title.isVisible = false
|
||||
appbar.elevation = resources.getDimension(R.dimen.elevation_large)
|
||||
}
|
||||
if (savedInstanceState?.containsKey(MvpDelegate.MOXY_DELEGATE_TAGS_KEY) != true) {
|
||||
onRequestMoreItems(0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
@@ -65,13 +68,6 @@ abstract class MangaListSheet<E> : BaseBottomSheet(R.layout.sheet_list), MangaLi
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
if (savedInstanceState?.containsKey(MvpDelegate.MOXY_DELEGATE_TAGS_KEY) != true) {
|
||||
onRequestMoreItems(0)
|
||||
}
|
||||
}
|
||||
|
||||
protected fun setTitle(title: CharSequence) {
|
||||
toolbar.title = title
|
||||
textView_title.text = title
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package org.koitharu.kotatsu.ui.main.list.local
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import androidx.activity.result.ActivityResultCallback
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import kotlinx.android.synthetic.main.fragment_list.*
|
||||
@@ -17,7 +18,7 @@ import org.koitharu.kotatsu.ui.main.list.MangaListFragment
|
||||
import org.koitharu.kotatsu.utils.ext.ellipsize
|
||||
import java.io.File
|
||||
|
||||
class LocalListFragment : MangaListFragment<File>() {
|
||||
class LocalListFragment : MangaListFragment<File>(), ActivityResultCallback<Uri> {
|
||||
|
||||
private val presenter by moxyPresenter(factory = ::LocalListPresenter)
|
||||
|
||||
@@ -35,11 +36,9 @@ class LocalListFragment : MangaListFragment<File>() {
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.action_import -> {
|
||||
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE)
|
||||
intent.type = "*/*"
|
||||
try {
|
||||
startActivityForResult(intent, REQUEST_IMPORT)
|
||||
registerForActivityResult(ActivityResultContracts.OpenDocument(), this)
|
||||
.launch(arrayOf("*/*"))
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
e.printStackTrace()
|
||||
@@ -63,13 +62,9 @@ class LocalListFragment : MangaListFragment<File>() {
|
||||
textView_holder.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
when (requestCode) {
|
||||
REQUEST_IMPORT -> if (resultCode == Activity.RESULT_OK) {
|
||||
val uri = data?.data ?: return
|
||||
presenter.importFile(context?.applicationContext ?: return, uri)
|
||||
}
|
||||
override fun onActivityResult(result: Uri?) {
|
||||
if (result != null) {
|
||||
presenter.importFile(context?.applicationContext ?: return, result)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,16 @@ import android.Manifest
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.ActivityResultCallback
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.postDelayed
|
||||
import androidx.core.view.updatePadding
|
||||
@@ -43,7 +47,7 @@ import org.koitharu.kotatsu.utils.ext.*
|
||||
class ReaderActivity : BaseFullscreenActivity(), ReaderView, ChaptersDialog.OnChapterChangeListener,
|
||||
GridTouchHelper.OnGridTouchListener, OnPageSelectListener, ReaderConfigDialog.Callback,
|
||||
ReaderListener, SharedPreferences.OnSharedPreferenceChangeListener,
|
||||
View.OnApplyWindowInsetsListener {
|
||||
View.OnApplyWindowInsetsListener, ActivityResultCallback<Boolean> {
|
||||
|
||||
private val presenter by moxyPresenter(factory = ::ReaderPresenter)
|
||||
private val settings by inject<AppSettings>()
|
||||
@@ -179,13 +183,17 @@ class ReaderActivity : BaseFullscreenActivity(), ReaderView, ChaptersDialog.OnCh
|
||||
}
|
||||
R.id.action_save_page -> {
|
||||
if (reader?.hasItems == true) {
|
||||
requestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) {
|
||||
if (it) {
|
||||
presenter.savePage(
|
||||
resolver = contentResolver,
|
||||
page = reader?.currentPage ?: return@requestPermission
|
||||
)
|
||||
}
|
||||
if (ContextCompat.checkSelfPermission(
|
||||
this,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
onActivityResult(true)
|
||||
} else {
|
||||
registerForActivityResult(
|
||||
ActivityResultContracts.RequestPermission(),
|
||||
this
|
||||
).launch(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
}
|
||||
} else {
|
||||
showWaitWhileLoading()
|
||||
@@ -195,6 +203,15 @@ class ReaderActivity : BaseFullscreenActivity(), ReaderView, ChaptersDialog.OnCh
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onActivityResult(result: Boolean) {
|
||||
if (result) {
|
||||
presenter.savePage(
|
||||
resolver = contentResolver,
|
||||
page = reader?.currentPage ?: return
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun saveState(chapterId: Long, page: Int, scroll: Float) {
|
||||
state = state.copy(chapterId = chapterId, page = page, scroll = scroll)
|
||||
ReaderPresenter.saveState(state)
|
||||
|
||||
@@ -46,10 +46,6 @@ abstract class AbstractReader(contentLayoutId: Int) : BaseFragment(contentLayout
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
adapter = onCreateAdapter(pages)
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
@Suppress("RemoveExplicitTypeArguments")
|
||||
val state = savedInstanceState?.getParcelable<ReaderState>(ARG_STATE)
|
||||
?: requireArguments().getParcelable<ReaderState>(ARG_STATE)!!
|
||||
|
||||
@@ -30,6 +30,7 @@ class SettingsActivity : BaseActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onPreferenceStartFragment(caller: PreferenceFragmentCompat, pref: Preference): Boolean {
|
||||
val fm = supportFragmentManager
|
||||
val fragment = fm.fragmentFactory.instantiate(classLoader, pref.fragment)
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<full-backup-content>
|
||||
<!-- TODO: Exclude specific shared preferences that contain GCM registration Id -->
|
||||
<!-- https://developer.android.com/guide/topics/data/autobackup -->
|
||||
</full-backup-content>
|
||||
<full-backup-content />
|
||||
|
||||
Reference in New Issue
Block a user