More comments and simple tweaks
This commit is contained in:
parent
7ce36f25ce
commit
6bd564823a
@ -293,9 +293,7 @@ class BackupRestoreService : Service() {
|
||||
// SY <--
|
||||
|
||||
private fun restoreManga(mangaJson: JsonObject) {
|
||||
// SY -->
|
||||
var manga = backupManager.parser.fromJson<MangaImpl>(mangaJson.get(MANGA))
|
||||
// SY <--
|
||||
/* SY --> */ var /* SY <-- */ manga = backupManager.parser.fromJson<MangaImpl>(mangaJson.get(MANGA))
|
||||
val chapters = backupManager.parser.fromJson<List<ChapterImpl>>(
|
||||
mangaJson.get(CHAPTERS)
|
||||
?: JsonArray()
|
||||
@ -451,9 +449,7 @@ class BackupRestoreService : Service() {
|
||||
* @return [Observable] that contains manga
|
||||
*/
|
||||
private fun chapterFetchObservable(source: Source, manga: Manga, chapters: List<Chapter>): Observable<Pair<List<Chapter>, List<Chapter>>> {
|
||||
// SY -->
|
||||
return backupManager.restoreChapterFetchObservable(source, manga, chapters, throttleManager)
|
||||
// SY <--
|
||||
return backupManager.restoreChapterFetchObservable(source, manga, chapters /* SY --> */, throttleManager /* SY <-- */)
|
||||
// If there's any error, return empty update and continue.
|
||||
.onErrorReturn {
|
||||
errors.add(Date() to "${manga.title} - ${it.message}")
|
||||
|
@ -36,7 +36,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory
|
||||
* This class provides operations to manage the database through its interfaces.
|
||||
*/
|
||||
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)
|
||||
.name(DbOpenCallback.DATABASE_NAME)
|
||||
|
@ -24,7 +24,7 @@ class DbOpenCallback : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) {
|
||||
/**
|
||||
* Version of the database.
|
||||
*/
|
||||
const val DATABASE_VERSION = 2 // [SY]
|
||||
const val DATABASE_VERSION = /* SY --> */ 2 /* SY <-- */
|
||||
}
|
||||
|
||||
override fun onCreate(db: SupportSQLiteDatabase) = with(db) {
|
||||
|
@ -266,10 +266,12 @@ class LibraryUpdateService(
|
||||
.doOnNext { notifier.showProgressNotification(it, count.andIncrement, mangaToUpdate.size) }
|
||||
// Update the chapters of the manga
|
||||
.concatMap { manga ->
|
||||
// SY -->
|
||||
if (manga.source in LIBRARY_UPDATE_EXCLUDED_SOURCES) {
|
||||
// Ignore EXH manga, updating chapters for every manga will get you banned
|
||||
Observable.empty()
|
||||
} else {
|
||||
// SY <--
|
||||
updateManga(manga)
|
||||
// If there's any error, return empty update and continue.
|
||||
.onErrorReturn {
|
||||
|
@ -103,7 +103,7 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
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)
|
||||
|
||||
|
@ -6,25 +6,23 @@ import java.util.concurrent.TimeUnit
|
||||
import okhttp3.Cache
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
// SY -->
|
||||
open class NetworkHelper(context: Context) {
|
||||
/* SY --> */ open /* SY <-- */ class NetworkHelper(context: Context) {
|
||||
|
||||
private val cacheDir = File(context.cacheDir, "network_cache")
|
||||
|
||||
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)
|
||||
.cache(Cache(cacheDir, cacheSize))
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.build()
|
||||
|
||||
open val cloudflareClient = client.newBuilder()
|
||||
/* SY --> */ open /* SY <-- */ val cloudflareClient = client.newBuilder()
|
||||
.addInterceptor(UserAgentInterceptor())
|
||||
.addInterceptor(CloudflareInterceptor(context))
|
||||
.build()
|
||||
}
|
||||
// SY <--
|
||||
|
@ -187,5 +187,3 @@ open class SourceManager(private val context: Context) {
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
|
||||
class SourceNotFoundException(message: String, val id: Long) : Exception(message)
|
||||
|
@ -6,9 +6,8 @@ import rx.subjects.Subject
|
||||
|
||||
open class Page(
|
||||
val index: Int,
|
||||
// SY -->
|
||||
var url: String = "",
|
||||
// SY <--
|
||||
/* SY --> */
|
||||
var /* SY <-- */ url: String = "",
|
||||
var imageUrl: String? = null,
|
||||
@Transient var uri: Uri? = null // Deprecated but can't be deleted due to extensions
|
||||
) : ProgressListener {
|
||||
|
@ -58,10 +58,12 @@ class ExtensionDetailsHeaderAdapter(private val presenter: ExtensionDetailsPrese
|
||||
binding.extensionWarningBanner.setText(R.string.unofficial_extension_message)
|
||||
}
|
||||
|
||||
// SY -->
|
||||
if (extension.isRedundant) {
|
||||
binding.extensionWarningBanner.visible()
|
||||
binding.extensionWarningBanner.setText(R.string.redundant_extension_message)
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,11 @@ class SearchController(
|
||||
}
|
||||
|
||||
override fun createPresenter(): GlobalSearchPresenter {
|
||||
return SearchPresenter(initialQuery, manga!!, sources = sources)
|
||||
return SearchPresenter(
|
||||
initialQuery,
|
||||
manga!!,
|
||||
sources
|
||||
)
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
@ -67,25 +71,6 @@ class SearchController(
|
||||
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() {
|
||||
val target = targetController as? MigrationInterface ?: return
|
||||
val manga = manga ?: return
|
||||
@ -125,7 +110,8 @@ class SearchController(
|
||||
return
|
||||
}
|
||||
newManga = manga
|
||||
val dialog = MigrationDialog()
|
||||
val dialog =
|
||||
MigrationDialog()
|
||||
dialog.targetController = this
|
||||
dialog.showDialog(router)
|
||||
}
|
||||
@ -142,16 +128,22 @@ class SearchController(
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val prefValue = preferences.migrateFlags().get()
|
||||
|
||||
val preselected = MigrationFlags.getEnabledFlagsPositions(prefValue)
|
||||
val preselected =
|
||||
MigrationFlags.getEnabledFlagsPositions(
|
||||
prefValue
|
||||
)
|
||||
|
||||
return MaterialDialog(activity!!)
|
||||
.message(R.string.data_to_include_in_migration)
|
||||
.message(R.string.migration_dialog_what_to_include)
|
||||
.listItemsMultiChoice(
|
||||
items = MigrationFlags.titles.map
|
||||
{ resources?.getString(it) as CharSequence },
|
||||
items = MigrationFlags.titles.map { resources?.getString(it) as CharSequence },
|
||||
initialSelection = preselected.toIntArray()
|
||||
) { _, positions, _ ->
|
||||
val newValue = MigrationFlags.getFlagsFromPositions(positions.toTypedArray())
|
||||
// Save current settings for the next time
|
||||
val newValue =
|
||||
MigrationFlags.getFlagsFromPositions(
|
||||
positions.toTypedArray()
|
||||
)
|
||||
preferences.migrateFlags().set(newValue)
|
||||
}
|
||||
.positiveButton(R.string.migrate) {
|
||||
@ -160,6 +152,7 @@ class SearchController(
|
||||
.negativeButton(R.string.copy) {
|
||||
(targetController as? SearchController)?.copyManga()
|
||||
}
|
||||
.neutralButton(android.R.string.cancel)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
|
||||
// Apply remote categories
|
||||
status.onNext(FavoritesSyncStatus.Processing("Updating category names"))
|
||||
applyRemoteCategories(errorList, favorites.second)
|
||||
applyRemoteCategories(favorites.second)
|
||||
|
||||
// Apply change sets
|
||||
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 newLocalCategories = localCategories.toMutableList()
|
||||
|
Loading…
x
Reference in New Issue
Block a user