Merge pull request #5 from TanelOrumaa/viewReworks

PIN1 layout changes
This commit is contained in:
Henrik Lepson 2021-10-06 09:23:46 +03:00 committed by GitHub
commit 634d168378
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 30 deletions

View File

@ -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() {

View File

@ -7,43 +7,73 @@
android:padding="24dp"
tools:context=".PinFragment">
<TextView
android:id="@+id/pin_fragment_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pin_fragment"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<EditText
android:id="@+id/pin_edit_text"
<com.google.android.material.card.MaterialCardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/enter_pin"
android:inputType="numberPassword"
android:layout_margin="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/pin_fragment_text"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp">
<TextView
android:id="@+id/pin_fragment_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="6dp"
android:text="@string/pin_fragment" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/pin_edit_text"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
android:hint="@string/enter_pin"
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">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberPassword"
android:textSize="14sp" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<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/pin_edit_text"
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" />
<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/pin_edit_text"
android:text="@string/cancel_text"
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

@ -1,15 +1,18 @@
<resources>
<string name="app_name">Mobile Authenticator</string>
<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="home_fragment">Work in progress</string>
<string name="begin_text">ALUSTA</string>
<string name="next_text">EDASI</string>
<string name="cancel_text">KATKESTA</string>
<string name="enter_pin">Sisesta PIN</string>
<!-- string resource sfor CanFragment -->
<!-- string resources for PinFragment -->
<string name="pin_fragment">Palun sisesta PIN1</string>
<string name="enter_pin">PIN1</string>
<string name="example_pin">Näide. 1234</string>
<string name="length_pin">PIN1 lubatud pikkus on 4-12</string>
<!-- string resources for CanFragment -->
<string name="example_can">Näide. 123456</string>
<string name="text_can">CAN</string>
<string name="enter_can">Sisesta ID kaardi CAN (Card Access Number)</string>