Release v6.8.1

This commit is contained in:
NerdNumber9
2018-02-14 17:21:29 -05:00
parent 2b7c0e8e80
commit 5447bd098b
11 changed files with 122 additions and 41 deletions

View File

@ -7,12 +7,37 @@ import com.afollestad.materialdialogs.MaterialDialog
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.util.launchUI
import eu.kanade.tachiyomi.util.toast
import timber.log.Timber
import kotlin.concurrent.thread
class ConfiguringDialogController : DialogController() {
private var materialDialog: MaterialDialog? = null
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
if(savedViewState == null)
thread {
try {
EHConfigurator().configureAll()
launchUI {
activity?.toast("Settings successfully uploaded!")
}
} catch (e: Exception) {
activity?.let {
it.runOnUiThread {
MaterialDialog.Builder(it)
.title("Configuration failed!")
.content("An error occurred during the configuration process: " + e.message)
.positiveText("Ok")
.show()
}
}
Timber.e(e, "Configuration error!")
}
launchUI {
finish()
}
}
return MaterialDialog.Builder(activity!!)
.title("Uploading settings to server")
.content("Please wait, this may take some time...")
@ -23,31 +48,6 @@ class ConfiguringDialogController : DialogController() {
}
}
override fun onAttach(view: View) {
super.onAttach(view)
thread {
try {
EHConfigurator().configureAll()
launchUI {
activity?.toast("Settings successfully uploaded!")
}
} catch (e: Exception) {
activity?.let {
it.runOnUiThread {
MaterialDialog.Builder(it)
.title("Configuration failed!")
.content("An error occurred during the configuration process: " + e.message)
.positiveText("Ok")
.show()
}
}
}
launchUI {
finish()
}
}
}
override fun onDestroyView(view: View) {
super.onDestroyView(view)
materialDialog = null

View File

@ -33,7 +33,7 @@ class EHConfigurator {
.add("profile_set", set)
.build())
.build())
.execute().asJsoup()
.execute()
private val EHentai.uconfigUrl get() = baseUrl + UCONFIG_URL
@ -81,7 +81,7 @@ class EHConfigurator {
if(it.text() == PROFILE_NAME) {
val id = it.attr("value")
//Delete old profile
lastDoc = source.execProfileActions("delete", "", id, id.toInt())
lastDoc = source.execProfileActions("delete", "", id, id.toInt()).asJsoup()
}
}
@ -97,7 +97,7 @@ class EHConfigurator {
//Create profile in available slot
val slot = availableProfiles.first()
source.execProfileActions("create",
val response = source.execProfileActions("create",
PROFILE_NAME,
slot.toString(),
1)
@ -111,8 +111,15 @@ class EHConfigurator {
.post(form)
.build()).execute()
//Persist slot
//Persist slot + sk
source.spPref().set(slot)
val keyCookie = response.headers().toMultimap()["Set-Cookie"]?.find {
it.startsWith("sk=")
}?.removePrefix("sk=")?.substringBefore(';')
if(keyCookie != null)
prefs.eh_settingsKey().set(keyCookie)
}
companion object {

View File

@ -0,0 +1,41 @@
package exh.uconfig
import android.app.Dialog
import android.os.Bundle
import com.afollestad.materialdialogs.MaterialDialog
import com.bluelinelabs.conductor.Router
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
class WarnConfigureDialogController : DialogController() {
private val prefs: PreferencesHelper by injectLazy()
override fun onCreateDialog(savedState: Bundle?): Dialog {
return MaterialDialog.Builder(activity!!)
.title("Settings profile note")
.content("""
The app will now add a new settings profile on E-Hentai and ExHentai to optimize app performance. Please ensure that you have less than three profiles on both sites.
If you have no idea what settings profiles are, then it probably doesn't matter, just hit 'OK'.
""".trimIndent())
.positiveText(android.R.string.ok)
.onPositive { _, _ ->
prefs.eh_showSettingsUploadWarning().set(false)
ConfiguringDialogController().showDialog(router)
}
.cancelable(false)
.build()
}
companion object {
fun uploadSettings(router: Router) {
if(Injekt.get<PreferencesHelper>().eh_showSettingsUploadWarning().getOrDefault())
WarnConfigureDialogController().showDialog(router)
else
ConfiguringDialogController().showDialog(router)
}
}
}

View File

@ -15,6 +15,7 @@ import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.online.all.EHentai
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import exh.EXH_SOURCE_ID
import exh.uconfig.WarnConfigureDialogController
import kotlinx.android.synthetic.main.eh_activity_login.view.*
import rx.Observable
import rx.android.schedulers.AndroidSchedulers
@ -102,6 +103,7 @@ class LoginController : NucleusController<LoginPresenter>() {
val eh = sourceManager
.getOnlineSources()
.find { it.id == EXH_SOURCE_ID } as EHentai
Observable.fromCallable {
//I honestly have no idea why we need to call this twice, but it works, so whatever
try {
@ -115,6 +117,9 @@ class LoginController : NucleusController<LoginPresenter>() {
.subscribe {
progressDialog.dismiss()
router.popCurrentController()
//Upload settings
WarnConfigureDialogController.uploadSettings(router)
}
}