MOB-14 reworked AuthFragment xml layout + countdown added

This commit is contained in:
Henrik Lepson 2021-10-03 14:46:42 +03:00
parent 7582a317bf
commit 276173365a
4 changed files with 77 additions and 21 deletions

View File

@ -4,7 +4,7 @@
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/Users/henri/Desktop/Tarkvaraprojekt/Estonian-ID-card-mobile-authenticator-POC/MobileAuthApp/app/src/main/res/layout/activity_main.xml" value="0.17300724637681159" />
<entry key="..\:/Users/henri/Desktop/Tarkvaraprojekt/Estonian-ID-card-mobile-authenticator-POC/MobileAuthApp/app/src/main/res/layout/fragment_auth.xml" value="0.1598731884057971" />
<entry key="..\:/Users/henri/Desktop/Tarkvaraprojekt/Estonian-ID-card-mobile-authenticator-POC/MobileAuthApp/app/src/main/res/layout/fragment_auth.xml" value="0.264" />
<entry key="..\:/Users/henri/Desktop/Tarkvaraprojekt/Estonian-ID-card-mobile-authenticator-POC/MobileAuthApp/app/src/main/res/layout/fragment_can.xml" value="0.1598731884057971" />
<entry key="..\:/Users/henri/Desktop/Tarkvaraprojekt/Estonian-ID-card-mobile-authenticator-POC/MobileAuthApp/app/src/main/res/layout/fragment_home.xml" value="0.17300724637681159" />
<entry key="..\:/Users/henri/Desktop/Tarkvaraprojekt/Estonian-ID-card-mobile-authenticator-POC/MobileAuthApp/app/src/main/res/layout/fragment_pin.xml" value="0.1598731884057971" />

View File

@ -1,6 +1,7 @@
package com.tarkvaraprojekt.mobileauthapp
import android.os.Bundle
import android.os.CountDownTimer
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -21,6 +22,10 @@ class AuthFragment : Fragment() {
private var binding: FragmentAuthBinding? = null
private lateinit var timer: CountDownTimer
private var timeRemaining: Int = 90
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@ -32,7 +37,16 @@ class AuthFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
timer = object : CountDownTimer(90000, 1000) {
override fun onTick(p0: Long) {
binding!!.timeCounter.text = getString(R.string.time_left, timeRemaining)
timeRemaining--
}
override fun onFinish() {
binding!!.timeCounter.text = getString(R.string.no_time)
}
}.start()
binding!!.nextButton.setOnClickListener { goToNextFragment() }
binding!!.cancelButton.setOnClickListener { goToTheStart() }
}
@ -42,11 +56,13 @@ class AuthFragment : Fragment() {
viewModel.setUserFirstName("John")
viewModel.setUserLastName("Doe")
viewModel.setUserIdentificationNumber("012345678910")
timer.cancel()
findNavController().navigate(R.id.action_authFragment_to_userFragment)
}
private fun goToTheStart() {
viewModel.clearUserInfo()
timer.cancel()
findNavController().navigate(R.id.action_authFragment_to_homeFragment)
}

View File

@ -7,34 +7,72 @@
android:padding="24dp"
tools:context=".AuthFragment">
<com.google.android.material.card.MaterialCardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20sp">
<TextView
android:id="@+id/auth_fragment_text"
android:id="@+id/auth_fragment_instruction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
android:gravity="center"
android:text="@string/auth_instruction_text"
android:textSize="20sp" />
<ImageView
android:id="@+id/nfc_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/auth_fragment"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
android:layout_gravity="center"
android:layout_margin="6dp"
android:src="@drawable/nfc_logo" />
<TextView
android:id="@+id/time_counter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
android:textSize="14sp"
app:layout_constraintTop_toBottomOf="@id/auth_fragment_instruction"
tools:text="@string/time_left" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<!-- later there will be no button, but the app will continue automatically -->
<Button
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/auth_fragment_text"
android:text="@string/next_text"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/cancel_button"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintTop_toBottomOf="@id/card_view" />
<Button
android:id="@+id/cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel_text"
android:layout_marginTop="24dp"
app:layout_constraintTop_toBottomOf="@id/auth_fragment_text"
android:text="@string/cancel_text"
android:textSize="18sp"
app:layout_constraintEnd_toStartOf="@id/next_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/next_button"/>
app:layout_constraintTop_toBottomOf="@id/card_view" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -3,16 +3,18 @@
<string name="home_fragment">This is home fragment</string>
<string name="pin_fragment">This is pin fragment</string>
<string name="can_fragment">This is can fragment</string>
<string name="auth_fragment">This is auth fragment</string>
<string name="user_fragment">This is user fragment</string>
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="begin_text">Begin</string>
<string name="next_text">Next</string>
<string name="cancel_text">Cancel</string>
<string name="begin_text">ALUSTA</string>
<string name="next_text">EDASI</string>
<string name="cancel_text">KATKESTA</string>
<string name="enter_can">Enter CAN</string>
<string name="enter_pin">Enter PIN</string>
<string name="enter_can">Sisesta CAN</string>
<string name="enter_pin">Sisesta PIN</string>
<!-- string resources for AuthFragment layout -->
<string name="auth_instruction_text">ID kaardiga ühenduse loomiseks pane kaart vastu telefoni</string>
<string name="time_left">Aega on jäänud %d sek</string>
<string name="no_time">Aeg on otsas</string>
<!-- string resources for UserFragment layout -->
<string name="user_name_label">NIMI</string>