|
|
|
@ -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)
|
|
|
|
|