Bugfixes
This commit is contained in:
parent
cc43d9daed
commit
e1a3ee1b81
@ -6,6 +6,7 @@ import com.hippo.unifile.UniFile
|
|||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.data.source.Source
|
import eu.kanade.tachiyomi.data.source.Source
|
||||||
import eu.kanade.tachiyomi.util.DiskUtil
|
import eu.kanade.tachiyomi.util.DiskUtil
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
@ -26,10 +27,13 @@ class DownloadProvider(private val context: Context) {
|
|||||||
/**
|
/**
|
||||||
* The root directory for downloads.
|
* The root directory for downloads.
|
||||||
*/
|
*/
|
||||||
private lateinit var downloadsDir: UniFile
|
private var downloadsDir = preferences.downloadsDirectory().getOrDefault().let {
|
||||||
|
UniFile.fromUri(context, Uri.parse(it))
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
preferences.downloadsDirectory().asObservable()
|
preferences.downloadsDirectory().asObservable()
|
||||||
|
.skip(1)
|
||||||
.subscribe { downloadsDir = UniFile.fromUri(context, Uri.parse(it)) }
|
.subscribe { downloadsDir = UniFile.fromUri(context, Uri.parse(it)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,4 +11,16 @@ abstract class BaseActivity : AppCompatActivity(), ActivityMixin {
|
|||||||
|
|
||||||
override fun getActivity() = this
|
override fun getActivity() = this
|
||||||
|
|
||||||
|
var isResumed = false
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
isResumed = true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
isResumed = false
|
||||||
|
super.onPause()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,4 +25,16 @@ abstract class BaseRxActivity<P : BasePresenter<*>> : NucleusAppCompatActivity<P
|
|||||||
|
|
||||||
override fun getActivity() = this
|
override fun getActivity() = this
|
||||||
|
|
||||||
|
var isResumed = false
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
isResumed = true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
isResumed = false
|
||||||
|
super.onPause()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,9 @@ class DownloadHolder(private val view: View) : RecyclerView.ViewHolder(view) {
|
|||||||
* Updates the progress bar of the download.
|
* Updates the progress bar of the download.
|
||||||
*/
|
*/
|
||||||
fun notifyProgress() {
|
fun notifyProgress() {
|
||||||
|
val pages = download.pages ?: return
|
||||||
if (view.download_progress.max == 1) {
|
if (view.download_progress.max == 1) {
|
||||||
view.download_progress.max = download.pages!!.size * 100
|
view.download_progress.max = pages.size * 100
|
||||||
}
|
}
|
||||||
view.download_progress.progress = download.totalProgress
|
view.download_progress.progress = download.totalProgress
|
||||||
}
|
}
|
||||||
@ -58,7 +59,8 @@ class DownloadHolder(private val view: View) : RecyclerView.ViewHolder(view) {
|
|||||||
* Updates the text field of the number of downloaded pages.
|
* Updates the text field of the number of downloaded pages.
|
||||||
*/
|
*/
|
||||||
fun notifyDownloadedPages() {
|
fun notifyDownloadedPages() {
|
||||||
view.download_progress_text.text = "${download.downloadedImages}/${download.pages!!.size}"
|
val pages = download.pages ?: return
|
||||||
|
view.download_progress_text.text = "${download.downloadedImages}/${pages.size}"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,9 @@ class MainActivity : BaseActivity() {
|
|||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
val fragment = supportFragmentManager.findFragmentById(R.id.frame_container)
|
val fragment = supportFragmentManager.findFragmentById(R.id.frame_container)
|
||||||
if (fragment != null && fragment.tag.toInt() != startScreenId) {
|
if (fragment != null && fragment.tag.toInt() != startScreenId) {
|
||||||
|
if (isResumed) {
|
||||||
setSelectedDrawerItem(startScreenId)
|
setSelectedDrawerItem(startScreenId)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.ui.manga.chapter.ChaptersFragment
|
|||||||
import eu.kanade.tachiyomi.ui.manga.info.MangaInfoFragment
|
import eu.kanade.tachiyomi.ui.manga.info.MangaInfoFragment
|
||||||
import eu.kanade.tachiyomi.ui.manga.myanimelist.MyAnimeListFragment
|
import eu.kanade.tachiyomi.ui.manga.myanimelist.MyAnimeListFragment
|
||||||
import eu.kanade.tachiyomi.util.SharedData
|
import eu.kanade.tachiyomi.util.SharedData
|
||||||
|
import eu.kanade.tachiyomi.util.toast
|
||||||
import kotlinx.android.synthetic.main.activity_manga.*
|
import kotlinx.android.synthetic.main.activity_manga.*
|
||||||
import kotlinx.android.synthetic.main.toolbar.*
|
import kotlinx.android.synthetic.main.toolbar.*
|
||||||
import nucleus.factory.RequiresPresenter
|
import nucleus.factory.RequiresPresenter
|
||||||
@ -50,12 +51,19 @@ class MangaActivity : BaseRxActivity<MangaPresenter>() {
|
|||||||
|
|
||||||
val fromLauncher = intent.getBooleanExtra(FROM_LAUNCHER_EXTRA, false)
|
val fromLauncher = intent.getBooleanExtra(FROM_LAUNCHER_EXTRA, false)
|
||||||
|
|
||||||
//Remove any current manga if we are launching from launcher
|
// Remove any current manga if we are launching from launcher
|
||||||
if(fromLauncher) SharedData.remove(MangaEvent::class.java)
|
if (fromLauncher) SharedData.remove(MangaEvent::class.java)
|
||||||
|
|
||||||
presenter.setMangaEvent(SharedData.getOrPut(MangaEvent::class.java) {
|
presenter.setMangaEvent(SharedData.getOrPut(MangaEvent::class.java) {
|
||||||
val id = intent.getLongExtra(MANGA_EXTRA, 0)
|
val id = intent.getLongExtra(MANGA_EXTRA, 0)
|
||||||
MangaEvent(presenter.db.getManga(id).executeAsBlocking()!!)
|
val dbManga = presenter.db.getManga(id).executeAsBlocking()
|
||||||
|
if (dbManga != null) {
|
||||||
|
MangaEvent(dbManga)
|
||||||
|
} else {
|
||||||
|
toast(R.string.manga_not_in_db)
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
setupToolbar(toolbar)
|
setupToolbar(toolbar)
|
||||||
|
@ -394,7 +394,8 @@ class ChaptersFragment : BaseRxFragment<ChaptersPresenter>(), ActionMode.Callbac
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun dismissDeletingDialog() {
|
fun dismissDeletingDialog() {
|
||||||
(childFragmentManager.findFragmentByTag(DeletingChaptersDialog.TAG) as? DialogFragment)?.dismiss()
|
(childFragmentManager.findFragmentByTag(DeletingChaptersDialog.TAG) as? DialogFragment)
|
||||||
|
?.dismissAllowingStateLoss()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onListItemClick(position: Int): Boolean {
|
override fun onListItemClick(position: Int): Boolean {
|
||||||
|
@ -226,6 +226,9 @@
|
|||||||
<string name="select_source">Select a source</string>
|
<string name="select_source">Select a source</string>
|
||||||
<string name="no_valid_sources">Please enable at least one valid source</string>
|
<string name="no_valid_sources">Please enable at least one valid source</string>
|
||||||
|
|
||||||
|
<!-- Manga activity -->
|
||||||
|
<string name="manga_not_in_db">This manga was removed from the database!</string>
|
||||||
|
|
||||||
<!-- Manga info fragment -->
|
<!-- Manga info fragment -->
|
||||||
<string name="manga_detail_tab">Info</string>
|
<string name="manga_detail_tab">Info</string>
|
||||||
<string name="description">Description</string>
|
<string name="description">Description</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user