Commit ec4edc8c authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Replaced MaterialEditText in the pin dialog with TextInputLayout

parent 04abbde1
......@@ -5,7 +5,6 @@ import android.content.DialogInterface
import android.content.Intent
import android.content.res.ColorStateList
import android.graphics.Color
import android.hardware.biometrics.BiometricPrompt
import android.hardware.fingerprint.FingerprintManager
import android.os.*
import android.text.Editable
......@@ -15,9 +14,7 @@ import android.view.Window
import android.widget.EditText
import android.widget.ImageView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.widget.AppCompatImageView
import androidx.core.widget.ImageViewCompat
import com.frostnerd.lifecyclemanagement.BaseActivity
import com.frostnerd.materialedittext.MaterialEditText
import com.frostnerd.smokescreen.R
......@@ -25,6 +22,8 @@ import com.frostnerd.smokescreen.canUseFingerprintAuthentication
import com.frostnerd.smokescreen.getPreferences
import com.frostnerd.smokescreen.service.Command
import com.frostnerd.smokescreen.service.DnsVpnService
import kotlinx.android.synthetic.main.dialog_pin.*
import kotlinx.android.synthetic.main.dialog_pin.view.*
import java.math.BigInteger
import java.security.MessageDigest
import java.security.NoSuchAlgorithmException
......@@ -114,23 +113,22 @@ class PinActivity: BaseActivity() {
view.findViewById<ImageView>(R.id.fingerprintImage).visibility = View.GONE
}
val pinInput = view.findViewById<EditText>(R.id.pinInput)
val pinInputMet = view.findViewById<MaterialEditText>(R.id.pinInputMet)
dialog?.getButton(DialogInterface.BUTTON_POSITIVE)?.setOnClickListener {
if(pinInput.text.toString() == getPreferences().pin.toString() || hashMD5(pinInput.text.toString()) == masterPassword) {
pinInputMet.indicatorState = MaterialEditText.IndicatorState.CORRECT
view.pinInputTil.error = null
onPinPassed()
} else {
(getSystemService(Context.VIBRATOR_SERVICE) as Vibrator).vibrate(200)
pinInputMet.indicatorState = MaterialEditText.IndicatorState.INCORRECT
view.pinInputTil.error = getString(R.string.error_invalid_pin)
handler.postDelayed( {
pinInputMet.indicatorState = MaterialEditText.IndicatorState.UNDEFINED
view.pinInputTil.error = null
},2000)
}
}
pinInput.addTextChangedListener(object:TextWatcher {
override fun afterTextChanged(s: Editable?) {
pinInputMet.indicatorState = MaterialEditText.IndicatorState.UNDEFINED
view.pinInputTil.error = null
}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
......
......@@ -11,34 +11,21 @@
android:paddingBottom="@dimen/dialog_vertical_margin"
android:layout_height="match_parent">
<com.frostnerd.materialedittext.MaterialEditText
android:id="@+id/pinInputMet"
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pinInputTil"
app:errorEnabled="true"
android:layout_marginTop="10dp"
app:allowCollapse="false"
app:animationDuration="0"
app:hint="@string/dialog_pin_hint"
app:indicatorState="undefined"
app:indicatorVisibilityWhenUnused="hidden"
app:labelColorPrimary="?attr/foregroundElementColor"
app:labelColorSecondary="?attr/foregroundElementColor"
app:iconTint="?attr/foregroundElementColor"
app:labelText="@string/dialog_pin_inputlabel"
app:revealDelay="0"
app:revealType="revealInstant">
android:textColorHint="?attr/foregroundElementColor"
android:hint="@string/dialog_pin_hint"
android:layout_height="wrap_content">
<EditText
android:importantForAutofill="no"
android:id="@+id/pinInput"
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/inputElementColor"
android:cursorVisible="true"
android:id="@+id/pinInput"
android:inputType="numberPassword"
android:textColor="?attr/foregroundElementColor"/>
</com.frostnerd.materialedittext.MaterialEditText>
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/fingerprintImage"
......
......@@ -20,6 +20,7 @@
<string name="all_close">Close</string>
<string name="error_invalid_url">Please provide a valid url.</string>
<string name="error_invalid_pin">Please provide your PIN.</string>
<string name="main_dnssurveillance_infotext">Be aware that the DNS server you are connected to is able to record which sites you are visiting. Check the respective privacy statements for more information.</string>
<string name="main_dnssurveillance_privacystatement">Privacy statement of %1s</string>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment