Merge pull request #2553 from dlvoy/dagger3-patient-name
Introduced Patient name, refactored SMS OTP and Prefs Export to use it
This commit is contained in:
commit
9f58270f88
|
@ -125,13 +125,13 @@ class ImportExportPrefs @Inject constructor(
|
|||
val n5 = Settings.Secure.getString(context.contentResolver, "lock_screen_owner_info")
|
||||
val n6 = Settings.Global.getString(context.contentResolver, "device_name")
|
||||
|
||||
// name we use for SMS OTP token in communicator
|
||||
val otpName = otp.name().trim()
|
||||
val defaultOtpName = resourceHelper.gs(R.string.smscommunicator_default_user_display_name)
|
||||
// name provided (hopefully) by user
|
||||
val patientName = sp.getString(R.string.key_patient_name, "")
|
||||
val defaultPatientName = resourceHelper.gs(R.string.patient_name_default)
|
||||
|
||||
// name we detect from OS
|
||||
val systemName = n1 ?: n2 ?: n3 ?: n4 ?: n5 ?: n6 ?: defaultOtpName
|
||||
val name = if (otpName.length > 0 && otpName != defaultOtpName) otpName else systemName
|
||||
val systemName = n1 ?: n2 ?: n3 ?: n4 ?: n5 ?: n6 ?: defaultPatientName
|
||||
val name = if (patientName.isNotEmpty() && patientName != defaultPatientName) patientName else systemName
|
||||
return name
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ class OneTimePassword @Inject constructor(
|
|||
* Name of master device (target of OTP)
|
||||
*/
|
||||
fun name(): String {
|
||||
val defaultUserName = resourceHelper.gs(R.string.smscommunicator_default_user_display_name)
|
||||
var userName = sp.getString(R.string.key_smscommunicator_otp_name, defaultUserName).replace(":", "").trim()
|
||||
val defaultUserName = resourceHelper.gs(R.string.patient_name_default)
|
||||
var userName = sp.getString(R.string.key_patient_name, defaultUserName).replace(":", "").trim()
|
||||
if (userName.isEmpty())
|
||||
userName = defaultUserName
|
||||
return userName
|
||||
|
@ -119,6 +119,6 @@ class OneTimePassword @Inject constructor(
|
|||
* Return URI used to provision Authenticator apps
|
||||
*/
|
||||
fun provisioningURI(): String? =
|
||||
key?.let { "otpauth://totp/AndroidAPS:" + URLEncoder.encode(name(), "utf-8") + "?secret=" + BaseEncoding.base32().encode(it.encoded).replace("=", "") + "&issuer=AndroidAPS" }
|
||||
key?.let { "otpauth://totp/AndroidAPS:" + URLEncoder.encode(name(), "utf-8").replace("+", "%20") + "?secret=" + BaseEncoding.base32().encode(it.encoded).replace("=", "") + "&issuer=AndroidAPS" }
|
||||
|
||||
}
|
|
@ -198,6 +198,14 @@ class SWDefinition @Inject constructor(
|
|||
.add(SWBreak(injector))
|
||||
.validator(SWValidator { nsClientPlugin.nsClientService != null && NSClientService.isConnected && NSClientService.hasWriteAuth })
|
||||
.visibility(SWValidator { !(nsClientPlugin.nsClientService != null && NSClientService.isConnected && NSClientService.hasWriteAuth) })
|
||||
private val screenPatientName = SWScreen(injector, R.string.patient_name)
|
||||
.skippable(true)
|
||||
.add(SWInfotext(injector)
|
||||
.label(R.string.patient_name_summary))
|
||||
.add(SWEditString(injector)
|
||||
.validator(SWTextValidator { text: String -> text.length > 0 })
|
||||
.preferenceId(R.string.key_patient_name)
|
||||
.updateDelay(5))
|
||||
private val screenAge = SWScreen(injector, R.string.patientage)
|
||||
.skippable(false)
|
||||
.add(SWBreak(injector))
|
||||
|
@ -389,6 +397,7 @@ class SWDefinition @Inject constructor(
|
|||
.add(screenUnits)
|
||||
.add(displaySettings)
|
||||
.add(screenNsClient)
|
||||
.add(screenPatientName)
|
||||
.add(screenAge)
|
||||
.add(screenInsulin)
|
||||
.add(screenBgSource)
|
||||
|
@ -415,6 +424,7 @@ class SWDefinition @Inject constructor(
|
|||
.add(screenUnits)
|
||||
.add(displaySettings)
|
||||
.add(screenNsClient)
|
||||
.add(screenPatientName)
|
||||
.add(screenAge)
|
||||
.add(screenInsulin)
|
||||
.add(screenBgSource)
|
||||
|
@ -437,6 +447,7 @@ class SWDefinition @Inject constructor(
|
|||
.add(displaySettings)
|
||||
.add(screenNsClient)
|
||||
.add(screenBgSource)
|
||||
.add(screenPatientName)
|
||||
.add(screenAge)
|
||||
.add(screenInsulin)
|
||||
.add(screenSensitivity)
|
||||
|
|
|
@ -276,7 +276,7 @@
|
|||
<string name="metadata_label_created_at">Created at</string>
|
||||
<string name="metadata_label_aaps_version">AAPS Version</string>
|
||||
<string name="metadata_label_aaps_flavour">Build Variant</string>
|
||||
<string name="metadata_label_device_name">Exporting device name</string>
|
||||
<string name="metadata_label_device_name">Exporting device patient name</string>
|
||||
<string name="metadata_label_device_model">Exporting device model</string>
|
||||
<string name="metadata_label_encryption">File encryption</string>
|
||||
|
||||
|
@ -611,6 +611,10 @@
|
|||
<string name="key_adult" translatable="false">adult</string>
|
||||
<string name="key_resistantadult" translatable="false">resistantadult</string>
|
||||
<string name="patientage_summary">Please select patient age to setup safety limits</string>
|
||||
<string name="patient_name">Patient name</string>
|
||||
<string name="patient_name_summary">Please provide patient name or nickname to differentiate among multiple setups</string>
|
||||
<string name="patient_name_default" comment="This is default patient display name, when user does not provide real one">User</string>
|
||||
<string name="key_patient_name" translatable="false">patient_name</string>
|
||||
<string name="key_i_understand" translatable="false">I_understand</string>
|
||||
<string name="Glimp">Glimp</string>
|
||||
<string name="needwhitelisting">%1$s needs battery optimalization whitelisting for proper performance</string>
|
||||
|
@ -1755,19 +1759,15 @@
|
|||
<!-- SMS Communicator & OTP Authenticator -->
|
||||
|
||||
<string name="key_smscommunicator_otp_enabled" translatable="false">smscommunicator_otp_enabled</string>
|
||||
<string name="key_smscommunicator_otp_name" translatable="false">smscommunicator_otp_name</string>
|
||||
<string name="key_smscommunicator_otp_password" translatable="false">smscommunicator_otp_password</string>
|
||||
<string name="key_smscommunicator_otp_secret" translatable="false">smscommunicator_otp_secret</string>
|
||||
|
||||
<string name="smscommunicator_default_user_display_name" comment="This is default user display name, shown by Authenticators">User</string>
|
||||
<string name="smscommunicator_code_from_authenticator_for" comment="This is continuation of sentence: To [ACTION] reply with code">from Authenticator app for: %1$s</string>
|
||||
|
||||
<string name="smscommunicator_otp_enabled">Enable Authenticator</string>
|
||||
<string name="smscommunicator_otp_enabled_summary">Authenticate commands using One Time Passwords generated by Google Authenticator or similar 2FA apps.</string>
|
||||
<string name="smscommunicator_otp_pin">Additional PIN at token end</string>
|
||||
<string name="smscommunicator_otp_pin_summary">Additional digits that should be memorised and glued at end of each generated One Time Password</string>
|
||||
<string name="smscommunicator_otp_name">User name for Authenticator</string>
|
||||
<string name="smscommunicator_otp_name_summary">User name displayed along with generated OTP on Authenticator App</string>
|
||||
|
||||
<string name="smscomunicator_tab_otp_label">Authenticator setup</string>
|
||||
|
||||
|
|
|
@ -20,6 +20,14 @@
|
|||
android:key="@string/key_language"
|
||||
android:title="@string/language" />
|
||||
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="textPersonName"
|
||||
android:key="@string/key_patient_name"
|
||||
android:title="@string/patient_name"
|
||||
android:summary="@string/patient_name_summary"
|
||||
/>
|
||||
|
||||
<PreferenceCategory android:title="@string/protection">
|
||||
|
||||
<Preference
|
||||
|
|
|
@ -49,14 +49,6 @@
|
|||
android:title="@string/smscommunicator_otp_pin"
|
||||
validate:testType="pinStrength" />
|
||||
|
||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||
android:dependency="@string/key_smscommunicator_remotecommandsallowed"
|
||||
android:key="@string/key_smscommunicator_otp_name"
|
||||
android:summary="@string/smscommunicator_otp_name_summary"
|
||||
android:title="@string/smscommunicator_otp_name"
|
||||
validate:testType="personName" />
|
||||
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
Reference in a new issue