SetupWizard: toolbar

This commit is contained in:
Milos Kozak 2023-08-19 09:29:20 +02:00
parent d065f1fd86
commit 5c6af3c3e1
9 changed files with 25 additions and 54 deletions

View file

@ -58,7 +58,7 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme.NoActionBar">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View file

@ -22,7 +22,6 @@ class PreferencesActivity : DaggerAppCompatActivityWithResult(), PreferenceFragm
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setTheme(info.nightscout.core.ui.R.style.AppTheme)
binding = ActivityPreferencesBinding.inflate(layoutInflater) binding = ActivityPreferencesBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)

View file

@ -8,7 +8,6 @@
android:name=".setupwizard.SetupWizardActivity" android:name=".setupwizard.SetupWizardActivity"
android:configChanges="orientation|keyboardHidden|screenSize" android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="false" android:exported="false"
android:label="@string/title_activity_setup_wizard"
android:theme="@style/AppTheme" /> android:theme="@style/AppTheme" />
<activity <activity
android:name=".maintenance.activities.LogSettingActivity" android:name=".maintenance.activities.LogSettingActivity"

View file

@ -33,7 +33,6 @@ open class DaggerAppCompatActivityWithResult : DaggerAppCompatActivity() {
public override fun onCreate(savedInstanceState: Bundle?) { public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setTheme(info.nightscout.core.ui.R.style.AppTheme_NoActionBar)
compositeDisposable.add(rxBus.toObservable(EventThemeSwitch::class.java).subscribe { compositeDisposable.add(rxBus.toObservable(EventThemeSwitch::class.java).subscribe {
recreate() recreate()

View file

@ -89,7 +89,7 @@ class SWDefinition @Inject constructor(
} }
private val screenSetupWizard private val screenSetupWizard
get() = SWScreen(injector, R.string.nav_setupwizard) get() = SWScreen(injector, R.string.welcome)
.add(SWInfoText(injector).label(R.string.welcometosetupwizard)) .add(SWInfoText(injector).label(R.string.welcometosetupwizard))
private val screenEula private val screenEula

View file

@ -2,9 +2,13 @@ package info.nightscout.configuration.setupwizard
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.widget.TextView import android.widget.TextView
import androidx.activity.OnBackPressedCallback import androidx.activity.OnBackPressedCallback
import androidx.core.view.MenuProvider
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.configuration.R import info.nightscout.configuration.R
import info.nightscout.configuration.activities.DaggerAppCompatActivityWithResult import info.nightscout.configuration.activities.DaggerAppCompatActivityWithResult
@ -51,6 +55,10 @@ class SetupWizardActivity : DaggerAppCompatActivityWithResult() {
binding = ActivitySetupwizardBinding.inflate(layoutInflater) binding = ActivitySetupwizardBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
title = rh.gs(R.string.nav_setupwizard)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
swDefinition.activity = this swDefinition.activity = this
screens = swDefinition.getScreens() screens = swDefinition.getScreens()
val intent = intent val intent = intent
@ -71,6 +79,20 @@ class SetupWizardActivity : DaggerAppCompatActivityWithResult() {
OKDialog.showConfirmation(this@SetupWizardActivity, rh.gs(R.string.exitwizard)) { finish() } else showPreviousPage(null) OKDialog.showConfirmation(this@SetupWizardActivity, rh.gs(R.string.exitwizard)) { finish() } else showPreviousPage(null)
} }
}) })
addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean =
when (menuItem.itemId) {
android.R.id.home -> {
sp.putBoolean(R.string.key_setupwizard_processed, true)
OKDialog.showConfirmation(this@SetupWizardActivity, rh.gs(R.string.exitwizard)) { finish() }
true
}
else -> false
}
})
} }
override fun onPause() { override fun onPause() {
@ -141,12 +163,6 @@ class SetupWizardActivity : DaggerAppCompatActivityWithResult() {
} }
} }
@Suppress("UNUSED_PARAMETER")
fun exitPressed(view: View?) {
sp.putBoolean(R.string.key_setupwizard_processed, true)
OKDialog.showConfirmation(this, rh.gs(R.string.exitwizard)) { finish() }
}
@Suppress("UNUSED_PARAMETER") @Suppress("UNUSED_PARAMETER")
fun showNextPage(view: View?) { fun showNextPage(view: View?) {
finish() finish()

View file

@ -1,12 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M16.495,12.092l-4.921,-4.92l-1.444,1.444l2.468,2.467l-9.765,0l0,2.042l9.765,0l-2.468,2.467l1.444,1.444l4.921,-4.92l-0.012,-0.012z"
android:fillColor="?attr/defaultTextColor" />
<path
android:pathData="M18.682,2.975H5.152c-1.272,0 -2.307,1.035 -2.307,2.307v3.801h2.126V5.282c0,-0.1 0.081,-0.181 0.181,-0.181h13.53c0.1,0 0.181,0.081 0.181,0.181v13.436c0,0.1 -0.081,0.181 -0.181,0.181H5.152c-0.1,0 -0.181,-0.081 -0.181,-0.181v-3.593H2.845v3.593c0,1.272 1.035,2.307 2.307,2.307h13.53c1.272,0 2.308,-1.034 2.308,-2.307V5.282C20.989,4.01 19.954,2.975 18.682,2.975z"
android:fillColor="?attr/defaultTextColor" />
</vector>

View file

@ -1,41 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context="info.nightscout.configuration.setupwizard.SetupWizardActivity"> tools:context="info.nightscout.configuration.setupwizard.SetupWizardActivity">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="@+id/sw_exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:importantForAccessibility="no"
android:onClick="exitPressed"
app:srcCompat="@drawable/ic_exit_to_app" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:text="@string/exit"
android:onClick="exitPressed"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textStyle="bold" />
</LinearLayout>
<TextView <TextView
android:id="@+id/sw_content" android:id="@+id/sw_content"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -4,11 +4,11 @@
<string name="units">Units</string> <string name="units">Units</string>
<string name="setupwizard_units_prompt">Select units you want to display values in</string> <string name="setupwizard_units_prompt">Select units you want to display values in</string>
<string name="title_activity_setup_wizard" translatable="false">SetupWizardActivity</string>
<string name="next_button">Next</string> <string name="next_button">Next</string>
<string name="previous_button">Prev</string> <string name="previous_button">Prev</string>
<string name="nav_setupwizard">Setup Wizard</string> <string name="nav_setupwizard">Setup Wizard</string>
<string name="setupwizard_finish">FINISH</string> <string name="setupwizard_finish">FINISH</string>
<string name="welcome">Welcome</string>
<string name="welcometosetupwizard">Welcome to setup wizard. It will guide you through the setup process\n</string> <string name="welcometosetupwizard">Welcome to setup wizard. It will guide you through the setup process\n</string>
<string name="end_user_license_agreement">End User License Agreement</string> <string name="end_user_license_agreement">End User License Agreement</string>
<string name="end_user_license_agreement_text">MUST NOT BE USED TO MAKE MEDICAL DECISIONS. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.</string> <string name="end_user_license_agreement_text">MUST NOT BE USED TO MAKE MEDICAL DECISIONS. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.</string>