From 507471e318b62875cd2c4f3acd173000f98985a2 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 7 Mar 2020 22:19:45 -0500 Subject: [PATCH] Label Kitsu login field as email address instead of username --- .../tachiyomi/ui/setting/SettingsTrackingController.kt | 2 +- .../tachiyomi/widget/preference/LoginDialogPreference.kt | 8 +++++++- .../tachiyomi/widget/preference/TrackLoginDialog.kt | 8 ++++++-- app/src/main/res/layout/pref_account_login.xml | 1 + app/src/main/res/values/strings.xml | 1 + 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt index 2a1b08a12..aeb24f37b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt @@ -53,7 +53,7 @@ class SettingsTrackingController : SettingsController(), tabsIntent.launchUrl(activity!!, AnilistApi.authUrl()) } trackPreference(trackManager.kitsu) { - val dialog = TrackLoginDialog(trackManager.kitsu) + val dialog = TrackLoginDialog(trackManager.kitsu, context.getString(R.string.email)) dialog.targetController = this@SettingsTrackingController dialog.showDialog(router) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt index d52c64d1a..5abb672e1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt @@ -15,10 +15,12 @@ import eu.kanade.tachiyomi.widget.SimpleTextWatcher import kotlinx.android.synthetic.main.pref_account_login.view.login import kotlinx.android.synthetic.main.pref_account_login.view.password import kotlinx.android.synthetic.main.pref_account_login.view.show_password +import kotlinx.android.synthetic.main.pref_account_login.view.username_label import rx.Subscription import uy.kohesive.injekt.injectLazy -abstract class LoginDialogPreference(bundle: Bundle? = null) : DialogController(bundle) { +abstract class LoginDialogPreference(private val usernameLabel: String? = null, bundle: Bundle? = null) : + DialogController(bundle) { var v: View? = null private set @@ -47,6 +49,10 @@ abstract class LoginDialogPreference(bundle: Bundle? = null) : DialogController( password.transformationMethod = PasswordTransformationMethod() } + if (!usernameLabel.isNullOrEmpty()) { + username_label.text = usernameLabel + } + login.setMode(ActionProcessButton.Mode.ENDLESS) login.setOnClickListener { checkLogin() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackLoginDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackLoginDialog.kt index 0743c2e02..0dacbfe83 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackLoginDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackLoginDialog.kt @@ -15,11 +15,15 @@ import rx.schedulers.Schedulers import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -class TrackLoginDialog(bundle: Bundle? = null) : LoginDialogPreference(bundle) { +class TrackLoginDialog(usernameLabel: String? = null, bundle: Bundle? = null) : + LoginDialogPreference(usernameLabel, bundle) { private val service = Injekt.get().getService(args.getInt("key"))!! - constructor(service: TrackService) : this(Bundle().apply { putInt("key", service.id) }) + constructor(service: TrackService) : this(service, null) + + constructor(service: TrackService, usernameLabel: String?) : + this(usernameLabel, Bundle().apply { putInt("key", service.id) }) override fun setCredentialsOnView(view: View) = with(view) { dialog_title.text = context.getString(R.string.login_title, service.name) diff --git a/app/src/main/res/layout/pref_account_login.xml b/app/src/main/res/layout/pref_account_login.xml index 3ee779edc..2f772054c 100644 --- a/app/src/main/res/layout/pref_account_login.xml +++ b/app/src/main/res/layout/pref_account_login.xml @@ -23,6 +23,7 @@ android:background="@color/dividerLight" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 232a3cee0..e4395bb17 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -341,6 +341,7 @@ Log in to %1$s Username + Email address Password Show password Login