mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-19 15:31:13 +01:00
Add hitomi.la preferences screen
Add hitomi.la early refresh Fix some typos in comments
This commit is contained in:
@@ -15,7 +15,6 @@ import android.support.v7.graphics.drawable.DrawerArrowDrawable
|
||||
import android.support.v7.widget.Toolbar
|
||||
import android.view.ViewGroup
|
||||
import com.bluelinelabs.conductor.*
|
||||
import com.jakewharton.rxbinding.support.v7.widget.navigationClicks
|
||||
import eu.kanade.tachiyomi.Migrations
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
@@ -41,11 +40,15 @@ import exh.ui.migration.MetadataFetchDialog
|
||||
import exh.util.defRealm
|
||||
import kotlinx.android.synthetic.main.main_activity.*
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import android.view.View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import com.jakewharton.rxbinding.view.longClicks
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.online.all.Hitomi
|
||||
import eu.kanade.tachiyomi.util.vibrate
|
||||
import exh.HITOMI_SOURCE_ID
|
||||
import rx.schedulers.Schedulers
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
|
||||
class MainActivity : BaseActivity() {
|
||||
@@ -170,6 +173,14 @@ class MainActivity : BaseActivity() {
|
||||
notifyLockSecurity(this)
|
||||
}
|
||||
}
|
||||
|
||||
// Early hitomi.la refresh
|
||||
if(preferences.eh_hl_earlyRefresh().getOrDefault()) {
|
||||
(Injekt.get<SourceManager>().get(HITOMI_SOURCE_ID) as Hitomi)
|
||||
.ensureCacheLoaded(false)
|
||||
.subscribeOn(Schedulers.computation())
|
||||
.subscribe()
|
||||
}
|
||||
// <-- EH
|
||||
|
||||
syncActivityViewWithController(router.backstack.lastOrNull()?.controller())
|
||||
|
||||
58
app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsHlController.kt
Executable file
58
app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsHlController.kt
Executable file
@@ -0,0 +1,58 @@
|
||||
package eu.kanade.tachiyomi.ui.setting
|
||||
|
||||
import android.support.v7.preference.PreferenceScreen
|
||||
import android.widget.Toast
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.online.all.Hitomi
|
||||
import eu.kanade.tachiyomi.util.toast
|
||||
import exh.HITOMI_SOURCE_ID
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
/**
|
||||
* hitomi.la Settings fragment
|
||||
*/
|
||||
|
||||
class SettingsHlController : SettingsController() {
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
||||
title = "hitomi.la"
|
||||
|
||||
editTextPreference {
|
||||
title = "Search database refresh frequency"
|
||||
summary = "How often to get new entries for the search database in hours. Setting this frequency too high may cause high CPU usage and network usage."
|
||||
key = PreferenceKeys.eh_hl_refreshFrequency
|
||||
defaultValue = "24"
|
||||
|
||||
onChange {
|
||||
it as String
|
||||
|
||||
if((it.toLongOrNull() ?: -1) <= 0) {
|
||||
context.toast("Invalid frequency. Frequency must be a positive whole number.")
|
||||
false
|
||||
} else true
|
||||
}
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
title = "Begin refreshing search database on app launch"
|
||||
summary = "Normally the search database gets refreshed (if required) when you open the hitomi.la catalogue. If you enable this option, the database gets refreshed in the background as soon as you open the app. It will result in higher data usage but may increase hitomi.la search speeds."
|
||||
key = PreferenceKeys.eh_hl_earlyRefresh
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
preference {
|
||||
title = "Force refresh search database now"
|
||||
summary = "Delete the local copy of the hitomi.la search database and download the new database now. Hitomi.la searching will not working in the ~10mins that it takes to refresh the search database"
|
||||
isPersistent = false
|
||||
|
||||
onClick {
|
||||
context.toast(if((Injekt.get<SourceManager>().get(HITOMI_SOURCE_ID) as Hitomi).forceEnsureCacheLoaded()) {
|
||||
"Refreshing database. You will NOT be notified when it is complete!"
|
||||
} else {
|
||||
"Could not begin refresh process as there is already one ongoing!"
|
||||
}, Toast.LENGTH_LONG)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,12 @@ class SettingsMainController : SettingsController() {
|
||||
titleRes = R.string.pref_category_nh
|
||||
onClick { navigateTo(SettingsNhController()) }
|
||||
}
|
||||
preference {
|
||||
iconRes = R.drawable.eh_ic_hllogo
|
||||
iconTint = tintColor
|
||||
titleRes = R.string.pref_category_hl
|
||||
onClick { navigateTo(SettingsHlController()) }
|
||||
}
|
||||
preference {
|
||||
iconRes = R.drawable.ic_code_black_24dp
|
||||
iconTint = tintColor
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.support.v7.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||
|
||||
/**
|
||||
* EH Settings fragment
|
||||
* nhentai Settings fragment
|
||||
*/
|
||||
|
||||
class SettingsNhController : SettingsController() {
|
||||
|
||||
Reference in New Issue
Block a user