diff --git a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/PinFragment.kt b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/PinFragment.kt
index 99c9e21..ec3e69b 100644
--- a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/PinFragment.kt
+++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/PinFragment.kt
@@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
@@ -36,10 +37,16 @@ class PinFragment : Fragment() {
}
private fun goToNextFragment() {
- viewModel.setUserPin(
- binding!!.pinEditText.text.toString()
- )
- findNavController().navigate(R.id.action_pinFragment_to_canFragment)
+ val enteredPin1 = binding!!.pinEditText.editText?.text.toString()
+ if (enteredPin1.length in 4..12) {
+ viewModel.setUserPin(
+ binding!!.pinEditText.editText?.text.toString()
+ )
+ findNavController().navigate(R.id.action_pinFragment_to_canFragment)
+ } else {
+ Toast.makeText(requireContext(), getString(R.string.length_pin), Toast.LENGTH_SHORT)
+ .show()
+ }
}
private fun goToTheStart() {
diff --git a/MobileAuthApp/app/src/main/res/layout/fragment_pin.xml b/MobileAuthApp/app/src/main/res/layout/fragment_pin.xml
index 250b816..a2668b8 100644
--- a/MobileAuthApp/app/src/main/res/layout/fragment_pin.xml
+++ b/MobileAuthApp/app/src/main/res/layout/fragment_pin.xml
@@ -19,20 +19,38 @@
+ android:orientation="vertical"
+ android:padding="20dp">
-
+ app:counterEnabled="true"
+ app:counterMaxLength="12"
+ app:endIconMode="password_toggle"
+ app:errorEnabled="true"
+ app:helperText="@string/example_pin"
+ app:helperTextEnabled="true"
+ app:startIconDrawable="@drawable/can_logo">
+
+
+
+
@@ -42,20 +60,20 @@
android:id="@+id/next_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/next_text"
android:layout_marginTop="24dp"
- app:layout_constraintTop_toBottomOf="@id/card_view"
+ android:text="@string/next_text"
+ app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/cancel_button"
- app:layout_constraintEnd_toEndOf="parent"/>
+ app:layout_constraintTop_toBottomOf="@id/card_view" />
+ app:layout_constraintTop_toBottomOf="@id/card_view" />
\ No newline at end of file
diff --git a/MobileAuthApp/app/src/main/res/values/strings.xml b/MobileAuthApp/app/src/main/res/values/strings.xml
index ac03c59..b82e7fe 100644
--- a/MobileAuthApp/app/src/main/res/values/strings.xml
+++ b/MobileAuthApp/app/src/main/res/values/strings.xml
@@ -1,6 +1,6 @@
Mobile Authenticator
- This is home fragment
+ Work in progress
ALUSTA
EDASI
@@ -9,6 +9,8 @@
Palun sisesta PIN1
PIN1
+ Näide. 1234
+ PIN1 lubatud pikkus on 4-12
Näide. 123456