fix menu
This commit is contained in:
parent
05733a72eb
commit
0ccc5bfdfc
|
@ -69,13 +69,13 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa
|
||||||
super.attachBaseContext(LocaleHelper.wrap(newBase))
|
super.attachBaseContext(LocaleHelper.wrap(newBase))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean =
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
android.R.id.home -> {
|
android.R.id.home -> {
|
||||||
onBackPressed()
|
onBackPressed()
|
||||||
return true
|
true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item)
|
else -> super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -27,24 +27,30 @@ class SingleFragmentActivity : DaggerAppCompatActivityWithResult() {
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
supportFragmentManager.beginTransaction().replace(R.id.frame_layout,
|
supportFragmentManager.beginTransaction().replace(
|
||||||
supportFragmentManager.fragmentFactory.instantiate(ClassLoader.getSystemClassLoader(), plugin?.pluginDescription?.fragmentClass!!)).commit()
|
R.id.frame_layout,
|
||||||
|
supportFragmentManager.fragmentFactory.instantiate(ClassLoader.getSystemClassLoader(), plugin?.pluginDescription?.fragmentClass!!)
|
||||||
|
).commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean =
|
||||||
if (item.itemId == android.R.id.home) {
|
when (item.itemId) {
|
||||||
|
android.R.id.home -> {
|
||||||
finish()
|
finish()
|
||||||
return true
|
true
|
||||||
} else if (item.itemId == R.id.nav_plugin_preferences) {
|
}
|
||||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, Runnable {
|
|
||||||
|
R.id.nav_plugin_preferences -> {
|
||||||
|
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
|
||||||
val i = Intent(this, PreferencesActivity::class.java)
|
val i = Intent(this, PreferencesActivity::class.java)
|
||||||
i.putExtra("id", plugin?.preferencesId)
|
i.putExtra("id", plugin?.preferencesId)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
}, null)
|
}, null)
|
||||||
return true
|
true
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
|
else -> super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
|
|
|
@ -7,7 +7,13 @@ import androidx.fragment.app.FragmentTransaction
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
|
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
|
||||||
import info.nightscout.androidaps.R
|
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.databinding.TreatmentsFragmentBinding
|
||||||
import info.nightscout.androidaps.extensions.toVisibility
|
import info.nightscout.androidaps.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
|
@ -55,15 +61,14 @@ class TreatmentsActivity : NoSplashAppCompatActivity() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean =
|
||||||
return when (item.itemId) {
|
when (item.itemId) {
|
||||||
android.R.id.home -> {
|
android.R.id.home -> {
|
||||||
finish()
|
finish()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> false
|
else -> super.onOptionsItemSelected(item)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setFragment(selectedFragment: Fragment) {
|
private fun setFragment(selectedFragment: Fragment) {
|
||||||
|
|
|
@ -119,7 +119,8 @@ class BGSourceFragment : DaggerFragment(), MenuProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMenuItemSelected(item: MenuItem) =
|
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>() {
|
inner class RecyclerViewAdapter internal constructor(private var glucoseValues: List<GlucoseValue>) : RecyclerView.Adapter<RecyclerViewAdapter.GlucoseValuesViewHolder>() {
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener, MenuProvider {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> false
|
else -> super.onContextItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
|
|
@ -114,7 +114,7 @@ class PrefImportListActivity : DaggerAppCompatActivity() {
|
||||||
finish()
|
finish()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun attachBaseContext(newBase: Context) {
|
override fun attachBaseContext(newBase: Context) {
|
||||||
|
|
|
@ -165,7 +165,7 @@ class PumpBLEConfigActivity : DaggerAppCompatActivity() {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> false
|
else -> super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
|
|
@ -155,7 +155,7 @@ class RileyLinkBLEConfigActivity : DaggerAppCompatActivity() {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> false
|
else -> super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun prepareForScanning() {
|
private fun prepareForScanning() {
|
||||||
|
|
Loading…
Reference in a new issue