DashPodHistoryActivity: toolbar

This commit is contained in:
Milos Kozak 2023-08-19 14:37:41 +02:00
parent ca9cbefaa7
commit cf5e7001a5
2 changed files with 31 additions and 8 deletions

View file

@ -23,6 +23,6 @@
<activity
android:name=".ui.DashPodHistoryActivity"
android:exported="false"
android:theme="@style/AppTheme.NoActionBar" />
android:theme="@style/AppTheme" />
</application>
</manifest>

View file

@ -3,12 +3,16 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui
import android.os.Bundle
import android.os.SystemClock
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.Spinner
import android.widget.TextView
import androidx.core.view.MenuProvider
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType
@ -44,8 +48,8 @@ class DashPodHistoryActivity : TranslatedDaggerAppCompatActivity() {
private var statusView: TextView? = null
private var recyclerView: RecyclerView? = null
private var linearLayoutManager: LinearLayoutManager? = null
private val fullHistoryList: MutableList<HistoryRecord> = ArrayList<HistoryRecord>()
private val filteredHistoryList: MutableList<HistoryRecord> = ArrayList<HistoryRecord>()
private val fullHistoryList: MutableList<HistoryRecord> = ArrayList()
private val filteredHistoryList: MutableList<HistoryRecord> = ArrayList()
private var recyclerViewAdapter: RecyclerViewAdapter? = null
private var manualChange = false
private var typeListFull: List<TypeList>? = null
@ -147,6 +151,10 @@ class DashPodHistoryActivity : TranslatedDaggerAppCompatActivity() {
setContentView(R.layout.omnipod_dash_pod_history_activity)
prepareData()
title = rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.omnipod_common_pod_management_button_pod_history)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
recyclerView = findViewById(R.id.omnipod_history_recyclerview)
recyclerViewAdapter = RecyclerViewAdapter(filteredHistoryList)
linearLayoutManager = LinearLayoutManager(this)
@ -178,6 +186,21 @@ class DashPodHistoryActivity : TranslatedDaggerAppCompatActivity() {
}
}
}
// 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 getTypeList(list: List<PumpHistoryEntryGroup>): List<TypeList> {
@ -217,8 +240,8 @@ class DashPodHistoryActivity : TranslatedDaggerAppCompatActivity() {
}
}
private fun setTextViewColor(check_result: Boolean, textview: TextView, record: HistoryRecord) {
if (check_result && !record.isSuccess()) {
private fun setTextViewColor(checkResult: Boolean, textview: TextView, record: HistoryRecord) {
if (checkResult && !record.isSuccess()) {
// Record says not success
textview.setTextColor(rh.gac(textview.context, info.nightscout.core.ui.R.attr.omniYellowColor))
return
@ -258,7 +281,7 @@ class DashPodHistoryActivity : TranslatedDaggerAppCompatActivity() {
private fun setType(record: HistoryRecord, typeView: TextView) {
typeView.text = rh.gs(record.commandType.resourceId)
// Set some color, include result
setTextViewColor(check_result = true, typeView, record)
setTextViewColor(checkResult = true, typeView, record)
}
private fun setValue(historyEntry: HistoryRecord, valueView: TextView) {
@ -295,13 +318,13 @@ class DashPodHistoryActivity : TranslatedDaggerAppCompatActivity() {
""
}
// Set some color
setTextViewColor(check_result = false, valueView, historyEntry)
setTextViewColor(checkResult = false, valueView, historyEntry)
}
private fun setAmount(historyEntry: HistoryRecord, amountView: TextView) {
amountView.text = historyEntry.totalAmountDelivered?.let { rh.gs(R.string.omnipod_common_history_total_delivered, it) }
// Set some color
setTextViewColor(check_result = false, amountView, historyEntry)
setTextViewColor(checkResult = false, amountView, historyEntry)
}
override fun getItemCount(): Int {