mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 18:45:07 +01:00
Fix #329. Add confirmation before removing favorite manga on multiple selection. Add new proguard rules
This commit is contained in:
parent
156e43290e
commit
d1db2d60ec
@ -117,7 +117,7 @@ dependencies {
|
||||
compile 'com.f2prateek.rx.preferences:rx-preferences:1.0.1'
|
||||
|
||||
// Network client
|
||||
compile "com.squareup.okhttp3:okhttp:3.3.0"
|
||||
compile "com.squareup.okhttp3:okhttp:3.3.1"
|
||||
|
||||
// REST
|
||||
compile "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
|
||||
|
8
app/proguard-rules.pro
vendored
8
app/proguard-rules.pro
vendored
@ -119,3 +119,11 @@
|
||||
# Keep the support library
|
||||
-keep class org.acra.** { *; }
|
||||
-keep interface org.acra.** { *; }
|
||||
|
||||
# SnakeYaml
|
||||
-keep class org.yaml.snakeyaml.** { public protected private *; }
|
||||
-keep class org.yaml.snakeyaml.** { public protected private *; }
|
||||
-dontwarn org.yaml.snakeyaml.**
|
||||
|
||||
# Duktape
|
||||
-keep class com.squareup.duktape.** { *; }
|
@ -1,5 +1,6 @@
|
||||
package eu.kanade.tachiyomi.data.source
|
||||
|
||||
import android.Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
import android.content.Context
|
||||
import android.os.Environment
|
||||
import eu.kanade.tachiyomi.R
|
||||
@ -9,6 +10,7 @@ import eu.kanade.tachiyomi.data.source.online.english.*
|
||||
import eu.kanade.tachiyomi.data.source.online.russian.Mangachan
|
||||
import eu.kanade.tachiyomi.data.source.online.russian.Mintmanga
|
||||
import eu.kanade.tachiyomi.data.source.online.russian.Readmanga
|
||||
import eu.kanade.tachiyomi.util.hasPermission
|
||||
import org.yaml.snakeyaml.Yaml
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
@ -54,7 +56,7 @@ open class SourceManager(private val context: Context) {
|
||||
val parsersDir = File(Environment.getExternalStorageDirectory().absolutePath +
|
||||
File.separator + context.getString(R.string.app_name), "parsers")
|
||||
|
||||
if (parsersDir.exists()) {
|
||||
if (parsersDir.exists() && context.hasPermission(READ_EXTERNAL_STORAGE)) {
|
||||
val yaml = Yaml()
|
||||
for (file in parsersDir.listFiles().filter { it.extension == "yml" }) {
|
||||
try {
|
||||
|
@ -111,7 +111,6 @@ class Mangafox(context: Context, override val id: Int) : ParsedOnlineSource(cont
|
||||
document.select("select.m").first().select("option:not([value=0])").forEach {
|
||||
pages.add(Page(pages.size, "$url/${it.attr("value")}.html"))
|
||||
}
|
||||
pages.getOrNull(0)?.imageUrl = imageUrlParse(document)
|
||||
}
|
||||
|
||||
// Not used, overrides parent.
|
||||
|
@ -134,7 +134,7 @@ class DownloadFragment : BaseRxFragment<DownloadPresenter>() {
|
||||
|
||||
// Set clear button visibility.
|
||||
clearButton = menu.findItem(R.id.clear_queue).apply {
|
||||
if (adapter.itemCount > 0) {
|
||||
if (!presenter.downloadQueue.isEmpty()) {
|
||||
isVisible = true
|
||||
}
|
||||
}
|
||||
@ -147,7 +147,6 @@ class DownloadFragment : BaseRxFragment<DownloadPresenter>() {
|
||||
R.id.clear_queue -> {
|
||||
DownloadService.stop(activity)
|
||||
presenter.clearQueue()
|
||||
clearButton?.isVisible = false
|
||||
}
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
@ -223,7 +222,7 @@ class DownloadFragment : BaseRxFragment<DownloadPresenter>() {
|
||||
isRunning = running
|
||||
startButton?.isVisible = !running && !presenter.downloadQueue.isEmpty()
|
||||
pauseButton?.isVisible = running
|
||||
clearButton?.isVisible = running
|
||||
clearButton?.isVisible = !presenter.downloadQueue.isEmpty()
|
||||
|
||||
// Check if download queue is empty and update information accordingly.
|
||||
setInformationView()
|
||||
|
@ -313,13 +313,8 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
||||
changeSelectedCover(presenter.selectedMangas)
|
||||
destroyActionModeIfNeeded()
|
||||
}
|
||||
R.id.action_move_to_category -> {
|
||||
moveMangasToCategories(presenter.selectedMangas)
|
||||
}
|
||||
R.id.action_delete -> {
|
||||
presenter.deleteMangas()
|
||||
destroyActionModeIfNeeded()
|
||||
}
|
||||
R.id.action_move_to_category -> moveMangasToCategories(presenter.selectedMangas)
|
||||
R.id.action_delete -> showDeleteMangaDialog()
|
||||
else -> return false
|
||||
}
|
||||
return true
|
||||
@ -409,6 +404,18 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun showDeleteMangaDialog() {
|
||||
MaterialDialog.Builder(activity)
|
||||
.content(R.string.confirm_delete_manga)
|
||||
.positiveText(android.R.string.yes)
|
||||
.negativeText(android.R.string.no)
|
||||
.onPositive { dialog, action ->
|
||||
presenter.removeMangaFromLibrary()
|
||||
destroyActionModeIfNeeded()
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the action mode if it's not created already.
|
||||
*/
|
||||
|
@ -236,7 +236,7 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
|
||||
/**
|
||||
* Remove the selected manga from the library.
|
||||
*/
|
||||
fun deleteMangas() {
|
||||
fun removeMangaFromLibrary() {
|
||||
// Create a set of the list
|
||||
val mangaToDelete = selectedMangas.toSet()
|
||||
|
||||
|
@ -4,8 +4,10 @@ import android.app.AlarmManager
|
||||
import android.app.Notification
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.support.annotation.StringRes
|
||||
import android.support.v4.app.NotificationCompat
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.widget.Toast
|
||||
|
||||
/**
|
||||
@ -37,6 +39,14 @@ inline fun Context.notification(func: NotificationCompat.Builder.() -> Unit): No
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the give permission is granted.
|
||||
* @param permission the permission to check.
|
||||
* @return true if it has permissions.
|
||||
*/
|
||||
fun Context.hasPermission(permission: String)
|
||||
= ContextCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_GRANTED
|
||||
|
||||
/**
|
||||
* Property to get the notification manager from the context.
|
||||
*/
|
||||
|
@ -193,6 +193,7 @@
|
||||
<string name="library_search_hint">Title or author…</string>
|
||||
<string name="library_selection_title">Selected</string>
|
||||
<string name="updating_category">Updating category</string>
|
||||
<string name="confirm_delete_manga">Are you sure you want to remove selected manga?</string>
|
||||
|
||||
<!-- Catalogue fragment -->
|
||||
<string name="source_requires_login">This source requires you to log in</string>
|
||||
|
Loading…
Reference in New Issue
Block a user