This commit is contained in:
Milos Kozak 2022-09-12 13:46:48 +02:00
parent 05733a72eb
commit 0ccc5bfdfc
8 changed files with 42 additions and 30 deletions

View file

@ -69,13 +69,13 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa
super.attachBaseContext(LocaleHelper.wrap(newBase))
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
override fun onOptionsItemSelected(item: MenuItem): Boolean =
when (item.itemId) {
android.R.id.home -> {
onBackPressed()
return true
true
}
else -> super.onOptionsItemSelected(item)
}
return super.onOptionsItemSelected(item)
}
}

View file

@ -27,25 +27,31 @@ class SingleFragmentActivity : DaggerAppCompatActivityWithResult() {
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
if (savedInstanceState == null) {
supportFragmentManager.beginTransaction().replace(R.id.frame_layout,
supportFragmentManager.fragmentFactory.instantiate(ClassLoader.getSystemClassLoader(), plugin?.pluginDescription?.fragmentClass!!)).commit()
supportFragmentManager.beginTransaction().replace(
R.id.frame_layout,
supportFragmentManager.fragmentFactory.instantiate(ClassLoader.getSystemClassLoader(), plugin?.pluginDescription?.fragmentClass!!)
).commit()
}
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == android.R.id.home) {
finish()
return true
} else if (item.itemId == R.id.nav_plugin_preferences) {
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, Runnable {
val i = Intent(this, PreferencesActivity::class.java)
i.putExtra("id", plugin?.preferencesId)
startActivity(i)
}, null)
return true
override fun onOptionsItemSelected(item: MenuItem): Boolean =
when (item.itemId) {
android.R.id.home -> {
finish()
true
}
R.id.nav_plugin_preferences -> {
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
val i = Intent(this, PreferencesActivity::class.java)
i.putExtra("id", plugin?.preferencesId)
startActivity(i)
}, null)
true
}
else -> super.onOptionsItemSelected(item)
}
return false
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
if (plugin?.preferencesId != -1) menuInflater.inflate(R.menu.menu_single_fragment, menu)

View file

@ -7,7 +7,13 @@ import androidx.fragment.app.FragmentTransaction
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.fragments.*
import info.nightscout.androidaps.activities.fragments.TreatmentsBolusCarbsFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsCareportalFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsExtendedBolusesFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsProfileSwitchFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsTempTargetFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsTemporaryBasalsFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsUserEntryFragment
import info.nightscout.androidaps.databinding.TreatmentsFragmentBinding
import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.ActivePlugin
@ -25,7 +31,7 @@ class TreatmentsActivity : NoSplashAppCompatActivity() {
super.onCreate(savedInstanceState)
binding = TreatmentsFragmentBinding.inflate(layoutInflater)
setContentView(binding.root)
// Use index, TabItems crashes with an id
val useFakeTempBasal = activePlugin.activePump.isFakingTempsByExtendedBoluses
binding.treatmentsTabs.getTabAt(1)?.view?.visibility = useFakeTempBasal.toVisibility()
@ -55,16 +61,15 @@ class TreatmentsActivity : NoSplashAppCompatActivity() {
})
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
override fun onOptionsItemSelected(item: MenuItem): Boolean =
when (item.itemId) {
android.R.id.home -> {
finish()
true
}
else -> false
else -> super.onOptionsItemSelected(item)
}
}
private fun setFragment(selectedFragment: Fragment) {
supportFragmentManager.beginTransaction()

View file

@ -119,7 +119,8 @@ class BGSourceFragment : DaggerFragment(), MenuProvider {
}
override fun onMenuItemSelected(item: MenuItem) =
actionHelper.onOptionsItemSelected(item)
if (actionHelper.onOptionsItemSelected(item)) true
else super.onContextItemSelected(item)
inner class RecyclerViewAdapter internal constructor(private var glucoseValues: List<GlucoseValue>) : RecyclerView.Adapter<RecyclerViewAdapter.GlucoseValuesViewHolder>() {

View file

@ -121,7 +121,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener, MenuProvider {
true
}
else -> false
else -> super.onContextItemSelected(item)
}
@SuppressLint("NotifyDataSetChanged")

View file

@ -114,7 +114,7 @@ class PrefImportListActivity : DaggerAppCompatActivity() {
finish()
return true
}
return false
return super.onOptionsItemSelected(item)
}
override fun attachBaseContext(newBase: Context) {

View file

@ -165,7 +165,7 @@ class PumpBLEConfigActivity : DaggerAppCompatActivity() {
true
}
else -> false
else -> super.onOptionsItemSelected(item)
}
override fun onResume() {

View file

@ -155,7 +155,7 @@ class RileyLinkBLEConfigActivity : DaggerAppCompatActivity() {
true
}
else -> false
else -> super.onOptionsItemSelected(item)
}
private fun prepareForScanning() {