Privacy option in StartupWizard
This commit is contained in:
parent
ae9c7b4329
commit
2b51525719
8 changed files with 71 additions and 4 deletions
|
@ -138,7 +138,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
.observeOn(aapsSchedulers.main)
|
||||
.subscribe({ processPreferenceChange(it) }, fabricPrivacy::logException)
|
||||
)
|
||||
if (!sp.getBoolean(R.string.key_setupwizard_processed, false) && !isRunningRealPumpTest()) {
|
||||
if (startWizard() && !isRunningRealPumpTest()) {
|
||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
|
||||
startActivity(Intent(this, SetupWizardActivity::class.java))
|
||||
})
|
||||
|
@ -156,6 +156,9 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
if (viewPager.currentItem >= 0) pluginPreferencesMenuItem?.isEnabled = (viewPager.adapter as TabPageAdapter).getPluginAt(viewPager.currentItem).preferencesId != -1
|
||||
}
|
||||
|
||||
private fun startWizard() : Boolean =
|
||||
!sp.getBoolean(R.string.key_setupwizard_processed, false)
|
||||
|
||||
override fun onPostCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
|
||||
super.onPostCreate(savedInstanceState, persistentState)
|
||||
actionBarDrawerToggle.syncState()
|
||||
|
@ -381,6 +384,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
FirebaseCrashlytics.getInstance().setCustomKey("Remote", remote)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("Committed", BuildConfig.COMMITTED)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("Hash", hashes[0])
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("Email", sp.getString(R.string.key_email_for_crash_report, ""))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ abstract class WizardModule {
|
|||
@ContributesAndroidInjector abstract fun swEditEncryptedPasswordInjector(): SWEditEncryptedPassword
|
||||
@ContributesAndroidInjector abstract fun swEditUrlInjector(): SWEditUrl
|
||||
@ContributesAndroidInjector abstract fun swFragmentInjector(): SWFragment
|
||||
@ContributesAndroidInjector abstract fun swPreferenceInjector(): SWPreference
|
||||
@ContributesAndroidInjector abstract fun swHtmlLinkInjector(): SWHtmlLink
|
||||
@ContributesAndroidInjector abstract fun swInfotextInjector(): SWInfoText
|
||||
@ContributesAndroidInjector abstract fun swItemInjector(): SWItem
|
||||
|
|
|
@ -188,6 +188,13 @@ class SWDefinition @Inject constructor(
|
|||
.add(SWEditString(injector)
|
||||
.validator(SWTextValidator(String::isNotEmpty))
|
||||
.preferenceId(R.string.key_patient_name))
|
||||
private val privacy = SWScreen(injector, R.string.privacy_settings)
|
||||
.skippable(true)
|
||||
.add(SWInfoText(injector)
|
||||
.label(R.string.privacy_summary))
|
||||
.add(SWPreference(injector, this)
|
||||
.option(R.xml.pref_datachoices)
|
||||
)
|
||||
private val screenMasterPassword = SWScreen(injector, R.string.master_password)
|
||||
.skippable(false)
|
||||
.add(SWInfoText(injector)
|
||||
|
@ -370,6 +377,7 @@ class SWDefinition @Inject constructor(
|
|||
.add(screenPermissionStore)
|
||||
.add(screenMasterPassword)
|
||||
.add(screenImport)
|
||||
.add(privacy)
|
||||
.add(screenUnits)
|
||||
.add(displaySettings)
|
||||
.add(screenNsClient)
|
||||
|
|
|
@ -31,8 +31,9 @@ open class SWItem(val injector: HasAndroidInjector, var type: Type) {
|
|||
injector.androidInjector().inject(this)
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
enum class Type {
|
||||
NONE, TEXT, HTML_LINK, BREAK, LISTENER, URL, STRING, NUMBER, DECIMAL_NUMBER, RADIOBUTTON, PLUGIN, BUTTON, FRAGMENT, UNIT_NUMBER
|
||||
NONE, TEXT, HTML_LINK, BREAK, LISTENER, URL, STRING, NUMBER, DECIMAL_NUMBER, RADIOBUTTON, PLUGIN, BUTTON, FRAGMENT, UNIT_NUMBER, PREFERENCE
|
||||
}
|
||||
|
||||
var label: Int? = null
|
||||
|
|
|
@ -18,7 +18,7 @@ import info.nightscout.androidaps.setupwizard.SWDefinition
|
|||
import info.nightscout.androidaps.setupwizard.events.EventSWUpdate
|
||||
import javax.inject.Inject
|
||||
|
||||
class SWPlugin(injector: HasAndroidInjector, val definition: SWDefinition) : SWItem(injector, Type.PLUGIN) {
|
||||
class SWPlugin(injector: HasAndroidInjector, private val definition: SWDefinition) : SWItem(injector, Type.PLUGIN) {
|
||||
|
||||
@Inject lateinit var pluginStore: PluginStore
|
||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package info.nightscout.androidaps.setupwizard.elements
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.LinearLayout
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.activities.MyPreferenceFragment
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
|
||||
import info.nightscout.androidaps.setupwizard.SWDefinition
|
||||
import javax.inject.Inject
|
||||
|
||||
class SWPreference(injector: HasAndroidInjector, private val definition: SWDefinition) : SWItem(injector, Type.PREFERENCE) {
|
||||
|
||||
@Inject lateinit var pluginStore: PluginStore
|
||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||
|
||||
private var xml: Int = -1
|
||||
|
||||
fun option(xml: Int): SWPreference {
|
||||
this.xml = xml
|
||||
return this
|
||||
}
|
||||
|
||||
override fun generateDialog(layout: LinearLayout) {
|
||||
addConfiguration(layout, xml)
|
||||
super.generateDialog(layout)
|
||||
}
|
||||
|
||||
private fun addConfiguration(layout: LinearLayout, xml: Int) {
|
||||
MyPreferenceFragment().also { fragment ->
|
||||
fragment.arguments = Bundle().also { it.putInt("id", xml) }
|
||||
definition.activity.supportFragmentManager.beginTransaction().run {
|
||||
replace(layout.id, fragment)
|
||||
commit()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1381,5 +1381,10 @@
|
|||
<string name="cannula">Cannula</string>
|
||||
<string name="userentry">User entry</string>
|
||||
<string name="common_values">Use values of your largest food you usually eat\n</string>
|
||||
<string name="key_email_for_crash_report">email_for_crash_report</string>
|
||||
<string name="summary_email_for_crash_report">This email address will attached to crash reports so we can contact you in urgent cases. It\'s optional.</string>
|
||||
<string name="email_address">Email address</string>
|
||||
<string name="privacy_settings">Privacy setting</string>
|
||||
<string name="privacy_summary">You can provide optional email address if you want to be notified about app crashes. This is not an automated service. You will be contacted by developers in dangerous situations.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:validate="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/data_choices"
|
||||
|
@ -12,6 +13,15 @@
|
|||
android:summary="@string/allow_automated_crash_reporting"
|
||||
android:title="@string/fabric_upload" />
|
||||
|
||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||
android:dialogMessage="@string/summary_email_for_crash_report"
|
||||
android:inputType="textEmailAddress"
|
||||
android:key="@string/key_email_for_crash_report"
|
||||
android:selectAllOnFocus="true"
|
||||
android:summary="@string/summary_email_for_crash_report"
|
||||
android:title="@string/email_address"
|
||||
validate:testType="email" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
|
|
Loading…
Reference in a new issue