diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt
index 09505d0e18..072e621cdc 100644
--- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt
+++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt
@@ -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, ""))
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/WizardModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/WizardModule.kt
index 2c105e9ce7..1405b8867f 100644
--- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/WizardModule.kt
+++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/WizardModule.kt
@@ -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
diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt
index 55ed268dfe..7f8923975f 100644
--- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt
+++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt
@@ -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)
diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.kt
index c6cc3f9620..2a25c2ea91 100644
--- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.kt
+++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.kt
@@ -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
diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPlugin.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPlugin.kt
index 76c140d708..95401bdfab 100644
--- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPlugin.kt
+++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPlugin.kt
@@ -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
diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPreference.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPreference.kt
new file mode 100644
index 0000000000..7abafa7c82
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPreference.kt
@@ -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()
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9c0acd512a..471ec88772 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1381,5 +1381,10 @@
Cannula
User entry
Use values of your largest food you usually eat\n
+ email_for_crash_report
+ This email address will attached to crash reports so we can contact you in urgent cases. It\'s optional.
+ Email address
+ Privacy setting
+ 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.
diff --git a/app/src/main/res/xml/pref_datachoices.xml b/app/src/main/res/xml/pref_datachoices.xml
index e60840d09d..d44c622d97 100644
--- a/app/src/main/res/xml/pref_datachoices.xml
+++ b/app/src/main/res/xml/pref_datachoices.xml
@@ -1,6 +1,7 @@
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:validate="http://schemas.android.com/apk/res-auto">
+
+