necessary,
This commit is contained in:
Rani Sargees 2020-05-01 20:57:14 -04:00 committed by Jobobby04
commit bc44eee5b7
20 changed files with 140 additions and 148 deletions

View File

@ -145,7 +145,7 @@ class Hitomi : HttpSource(), LewdSource<HitomiSearchMetadata, Document>, UrlImpo
} }
} }
uploadDate = DATE_FORMAT.parse(input.selectFirst(".gallery-info .date").text()).time uploadDate = DATE_FORMAT.parse(input.selectFirst(".gallery-info .date").text())!!.time
} }
} }

View File

@ -68,7 +68,7 @@ class NHentai(context: Context) : HttpSource(), LewdSource<NHentaiSearchMetadata
val langFilter = filters.filterIsInstance<filterLang>().firstOrNull() val langFilter = filters.filterIsInstance<filterLang>().firstOrNull()
var langFilterString = "" var langFilterString = ""
if (langFilter != null) { if (langFilter != null) {
langFilterString = SOURCE_LANG_LIST.first { it.first == langFilter!!.values[langFilter!!.state] }.second langFilterString = SOURCE_LANG_LIST.first { it.first == langFilter.values[langFilter.state] }.second
} }
val uri = if (query.isNotBlank()) { val uri = if (query.isNotBlank()) {

View File

@ -230,7 +230,7 @@ class PervEden(override val id: Long, val pvLang: PervEdenLang) : ParsedHttpSour
}) })
try { try {
date_upload = DATE_FORMAT.parse(element.getElementsByClass("chapterDate").first().text().trim()).time date_upload = DATE_FORMAT.parse(element.getElementsByClass("chapterDate").first().text().trim())!!.time
} catch (ignored: Exception) { } catch (ignored: Exception) {
} }
} }

View File

@ -64,7 +64,7 @@ class Tsumino(delegate: HttpSource) : DelegatedHttpSource(delegate),
} }
input.getElementById("Uploaded")?.text()?.let { input.getElementById("Uploaded")?.text()?.let {
uploadDate = TM_DATE_FORMAT.parse(it.trim()).time uploadDate = TM_DATE_FORMAT.parse(it.trim())!!.time
} }
input.getElementById("Pages")?.text()?.let { input.getElementById("Pages")?.text()?.let {

View File

@ -642,16 +642,16 @@ class LibraryController(
} }
private fun buildDialog() = activity?.let { private fun buildDialog() = activity?.let {
MaterialDialog.Builder(it) MaterialDialog(it)
} }
private fun showSyncProgressDialog() { private fun showSyncProgressDialog() {
favSyncDialog?.dismiss() favSyncDialog?.dismiss()
favSyncDialog = buildDialog() favSyncDialog = buildDialog()
?.title("Favorites syncing") ?.title(text = "Favorites syncing")
?.cancelable(false) ?.cancelable(false)
?.progress(true, 0) // ?.progress(true, 0)
?.show() favSyncDialog?.show()
} }
private fun takeSyncLocks() { private fun takeSyncLocks() {
@ -675,47 +675,43 @@ class LibraryController(
favSyncDialog?.dismiss() favSyncDialog?.dismiss()
favSyncDialog = buildDialog() favSyncDialog = buildDialog()
?.title("Favorites sync error") ?.title(text = "Favorites sync error")
?.content(status.message + " Sync will not start until the gallery is in only one category.") ?.message(text = status.message + " Sync will not start until the gallery is in only one category.")
?.cancelable(false) ?.cancelable(false)
?.positiveText("Show gallery") ?.positiveButton(text = "Show gallery") {
?.onPositive { _, _ ->
openManga(status.manga) openManga(status.manga)
presenter.favoritesSync.status.onNext(FavoritesSyncStatus.Idle()) presenter.favoritesSync.status.onNext(FavoritesSyncStatus.Idle())
} }
?.negativeText("Ok") ?.negativeButton(android.R.string.ok) {
?.onNegative { _, _ ->
presenter.favoritesSync.status.onNext(FavoritesSyncStatus.Idle()) presenter.favoritesSync.status.onNext(FavoritesSyncStatus.Idle())
} }
?.show() favSyncDialog?.show()
} }
is FavoritesSyncStatus.Error -> { is FavoritesSyncStatus.Error -> {
releaseSyncLocks() releaseSyncLocks()
favSyncDialog?.dismiss() favSyncDialog?.dismiss()
favSyncDialog = buildDialog() favSyncDialog = buildDialog()
?.title("Favorites sync error") ?.title(text = "Favorites sync error")
?.content("An error occurred during the sync process: ${status.message}") ?.message(text = "An error occurred during the sync process: ${status.message}")
?.cancelable(false) ?.cancelable(false)
?.positiveText("Ok") ?.positiveButton(android.R.string.ok) {
?.onPositive { _, _ ->
presenter.favoritesSync.status.onNext(FavoritesSyncStatus.Idle()) presenter.favoritesSync.status.onNext(FavoritesSyncStatus.Idle())
} }
?.show() favSyncDialog?.show()
} }
is FavoritesSyncStatus.CompleteWithErrors -> { is FavoritesSyncStatus.CompleteWithErrors -> {
releaseSyncLocks() releaseSyncLocks()
favSyncDialog?.dismiss() favSyncDialog?.dismiss()
favSyncDialog = buildDialog() favSyncDialog = buildDialog()
?.title("Favorites sync complete with errors") ?.title(text = "Favorites sync complete with errors")
?.content("Errors occurred during the sync process that were ignored:\n${status.message}") ?.message(text = "Errors occurred during the sync process that were ignored:\n${status.message}")
?.cancelable(false) ?.cancelable(false)
?.positiveText("Ok") ?.positiveButton(android.R.string.ok) {
?.onPositive { _, _ ->
presenter.favoritesSync.status.onNext(FavoritesSyncStatus.Idle()) presenter.favoritesSync.status.onNext(FavoritesSyncStatus.Idle())
} }
?.show() favSyncDialog?.show()
} }
is FavoritesSyncStatus.Processing, is FavoritesSyncStatus.Processing,
is FavoritesSyncStatus.Initializing -> { is FavoritesSyncStatus.Initializing -> {
@ -726,7 +722,7 @@ class LibraryController(
&& oldSyncStatus !is FavoritesSyncStatus.Processing)) && oldSyncStatus !is FavoritesSyncStatus.Processing))
showSyncProgressDialog() showSyncProgressDialog()
favSyncDialog?.setContent(status.message) favSyncDialog?.message(text = status.message)
} }
} }
oldSyncStatus = status oldSyncStatus = status

View File

@ -27,15 +27,14 @@ class MigrationMangaDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
mangaSet, ( mangaSet, (
if (mangaSkipped > 0) " " + applicationContext?.getString(R.string.skipping_, mangaSkipped) if (mangaSkipped > 0) " " + applicationContext?.getString(R.string.skipping_, mangaSkipped)
else "")) ?: "" else "")) ?: ""
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.content(confirmString) .message(text = confirmString)
.positiveText(if (copy) R.string.copy else R.string.migrate) .positiveButton(if (copy) R.string.copy else R.string.migrate) {
.negativeText(android.R.string.no)
.onPositive { _, _ ->
if (copy) if (copy)
(targetController as? MigrationListController)?.copyMangas() (targetController as? MigrationListController)?.copyMangas()
else else
(targetController as? MigrationListController)?.migrateMangas() (targetController as? MigrationListController)?.migrateMangas()
}.show() }
.negativeButton(android.R.string.no)
} }
} }

View File

@ -419,13 +419,12 @@ class MigrationListController(bundle: Bundle? = null) : BaseController<Migration
override fun handleBack(): Boolean { override fun handleBack(): Boolean {
activity?.let { activity?.let {
MaterialDialog.Builder(it).title(R.string.stop_migrating) MaterialDialog(it).title(R.string.stop_migrating)
.positiveText(R.string.action_stop) .positiveButton(R.string.action_stop) {
.negativeText(android.R.string.cancel)
.onPositive { _, _ ->
router.popCurrentController() router.popCurrentController()
migrationsJob?.cancel() migrationsJob?.cancel()
} }
.negativeButton(android.R.string.cancel)
.show() .show()
} }
return true return true

View File

@ -200,12 +200,11 @@ class SettingsEhController : SettingsController() {
summary = "Performs a full resynchronization on the next sync. Removals will not be synced. All favorites in the app will be re-uploaded to ExHentai and all favorites on ExHentai will be re-downloaded into the app. Useful for repairing sync after sync has been interrupted." summary = "Performs a full resynchronization on the next sync. Removals will not be synced. All favorites in the app will be re-uploaded to ExHentai and all favorites on ExHentai will be re-downloaded into the app. Useful for repairing sync after sync has been interrupted."
onClick { onClick {
activity?.let { activity?.let { activity ->
MaterialDialog.Builder(it) MaterialDialog(activity)
.title("Are you sure?") .title(R.string.eh_force_sync_reset_title)
.content("Resetting the sync state can cause your next sync to be extremely slow.") .message(R.string.eh_force_sync_reset_message)
.positiveText("Yes") .positiveButton(android.R.string.yes) {
.onPositive { _, _ ->
LocalFavoritesStorage().apply { LocalFavoritesStorage().apply {
getRealm().use { getRealm().use {
it.trans { it.trans {
@ -213,9 +212,9 @@ class SettingsEhController : SettingsController() {
} }
} }
} }
it.toast("Sync state reset", Toast.LENGTH_LONG) activity.toast("Sync state reset", Toast.LENGTH_LONG)
} }
.negativeText("No") .negativeButton(android.R.string.no)
.cancelable(false) .cancelable(false)
.show() .show()
} }
@ -281,11 +280,10 @@ class SettingsEhController : SettingsController() {
title = "Show updater statistics" title = "Show updater statistics"
onClick { onClick {
val progress = MaterialDialog.Builder(context) val progress = MaterialDialog(context)
.progress(true, 0) .message(R.string.eh_show_update_statistics_dialog)
.content("Collecting statistics...")
.cancelable(false) .cancelable(false)
.show() progress.show()
GlobalScope.launch(Dispatchers.IO) { GlobalScope.launch(Dispatchers.IO) {
val updateInfo = try { val updateInfo = try {
@ -330,10 +328,10 @@ class SettingsEhController : SettingsController() {
} }
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
MaterialDialog.Builder(context) MaterialDialog(context)
.title("Gallery updater statistics") .title(text = "Gallery updater statistics")
.content(updateInfo) .message(text = updateInfo)
.positiveText("Ok") .positiveButton(android.R.string.ok)
.show() .show()
} }
} }

View File

@ -8,6 +8,7 @@ import android.widget.TextView
import androidx.core.text.HtmlCompat import androidx.core.text.HtmlCompat
import androidx.preference.PreferenceScreen import androidx.preference.PreferenceScreen
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import eu.kanade.tachiyomi.ui.setting.SettingsController import eu.kanade.tachiyomi.ui.setting.SettingsController
import eu.kanade.tachiyomi.util.preference.defaultValue import eu.kanade.tachiyomi.util.preference.defaultValue
import eu.kanade.tachiyomi.util.preference.onClick import eu.kanade.tachiyomi.util.preference.onClick
@ -43,12 +44,12 @@ class SettingsDebugController : SettingsController() {
try { try {
val result = it.call(DebugFunctions) val result = it.call(DebugFunctions)
view.text = "Function returned result:\n\n$result" view.text = "Function returned result:\n\n$result"
MaterialDialog.Builder(context) MaterialDialog(context)
.customView(hView, true) .customView(view = hView, scrollable = true)
} catch (t: Throwable) { } catch (t: Throwable) {
view.text = "Function threw exception:\n\n${Log.getStackTraceString(t)}" view.text = "Function threw exception:\n\n${Log.getStackTraceString(t)}"
MaterialDialog.Builder(context) MaterialDialog(context)
.customView(hView, true) .customView(view = hView, scrollable = true)
}.show() }.show()
} }
} }

View File

@ -9,11 +9,10 @@ import uy.kohesive.injekt.injectLazy
class FavoritesIntroDialog { class FavoritesIntroDialog {
private val prefs: PreferencesHelper by injectLazy() private val prefs: PreferencesHelper by injectLazy()
fun show(context: Context) = MaterialDialog.Builder(context) fun show(context: Context) = MaterialDialog(context)
.title("IMPORTANT FAVORITES SYNC NOTES") .title(text = "IMPORTANT FAVORITES SYNC NOTES")
.content(HtmlCompat.fromHtml(FAVORITES_INTRO_TEXT, HtmlCompat.FROM_HTML_MODE_LEGACY)) .message(text = HtmlCompat.fromHtml(FAVORITES_INTRO_TEXT, HtmlCompat.FROM_HTML_MODE_LEGACY))
.positiveText("Ok") .positiveButton(android.R.string.ok) {
.onPositive { _, _ ->
prefs.eh_showSyncIntro().set(false) prefs.eh_showSyncIntro().set(false)
} }
.cancelable(false) .cancelable(false)

View File

@ -24,10 +24,10 @@ class ConfiguringDialogController : DialogController() {
} catch (e: Exception) { } catch (e: Exception) {
activity?.let { activity?.let {
it.runOnUiThread { it.runOnUiThread {
MaterialDialog.Builder(it) MaterialDialog(it)
.title("Configuration failed!") .title(text = "Configuration failed!")
.content("An error occurred during the configuration process: " + e.message) .message(text = "An error occurred during the configuration process: " + e.message)
.positiveText("Ok") .positiveButton(android.R.string.ok)
.show() .show()
} }
} }
@ -38,12 +38,11 @@ class ConfiguringDialogController : DialogController() {
} }
} }
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.title("Uploading settings to server") .title(text = "Uploading settings to server")
.content("Please wait, this may take some time...") .message(text = "Please wait, this may take some time...")
.progress(true, 0)
.cancelable(false) .cancelable(false)
.build().also { .also {
materialDialog = it materialDialog = it
} }
} }

View File

@ -12,21 +12,19 @@ import uy.kohesive.injekt.injectLazy
class WarnConfigureDialogController : DialogController() { class WarnConfigureDialogController : DialogController() {
private val prefs: PreferencesHelper by injectLazy() private val prefs: PreferencesHelper by injectLazy()
override fun onCreateDialog(savedState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.title("Settings profile note") .title(text = "Settings profile note")
.content(""" .message(text = """
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. 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'. If you have no idea what settings profiles are, then it probably doesn't matter, just hit 'OK'.
""".trimIndent()) """.trimIndent())
.positiveText(android.R.string.ok) .positiveButton(android.R.string.ok) {
.onPositive { _, _ ->
prefs.eh_showSettingsUploadWarning().set(false) prefs.eh_showSettingsUploadWarning().set(false)
ConfiguringDialogController().showDialog(router) ConfiguringDialogController().showDialog(router)
} }
.cancelable(false) .cancelable(false)
.build()
} }
companion object { companion object {

View File

@ -143,13 +143,12 @@ class BatchAddController : NucleusController<EhFragmentBatchAddBinding, BatchAdd
private fun noGalleriesSpecified() { private fun noGalleriesSpecified() {
activity?.let { activity?.let {
MaterialDialog.Builder(it) MaterialDialog(it)
.title("No galleries to add!") .title(text = "No galleries to add!")
.content("You must specify at least one gallery to add!") .message(text = "You must specify at least one gallery to add!")
.positiveText("Ok") .positiveButton(android.R.string.ok) { materialDialog -> materialDialog.dismiss() }
.onPositive { materialDialog, _ -> materialDialog.dismiss() }
.cancelable(true) .cancelable(true)
.canceledOnTouchOutside(true) .cancelOnTouchOutside(true)
.show() .show()
} }
} }

View File

@ -175,12 +175,12 @@ class BrowserActionActivity : AppCompatActivity() {
Timber.e(IllegalStateException("Captcha solve failure!")) Timber.e(IllegalStateException("Captcha solve failure!"))
runOnUiThread { runOnUiThread {
webview.evaluateJavascript(SOLVE_UI_SCRIPT_HIDE, null) webview.evaluateJavascript(SOLVE_UI_SCRIPT_HIDE, null)
MaterialDialog.Builder(this) MaterialDialog(this)
.title("Captcha solve failure") .title(text = "Captcha solve failure")
.content("Failed to auto-solve the captcha!") .message(text = "Failed to auto-solve the captcha!")
.cancelable(true) .cancelable(true)
.canceledOnTouchOutside(true) .cancelOnTouchOutside(true)
.positiveText("Ok") .positiveButton(android.R.string.ok)
.show() .show()
} }
} }

View File

@ -4,6 +4,8 @@ import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.MenuItem import android.view.MenuItem
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.callbacks.onCancel
import com.afollestad.materialdialogs.callbacks.onDismiss
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.EhActivityInterceptBinding import eu.kanade.tachiyomi.databinding.EhActivityInterceptBinding
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
@ -67,14 +69,14 @@ class InterceptActivity : BaseRxActivity<EhActivityInterceptBinding, InterceptAc
is InterceptResult.Failure -> { is InterceptResult.Failure -> {
binding.interceptProgress.gone() binding.interceptProgress.gone()
binding.interceptStatus.text = "Error: ${it.reason}" binding.interceptStatus.text = "Error: ${it.reason}"
MaterialDialog.Builder(this) MaterialDialog(this)
.title("Error") .title(text = "Error")
.content("Could not open this gallery:\n\n${it.reason}") .message(text = "Could not open this gallery:\n\n${it.reason}")
.cancelable(true) .cancelable(true)
.canceledOnTouchOutside(true) .cancelOnTouchOutside(true)
.positiveText("Ok") .positiveButton(android.R.string.ok)
.cancelListener { onBackPressed() } .onCancel { onBackPressed() }
.dismissListener { onBackPressed() } .onDismiss { onBackPressed() }
.show() .show()
} }
} }

View File

@ -11,10 +11,12 @@ import android.widget.TextView
import androidx.appcompat.widget.LinearLayoutCompat import androidx.appcompat.widget.LinearLayoutCompat
import androidx.preference.SwitchPreferenceCompat import androidx.preference.SwitchPreferenceCompat
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import com.github.ajalt.reprint.core.AuthenticationResult import com.github.ajalt.reprint.core.AuthenticationResult
import com.github.ajalt.reprint.core.Reprint import com.github.ajalt.reprint.core.Reprint
import com.github.ajalt.reprint.rxjava.RxReprint import com.github.ajalt.reprint.rxjava.RxReprint
import com.mattprecious.swirl.SwirlView import com.mattprecious.swirl.SwirlView
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.util.preference.onChange import eu.kanade.tachiyomi.util.preference.onChange
@ -106,14 +108,13 @@ class FingerLockPreference @JvmOverloads constructor(context: Context, attrs: At
addView(statusTextView) addView(statusTextView)
addView(iconView) addView(iconView)
} }
val dialog = MaterialDialog.Builder(context) val dialog = MaterialDialog(context)
.title("Fingerprint verification") .title(text = "Fingerprint verification")
.customView(linearLayout, false) .customView(view = linearLayout)
.negativeText("Cancel") .negativeButton(R.string.action_cancel)
.autoDismiss(true)
.cancelable(true) .cancelable(true)
.canceledOnTouchOutside(true) .cancelOnTouchOutside(true)
.show() dialog.show()
iconView.setState(SwirlView.State.ON) iconView.setState(SwirlView.State.ON)
val subscription = RxReprint.authenticate() val subscription = RxReprint.authenticate()
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
@ -130,13 +131,12 @@ class FingerLockPreference @JvmOverloads constructor(context: Context, attrs: At
statusTextView.text = result.errorMessage statusTextView.text = result.errorMessage
} }
AuthenticationResult.Status.FATAL_FAILURE, null -> { AuthenticationResult.Status.FATAL_FAILURE, null -> {
MaterialDialog.Builder(context) MaterialDialog(context)
.title("Fingerprint verification failed!") .title(text = "Fingerprint verification failed!")
.content(result.errorMessage) .message(text = result.errorMessage)
.positiveText("Ok") .positiveButton(android.R.string.ok)
.autoDismiss(true)
.cancelable(true) .cancelable(true)
.canceledOnTouchOutside(false) .cancelOnTouchOutside(false)
.show() .show()
dialog.dismiss() dialog.dismiss()
} }

View File

@ -52,13 +52,12 @@ class LockController : NucleusController<ActivityLockBinding, LockPresenter>() {
// Yay! // Yay!
closeLock() closeLock()
} else { } else {
MaterialDialog.Builder(context) MaterialDialog(context)
.title("PIN code incorrect") .title(text = "PIN code incorrect")
.content("The PIN code you entered is incorrect. Please try again.") .message(text = "The PIN code you entered is incorrect. Please try again.")
.cancelable(true) .cancelable(true)
.canceledOnTouchOutside(true) .cancelOnTouchOutside(true)
.positiveText("Ok") .positiveButton(android.R.string.ok)
.autoDismiss(true)
.show() .show()
binding.pinLockView.resetPinLockView() binding.pinLockView.resetPinLockView()
} }
@ -105,13 +104,12 @@ class LockController : NucleusController<ActivityLockBinding, LockPresenter>() {
AuthenticationResult.Status.SUCCESS -> closeLock() AuthenticationResult.Status.SUCCESS -> closeLock()
AuthenticationResult.Status.NONFATAL_FAILURE -> icon.setState(SwirlView.State.ERROR) AuthenticationResult.Status.NONFATAL_FAILURE -> icon.setState(SwirlView.State.ERROR)
AuthenticationResult.Status.FATAL_FAILURE, null -> { AuthenticationResult.Status.FATAL_FAILURE, null -> {
MaterialDialog.Builder(context) MaterialDialog(context)
.title("Fingerprint error!") .title(text = "Fingerprint error!")
.content(it.errorMessage) .message(text = it.errorMessage)
.cancelable(false) .cancelable(false)
.canceledOnTouchOutside(false) .cancelOnTouchOutside(false)
.positiveText("Ok") .positiveButton(android.R.string.ok)
.autoDismiss(true)
.show() .show()
icon.setState(SwirlView.State.OFF) icon.setState(SwirlView.State.OFF)
} }

View File

@ -5,6 +5,7 @@ import android.text.InputType
import android.util.AttributeSet import android.util.AttributeSet
import androidx.preference.SwitchPreferenceCompat import androidx.preference.SwitchPreferenceCompat
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.input.input
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.util.preference.onChange import eu.kanade.tachiyomi.util.preference.onChange
@ -44,17 +45,16 @@ class LockPreference @JvmOverloads constructor(context: Context, attrs: Attribut
fun tryChange() { fun tryChange() {
if (!notifyLockSecurity(context)) { if (!notifyLockSecurity(context)) {
MaterialDialog.Builder(context) MaterialDialog(context)
.title("Lock application") .title(text = "Lock application")
.content("Enter a pin to lock the application. Enter nothing to disable the pin lock.") .message(text = "Enter a pin to lock the application. Enter nothing to disable the pin lock.")
.inputRangeRes(0, 10, R.color.material_red_500) // .inputRangeRes(0, 10, R.color.material_red_500)
.inputType(InputType.TYPE_CLASS_NUMBER) // .inputType(InputType.TYPE_CLASS_NUMBER)
.input("", "", { _, c -> .input(maxLength = 10, inputType = InputType.TYPE_CLASS_NUMBER, allowEmpty = true) { _, c ->
val progressDialog = MaterialDialog.Builder(context) val progressDialog = MaterialDialog(context)
.title("Saving password") .title(text = "Saving password")
.progress(true, 0)
.cancelable(false) .cancelable(false)
.show() progressDialog.show()
Observable.fromCallable { Observable.fromCallable {
savePassword(c.toString()) savePassword(c.toString())
}.subscribeOn(Schedulers.computation()) }.subscribeOn(Schedulers.computation())
@ -63,11 +63,10 @@ class LockPreference @JvmOverloads constructor(context: Context, attrs: Attribut
progressDialog.dismiss() progressDialog.dismiss()
updateSummary() updateSummary()
} }
}) }
.negativeText("Cancel") .negativeButton(R.string.action_cancel)
.autoDismiss(true)
.cancelable(true) .cancelable(true)
.canceledOnTouchOutside(true) .cancelOnTouchOutside(true)
.show() .show()
} }
} }

View File

@ -54,30 +54,27 @@ fun notifyLockSecurity(
return false return false
if (!prefs.eh_lockManually().getOrDefault() && if (!prefs.eh_lockManually().getOrDefault() &&
!hasAccessToUsageStats(context)) { !hasAccessToUsageStats(context)) {
MaterialDialog.Builder(context) MaterialDialog(context)
.title("Permission required") .title(text = "Permission required")
.content("${context.getString(R.string.app_name)} requires the usage stats permission to detect when you leave the app. " + .message(text = "${context.getString(R.string.app_name)} requires the usage stats permission to detect when you leave the app. " +
"This is required for the application lock to function properly. " + "This is required for the application lock to function properly. " +
"Press OK to grant this permission now.") "Press OK to grant this permission now.")
.negativeText("Cancel") .negativeButton(R.string.action_cancel)
.positiveText("Ok") .positiveButton(android.R.string.ok) {
.onPositive { _, _ ->
try { try {
context.startActivity(Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS)) context.startActivity(Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS))
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
XLog.e("Device does not support USAGE_ACCESS_SETTINGS shortcut!") XLog.e("Device does not support USAGE_ACCESS_SETTINGS shortcut!")
MaterialDialog.Builder(context) MaterialDialog(context)
.title("Grant permission manually") .title(text = "Grant permission manually")
.content("Failed to launch the window used to grant the usage stats permission. " + .message(text = "Failed to launch the window used to grant the usage stats permission. " +
"You can still grant this permission manually: go to your phone's settings and search for 'usage access'.") "You can still grant this permission manually: go to your phone's settings and search for 'usage access'.")
.positiveText("Ok") .positiveButton(android.R.string.ok) { it.dismiss() }
.onPositive { dialog, _ -> dialog.dismiss() }
.cancelable(true) .cancelable(true)
.canceledOnTouchOutside(false) .cancelOnTouchOutside(false)
.show() .show()
} }
} }
.autoDismiss(true)
.cancelable(false) .cancelable(false)
.show() .show()
return true return true

View File

@ -710,6 +710,14 @@
<string name="eh_rounded_corners_desc">The level of radius that the corners are rounded to. Current value is: %s</string> <string name="eh_rounded_corners_desc">The level of radius that the corners are rounded to. Current value is: %s</string>
<string name="merge">Merge with current</string> <string name="merge">Merge with current</string>
<string name="eh_merge_with_another_source">Merge With Another</string> <string name="eh_merge_with_another_source">Merge With Another</string>
<string name="eh_autoscroll_help">Autoscroll help</string>
<string name="eh_autoscroll_help_message">Automatically scroll to the next page in the specified interval. Interval is specified in seconds.</string>
<string name="eh_retry_all_help">Retry all help</string>
<string name="eh_retry_all_help_message">Re-add all failed pages to the download queue.</string>
<string name="eh_boost_page_help">Boost page help</string>
<string name="eh_boost_page_help_message">Normally the downloader can only download a specific amount of pages at the same time. This means you can be waiting for a page to download but the downloader will not start downloading the page until it has a free download slot. Pressing \'Boost page\' will force the downloader to begin downloading the current page, regardless of whether or not there is an available slot.</string>
<string name="eh_force_sync_reset_title">Are you sure?</string>
<string name="eh_force_sync_reset_message">Resetting the sync state can cause your next sync to be extremely slow.</string>
<string name="eh_show_update_statistics_dialog">Collecting statistics…</string>
</resources> </resources>