Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/res/drawable/ic_key_round.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M12.65,10C11.83,7.67 9.61,6 7,6c-3.31,0 -6,2.69 -6,6s2.69,6 6,6c2.61,0 4.83,-1.67 5.65,-4H17v4h4v-4h2v-4H12.65zM7,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
</vector>
27 changes: 11 additions & 16 deletions app/res/layout/fragment_recovery_code.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,23 +212,22 @@
android:textSize="16sp"
android:visibility="gone"/>

<androidx.constraintlayout.widget.ConstraintLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/not_me_button"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/personalid_this_is_not_me"
android:textColor="@color/cc_brand_color"
android:textSize="14sp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:clickable="true"
android:layout_marginEnd="10dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toStartOf="@id/connect_backup_code_button"
app:layout_constraintBottom_toBottomOf="parent"
android:visibility="gone"
android:textStyle="bold"/>

Expand All @@ -237,17 +236,13 @@
style="@style/CustomButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_gravity="end"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="@string/personalid_continue_label"
android:drawableRight="@drawable/connect_right_arrow"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
android:drawableRight="@drawable/connect_right_arrow"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</layout>
43 changes: 32 additions & 11 deletions app/res/layout/personalid_profile_screen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,41 @@
android:layout_marginTop="16dp"
android:background="@color/grey_light" />

<com.google.android.material.button.MaterialButton
android:id="@+id/profile_btn_forget_personalid"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/personalid_profile_forget_account"
android:textAllCaps="false"
android:textColor="@color/white"
android:layout_gravity="center"
android:textSize="14sp"
app:backgroundTint="@color/red_700"
app:icon="@drawable/ic_personalid_forget_warning"
app:iconGravity="textStart"
app:iconTint="@null" />
android:layout_marginTop="32dp"
android:orientation="vertical">

<com.google.android.material.button.MaterialButton
android:id="@+id/profile_change_backup_code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/personalid_profile_change_backup_code"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="14sp"
app:backgroundTint="@color/connect_dark_blue_color"
app:icon="@drawable/ic_key_round"
app:iconGravity="textStart"
app:iconTint="@null" />

<com.google.android.material.button.MaterialButton
android:id="@+id/profile_btn_forget_personalid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/personalid_profile_forget_account"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="14sp"
app:backgroundTint="@color/red_700"
app:icon="@drawable/ic_personalid_forget_warning"
app:iconGravity="textStart"
app:iconTint="@null" />

</LinearLayout>

</LinearLayout>
</ScrollView>
21 changes: 21 additions & 0 deletions app/res/navigation/nav_graph_personalid_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<action
android:id="@+id/action_profile_to_profile_edit"
app:destination="@id/personalid_profile_edit_fragment" />
<action
android:id="@+id/action_profile_to_profile_backup_code"
app:destination="@id/personalid_profile_backup_code_fragment" />
</fragment>

<fragment
Expand All @@ -38,4 +41,22 @@
android:name="emailOtpRequestCount"
app:argType="integer" />
</fragment>

<fragment
android:id="@+id/personalid_profile_backup_code_fragment"
android:name="org.commcare.personalId.profile.PersonalIdProfileBackupCodeFragment"
android:label="@string/connect_backup_code_title_confirm">
<action
android:id="@+id/action_profile_backup_code_to_set_new_backup_code"
app:destination="@id/personalid_set_new_backup_code_fragment" />
<action
android:id="@+id/action_profile_backup_code_to_email_verification"
app:destination="@id/personalid_email_verification_fragment" />
</fragment>

<fragment
android:id="@+id/personalid_set_new_backup_code_fragment"
android:name="org.commcare.personalId.profile.SetNewBackupCodeFragment"
android:label="@string/personalid_set_new_backup_code_title" />

</navigation>
5 changes: 5 additions & 0 deletions app/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@
<string name="personalid_profile_edit_save">Guardar</string>
<string name="personalid_profile_edit_cancel">Cancelar</string>
<string name="personalid_profile_edit_save_success">Tu perfil se ha actualizado correctamente.</string>
<string name="personalid_profile_change_backup_code">Cambiar código de respaldo</string>
<string name="personalid_forgot_backup_code">¿Olvidaste tu código de respaldo?</string>
<string name="personalid_backup_code_too_many_attempts">Demasiados intentos. Por favor, inténtalo de nuevo más tarde.</string>
<string name="personalid_no_email_forgot_backup_code_toast">Por favor, añade una dirección de correo electrónico</string>
<string name="personalid_set_new_backup_code_title">Establecer nuevo código de respaldo</string>
<string name="connect_job_info_delivery_detail">Detalles de la entrega</string>
<string name="connect_job_info_review_delivery">Revisar detalles de la entrega</string>
<string name="connect_job_info_visit">%d visitas máximo</string>
Expand Down
5 changes: 5 additions & 0 deletions app/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@ License.
<string name="personalid_profile_edit_save">Enregistrer</string>
<string name="personalid_profile_edit_cancel">Annuler</string>
<string name="personalid_profile_edit_save_success">Votre profil a été mis à jour avec succès.</string>
<string name="personalid_profile_change_backup_code">Changer le code de sauvegarde</string>
<string name="personalid_forgot_backup_code">Vous avez oublié votre code de sauvegarde ?</string>
<string name="personalid_backup_code_too_many_attempts">Trop de tentatives. Veuillez réessayer plus tard.</string>
<string name="personalid_no_email_forgot_backup_code_toast">Veuillez ajouter une adresse e-mail</string>
<string name="personalid_set_new_backup_code_title">Définir un nouveau code de sauvegarde</string>
<string name="connect_job_info_delivery_detail">Détails de livraison</string>
<string name="connect_job_info_review_delivery">Vérifiez les détails de livraison</string>
<string name="connect_job_info_visit">%d visites maximum</string>
Expand Down
5 changes: 5 additions & 0 deletions app/res/values-ha/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ Don cikakken aiki na wurin zama na aikace-aikace da yawa, da fatan za a yi sabon
<string name="personalid_profile_edit_save">Ajiye</string>
<string name="personalid_profile_edit_cancel">Soke</string>
<string name="personalid_profile_edit_save_success">An sabunta bayanan martabarka cikin nasara.</string>
<string name="personalid_profile_change_backup_code">Canza lambar sirrin ajiyar bayanai</string>
<string name="personalid_forgot_backup_code">Ka manta da lambar sirrin ajiyar bayananka?</string>
<string name="personalid_backup_code_too_many_attempts">Yunkuri da yawa. Da fatan za a sake gwadawa daga baya.</string>
<string name="personalid_no_email_forgot_backup_code_toast">Da fatan za a ƙara adireshin imel</string>
<string name="personalid_set_new_backup_code_title">Saita sabuwar lambar sirrin ajiyar bayanai</string>
<string name="connect_job_info_delivery_detail">Cikakkun Bayanan Isarwa</string>
<string name="connect_job_info_review_delivery">Yi bitar cikakkun bayanai game da isar da kaya</string>
<string name="connect_job_info_visit">Matsakaicin Ziyarar %d</string>
Expand Down
4 changes: 4 additions & 0 deletions app/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ License.
<string name="personalid_profile_edit_save">सहेजें</string>
<string name="personalid_profile_edit_cancel">रद्द करें</string>
<string name="personalid_profile_edit_save_success">आपकी प्रोफ़ाइल सफलतापूर्वक अपडेट कर दी गई है।</string>
<string name="personalid_profile_change_backup_code">बैकअप कोड बदलें</string>
<string name="personalid_forgot_backup_code">अपना बैकअप कोड भूल गए?</string>
<string name="personalid_backup_code_too_many_attempts">Too many attempts. Please try again later.</string>
<string name="personalid_no_email_forgot_backup_code_toast">Please add an email address</string>
<string name="connect_job_info_delivery_detail">वितरण विवरण</string>
<string name="connect_job_info_review_delivery">वितरण विवरण की समीक्षा करें</string>
<string name="connect_job_info_visit">अधिकतम %d विज़िट</string>
Expand Down
4 changes: 4 additions & 0 deletions app/res/values-lt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
<string name="personalid_profile_edit_save">Išsaugoti</string>
<string name="personalid_profile_edit_cancel">Atšaukti</string>
<string name="personalid_profile_edit_save_success">Jūsų profilis sėkmingai atnaujintas.</string>
<string name="personalid_profile_change_backup_code">Keisti atsarginį kodą</string>
<string name="personalid_forgot_backup_code">Pamiršote savo atsarginį kodą?</string>
<string name="personalid_backup_code_too_many_attempts">Too many attempts. Please try again later.</string>
<string name="personalid_no_email_forgot_backup_code_toast">Please add an email address</string>
<string name="nav_drawer_signin_register">Prisijungti / Registruotis</string>
<string name="nav_drawer_help">Pagalba</string>
<string name="nav_drawer_not_signed_in_to_personal_id">Neprisijungta prie „PersonalID“</string>
Expand Down
4 changes: 4 additions & 0 deletions app/res/values-no/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
<string name="personalid_profile_edit_save">Lagre</string>
<string name="personalid_profile_edit_cancel">Avbryt</string>
<string name="personalid_profile_edit_save_success">Profilen din er oppdatert.</string>
<string name="personalid_profile_change_backup_code">Endre sikkerhetskode</string>
<string name="personalid_forgot_backup_code">Glemt sikkerhetskoden din?</string>
<string name="personalid_backup_code_too_many_attempts">Too many attempts. Please try again later.</string>
<string name="personalid_no_email_forgot_backup_code_toast">Please add an email address</string>
<string name="nav_drawer_signin_register">Logg inn / Registrer deg</string>
<string name="nav_drawer_help">Hjelp</string>
<string name="nav_drawer_not_signed_in_to_personal_id">Du er ikke logget inn med PersonalID</string>
Expand Down
5 changes: 5 additions & 0 deletions app/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@
<string name="personalid_profile_edit_save">Salvar</string>
<string name="personalid_profile_edit_cancel">Cancelar</string>
<string name="personalid_profile_edit_save_success">Seu perfil foi atualizado com sucesso.</string>
<string name="personalid_profile_change_backup_code">Alterar código de backup</string>
<string name="personalid_forgot_backup_code">Esqueceu o seu código de backup?</string>
<string name="personalid_backup_code_too_many_attempts">Muitas tentativas. Por favor, tente novamente mais tarde.</string>
<string name="personalid_no_email_forgot_backup_code_toast">Por favor, adicione um endereço de e-mail</string>
<string name="personalid_set_new_backup_code_title">Definir novo código de backup</string>
<string name="connect_job_info_delivery_detail">Detalhes da entrega</string>
<string name="connect_job_info_review_delivery">Revise os detalhes da entrega</string>
<string name="connect_job_info_visit">%d máximo de visitas</string>
Expand Down
4 changes: 4 additions & 0 deletions app/res/values-sw/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@
<string name="personalid_profile_edit_save">Hifadhi</string>
<string name="personalid_profile_edit_cancel">Ghairi</string>
<string name="personalid_profile_edit_save_success">Wasifu wako umesasishwa kwa mafanikio.</string>
<string name="personalid_profile_change_backup_code">Badilisha nambari ya hifadhi nakala</string>
<string name="personalid_forgot_backup_code">Umesahau nambari yako ya hifadhi nakala?</string>
<string name="personalid_backup_code_too_many_attempts">Too many attempts. Please try again later.</string>
<string name="personalid_no_email_forgot_backup_code_toast">Please add an email address</string>
<string name="connect_job_info_delivery_detail">Maelezo ya Uwasilishaji</string>
<string name="connect_job_info_review_delivery">Kagua maelezo ya utoaji</string>
<string name="connect_job_info_visit">%d upeo wa Ziara</string>
Expand Down
5 changes: 5 additions & 0 deletions app/res/values-ti/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@
<string name="personalid_profile_edit_save">ኣቐምጥ</string>
<string name="personalid_profile_edit_cancel">ሰርዝ</string>
<string name="personalid_profile_edit_save_success">ፕሮፋይልኩም ብዓወት ተሐዲሱ።</string>
<string name="personalid_profile_change_backup_code">ናይ ምትካእ ኮድ ቀይር</string>
<string name="personalid_forgot_backup_code">ናይ ምትካእ ኮድካ ረሲዕካ?</string>
<string name="personalid_backup_code_too_many_attempts">ብዙሕ ፈተናታት። በጃኻ ድሕሪ ሕጂ እንደገና ፈትን።</string>
<string name="personalid_no_email_forgot_backup_code_toast">በጃኻ ናይ ኢ-መይል ኣድራሻ ወስኽ</string>
<string name="personalid_set_new_backup_code_title">ሓድሽ ናይ ምትካእ ኮድ ኣቐምጥ</string>
<string name="connect_job_info_delivery_detail">ዝርዝር (ኣተገባብራ)ኣወሃህባ</string>
<string name="connect_job_info_review_delivery">ዝርዝር ኣወሃህባ ዳህሳስ ከልስ</string>
<string name="connect_job_info_visit">%d ዝለዓለ ምብጻሕ</string>
Expand Down
5 changes: 5 additions & 0 deletions app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@
<string name="connect_backup_code_message">Enter your 6-digit Backup Code</string>
<string name="connect_backup_code_remember">Please be sure to remember your backup code! It must be %d digits. Keep it in a safe place as you will need it to access your account again.</string>
<string name="connect_backup_code_mismatch">The backup codes you enter must match.</string>
<string name="personalid_set_new_backup_code_title">Set New Backup Code</string>

<string name="connect_backup_fail_title">Wrong Backup Code</string>
<string name="personalid_network_response_parsing_error">Error parsing data from server. Please contact customer support.</string>
Expand Down Expand Up @@ -797,6 +798,10 @@
<string name="personalid_photo_capture_take_photo_button">Take Photo</string>
<string name="personalid_photo_capture_save_photo_button">Save Photo</string>
<string name="personalid_this_is_not_me"><u>This is not me</u></string>
<string name="personalid_profile_change_backup_code">Change backup code</string>
<string name="personalid_forgot_backup_code">Forgot your backup code?</string>
<string name="personalid_backup_code_too_many_attempts">Too many attempts. Please try again later.</string>
<string name="personalid_no_email_forgot_backup_code_toast">Please add an email address</string>
<string name="personalid_welcome_back_msg">Welcome back %s</string>
<string name="personalid_wrong_backup_message">You have entered the wrong Backup Code. Please try again. Your account will be locked after %d more incorrect attempts.</string>
<string name="personalid_second_device_login_title">Login on Second Device</string>
Expand Down
11 changes: 11 additions & 0 deletions app/src/org/commcare/fragments/personalId/BackupCodeWorkflow.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.commcare.fragments.personalId

/**
* Identifies which backup-code flow is being executed.
*
* - [CONFIRM_BACKUP_CODE_CHANGE_CODE]: user is on the Manage Profile screen and wants to change
* their backup code; must confirm the current code first before setting a new one.
*/
enum class BackupCodeWorkflow {
CONFIRM_BACKUP_CODE_CHANGE_CODE,
}
Comment on lines +9 to +11

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be used anywhere right now. Where do we anticipate using this workflow?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll mostly be used for analytics which is part of another ticket, I am happy to remove it for now from the PR if you prefer that.

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.commcare.fragments.personalId

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import org.commcare.dalvik.R
import org.commcare.dalvik.databinding.FragmentRecoveryCodeBinding
import org.commcare.views.connect.NumericCodeView

abstract class BasePersonalIdBackupCodeFragment : BasePersonalIdFragment() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This base class isn't doing much beyond inflating the view. I think we should pass the BackupCodeWorkflow mode (e.g., PROFILE_CONFIRM_CODE, PROFILE_CREATE_CODE, SIGNUP_CONFIRM_CODE, SIGNUP_CREATE_CODE) to this base class and configuring the UI (i.e. setting title, hide/show components) directly within this base class for each mode. It should also encapsulate shared behaviors like numeric code listeners rather than duplicating them across every fragment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This base class isn't doing much beyond inflating the view. I think we should pass the BackupCodeWorkflow mode (e.g., PROFILE_CONFIRM_CODE, PROFILE_CREATE_CODE, SIGNUP_CONFIRM_CODE, SIGNUP_CREATE_CODE)

Doesn't it defeat the purpose of abstracting a base class if it needs to implement conditional logic based on a passed constant ?

It should also encapsulate shared behaviors like numeric code listeners rather than duplicating them across every fragment.

Agree that the common code should be abstracted - 6d2c7c8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This base class isn't doing much beyond inflating the view. I think we should pass the BackupCodeWorkflow mode (e.g., PROFILE_CONFIRM_CODE, PROFILE_CREATE_CODE, SIGNUP_CONFIRM_CODE, SIGNUP_CREATE_CODE)

Doesn't it defeat the purpose of abstracting a base class if it needs to implement conditional logic based on a passed constant ?

That's a valid point, but my suggestion stems from the fact that the base class already inflates the main container view. Since PROFILE_CONFIRM_CODE and SIGNUP_CONFIRM_CODE (Recovery mode) share the exact same view—and PROFILE_CREATE_CODE and SIGNUP_CREATE_CODE (Sign up) share theirs—handling this in the base class will significantly reduce code duplication across individual fragments.

protected lateinit var binding: FragmentRecoveryCodeBinding

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View {
binding = FragmentRecoveryCodeBinding.inflate(inflater, container, false)
clearBackupCodeFields()
return binding.root
}

override fun onResume() {
super.onResume()
binding.backupCodeView.requestFocus(requireActivity())
}

protected fun clearBackupCodeFields() {
binding.backupCodeView.clearCode()
binding.confirmCodeView.clearCode()
}

protected open fun submitIfEnabled() {
if (binding.connectBackupCodeButton.isEnabled) handleBackupCodeSubmission()
}

abstract fun handleBackupCodeSubmission()

protected fun togglePasswordVisibility(
codeView: NumericCodeView,
toggle: ImageView,
) {
codeView.isPasswordVisible = !codeView.isPasswordVisible
toggle.setImageResource(
if (codeView.isPasswordVisible) R.drawable.ic_visibility_off_24 else R.drawable.ic_visibility_24,
)
}

protected fun clearError() {
binding.connectBackupCodeErrorMessage.visibility = View.GONE
binding.connectBackupCodeErrorMessage.text = ""
}

protected fun showError(message: String) {
binding.connectBackupCodeErrorMessage.visibility = View.VISIBLE
binding.connectBackupCodeErrorMessage.text = message
}

protected fun enableContinueButton(enabled: Boolean) {
binding.connectBackupCodeButton.isEnabled = enabled
}

companion object {
const val BACKUP_CODE_LENGTH = 6
}
}
Loading
Loading