ProfileHelperActivity: toolbar

This commit is contained in:
Milos Kozak 2023-08-19 10:05:02 +02:00
parent 69f06f598b
commit 4d19608106
2 changed files with 24 additions and 1 deletions

View file

@ -51,7 +51,7 @@
<activity
android:name=".activities.ProfileHelperActivity"
android:exported="false"
android:theme="@style/AppTheme.NoActionBar" />
android:theme="@style/AppTheme" />
<activity
android:name="info.nightscout.ui.activities.QuickWizardListActivity"
android:exported="false"

View file

@ -4,8 +4,12 @@ import android.annotation.SuppressLint
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.widget.ArrayAdapter
import android.widget.TextView
import androidx.core.view.MenuProvider
import com.google.android.material.tabs.TabLayout
import com.google.common.collect.Lists
import info.nightscout.core.profile.ProfileSealed
@ -83,6 +87,10 @@ class ProfileHelperActivity : TranslatedDaggerAppCompatActivity() {
binding = ActivityProfilehelperBinding.inflate(layoutInflater)
setContentView(binding.root)
title = rh.gs(R.string.nav_profile_helper)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
binding.tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab) {
switchTab(tab.position, typeSelected[tab.position])
@ -246,6 +254,21 @@ class ProfileHelperActivity : TranslatedDaggerAppCompatActivity() {
binding.basalPctFromTddLabel.labelFor = binding.basalPctFromTdd.editTextId
switchTab(0, typeSelected[0], false)
// Add menu items without overriding methods in the Activity
addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean =
when (menuItem.itemId) {
android.R.id.home -> {
onBackPressedDispatcher.onBackPressed()
true
}
else -> false
}
})
}
private fun getProfile(age: Int, tdd: Double, weight: Double, basalPct: Double, tab: Int): PureProfile? =