DanaUserOptionsActivity: toolbar

This commit is contained in:
Milos Kozak 2023-08-19 10:52:02 +02:00
parent e3ff4f33d6
commit 7d272cd4d7
3 changed files with 24 additions and 36 deletions

View file

@ -8,6 +8,6 @@
<activity
android:name="info.nightscout.pump.dana.activities.DanaUserOptionsActivity"
android:exported="false"
android:theme="@style/AppTheme.NoActionBar" />
android:theme="@style/AppTheme" />
</application>
</manifest>

View file

@ -2,6 +2,10 @@ package info.nightscout.pump.dana.activities
import android.content.Context
import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import androidx.core.view.MenuProvider
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.Constants
@ -70,6 +74,10 @@ class DanaUserOptionsActivity : TranslatedDaggerAppCompatActivity() {
binding = DanarUserOptionsActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
title = rh.gs(R.string.danar_pump_settings)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
binding.saveUserOptions.setOnClickListener { onSaveClick() }
minBacklight = if (danaPump.hwModel < 7) 1 else 0 // Dana-i allows zero
@ -114,6 +122,21 @@ class DanaUserOptionsActivity : TranslatedDaggerAppCompatActivity() {
aapsLogger.error(LTag.PUMP, "No settings loaded from pump!")
else
setData()
// 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 setData() {

View file

@ -13,41 +13,6 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="?attr/activity_title_backgroundColor"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:importantForAccessibility="no"
app:srcCompat="@drawable/ic_user_options" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:text="@string/danar_pump_settings"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
<LinearLayout
android:id="@+id/spacer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/time_format"
android:layout_width="match_parent"