mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 20:31:02 -05: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
9 changed files with 41 additions and 15 deletions
|
@ -117,7 +117,7 @@ dependencies {
|
||||||
compile 'com.f2prateek.rx.preferences:rx-preferences:1.0.1'
|
compile 'com.f2prateek.rx.preferences:rx-preferences:1.0.1'
|
||||||
|
|
||||||
// Network client
|
// Network client
|
||||||
compile "com.squareup.okhttp3:okhttp:3.3.0"
|
compile "com.squareup.okhttp3:okhttp:3.3.1"
|
||||||
|
|
||||||
// REST
|
// REST
|
||||||
compile "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
|
compile "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
|
||||||
|
|
10
app/proguard-rules.pro
vendored
10
app/proguard-rules.pro
vendored
|
@ -118,4 +118,12 @@
|
||||||
|
|
||||||
# Keep the support library
|
# Keep the support library
|
||||||
-keep class org.acra.** { *; }
|
-keep class org.acra.** { *; }
|
||||||
-keep interface 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
|
package eu.kanade.tachiyomi.data.source
|
||||||
|
|
||||||
|
import android.Manifest.permission.READ_EXTERNAL_STORAGE
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import eu.kanade.tachiyomi.R
|
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.Mangachan
|
||||||
import eu.kanade.tachiyomi.data.source.online.russian.Mintmanga
|
import eu.kanade.tachiyomi.data.source.online.russian.Mintmanga
|
||||||
import eu.kanade.tachiyomi.data.source.online.russian.Readmanga
|
import eu.kanade.tachiyomi.data.source.online.russian.Readmanga
|
||||||
|
import eu.kanade.tachiyomi.util.hasPermission
|
||||||
import org.yaml.snakeyaml.Yaml
|
import org.yaml.snakeyaml.Yaml
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -54,7 +56,7 @@ open class SourceManager(private val context: Context) {
|
||||||
val parsersDir = File(Environment.getExternalStorageDirectory().absolutePath +
|
val parsersDir = File(Environment.getExternalStorageDirectory().absolutePath +
|
||||||
File.separator + context.getString(R.string.app_name), "parsers")
|
File.separator + context.getString(R.string.app_name), "parsers")
|
||||||
|
|
||||||
if (parsersDir.exists()) {
|
if (parsersDir.exists() && context.hasPermission(READ_EXTERNAL_STORAGE)) {
|
||||||
val yaml = Yaml()
|
val yaml = Yaml()
|
||||||
for (file in parsersDir.listFiles().filter { it.extension == "yml" }) {
|
for (file in parsersDir.listFiles().filter { it.extension == "yml" }) {
|
||||||
try {
|
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 {
|
document.select("select.m").first().select("option:not([value=0])").forEach {
|
||||||
pages.add(Page(pages.size, "$url/${it.attr("value")}.html"))
|
pages.add(Page(pages.size, "$url/${it.attr("value")}.html"))
|
||||||
}
|
}
|
||||||
pages.getOrNull(0)?.imageUrl = imageUrlParse(document)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not used, overrides parent.
|
// Not used, overrides parent.
|
||||||
|
|
|
@ -134,7 +134,7 @@ class DownloadFragment : BaseRxFragment<DownloadPresenter>() {
|
||||||
|
|
||||||
// Set clear button visibility.
|
// Set clear button visibility.
|
||||||
clearButton = menu.findItem(R.id.clear_queue).apply {
|
clearButton = menu.findItem(R.id.clear_queue).apply {
|
||||||
if (adapter.itemCount > 0) {
|
if (!presenter.downloadQueue.isEmpty()) {
|
||||||
isVisible = true
|
isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,6 @@ class DownloadFragment : BaseRxFragment<DownloadPresenter>() {
|
||||||
R.id.clear_queue -> {
|
R.id.clear_queue -> {
|
||||||
DownloadService.stop(activity)
|
DownloadService.stop(activity)
|
||||||
presenter.clearQueue()
|
presenter.clearQueue()
|
||||||
clearButton?.isVisible = false
|
|
||||||
}
|
}
|
||||||
else -> return super.onOptionsItemSelected(item)
|
else -> return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
@ -223,7 +222,7 @@ class DownloadFragment : BaseRxFragment<DownloadPresenter>() {
|
||||||
isRunning = running
|
isRunning = running
|
||||||
startButton?.isVisible = !running && !presenter.downloadQueue.isEmpty()
|
startButton?.isVisible = !running && !presenter.downloadQueue.isEmpty()
|
||||||
pauseButton?.isVisible = running
|
pauseButton?.isVisible = running
|
||||||
clearButton?.isVisible = running
|
clearButton?.isVisible = !presenter.downloadQueue.isEmpty()
|
||||||
|
|
||||||
// Check if download queue is empty and update information accordingly.
|
// Check if download queue is empty and update information accordingly.
|
||||||
setInformationView()
|
setInformationView()
|
||||||
|
|
|
@ -313,13 +313,8 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
||||||
changeSelectedCover(presenter.selectedMangas)
|
changeSelectedCover(presenter.selectedMangas)
|
||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
}
|
}
|
||||||
R.id.action_move_to_category -> {
|
R.id.action_move_to_category -> moveMangasToCategories(presenter.selectedMangas)
|
||||||
moveMangasToCategories(presenter.selectedMangas)
|
R.id.action_delete -> showDeleteMangaDialog()
|
||||||
}
|
|
||||||
R.id.action_delete -> {
|
|
||||||
presenter.deleteMangas()
|
|
||||||
destroyActionModeIfNeeded()
|
|
||||||
}
|
|
||||||
else -> return false
|
else -> return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -409,6 +404,18 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
||||||
.show()
|
.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.
|
* 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.
|
* Remove the selected manga from the library.
|
||||||
*/
|
*/
|
||||||
fun deleteMangas() {
|
fun removeMangaFromLibrary() {
|
||||||
// Create a set of the list
|
// Create a set of the list
|
||||||
val mangaToDelete = selectedMangas.toSet()
|
val mangaToDelete = selectedMangas.toSet()
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,10 @@ import android.app.AlarmManager
|
||||||
import android.app.Notification
|
import android.app.Notification
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.support.annotation.StringRes
|
import android.support.annotation.StringRes
|
||||||
import android.support.v4.app.NotificationCompat
|
import android.support.v4.app.NotificationCompat
|
||||||
|
import android.support.v4.content.ContextCompat
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,6 +39,14 @@ inline fun Context.notification(func: NotificationCompat.Builder.() -> Unit): No
|
||||||
return builder.build()
|
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.
|
* 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_search_hint">Title or author…</string>
|
||||||
<string name="library_selection_title">Selected</string>
|
<string name="library_selection_title">Selected</string>
|
||||||
<string name="updating_category">Updating category</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 -->
|
<!-- Catalogue fragment -->
|
||||||
<string name="source_requires_login">This source requires you to log in</string>
|
<string name="source_requires_login">This source requires you to log in</string>
|
||||||
|
|
Loading…
Reference in a new issue