|  | @@ -1,18 +1,23 @@
 | 
											
												
													
														|  |  package eu.kanade.tachiyomi.widget.preference
 |  |  package eu.kanade.tachiyomi.widget.preference
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -import android.support.v7.app.AlertDialog
 |  | 
 | 
											
												
													
														|  | -import android.support.v7.preference.PreferenceDialogFragmentCompat
 |  | 
 | 
											
												
													
														|  | 
 |  | +import android.app.Dialog
 | 
											
												
													
														|  | 
 |  | +import android.app.DialogFragment
 | 
											
												
													
														|  | 
 |  | +import android.content.DialogInterface
 | 
											
												
													
														|  | 
 |  | +import android.content.Intent
 | 
											
												
													
														|  | 
 |  | +import android.os.Bundle
 | 
											
												
													
														|  |  import android.text.Editable
 |  |  import android.text.Editable
 | 
											
												
													
														|  |  import android.text.TextWatcher
 |  |  import android.text.TextWatcher
 | 
											
												
													
														|  |  import android.text.method.PasswordTransformationMethod
 |  |  import android.text.method.PasswordTransformationMethod
 | 
											
												
													
														|  |  import android.view.View
 |  |  import android.view.View
 | 
											
												
													
														|  | 
 |  | +import com.afollestad.materialdialogs.MaterialDialog
 | 
											
												
													
														|  |  import com.dd.processbutton.iml.ActionProcessButton
 |  |  import com.dd.processbutton.iml.ActionProcessButton
 | 
											
												
													
														|  | 
 |  | +import eu.kanade.tachiyomi.R
 | 
											
												
													
														|  |  import eu.kanade.tachiyomi.data.preference.PreferencesHelper
 |  |  import eu.kanade.tachiyomi.data.preference.PreferencesHelper
 | 
											
												
													
														|  |  import eu.kanade.tachiyomi.ui.setting.SettingsActivity
 |  |  import eu.kanade.tachiyomi.ui.setting.SettingsActivity
 | 
											
												
													
														|  |  import kotlinx.android.synthetic.main.pref_account_login.view.*
 |  |  import kotlinx.android.synthetic.main.pref_account_login.view.*
 | 
											
												
													
														|  |  import rx.Subscription
 |  |  import rx.Subscription
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -abstract class LoginDialogPreference : PreferenceDialogFragmentCompat() {
 |  | 
 | 
											
												
													
														|  | 
 |  | +abstract class LoginDialogPreference : DialogFragment() {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      var v: View? = null
 |  |      var v: View? = null
 | 
											
												
													
														|  |          private set
 |  |          private set
 | 
											
										
											
												
													
														|  | @@ -22,13 +27,18 @@ abstract class LoginDialogPreference : PreferenceDialogFragmentCompat() {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      var requestSubscription: Subscription? = null
 |  |      var requestSubscription: Subscription? = null
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    override fun onPrepareDialogBuilder(builder: AlertDialog.Builder) {
 |  | 
 | 
											
												
													
														|  | -        // Hide positive button
 |  | 
 | 
											
												
													
														|  | -        builder.setPositiveButton("", this)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    override fun onCreateDialog(savedState: Bundle?): Dialog {
 | 
											
												
													
														|  | 
 |  | +        val dialog = MaterialDialog.Builder(activity)
 | 
											
												
													
														|  | 
 |  | +                .customView(R.layout.pref_account_login, false)
 | 
											
												
													
														|  | 
 |  | +                .negativeText(android.R.string.cancel)
 | 
											
												
													
														|  | 
 |  | +                .build();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        onViewCreated(dialog.view, savedState)
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        return dialog
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    override fun onBindDialogView(view: View) {
 |  | 
 | 
											
												
													
														|  | -        super.onBindDialogView(view)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    override fun onViewCreated(view: View, savedState: Bundle?) {
 | 
											
												
													
														|  |          v = view.apply {
 |  |          v = view.apply {
 | 
											
												
													
														|  |              show_password.setOnCheckedChangeListener { v, isChecked ->
 |  |              show_password.setOnCheckedChangeListener { v, isChecked ->
 | 
											
												
													
														|  |                  if (isChecked)
 |  |                  if (isChecked)
 | 
											
										
											
												
													
														|  | @@ -59,10 +69,16 @@ abstract class LoginDialogPreference : PreferenceDialogFragmentCompat() {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    override fun onDialogClosed(positiveResult: Boolean) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +    override fun onPause() {
 | 
											
												
													
														|  | 
 |  | +        super.onPause()
 | 
											
												
													
														|  |          requestSubscription?.unsubscribe()
 |  |          requestSubscription?.unsubscribe()
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    override fun onDismiss(dialog: DialogInterface) {
 | 
											
												
													
														|  | 
 |  | +        super.onDismiss(dialog)
 | 
											
												
													
														|  | 
 |  | +        targetFragment?.onActivityResult(targetRequestCode, arguments.getInt("key"), Intent())
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      protected abstract fun checkLogin()
 |  |      protected abstract fun checkLogin()
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      protected abstract fun setCredentialsOnView(view: View)
 |  |      protected abstract fun setCredentialsOnView(view: View)
 |