Albirew/tachiyomi
Archivé
1
0
Bifurcation 0

Use actual dialog title for tracker login dialogs

Cette révision appartient à :
arkon 2020-03-15 17:31:36 -04:00
Parent 3f88a67865
révision 3e5a48e5e4
6 fichiers modifiés avec 31 ajouts et 33 suppressions

Voir le fichier

@ -53,7 +53,7 @@ class SettingsTrackingController : SettingsController(),
tabsIntent.launchUrl(activity!!, AnilistApi.authUrl())
}
trackPreference(trackManager.kitsu) {
val dialog = TrackLoginDialog(trackManager.kitsu, context.getString(R.string.email))
val dialog = TrackLoginDialog(trackManager.kitsu, R.string.email)
dialog.targetController = this@SettingsTrackingController
dialog.showDialog(router)
}

Voir le fichier

@ -4,6 +4,7 @@ import android.app.Dialog
import android.os.Bundle
import android.text.method.PasswordTransformationMethod
import android.view.View
import androidx.annotation.StringRes
import com.afollestad.materialdialogs.MaterialDialog
import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType
@ -19,8 +20,12 @@ import kotlinx.android.synthetic.main.pref_account_login.view.username_label
import rx.Subscription
import uy.kohesive.injekt.injectLazy
abstract class LoginDialogPreference(private val usernameLabel: String? = null, bundle: Bundle? = null) :
DialogController(bundle) {
abstract class LoginDialogPreference(
@StringRes private val titleRes: Int? = null,
private val titleFormatArgs: Any? = null,
@StringRes private val usernameLabelRes: Int? = null,
bundle: Bundle? = null
) : DialogController(bundle) {
var v: View? = null
private set
@ -30,10 +35,15 @@ abstract class LoginDialogPreference(private val usernameLabel: String? = null,
var requestSubscription: Subscription? = null
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
val dialog = MaterialDialog.Builder(activity!!)
var dialogBuilder = MaterialDialog.Builder(activity!!)
.customView(R.layout.pref_account_login, false)
.negativeText(android.R.string.cancel)
.build()
if (titleRes != null) {
dialogBuilder = dialogBuilder.title(activity!!.getString(titleRes, titleFormatArgs))
}
val dialog = dialogBuilder.build()
onViewCreated(dialog.view)
@ -49,8 +59,8 @@ abstract class LoginDialogPreference(private val usernameLabel: String? = null,
password.transformationMethod = PasswordTransformationMethod()
}
if (!usernameLabel.isNullOrEmpty()) {
username_label.hint = usernameLabel
if (usernameLabelRes != null) {
username_label.hint = context.getString(usernameLabelRes)
}
login.setMode(ActionProcessButton.Mode.ENDLESS)

Voir le fichier

@ -2,11 +2,11 @@ package eu.kanade.tachiyomi.widget.preference
import android.os.Bundle
import android.view.View
import androidx.annotation.StringRes
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.data.track.TrackService
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.android.synthetic.main.pref_account_login.view.dialog_title
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.username
@ -15,18 +15,21 @@ import rx.schedulers.Schedulers
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
class TrackLoginDialog(usernameLabel: String? = null, bundle: Bundle? = null) :
LoginDialogPreference(usernameLabel, bundle) {
class TrackLoginDialog(
@StringRes titleRes: Int? = null,
titleFormatArgs: Any? = null,
@StringRes usernameLabelRes: Int? = null,
bundle: Bundle? = null
) : LoginDialogPreference(titleRes, titleFormatArgs, usernameLabelRes, bundle) {
private val service = Injekt.get<TrackManager>().getService(args.getInt("key"))!!
constructor(service: TrackService) : this(service, null)
constructor(service: TrackService, usernameLabel: String?) :
this(usernameLabel, Bundle().apply { putInt("key", service.id) })
constructor(service: TrackService, @StringRes usernameLabelRes: Int?) :
this(R.string.login_title, service.name, usernameLabelRes, Bundle().apply { putInt("key", service.id) })
override fun setCredentialsOnView(view: View) = with(view) {
dialog_title.text = context.getString(R.string.login_title, service.name)
username.setText(service.getUsername())
password.setText(service.getPassword())
}

Voir le fichier

@ -4,7 +4,7 @@ The regular version uses ?attr/colorPrimary when focused, which doesn't work wel
https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/textfield/res/color/mtrl_filled_stroke_color.xml
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorAccent" android:state_focused="true" />
<item android:color="?attr/colorSecondary" android:state_focused="true" />
<item android:alpha="0.87" android:color="?attr/colorOnSurface" android:state_hovered="true" />
<item android:alpha="0.12" android:color="?attr/colorOnSurface" android:state_enabled="false" />
<item android:alpha="0.38" android:color="?attr/colorOnSurface" />

Voir le fichier

@ -4,23 +4,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="24dp">
<TextView
android:id="@+id/dialog_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="16sp"
android:textStyle="bold" />
<View
android:id="@+id/titleDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="6dp"
android:layout_marginBottom="24dp"
android:background="?android:attr/divider" />
android:paddingStart="24dp"
android:paddingEnd="24dp">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/username_label"

Voir le fichier

@ -211,12 +211,12 @@
<style name="Theme.Widget.TextInputLayout.OutlinedBox" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="boxStrokeColor">@color/text_input_stroke</item>
<item name="hintTextColor">?attr/colorAccent</item>
<item name="hintTextColor">?attr/colorSecondary</item>
</style>
<style name="Theme.Widget.TextInputLayout.OutlinedBox.Dense" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
<item name="boxStrokeColor">@color/text_input_stroke</item>
<item name="hintTextColor">?attr/colorAccent</item>
<item name="hintTextColor">?attr/colorSecondary</item>
</style>