Skip to content

Commit aab0b8e

Browse files
committed
Share service as QR code
1 parent ddf5d1d commit aab0b8e

File tree

27 files changed

+253
-40
lines changed

27 files changed

+253
-40
lines changed

core/common/src/main/java/com/twofasapp/common/domain/Service.kt

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.twofasapp.common.domain
22

3+
import android.net.Uri
4+
35
data class Service(
46
val id: Long,
57
val serviceTypeId: String?,
@@ -125,4 +127,44 @@ data class Service(
125127
backupSyncStatus = BackupSyncStatus.SYNCED,
126128
)
127129
}
128-
}
130+
131+
fun toUri(): String {
132+
return Uri.Builder()
133+
.apply {
134+
135+
scheme("otpauth")
136+
137+
authority(authType.name.lowercase())
138+
139+
if (info.isNullOrBlank().not()) {
140+
appendEncodedPath("$name:$info")
141+
} else {
142+
appendEncodedPath(name)
143+
}
144+
145+
appendQueryParameter("secret", secret)
146+
147+
if (issuer.isNullOrBlank().not()) {
148+
appendQueryParameter("issuer", issuer)
149+
}
150+
151+
if (digits != null && digits != DefaultDigits) {
152+
appendQueryParameter("digits", digits.toString())
153+
}
154+
155+
if (period != null && period != DefaultPeriod) {
156+
appendQueryParameter("period", period.toString())
157+
}
158+
159+
if (hotpCounter != null && authType == AuthType.HOTP) {
160+
appendQueryParameter("counter", hotpCounter.toString())
161+
}
162+
163+
if (algorithm != null && algorithm != DefaultAlgorithm) {
164+
appendQueryParameter("algorithm", algorithm.name)
165+
}
166+
167+
}
168+
.toString()
169+
}
170+
}

core/designsystem/src/main/java/com/twofasapp/designsystem/dialog/ListDialog.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import androidx.compose.ui.Alignment
1414
import androidx.compose.ui.Modifier
1515
import androidx.compose.ui.tooling.preview.Preview
1616
import androidx.compose.ui.unit.dp
17+
import com.twofasapp.designsystem.TwTheme
1718

1819
@Composable
1920
fun ListDialog(
@@ -38,6 +39,7 @@ fun ListDialog(
3839
Text(
3940
text = text,
4041
style = MaterialTheme.typography.bodyLarge,
42+
color = TwTheme.color.onSurfacePrimary,
4143
modifier = Modifier
4244
.fillMaxWidth()
4345
.padding(horizontal = DialogPadding)

core/designsystem/src/main/java/com/twofasapp/designsystem/dialog/ListRadioDialog.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ fun ListRadioDialog(
6666
)
6767
Text(
6868
text = text,
69+
color = TwTheme.color.onSurfacePrimary,
6970
style = MaterialTheme.typography.bodyLarge,
7071
modifier = Modifier.padding(start = 16.dp)
7172
)

core/locale/src/main/res/values-de-rDE/strings.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Project: 2FAS App
55
Locale: de-DE, German (Germany)
66
Exported by: rafakob
7-
Exported at: Tue, 14 Jan 2025 04:37:30 -0800
7+
Exported at: Thu, 16 Jan 2025 04:52:12 -0800
88
-->
99
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1010
<!-- InfoPlist.strings
@@ -854,5 +854,8 @@
854854
<string name="widget__no_selected_services">Gedrückt halten und Service auswählen, um das Widget zu aktivieren...</string>
855855
<string name="widget__reveal_tokens_long_message">Decke deine 2FAS-Token für 60 Sekunden auf</string>
856856
<string name="widget__reveal_tokens_short_message">Aufdecken für 60 Sekunden</string>
857-
<string name="settings__show_error_details">Show error details</string>
857+
<string name="settings__show_error_details">Fehlerdetails anzeigen</string>
858+
<string name="tokens__show_qr_code">Zeige Dienst-QR</string>
859+
<string name="tokens__show_service_qr_setup_lock">Dein Dienst ist geschützt. Bitte füge eine PIN oder Fingerabdrucksperre hinzu, um den QR-Code zu sehen.</string>
860+
<string name="tokens__copy_uri">Copy URI</string>
858861
</resources>

core/locale/src/main/res/values-el-rGR/strings.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Project: 2FAS App
55
Locale: el-GR, Greek (Greece)
66
Exported by: rafakob
7-
Exported at: Tue, 14 Jan 2025 04:37:31 -0800
7+
Exported at: Thu, 16 Jan 2025 04:52:12 -0800
88
-->
99
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1010
<!-- InfoPlist.strings
@@ -854,5 +854,8 @@
854854
<string name="widget__no_selected_services">Κρατήστε πατημένο και επιλέξτε service για να ενεργοποιήσετε το widget...</string>
855855
<string name="widget__reveal_tokens_long_message">Αποκαλύψτε τις μάρκες 2FAS για 60 δευτερόλεπτα</string>
856856
<string name="widget__reveal_tokens_short_message">Αποκάλυψη για 60 δευτερόλεπτα</string>
857-
<string name="settings__show_error_details">Show error details</string>
857+
<string name="settings__show_error_details">Εμφάνιση λεπτομερειών σφάλματος</string>
858+
<string name="tokens__show_qr_code">Κωδικός QR Υπηρεσίας</string>
859+
<string name="tokens__show_service_qr_setup_lock">Η υπηρεσία σας είναι προστατευμένη. Παρακαλώ προσθέστε ένα PIN ή κλείδωμα με δακτυλικό αποτύπωμα για να δείτε τον κωδικό QR.</string>
860+
<string name="tokens__copy_uri">Copy URI</string>
858861
</resources>

core/locale/src/main/res/values-es-rES/strings.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Project: 2FAS App
55
Locale: es-ES, Spanish (Spain)
66
Exported by: rafakob
7-
Exported at: Tue, 14 Jan 2025 04:37:30 -0800
7+
Exported at: Thu, 16 Jan 2025 04:52:12 -0800
88
-->
99
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1010
<!-- InfoPlist.strings
@@ -855,4 +855,7 @@
855855
<string name="widget__reveal_tokens_long_message">Revela tus fichas 2FAS durante 60 segundos</string>
856856
<string name="widget__reveal_tokens_short_message">Revela durante 60 segundos</string>
857857
<string name="settings__show_error_details">Show error details</string>
858+
<string name="tokens__show_qr_code">Service QR Code</string>
859+
<string name="tokens__show_service_qr_setup_lock">Your service is protected. Please add a PIN or Fingerprint lock to see QR code.</string>
860+
<string name="tokens__copy_uri">Copy URI</string>
858861
</resources>

core/locale/src/main/res/values-fr-rFR/strings.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Project: 2FAS App
55
Locale: fr-FR, French (France)
66
Exported by: rafakob
7-
Exported at: Tue, 14 Jan 2025 04:37:30 -0800
7+
Exported at: Thu, 16 Jan 2025 04:52:12 -0800
88
-->
99
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1010
<!-- InfoPlist.strings
@@ -854,5 +854,8 @@
854854
<string name="widget__no_selected_services">Maintenir et sélectionner le service pour activer le widget...</string>
855855
<string name="widget__reveal_tokens_long_message">Révéler les jetons 2FAS pendant 60 secondes</string>
856856
<string name="widget__reveal_tokens_short_message">Révéler pendant 60 secondes</string>
857-
<string name="settings__show_error_details">Show error details</string>
857+
<string name="settings__show_error_details">Afficher les détails de l\'erreur</string>
858+
<string name="tokens__show_qr_code">QR Code du service</string>
859+
<string name="tokens__show_service_qr_setup_lock">Le service est protégé. Merci de configurer la protection par PIN ou empreinte pour afficher le QR code.</string>
860+
<string name="tokens__copy_uri">Copy URI</string>
858861
</resources>

core/locale/src/main/res/values-it-rIT/strings.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Project: 2FAS App
55
Locale: it-IT, Italian (Italy)
66
Exported by: rafakob
7-
Exported at: Tue, 14 Jan 2025 04:37:31 -0800
7+
Exported at: Thu, 16 Jan 2025 04:52:12 -0800
88
-->
99
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1010
<!-- InfoPlist.strings
@@ -855,4 +855,7 @@
855855
<string name="widget__reveal_tokens_long_message">Mostra il tuo token 2FAS per 60 secondi</string>
856856
<string name="widget__reveal_tokens_short_message">Mostra per 60 secondi</string>
857857
<string name="settings__show_error_details">Show error details</string>
858+
<string name="tokens__show_qr_code">Service QR Code</string>
859+
<string name="tokens__show_service_qr_setup_lock">Your service is protected. Please add a PIN or Fingerprint lock to see QR code.</string>
860+
<string name="tokens__copy_uri">Copy URI</string>
858861
</resources>

core/locale/src/main/res/values-ja-rJP/strings.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Project: 2FAS App
55
Locale: ja-JP, Japanese (Japan)
66
Exported by: rafakob
7-
Exported at: Tue, 14 Jan 2025 04:37:31 -0800
7+
Exported at: Thu, 16 Jan 2025 04:52:12 -0800
88
-->
99
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1010
<!-- InfoPlist.strings
@@ -848,5 +848,8 @@
848848
<string name="widget__no_selected_services">ウィジェットを有効化するには、サービスを長押しして選択してください...</string>
849849
<string name="widget__reveal_tokens_long_message">2FASのトークンを60秒間表示</string>
850850
<string name="widget__reveal_tokens_short_message">60秒間表示</string>
851-
<string name="settings__show_error_details">Show error details</string>
851+
<string name="settings__show_error_details">エラーの詳細を表示</string>
852+
<string name="tokens__show_qr_code">QRコードの表示</string>
853+
<string name="tokens__show_service_qr_setup_lock">サービスは保護されています。QRコードを表示するにはPINまたは指紋認証のロックを設定してください。</string>
854+
<string name="tokens__copy_uri">Copy URI</string>
852855
</resources>

core/locale/src/main/res/values-nl-rNL/strings.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Project: 2FAS App
55
Locale: nl-NL, Dutch (Netherlands)
66
Exported by: rafakob
7-
Exported at: Tue, 14 Jan 2025 04:37:31 -0800
7+
Exported at: Thu, 16 Jan 2025 04:52:12 -0800
88
-->
99
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1010
<!-- InfoPlist.strings
@@ -855,4 +855,7 @@
855855
<string name="widget__reveal_tokens_long_message">Uw 2FAS tokens voor 60 seconden onthullen</string>
856856
<string name="widget__reveal_tokens_short_message">60 seconden onthullen</string>
857857
<string name="settings__show_error_details">Show error details</string>
858+
<string name="tokens__show_qr_code">Service QR Code</string>
859+
<string name="tokens__show_service_qr_setup_lock">Your service is protected. Please add a PIN or Fingerprint lock to see QR code.</string>
860+
<string name="tokens__copy_uri">Copy URI</string>
858861
</resources>

core/locale/src/main/res/values-pl-rPL/strings.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Project: 2FAS App
55
Locale: pl-PL, Polish (Poland)
66
Exported by: rafakob
7-
Exported at: Tue, 14 Jan 2025 04:37:31 -0800
7+
Exported at: Thu, 16 Jan 2025 04:52:12 -0800
88
-->
99
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1010
<!-- InfoPlist.strings
@@ -860,5 +860,8 @@
860860
<string name="widget__no_selected_services">Przytrzymaj i wybierz serwis, aby aktywować widget...</string>
861861
<string name="widget__reveal_tokens_long_message">Odsłoń swoje tokeny 2FAS na 60 sekund</string>
862862
<string name="widget__reveal_tokens_short_message">Odsłoń na 60 sekund</string>
863-
<string name="settings__show_error_details">Show error details</string>
863+
<string name="settings__show_error_details">Pokaż szczegóły błędu</string>
864+
<string name="tokens__show_qr_code">Kod QR serwisu</string>
865+
<string name="tokens__show_service_qr_setup_lock">Twój serwis jest chroniony. Dodaj kod PIN lub odcisk palca, aby zobaczyć kod QR.</string>
866+
<string name="tokens__copy_uri">Copy URI</string>
864867
</resources>

core/locale/src/main/res/values-pt-rBR/strings.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Project: 2FAS App
55
Locale: pt-BR, Brazilian Portuguese
66
Exported by: rafakob
7-
Exported at: Tue, 14 Jan 2025 04:37:31 -0800
7+
Exported at: Thu, 16 Jan 2025 04:52:12 -0800
88
-->
99
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1010
<!-- InfoPlist.strings
@@ -854,5 +854,8 @@
854854
<string name="widget__no_selected_services">Mantenha pressionado e selecione o serviço para ativar o widget...</string>
855855
<string name="widget__reveal_tokens_long_message">Revele seus tokens 2FAS por 60 segundos</string>
856856
<string name="widget__reveal_tokens_short_message">Revele por 60 segundos</string>
857-
<string name="settings__show_error_details">Show error details</string>
857+
<string name="settings__show_error_details">Mostrar detalhes do erro</string>
858+
<string name="tokens__show_qr_code">Mostrar serviço do QR code</string>
859+
<string name="tokens__show_service_qr_setup_lock">Seu serviço está protegido. Adicione um PIN ou bloqueio de impressão digital para ver o código QR.</string>
860+
<string name="tokens__copy_uri">Copy URI</string>
858861
</resources>

core/locale/src/main/res/values-pt-rPT/strings.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Project: 2FAS App
55
Locale: pt-PT, Portuguese (Portugal)
66
Exported by: rafakob
7-
Exported at: Tue, 14 Jan 2025 04:37:31 -0800
7+
Exported at: Thu, 16 Jan 2025 04:52:12 -0800
88
-->
99
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1010
<!-- InfoPlist.strings
@@ -855,4 +855,7 @@
855855
<string name="widget__reveal_tokens_long_message">Revele as suas fichas 2FAS durante 60 segundos</string>
856856
<string name="widget__reveal_tokens_short_message">Revelar durante 60 segundos</string>
857857
<string name="settings__show_error_details">Show error details</string>
858+
<string name="tokens__show_qr_code">Service QR Code</string>
859+
<string name="tokens__show_service_qr_setup_lock">Your service is protected. Please add a PIN or Fingerprint lock to see QR code.</string>
860+
<string name="tokens__copy_uri">Copy URI</string>
858861
</resources>

core/locale/src/main/res/values-tr-rTR/strings.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Project: 2FAS App
55
Locale: tr-TR, Turkish (Turkey)
66
Exported by: rafakob
7-
Exported at: Tue, 14 Jan 2025 04:37:31 -0800
7+
Exported at: Thu, 16 Jan 2025 04:52:12 -0800
88
-->
99
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1010
<!-- InfoPlist.strings
@@ -855,4 +855,7 @@
855855
<string name="widget__reveal_tokens_long_message">2FAS jetonları 60 saniye boyunca gösterin</string>
856856
<string name="widget__reveal_tokens_short_message">60 saniye boyunca göster</string>
857857
<string name="settings__show_error_details">Show error details</string>
858+
<string name="tokens__show_qr_code">Service QR Code</string>
859+
<string name="tokens__show_service_qr_setup_lock">Your service is protected. Please add a PIN or Fingerprint lock to see QR code.</string>
860+
<string name="tokens__copy_uri">Copy URI</string>
858861
</resources>

core/locale/src/main/res/values-uk-rUA/strings.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Project: 2FAS App
55
Locale: uk-UA, Ukrainian (Ukraine)
66
Exported by: rafakob
7-
Exported at: Tue, 14 Jan 2025 04:37:31 -0800
7+
Exported at: Thu, 16 Jan 2025 04:52:12 -0800
88
-->
99
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1010
<!-- InfoPlist.strings
@@ -861,4 +861,7 @@
861861
<string name="widget__reveal_tokens_long_message">Розкрийте свої токени 2FAS на 60 секунд</string>
862862
<string name="widget__reveal_tokens_short_message">Розкрийте на 60 секунд</string>
863863
<string name="settings__show_error_details">Show error details</string>
864+
<string name="tokens__show_qr_code">Service QR Code</string>
865+
<string name="tokens__show_service_qr_setup_lock">Your service is protected. Please add a PIN or Fingerprint lock to see QR code.</string>
866+
<string name="tokens__copy_uri">Copy URI</string>
864867
</resources>

core/locale/src/main/res/values-zh/strings.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Project: 2FAS App
55
Locale: zh-Hans, Simplified Chinese
66
Exported by: rafakob
7-
Exported at: Tue, 14 Jan 2025 04:37:31 -0800
7+
Exported at: Thu, 16 Jan 2025 04:52:12 -0800
88
-->
99
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1010
<!-- InfoPlist.strings
@@ -849,4 +849,7 @@
849849
<string name="widget__reveal_tokens_long_message">显示您的 2FAS 令牌 60 秒</string>
850850
<string name="widget__reveal_tokens_short_message">显示 60 秒</string>
851851
<string name="settings__show_error_details">Show error details</string>
852+
<string name="tokens__show_qr_code">Service QR Code</string>
853+
<string name="tokens__show_service_qr_setup_lock">Your service is protected. Please add a PIN or Fingerprint lock to see QR code.</string>
854+
<string name="tokens__copy_uri">Copy URI</string>
852855
</resources>

core/locale/src/main/res/values/strings.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Project: 2FAS App
55
Locale: en, English
66
Exported by: rafakob
7-
Exported at: Tue, 14 Jan 2025 04:37:30 -0800
7+
Exported at: Thu, 16 Jan 2025 04:52:12 -0800
88
-->
99
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1010
<!-- InfoPlist.strings
@@ -855,4 +855,7 @@
855855
<string name="widget__reveal_tokens_long_message">Reveal your 2FAS tokens for 60 seconds</string>
856856
<string name="widget__reveal_tokens_short_message">Reveal for 60 seconds</string>
857857
<string name="settings__show_error_details">Show error details</string>
858+
<string name="tokens__show_qr_code">Service QR Code</string>
859+
<string name="tokens__show_service_qr_setup_lock">Your service is protected. Please add a PIN or Fingerprint lock to see QR code.</string>
860+
<string name="tokens__copy_uri">Copy URI</string>
858861
</resources>

feature/home/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ dependencies {
3030
implementation(libs.bundles.commonmark)
3131
implementation(libs.timber)
3232
implementation(libs.kotlinSerialization)
33+
implementation(libs.zxing)
3334
}

0 commit comments

Comments
 (0)