diff --git a/app/src/main/java/com/etesync/syncadapter/ui/setup/EncryptionDetailsFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/setup/EncryptionDetailsFragment.kt index 1863edfd..eee8a2e9 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/setup/EncryptionDetailsFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/setup/EncryptionDetailsFragment.kt @@ -9,6 +9,7 @@ package com.etesync.syncadapter.ui.setup import android.os.Bundle +import android.support.design.widget.TextInputLayout import android.support.v4.app.Fragment import android.view.LayoutInflater import android.view.View @@ -18,10 +19,9 @@ import android.widget.TextView import com.etesync.syncadapter.Constants import com.etesync.syncadapter.R -import com.etesync.syncadapter.ui.widget.EditPassword class EncryptionDetailsFragment : Fragment() { - internal var editPassword: EditPassword? = null + internal lateinit var editPassword: TextInputLayout override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { @@ -35,7 +35,7 @@ class EncryptionDetailsFragment : Fragment() { val accountName = v.findViewById(R.id.account_name) as TextView accountName.text = getString(R.string.login_encryption_account_label) + " " + config.userName - editPassword = v.findViewById(R.id.encryption_password) as EditPassword + editPassword = v.findViewById(R.id.encryption_password) as TextInputLayout val btnCreate = v.findViewById(R.id.create_account) as Button btnCreate.setOnClickListener(View.OnClickListener { @@ -54,9 +54,9 @@ class EncryptionDetailsFragment : Fragment() { private fun validateEncryptionData(config: BaseConfigurationFinder.Configuration): BaseConfigurationFinder.Configuration? { var valid = true - val password = editPassword!!.text.toString() + val password = editPassword.editText?.text.toString() if (password.isEmpty()) { - editPassword!!.setError(getString(R.string.login_password_required)) + editPassword.error = getString(R.string.login_password_required) valid = false } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/setup/LoginCredentialsFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/setup/LoginCredentialsFragment.kt index 5f74c9ff..fc8361c4 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/setup/LoginCredentialsFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/setup/LoginCredentialsFragment.kt @@ -9,6 +9,7 @@ package com.etesync.syncadapter.ui.setup import android.os.Bundle +import android.support.design.widget.TextInputLayout import android.support.v4.app.Fragment import android.view.LayoutInflater import android.view.View @@ -20,14 +21,13 @@ import android.widget.TextView import com.etesync.syncadapter.Constants import com.etesync.syncadapter.R import com.etesync.syncadapter.ui.WebViewActivity -import com.etesync.syncadapter.ui.widget.EditPassword import net.cachapa.expandablelayout.ExpandableLayout import okhttp3.HttpUrl import java.net.URI class LoginCredentialsFragment : Fragment() { internal lateinit var editUserName: EditText - internal lateinit var editUrlPassword: EditPassword + internal lateinit var editUrlPassword: TextInputLayout internal lateinit var showAdvanced: CheckedTextView internal lateinit var customServer: EditText @@ -37,7 +37,7 @@ class LoginCredentialsFragment : Fragment() { val v = inflater.inflate(R.layout.login_credentials_fragment, container, false) editUserName = v.findViewById(R.id.user_name) as EditText - editUrlPassword = v.findViewById(R.id.url_password) as EditPassword + editUrlPassword = v.findViewById(R.id.url_password) as TextInputLayout showAdvanced = v.findViewById(R.id.show_advanced) as CheckedTextView customServer = v.findViewById(R.id.custom_server) as EditText @@ -50,7 +50,7 @@ class LoginCredentialsFragment : Fragment() { val password = intent.getStringExtra(LoginActivity.EXTRA_PASSWORD) editUserName.setText(username) - editUrlPassword.setText(password) + editUrlPassword.editText?.setText(password) } } @@ -94,9 +94,9 @@ class LoginCredentialsFragment : Fragment() { valid = false } - val password = editUrlPassword.text.toString() + val password = editUrlPassword.editText?.text.toString() if (password.isEmpty()) { - editUrlPassword.setError(getString(R.string.login_password_required)) + editUrlPassword.error = getString(R.string.login_password_required) valid = false } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/widget/EditPassword.kt b/app/src/main/java/com/etesync/syncadapter/ui/widget/EditPassword.kt deleted file mode 100644 index d3a79289..00000000 --- a/app/src/main/java/com/etesync/syncadapter/ui/widget/EditPassword.kt +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - */ - -package com.etesync.syncadapter.ui.widget - -import android.content.Context -import android.text.Editable -import android.util.AttributeSet -import android.view.View -import android.view.inputmethod.EditorInfo -import android.widget.CheckBox -import android.widget.EditText -import android.widget.LinearLayout -import com.etesync.syncadapter.R - -class EditPassword : LinearLayout { - - internal var editPassword: EditText - - val text: Editable - get() = editPassword.text - - init { - View.inflate(context, R.layout.edit_password, this) - - editPassword = findViewById(R.id.password) as EditText - } - - constructor(context: Context) : super(context) {} - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - editPassword.setHint(attrs.getAttributeResourceValue(NS_ANDROID, "hint", 0)) - editPassword.setText(attrs.getAttributeValue(NS_ANDROID, "text")) - - val checkShowPassword = findViewById(R.id.show_password) as CheckBox - checkShowPassword.setOnCheckedChangeListener { buttonView, isChecked -> - var inputType = editPassword.inputType and EditorInfo.TYPE_MASK_VARIATION.inv() - inputType = inputType or if (isChecked) EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD else EditorInfo.TYPE_TEXT_VARIATION_PASSWORD - editPassword.inputType = inputType - } - } - - fun setError(error: CharSequence) { - editPassword.error = error - } - - fun setText(text: CharSequence) { - editPassword.setText(text) - } - - companion object { - private val NS_ANDROID = "http://schemas.android.com/apk/res/android" - } - -} diff --git a/app/src/main/res/drawable/password_eye_button.xml b/app/src/main/res/drawable/password_eye_button.xml deleted file mode 100644 index 24e23ca7..00000000 --- a/app/src/main/res/drawable/password_eye_button.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/edit_password.xml b/app/src/main/res/layout/edit_password.xml deleted file mode 100644 index 2657452a..00000000 --- a/app/src/main/res/layout/edit_password.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/login_credentials_fragment.xml b/app/src/main/res/layout/login_credentials_fragment.xml index c97fc02d..c2be7b58 100644 --- a/app/src/main/res/layout/login_credentials_fragment.xml +++ b/app/src/main/res/layout/login_credentials_fragment.xml @@ -8,10 +8,11 @@ --> + xmlns:tools="http://schemas.android.com/tools" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> - + app:passwordToggleEnabled="true"> + + + + xmlns:app="http://schemas.android.com/apk/res-auto" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> - + app:passwordToggleEnabled="true"> + +