More comments and simple tweaks

This commit is contained in:
Jobobby04 2020-06-20 16:55:05 -04:00
parent 7ce36f25ce
commit 6bd564823a
11 changed files with 36 additions and 48 deletions

View File

@ -293,9 +293,7 @@ class BackupRestoreService : Service() {
// SY <-- // SY <--
private fun restoreManga(mangaJson: JsonObject) { private fun restoreManga(mangaJson: JsonObject) {
// SY --> /* SY --> */ var /* SY <-- */ manga = backupManager.parser.fromJson<MangaImpl>(mangaJson.get(MANGA))
var manga = backupManager.parser.fromJson<MangaImpl>(mangaJson.get(MANGA))
// SY <--
val chapters = backupManager.parser.fromJson<List<ChapterImpl>>( val chapters = backupManager.parser.fromJson<List<ChapterImpl>>(
mangaJson.get(CHAPTERS) mangaJson.get(CHAPTERS)
?: JsonArray() ?: JsonArray()
@ -451,9 +449,7 @@ class BackupRestoreService : Service() {
* @return [Observable] that contains manga * @return [Observable] that contains manga
*/ */
private fun chapterFetchObservable(source: Source, manga: Manga, chapters: List<Chapter>): Observable<Pair<List<Chapter>, List<Chapter>>> { private fun chapterFetchObservable(source: Source, manga: Manga, chapters: List<Chapter>): Observable<Pair<List<Chapter>, List<Chapter>>> {
// SY --> return backupManager.restoreChapterFetchObservable(source, manga, chapters /* SY --> */, throttleManager /* SY <-- */)
return backupManager.restoreChapterFetchObservable(source, manga, chapters, throttleManager)
// SY <--
// If there's any error, return empty update and continue. // If there's any error, return empty update and continue.
.onErrorReturn { .onErrorReturn {
errors.add(Date() to "${manga.title} - ${it.message}") errors.add(Date() to "${manga.title} - ${it.message}")

View File

@ -36,7 +36,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory
* This class provides operations to manage the database through its interfaces. * This class provides operations to manage the database through its interfaces.
*/ */
open class DatabaseHelper(context: Context) : open class DatabaseHelper(context: Context) :
MangaQueries, ChapterQueries, TrackQueries, CategoryQueries, MangaCategoryQueries, HistoryQueries, /* EXH --> */ SearchMetadataQueries, SearchTagQueries, SearchTitleQueries /* EXH <-- */ { MangaQueries, ChapterQueries, TrackQueries, CategoryQueries, MangaCategoryQueries, HistoryQueries /* EXH --> */, SearchMetadataQueries, SearchTagQueries, SearchTitleQueries /* EXH <-- */ {
private val configuration = SupportSQLiteOpenHelper.Configuration.builder(context) private val configuration = SupportSQLiteOpenHelper.Configuration.builder(context)
.name(DbOpenCallback.DATABASE_NAME) .name(DbOpenCallback.DATABASE_NAME)

View File

@ -24,7 +24,7 @@ class DbOpenCallback : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) {
/** /**
* Version of the database. * Version of the database.
*/ */
const val DATABASE_VERSION = 2 // [SY] const val DATABASE_VERSION = /* SY --> */ 2 /* SY <-- */
} }
override fun onCreate(db: SupportSQLiteDatabase) = with(db) { override fun onCreate(db: SupportSQLiteDatabase) = with(db) {

View File

@ -266,10 +266,12 @@ class LibraryUpdateService(
.doOnNext { notifier.showProgressNotification(it, count.andIncrement, mangaToUpdate.size) } .doOnNext { notifier.showProgressNotification(it, count.andIncrement, mangaToUpdate.size) }
// Update the chapters of the manga // Update the chapters of the manga
.concatMap { manga -> .concatMap { manga ->
// SY -->
if (manga.source in LIBRARY_UPDATE_EXCLUDED_SOURCES) { if (manga.source in LIBRARY_UPDATE_EXCLUDED_SOURCES) {
// Ignore EXH manga, updating chapters for every manga will get you banned // Ignore EXH manga, updating chapters for every manga will get you banned
Observable.empty() Observable.empty()
} else { } else {
// SY <--
updateManga(manga) updateManga(manga)
// If there's any error, return empty update and continue. // If there's any error, return empty update and continue.
.onErrorReturn { .onErrorReturn {

View File

@ -103,7 +103,7 @@ class PreferencesHelper(val context: Context) {
fun colorFilterMode() = flowPrefs.getInt(Keys.colorFilterMode, 0) fun colorFilterMode() = flowPrefs.getInt(Keys.colorFilterMode, 0)
fun defaultViewer() = prefs.getInt(Keys.defaultViewer, 1) fun defaultViewer() = prefs.getInt(Keys.defaultViewer, 2)
fun imageScaleType() = flowPrefs.getInt(Keys.imageScaleType, 1) fun imageScaleType() = flowPrefs.getInt(Keys.imageScaleType, 1)

View File

@ -6,25 +6,23 @@ import java.util.concurrent.TimeUnit
import okhttp3.Cache import okhttp3.Cache
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
// SY --> /* SY --> */ open /* SY <-- */ class NetworkHelper(context: Context) {
open class NetworkHelper(context: Context) {
private val cacheDir = File(context.cacheDir, "network_cache") private val cacheDir = File(context.cacheDir, "network_cache")
private val cacheSize = 5L * 1024 * 1024 // 5 MiB private val cacheSize = 5L * 1024 * 1024 // 5 MiB
open val cookieManager = AndroidCookieJar() /* SY --> */ open /* SY <-- */ val cookieManager = AndroidCookieJar()
open val client = OkHttpClient.Builder() /* SY --> */ open /* SY <-- */ val client = OkHttpClient.Builder()
.cookieJar(cookieManager) .cookieJar(cookieManager)
.cache(Cache(cacheDir, cacheSize)) .cache(Cache(cacheDir, cacheSize))
.connectTimeout(30, TimeUnit.SECONDS) .connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS)
.build() .build()
open val cloudflareClient = client.newBuilder() /* SY --> */ open /* SY <-- */ val cloudflareClient = client.newBuilder()
.addInterceptor(UserAgentInterceptor()) .addInterceptor(UserAgentInterceptor())
.addInterceptor(CloudflareInterceptor(context)) .addInterceptor(CloudflareInterceptor(context))
.build() .build()
} }
// SY <--

View File

@ -187,5 +187,3 @@ open class SourceManager(private val context: Context) {
} }
// SY <-- // SY <--
} }
class SourceNotFoundException(message: String, val id: Long) : Exception(message)

View File

@ -6,9 +6,8 @@ import rx.subjects.Subject
open class Page( open class Page(
val index: Int, val index: Int,
// SY --> /* SY --> */
var url: String = "", var /* SY <-- */ url: String = "",
// SY <--
var imageUrl: String? = null, var imageUrl: String? = null,
@Transient var uri: Uri? = null // Deprecated but can't be deleted due to extensions @Transient var uri: Uri? = null // Deprecated but can't be deleted due to extensions
) : ProgressListener { ) : ProgressListener {

View File

@ -58,10 +58,12 @@ class ExtensionDetailsHeaderAdapter(private val presenter: ExtensionDetailsPrese
binding.extensionWarningBanner.setText(R.string.unofficial_extension_message) binding.extensionWarningBanner.setText(R.string.unofficial_extension_message)
} }
// SY -->
if (extension.isRedundant) { if (extension.isRedundant) {
binding.extensionWarningBanner.visible() binding.extensionWarningBanner.visible()
binding.extensionWarningBanner.setText(R.string.redundant_extension_message) binding.extensionWarningBanner.setText(R.string.redundant_extension_message)
} }
// SY <--
} }
} }
} }

View File

@ -52,7 +52,11 @@ class SearchController(
} }
override fun createPresenter(): GlobalSearchPresenter { override fun createPresenter(): GlobalSearchPresenter {
return SearchPresenter(initialQuery, manga!!, sources = sources) return SearchPresenter(
initialQuery,
manga!!,
sources
)
} }
override fun onSaveInstanceState(outState: Bundle) { override fun onSaveInstanceState(outState: Bundle) {
@ -67,25 +71,6 @@ class SearchController(
newManga = savedInstanceState.getSerializable(::newManga.name) as? Manga newManga = savedInstanceState.getSerializable(::newManga.name) as? Manga
} }
/*override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
if (totalProgress > 1) {
val menuItem = menu.add(Menu.NONE, 1, Menu.NONE, R.string.action_skip_manga)
menuItem.icon = VectorDrawableCompat.create(resources!!, R.drawable
.baseline_skip_next_white_24, null)
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS)
}
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
1 -> {
newManga = manga
migrateManga()
}
}
return true
}*/
fun migrateManga() { fun migrateManga() {
val target = targetController as? MigrationInterface ?: return val target = targetController as? MigrationInterface ?: return
val manga = manga ?: return val manga = manga ?: return
@ -125,7 +110,8 @@ class SearchController(
return return
} }
newManga = manga newManga = manga
val dialog = MigrationDialog() val dialog =
MigrationDialog()
dialog.targetController = this dialog.targetController = this
dialog.showDialog(router) dialog.showDialog(router)
} }
@ -142,16 +128,22 @@ class SearchController(
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
val prefValue = preferences.migrateFlags().get() val prefValue = preferences.migrateFlags().get()
val preselected = MigrationFlags.getEnabledFlagsPositions(prefValue) val preselected =
MigrationFlags.getEnabledFlagsPositions(
prefValue
)
return MaterialDialog(activity!!) return MaterialDialog(activity!!)
.message(R.string.data_to_include_in_migration) .message(R.string.migration_dialog_what_to_include)
.listItemsMultiChoice( .listItemsMultiChoice(
items = MigrationFlags.titles.map items = MigrationFlags.titles.map { resources?.getString(it) as CharSequence },
{ resources?.getString(it) as CharSequence },
initialSelection = preselected.toIntArray() initialSelection = preselected.toIntArray()
) { _, positions, _ -> ) { _, positions, _ ->
val newValue = MigrationFlags.getFlagsFromPositions(positions.toTypedArray()) // Save current settings for the next time
val newValue =
MigrationFlags.getFlagsFromPositions(
positions.toTypedArray()
)
preferences.migrateFlags().set(newValue) preferences.migrateFlags().set(newValue)
} }
.positiveButton(R.string.migrate) { .positiveButton(R.string.migrate) {
@ -160,6 +152,7 @@ class SearchController(
.negativeButton(R.string.copy) { .negativeButton(R.string.copy) {
(targetController as? SearchController)?.copyManga() (targetController as? SearchController)?.copyManga()
} }
.neutralButton(android.R.string.cancel)
} }
} }

View File

@ -138,7 +138,7 @@ class FavoritesSyncHelper(val context: Context) {
// Apply remote categories // Apply remote categories
status.onNext(FavoritesSyncStatus.Processing("Updating category names")) status.onNext(FavoritesSyncStatus.Processing("Updating category names"))
applyRemoteCategories(errorList, favorites.second) applyRemoteCategories(favorites.second)
// Apply change sets // Apply change sets
applyChangeSetToLocal(errorList, remoteChanges) applyChangeSetToLocal(errorList, remoteChanges)
@ -186,7 +186,7 @@ class FavoritesSyncHelper(val context: Context) {
} }
} }
private fun applyRemoteCategories(errorList: MutableList<String>, categories: List<String>) { private fun applyRemoteCategories(categories: List<String>) {
val localCategories = db.getCategories().executeAsBlocking() val localCategories = db.getCategories().executeAsBlocking()
val newLocalCategories = localCategories.toMutableList() val newLocalCategories = localCategories.toMutableList()