cleanup activities

This commit is contained in:
Milos Kozak 2023-08-26 22:56:34 +02:00
parent dbf1ff5ddd
commit ab74947c24
32 changed files with 157 additions and 625 deletions

View file

@ -4,8 +4,6 @@
<option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" /> <option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" />
<JetCodeStyleSettings> <JetCodeStyleSettings>
<option name="ALIGN_IN_COLUMNS_CASE_BRANCH" value="true" /> <option name="ALIGN_IN_COLUMNS_CASE_BRANCH" value="true" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
<option name="BLANK_LINES_AROUND_BLOCK_WHEN_BRANCHES" value="1" /> <option name="BLANK_LINES_AROUND_BLOCK_WHEN_BRANCHES" value="1" />
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" /> <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings> </JetCodeStyleSettings>

View file

@ -13,6 +13,7 @@ import android.text.style.ForegroundColorSpan
import android.text.util.Linkify import android.text.util.Linkify
import android.util.TypedValue import android.util.TypedValue
import android.view.Menu import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View import android.view.View
@ -26,6 +27,7 @@ import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.core.view.GravityCompat import androidx.core.view.GravityCompat
import androidx.core.view.MenuCompat import androidx.core.view.MenuCompat
import androidx.core.view.MenuProvider
import androidx.viewpager2.widget.ViewPager2 import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.tabs.TabLayoutMediator import com.google.android.material.tabs.TabLayoutMediator
@ -165,6 +167,114 @@ class MainActivity : DaggerAppCompatActivityWithResult() {
else finish() else finish()
} }
}) })
addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
MenuCompat.setGroupDividerEnabled(menu, true)
this@MainActivity.menu = menu
menuInflater.inflate(R.menu.menu_main, menu)
pluginPreferencesMenuItem = menu.findItem(R.id.nav_plugin_preferences)
}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean =
when (menuItem.itemId) {
R.id.nav_preferences -> {
protectionCheck.queryProtection(this@MainActivity, ProtectionCheck.Protection.PREFERENCES, {
startActivity(
Intent(this@MainActivity, PreferencesActivity::class.java)
.setAction("info.nightscout.androidaps.MainActivity")
.putExtra("id", -1)
)
})
true
}
R.id.nav_historybrowser -> {
startActivity(Intent(this@MainActivity, HistoryBrowseActivity::class.java).setAction("info.nightscout.androidaps.MainActivity"))
true
}
R.id.nav_treatments -> {
startActivity(Intent(this@MainActivity, TreatmentsActivity::class.java).setAction("info.nightscout.androidaps.MainActivity"))
true
}
R.id.nav_setupwizard -> {
protectionCheck.queryProtection(this@MainActivity, ProtectionCheck.Protection.PREFERENCES, {
startActivity(Intent(this@MainActivity, SetupWizardActivity::class.java).setAction("info.nightscout.androidaps.MainActivity"))
})
true
}
R.id.nav_about -> {
var message = "Build: ${BuildConfig.BUILDVERSION}\n"
message += "Flavor: ${BuildConfig.FLAVOR}${BuildConfig.BUILD_TYPE}\n"
message += "${rh.gs(info.nightscout.configuration.R.string.configbuilder_nightscoutversion_label)} ${activePlugin.activeNsClient?.detectedNsVersion() ?: rh.gs(info.nightscout.plugins.R.string.not_available_full)}"
if (config.isEngineeringMode()) message += "\n${rh.gs(info.nightscout.configuration.R.string.engineering_mode_enabled)}"
if (config.isUnfinishedMode()) message += "\nUnfinished mode enabled"
if (!fabricPrivacy.fabricEnabled()) message += "\n${rh.gs(info.nightscout.core.ui.R.string.fabric_upload_disabled)}"
message += rh.gs(info.nightscout.core.ui.R.string.about_link_urls)
val messageSpanned = SpannableString(message)
Linkify.addLinks(messageSpanned, Linkify.WEB_URLS)
MaterialAlertDialogBuilder(this@MainActivity, info.nightscout.core.ui.R.style.DialogTheme)
.setTitle(rh.gs(R.string.app_name) + " " + BuildConfig.VERSION)
.setIcon(iconsProvider.getIcon())
.setMessage(messageSpanned)
.setPositiveButton(rh.gs(info.nightscout.core.ui.R.string.ok), null)
.setNeutralButton(rh.gs(info.nightscout.core.ui.R.string.cta_dont_kill_my_app_info)) { _, _ ->
startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse("https://dontkillmyapp.com/" + Build.MANUFACTURER.lowercase().replace(" ", "-"))
)
)
}
.create().apply {
show()
findViewById<TextView>(android.R.id.message)?.movementMethod = LinkMovementMethod.getInstance()
}
true
}
R.id.nav_exit -> {
aapsLogger.debug(LTag.CORE, "Exiting")
uel.log(Action.EXIT_AAPS, Sources.Aaps)
rxBus.send(EventAppExit())
finish()
System.runFinalization()
exitProcess(0)
}
R.id.nav_plugin_preferences -> {
val plugin = (binding.mainPager.adapter as TabPageAdapter).getPluginAt(binding.mainPager.currentItem)
protectionCheck.queryProtection(this@MainActivity, ProtectionCheck.Protection.PREFERENCES, {
startActivity(
Intent(this@MainActivity, PreferencesActivity::class.java)
.setAction("info.nightscout.androidaps.MainActivity")
.putExtra("id", plugin.preferencesId)
)
})
true
}
/*
R.id.nav_survey -> {
startActivity(Intent(this, SurveyActivity::class.java))
return true
}
*/
R.id.nav_defaultprofile -> {
startActivity(Intent(this@MainActivity, ProfileHelperActivity::class.java).setAction("info.nightscout.androidaps.MainActivity"))
true
}
R.id.nav_stats -> {
startActivity(Intent(this@MainActivity, StatsActivity::class.java).setAction("info.nightscout.androidaps.MainActivity"))
true
}
else ->
actionBarDrawerToggle.onOptionsItemSelected(menuItem)
}
})
// Setup views on 2nd and next activity start // Setup views on 2nd and next activity start
// On 1st start app is still initializing, start() is delayed and run from EventAppInitialized // On 1st start app is still initializing, start() is delayed and run from EventAppInitialized
if (config.appInitialized) start() if (config.appInitialized) start()
@ -332,115 +442,6 @@ class MainActivity : DaggerAppCompatActivityWithResult() {
super.onPanelClosed(featureId, menu) super.onPanelClosed(featureId, menu)
} }
override fun onCreateOptionsMenu(menu: Menu): Boolean {
super.onCreateOptionsMenu(menu)
MenuCompat.setGroupDividerEnabled(menu, true)
this.menu = menu
menuInflater.inflate(R.menu.menu_main, menu)
pluginPreferencesMenuItem = menu.findItem(R.id.nav_plugin_preferences)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
super.onOptionsItemSelected(item)
when (item.itemId) {
R.id.nav_preferences -> {
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
startActivity(
Intent(this, PreferencesActivity::class.java)
.setAction("info.nightscout.androidaps.MainActivity")
.putExtra("id", -1)
)
})
return true
}
R.id.nav_historybrowser -> {
startActivity(Intent(this, HistoryBrowseActivity::class.java).setAction("info.nightscout.androidaps.MainActivity"))
return true
}
R.id.nav_treatments -> {
startActivity(Intent(this, TreatmentsActivity::class.java).setAction("info.nightscout.androidaps.MainActivity"))
return true
}
R.id.nav_setupwizard -> {
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
startActivity(Intent(this, SetupWizardActivity::class.java).setAction("info.nightscout.androidaps.MainActivity"))
})
return true
}
R.id.nav_about -> {
var message = "Build: ${BuildConfig.BUILDVERSION}\n"
message += "Flavor: ${BuildConfig.FLAVOR}${BuildConfig.BUILD_TYPE}\n"
message += "${rh.gs(info.nightscout.configuration.R.string.configbuilder_nightscoutversion_label)} ${activePlugin.activeNsClient?.detectedNsVersion() ?: rh.gs(info.nightscout.plugins.R.string.not_available_full)}"
if (config.isEngineeringMode()) message += "\n${rh.gs(info.nightscout.configuration.R.string.engineering_mode_enabled)}"
if (config.isUnfinishedMode()) message += "\nUnfinished mode enabled"
if (!fabricPrivacy.fabricEnabled()) message += "\n${rh.gs(info.nightscout.core.ui.R.string.fabric_upload_disabled)}"
message += rh.gs(info.nightscout.core.ui.R.string.about_link_urls)
val messageSpanned = SpannableString(message)
Linkify.addLinks(messageSpanned, Linkify.WEB_URLS)
MaterialAlertDialogBuilder(this, info.nightscout.core.ui.R.style.DialogTheme)
.setTitle(rh.gs(R.string.app_name) + " " + BuildConfig.VERSION)
.setIcon(iconsProvider.getIcon())
.setMessage(messageSpanned)
.setPositiveButton(rh.gs(info.nightscout.core.ui.R.string.ok), null)
.setNeutralButton(rh.gs(info.nightscout.core.ui.R.string.cta_dont_kill_my_app_info)) { _, _ ->
startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse("https://dontkillmyapp.com/" + Build.MANUFACTURER.lowercase().replace(" ", "-"))
)
)
}
.create().apply {
show()
findViewById<TextView>(android.R.id.message)?.movementMethod = LinkMovementMethod.getInstance()
}
return true
}
R.id.nav_exit -> {
aapsLogger.debug(LTag.CORE, "Exiting")
uel.log(Action.EXIT_AAPS, Sources.Aaps)
rxBus.send(EventAppExit())
finish()
System.runFinalization()
exitProcess(0)
}
R.id.nav_plugin_preferences -> {
val plugin = (binding.mainPager.adapter as TabPageAdapter).getPluginAt(binding.mainPager.currentItem)
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
startActivity(
Intent(this, PreferencesActivity::class.java)
.setAction("info.nightscout.androidaps.MainActivity")
.putExtra("id", plugin.preferencesId)
)
})
return true
}
/*
R.id.nav_survey -> {
startActivity(Intent(this, SurveyActivity::class.java))
return true
}
*/
R.id.nav_defaultprofile -> {
startActivity(Intent(this, ProfileHelperActivity::class.java).setAction("info.nightscout.androidaps.MainActivity"))
return true
}
R.id.nav_stats -> {
startActivity(Intent(this, StatsActivity::class.java).setAction("info.nightscout.androidaps.MainActivity"))
return true
}
}
return actionBarDrawerToggle.onOptionsItemSelected(item)
}
// Correct place for calling setUserStats() would be probably MainApp // Correct place for calling setUserStats() would be probably MainApp
// but we need to have it called at least once a day. Thus this location // but we need to have it called at least once a day. Thus this location

View file

@ -4,14 +4,10 @@ import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.util.DisplayMetrics import android.util.DisplayMetrics
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.RelativeLayout import android.widget.RelativeLayout
import android.widget.TextView import android.widget.TextView
import androidx.core.view.MenuProvider
import com.google.android.material.datepicker.MaterialDatePicker import com.google.android.material.datepicker.MaterialDatePicker
import com.jjoe64.graphview.GraphView import com.jjoe64.graphview.GraphView
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
@ -148,20 +144,6 @@ class HistoryBrowseActivity : TranslatedDaggerAppCompatActivity() {
historyBrowserData.overviewData.fromTime = bundle.getLong("start", 0) historyBrowserData.overviewData.fromTime = bundle.getLong("start", 0)
historyBrowserData.overviewData.toTime = bundle.getLong("end", 0) historyBrowserData.overviewData.toTime = bundle.getLong("end", 0)
} }
// 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
}
})
} }
override fun onPause() { override fun onPause() {

View file

@ -1,6 +1,11 @@
package info.nightscout.core.ui.activities package info.nightscout.core.ui.activities
import android.content.Context 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 dagger.android.support.DaggerAppCompatActivity import dagger.android.support.DaggerAppCompatActivity
import info.nightscout.core.ui.locale.LocaleHelper import info.nightscout.core.ui.locale.LocaleHelper
@ -8,4 +13,23 @@ open class TranslatedDaggerAppCompatActivity : DaggerAppCompatActivity() {
override fun attachBaseContext(newBase: Context) { override fun attachBaseContext(newBase: Context) {
super.attachBaseContext(LocaleHelper.wrap(newBase)) super.attachBaseContext(LocaleHelper.wrap(newBase))
} }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// 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
}
})
}
} }

View file

@ -3,17 +3,15 @@ package info.nightscout.configuration.maintenance.activities
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.MenuItem
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import info.nightscout.configuration.R
import info.nightscout.configuration.databinding.CustomWatchfaceImportListActivityBinding
import info.nightscout.configuration.databinding.CustomWatchfaceImportListItemBinding
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
import info.nightscout.interfaces.maintenance.PrefFileListProvider import info.nightscout.interfaces.maintenance.PrefFileListProvider
import info.nightscout.configuration.databinding.CustomWatchfaceImportListActivityBinding
import info.nightscout.configuration.R
import info.nightscout.configuration.databinding.CustomWatchfaceImportListItemBinding
import info.nightscout.interfaces.versionChecker.VersionCheckerUtils import info.nightscout.interfaces.versionChecker.VersionCheckerUtils
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventMobileDataToWear import info.nightscout.rx.events.EventMobileDataToWear
@ -21,7 +19,12 @@ import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.weardata.CUSTOM_VERSION import info.nightscout.rx.weardata.CUSTOM_VERSION
import info.nightscout.rx.weardata.CwfData import info.nightscout.rx.weardata.CwfData
import info.nightscout.rx.weardata.CwfDrawableFileMap import info.nightscout.rx.weardata.CwfDrawableFileMap
import info.nightscout.rx.weardata.CwfMetadataKey.* import info.nightscout.rx.weardata.CwfMetadataKey.CWF_AUTHOR
import info.nightscout.rx.weardata.CwfMetadataKey.CWF_AUTHOR_VERSION
import info.nightscout.rx.weardata.CwfMetadataKey.CWF_CREATED_AT
import info.nightscout.rx.weardata.CwfMetadataKey.CWF_FILENAME
import info.nightscout.rx.weardata.CwfMetadataKey.CWF_NAME
import info.nightscout.rx.weardata.CwfMetadataKey.CWF_VERSION
import info.nightscout.rx.weardata.CwfMetadataMap import info.nightscout.rx.weardata.CwfMetadataMap
import info.nightscout.rx.weardata.EventData import info.nightscout.rx.weardata.EventData
import info.nightscout.shared.extensions.toVisibility import info.nightscout.shared.extensions.toVisibility
@ -109,14 +112,6 @@ class CustomWatchfaceImportListActivity: TranslatedDaggerAppCompatActivity() {
} }
} }
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == android.R.id.home) {
finish()
return true
}
return super.onOptionsItemSelected(item)
}
private fun checkCustomVersion(metadata: CwfMetadataMap): Boolean { private fun checkCustomVersion(metadata: CwfMetadataMap): Boolean {
metadata[CWF_VERSION]?.let { version -> metadata[CWF_VERSION]?.let { version ->
val currentAppVer = versionCheckerUtils.versionDigits(CUSTOM_VERSION) val currentAppVer = versionCheckerUtils.versionDigits(CUSTOM_VERSION)

View file

@ -1,14 +1,10 @@
package info.nightscout.configuration.maintenance.activities package info.nightscout.configuration.maintenance.activities
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.widget.CheckBox import android.widget.CheckBox
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.core.view.MenuProvider
import info.nightscout.configuration.R import info.nightscout.configuration.R
import info.nightscout.configuration.databinding.ActivityLogsettingBinding import info.nightscout.configuration.databinding.ActivityLogsettingBinding
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
@ -39,20 +35,6 @@ class LogSettingActivity : TranslatedDaggerAppCompatActivity() {
l.resetToDefaults() l.resetToDefaults()
createViewsForSettings() createViewsForSettings()
} }
// 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 createViewsForSettings() { private fun createViewsForSettings() {

View file

@ -3,12 +3,8 @@ package info.nightscout.configuration.maintenance.activities
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.MenuProvider
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -44,21 +40,6 @@ class PrefImportListActivity : TranslatedDaggerAppCompatActivity() {
binding.recyclerview.layoutManager = LinearLayoutManager(this) binding.recyclerview.layoutManager = LinearLayoutManager(this)
binding.recyclerview.adapter = RecyclerViewAdapter(prefFileListProvider.listPreferenceFiles(loadMetadata = true)) binding.recyclerview.adapter = RecyclerViewAdapter(prefFileListProvider.listPreferenceFiles(loadMetadata = true))
// 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
}
})
} }
inner class RecyclerViewAdapter internal constructor(private var prefFileList: List<PrefsFile>) : RecyclerView.Adapter<RecyclerViewAdapter.PrefFileViewHolder>() { inner class RecyclerViewAdapter internal constructor(private var prefFileList: List<PrefsFile>) : RecyclerView.Adapter<RecyclerViewAdapter.PrefFileViewHolder>() {

View file

@ -8,12 +8,8 @@ import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.text.Editable import android.text.Editable
import android.text.TextWatcher import android.text.TextWatcher
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.view.WindowManager import android.view.WindowManager
import androidx.core.view.MenuProvider
import com.google.common.primitives.Ints.min import com.google.common.primitives.Ints.min
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
@ -107,20 +103,6 @@ class SmsCommunicatorOtpActivity : TranslatedDaggerAppCompatActivity() {
true true
} }
// 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
}
})
} }
@Synchronized @Synchronized

View file

@ -2,12 +2,8 @@ package info.nightscout.plugins.general.wear.activities
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.MenuProvider
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
@ -60,21 +56,6 @@ class CwfInfosActivity : TranslatedDaggerAppCompatActivity() {
supportActionBar?.setDisplayShowTitleEnabled(true) supportActionBar?.setDisplayShowTitleEnabled(true)
updateGui() updateGui()
// 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
}
})
} }
override fun onPause() { override fun onPause() {

View file

@ -3,15 +3,11 @@ package info.nightscout.plugins.sync.openhumans.ui
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.widget.CheckBox import android.widget.CheckBox
import androidx.activity.OnBackPressedCallback import androidx.activity.OnBackPressedCallback
import androidx.activity.viewModels import androidx.activity.viewModels
import androidx.browser.customtabs.CustomTabsIntent import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.view.MenuProvider
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
@ -98,20 +94,6 @@ class OHLoginActivity : TranslatedDaggerAppCompatActivity() {
if (code != null) { if (code != null) {
viewModel.submitBearerToken(code) viewModel.submitBearerToken(code)
} }
// 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
}
})
onBackPressedDispatcher.addCallback(this, object: OnBackPressedCallback(true) { onBackPressedDispatcher.addCallback(this, object: OnBackPressedCallback(true) {
override fun handleOnBackPressed() { override fun handleOnBackPressed() {
if (!viewModel.goBack()) finish() if (!viewModel.goBack()) finish()

View file

@ -7,16 +7,12 @@ import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.text.Editable import android.text.Editable
import android.text.TextWatcher import android.text.TextWatcher
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import androidx.activity.ComponentActivity import androidx.activity.ComponentActivity
import androidx.activity.OnBackPressedCallback import androidx.activity.OnBackPressedCallback
import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.view.MenuProvider
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@ -202,20 +198,6 @@ class ComboV2PairingActivity : TranslatedDaggerAppCompatActivity() {
finish() finish()
} }
}) })
// 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
}
})
} }
override fun onDestroy() { override fun onDestroy() {

View file

@ -2,14 +2,10 @@ package info.nightscout.pump.dana.activities
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import androidx.core.view.MenuProvider
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
@ -141,20 +137,6 @@ class DanaHistoryActivity : TranslatedDaggerAppCompatActivity() {
showingType = selected.type showingType = selected.type
swapAdapter(selected.type) swapAdapter(selected.type)
} }
// 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
}
})
} }
inner class RecyclerViewAdapter internal constructor(private var historyList: List<DanaHistoryRecord>) : RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder>() { inner class RecyclerViewAdapter internal constructor(private var historyList: List<DanaHistoryRecord>) : RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder>() {

View file

@ -2,10 +2,6 @@ package info.nightscout.pump.dana.activities
import android.content.Context import android.content.Context
import android.os.Bundle 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.ui.activities.TranslatedDaggerAppCompatActivity
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
@ -122,21 +118,6 @@ class DanaUserOptionsActivity : TranslatedDaggerAppCompatActivity() {
aapsLogger.error(LTag.PUMP, "No settings loaded from pump!") aapsLogger.error(LTag.PUMP, "No settings loaded from pump!")
else else
setData() 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() { private fun setData() {

View file

@ -15,15 +15,11 @@ import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.BaseAdapter import android.widget.BaseAdapter
import android.widget.TextView import android.widget.TextView
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.view.MenuProvider
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.extensions.safeEnable import info.nightscout.core.utils.extensions.safeEnable
@ -69,21 +65,6 @@ class BLEScanActivity : TranslatedDaggerAppCompatActivity() {
binding.bleScannerListview.emptyView = binding.bleScannerNoDevice binding.bleScannerListview.emptyView = binding.bleScannerNoDevice
binding.bleScannerListview.adapter = listAdapter binding.bleScannerListview.adapter = listAdapter
listAdapter?.notifyDataSetChanged() listAdapter?.notifyDataSetChanged()
// 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
}
})
} }
override fun onResume() { override fun onResume() {

View file

@ -18,15 +18,11 @@ import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.os.ParcelUuid import android.os.ParcelUuid
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.BaseAdapter import android.widget.BaseAdapter
import android.widget.TextView import android.widget.TextView
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.view.MenuProvider
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.extensions.safeEnable import info.nightscout.core.utils.extensions.safeEnable
@ -71,21 +67,6 @@ class DiaconnG8BLEScanActivity : TranslatedDaggerAppCompatActivity() {
binding.bleScannerListview.emptyView = binding.bleScannerNoDevice binding.bleScannerListview.emptyView = binding.bleScannerNoDevice
binding.bleScannerListview.adapter = listAdapter binding.bleScannerListview.adapter = listAdapter
listAdapter?.notifyDataSetChanged() listAdapter?.notifyDataSetChanged()
// 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
}
})
} }
override fun onResume() { override fun onResume() {

View file

@ -2,15 +2,11 @@ package info.nightscout.pump.diaconn.activities
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import android.widget.TextView import android.widget.TextView
import androidx.core.view.MenuProvider
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
@ -120,20 +116,6 @@ class DiaconnG8HistoryActivity : TranslatedDaggerAppCompatActivity() {
showingType = selected.type showingType = selected.type
swapAdapter(selected.type) swapAdapter(selected.type)
} }
// 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
}
})
} }
inner class RecyclerViewAdapter internal constructor(private var historyList: List<DiaconnHistoryRecord>) : RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder>() { inner class RecyclerViewAdapter internal constructor(private var historyList: List<DiaconnHistoryRecord>) : RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder>() {

View file

@ -2,13 +2,9 @@ package info.nightscout.pump.diaconn.activities
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import androidx.core.view.MenuProvider
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
@ -107,20 +103,6 @@ class DiaconnG8UserOptionsActivity : TranslatedDaggerAppCompatActivity() {
2 -> binding.pumplangKorean.isChecked = true 2 -> binding.pumplangKorean.isChecked = true
3 -> binding.pumplangEnglish.isChecked = true 3 -> binding.pumplangEnglish.isChecked = true
} }
// 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 onSaveAlarmClick() { private fun onSaveAlarmClick() {

View file

@ -5,13 +5,9 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.ActivityInfo import android.content.pm.ActivityInfo
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.MotionEvent import android.view.MotionEvent
import androidx.activity.OnBackPressedCallback import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.view.MenuProvider
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import info.nightscout.androidaps.plugins.pump.eopatch.R import info.nightscout.androidaps.plugins.pump.eopatch.R
import info.nightscout.androidaps.plugins.pump.eopatch.code.EventType import info.nightscout.androidaps.plugins.pump.eopatch.code.EventType
@ -123,20 +119,6 @@ class EopatchActivity : EoBaseActivity<ActivityEopatchBinding>() {
} }
} }
}) })
// 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
}
})
} }
override fun onNewIntent(intent: Intent?) { override fun onNewIntent(intent: Intent?) {

View file

@ -4,13 +4,8 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.ActivityInfo import android.content.pm.ActivityInfo
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.MotionEvent
import android.view.WindowManager import android.view.WindowManager
import androidx.activity.OnBackPressedCallback import androidx.activity.OnBackPressedCallback
import androidx.core.view.MenuProvider
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import info.nightscout.core.utils.extensions.safeGetSerializableExtra import info.nightscout.core.utils.extensions.safeGetSerializableExtra
import info.nightscout.pump.medtrum.R import info.nightscout.pump.medtrum.R
@ -97,20 +92,6 @@ class MedtrumActivity : MedtrumBaseActivity<ActivityMedtrumBinding>() {
} }
} }
}) })
// 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
}
})
} }
override fun onNewIntent(intent: Intent?) { override fun onNewIntent(intent: Intent?) {

View file

@ -7,14 +7,13 @@ import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding import androidx.databinding.ViewDataBinding
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import dagger.android.support.DaggerAppCompatActivity import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
import info.nightscout.core.ui.R
import info.nightscout.pump.medtrum.di.MedtrumPluginQualifier import info.nightscout.pump.medtrum.di.MedtrumPluginQualifier
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import javax.inject.Inject import javax.inject.Inject
abstract class MedtrumBaseActivity<B : ViewDataBinding> : DaggerAppCompatActivity(), MedtrumBaseNavigator { abstract class MedtrumBaseActivity<B : ViewDataBinding> : TranslatedDaggerAppCompatActivity(), MedtrumBaseNavigator {
@Inject @Inject
@MedtrumPluginQualifier @MedtrumPluginQualifier
lateinit var viewModelFactory: ViewModelProvider.Factory lateinit var viewModelFactory: ViewModelProvider.Factory

View file

@ -1,12 +1,8 @@
package info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.common.activity package info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.common.activity
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import androidx.activity.OnBackPressedCallback import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.view.MenuProvider
import androidx.navigation.NavController import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment import androidx.navigation.fragment.NavHostFragment
import info.nightscout.androidaps.plugins.pump.omnipod.common.R import info.nightscout.androidaps.plugins.pump.omnipod.common.R
@ -21,20 +17,6 @@ abstract class OmnipodWizardActivityBase : TranslatedDaggerAppCompatActivity() {
exitActivityAfterConfirmation() exitActivityAfterConfirmation()
} }
}) })
// 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
}
})
} }
fun exitActivityAfterConfirmation() { fun exitActivityAfterConfirmation() {

View file

@ -3,16 +3,12 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui
import android.os.Bundle import android.os.Bundle
import android.os.SystemClock import android.os.SystemClock
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import android.widget.Spinner import android.widget.Spinner
import android.widget.TextView import android.widget.TextView
import androidx.core.view.MenuProvider
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType
@ -187,21 +183,6 @@ 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> { private fun getTypeList(list: List<PumpHistoryEntryGroup>): List<TypeList> {

View file

@ -3,10 +3,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import androidx.core.view.MenuProvider
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandPlayTestBeep import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandPlayTestBeep
import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.PodActivationWizardActivity import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.PodActivationWizardActivity
@ -110,20 +106,6 @@ class DashPodManagementActivity : TranslatedDaggerAppCompatActivity() {
binding.buttonPodHistory.setOnClickListener { binding.buttonPodHistory.setOnClickListener {
startActivity(Intent(this, DashPodHistoryActivity::class.java)) startActivity(Intent(this, DashPodHistoryActivity::class.java))
} }
// 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
}
})
} }
override fun onResume() { override fun onResume() {

View file

@ -4,24 +4,20 @@ import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import android.os.SystemClock import android.os.SystemClock
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import android.widget.Spinner import android.widget.Spinner
import android.widget.TextView import android.widget.TextView
import androidx.core.view.MenuProvider
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerAppCompatActivity
import info.nightscout.androidaps.plugins.pump.omnipod.eros.R import info.nightscout.androidaps.plugins.pump.omnipod.eros.R
import info.nightscout.androidaps.plugins.pump.omnipod.eros.definition.PodHistoryEntryType import info.nightscout.androidaps.plugins.pump.omnipod.eros.definition.PodHistoryEntryType
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.ErosHistory import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.ErosHistory
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryRecordEntity import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryRecordEntity
import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.AapsOmnipodUtil import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.AapsOmnipodUtil
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
import info.nightscout.interfaces.profile.Profile.ProfileValue import info.nightscout.interfaces.profile.Profile.ProfileValue
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.pump.common.defs.PumpHistoryEntryGroup import info.nightscout.pump.common.defs.PumpHistoryEntryGroup
@ -35,7 +31,7 @@ import java.util.Calendar
import java.util.GregorianCalendar import java.util.GregorianCalendar
import javax.inject.Inject import javax.inject.Inject
class ErosPodHistoryActivity : DaggerAppCompatActivity() { class ErosPodHistoryActivity : TranslatedDaggerAppCompatActivity() {
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var aapsOmnipodUtil: AapsOmnipodUtil @Inject lateinit var aapsOmnipodUtil: AapsOmnipodUtil
@ -127,21 +123,6 @@ class ErosPodHistoryActivity : DaggerAppCompatActivity() {
filterHistory(PumpHistoryEntryGroup.All) filterHistory(PumpHistoryEntryGroup.All)
} }
} }
// 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> { private fun getTypeList(list: List<PumpHistoryEntryGroup>): List<TypeList> {

View file

@ -5,10 +5,6 @@ import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.HandlerThread import android.os.HandlerThread
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import androidx.core.view.MenuProvider
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
@ -153,20 +149,6 @@ class ErosPodManagementActivity : TranslatedDaggerAppCompatActivity() {
binding.buttonPodHistory.setOnClickListener { binding.buttonPodHistory.setOnClickListener {
startActivity(Intent(this, ErosPodHistoryActivity::class.java)) startActivity(Intent(this, ErosPodHistoryActivity::class.java))
} }
// 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
}
})
} }
override fun onResume() { override fun onResume() {

View file

@ -13,16 +13,12 @@ import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.HandlerThread import android.os.HandlerThread
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.AdapterView.OnItemClickListener import android.widget.AdapterView.OnItemClickListener
import android.widget.BaseAdapter import android.widget.BaseAdapter
import android.widget.TextView import android.widget.TextView
import androidx.core.view.MenuProvider
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
@ -143,21 +139,6 @@ class PumpBLEConfigActivity : TranslatedDaggerAppCompatActivity() {
updateCurrentlySelectedBTDevice() updateCurrentlySelectedBTDevice()
}) })
} }
// 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 updateCurrentlySelectedBTDevice() { private fun updateCurrentlySelectedBTDevice() {

View file

@ -17,9 +17,6 @@ import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.HandlerThread import android.os.HandlerThread
import android.os.ParcelUuid import android.os.ParcelUuid
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.AdapterView import android.widget.AdapterView
@ -28,7 +25,6 @@ import android.widget.BaseAdapter
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.view.MenuProvider
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
@ -121,21 +117,6 @@ class RileyLinkBLEConfigActivity : TranslatedDaggerAppCompatActivity() {
updateCurrentlySelectedRileyLink() updateCurrentlySelectedRileyLink()
}) })
} }
// 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 updateCurrentlySelectedRileyLink() { private fun updateCurrentlySelectedRileyLink() {

View file

@ -4,12 +4,8 @@ import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import android.text.Editable import android.text.Editable
import android.text.TextWatcher import android.text.TextWatcher
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import android.widget.TextView import android.widget.TextView
import androidx.core.view.MenuProvider
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import com.google.common.collect.Lists import com.google.common.collect.Lists
import info.nightscout.core.profile.ProfileSealed import info.nightscout.core.profile.ProfileSealed
@ -254,21 +250,6 @@ class ProfileHelperActivity : TranslatedDaggerAppCompatActivity() {
binding.basalPctFromTddLabel.labelFor = binding.basalPctFromTdd.editTextId binding.basalPctFromTddLabel.labelFor = binding.basalPctFromTdd.editTextId
switchTab(0, typeSelected[0], false) 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? = private fun getProfile(age: Int, tdd: Double, weight: Double, basalPct: Double, tab: Int): PureProfile? =

View file

@ -5,11 +5,13 @@ import android.os.Bundle
import android.util.SparseArray import android.util.SparseArray
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.util.forEach import androidx.core.util.forEach
import androidx.core.view.MenuProvider
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -152,6 +154,14 @@ class QuickWizardListActivity : TranslatedDaggerAppCompatActivity(), OnStartDrag
val editQuickWizardDialog = EditQuickWizardDialog() val editQuickWizardDialog = EditQuickWizardDialog()
editQuickWizardDialog.show(manager, "EditQuickWizardDialog") editQuickWizardDialog.show(manager, "EditQuickWizardDialog")
} }
addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
menuInflater.inflate(info.nightscout.core.utils.R.menu.menu_actions, menu)
}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean =
actionHelper.onOptionsItemSelected(menuItem)
})
} }
override fun onResume() { override fun onResume() {
@ -181,22 +191,6 @@ class QuickWizardListActivity : TranslatedDaggerAppCompatActivity(), OnStartDrag
}) })
} }
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(info.nightscout.core.utils.R.menu.menu_actions, menu)
return super.onCreateOptionsMenu(menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean =
when (item.itemId) {
android.R.id.home -> {
finish()
true
}
else -> actionHelper.onOptionsItemSelected(item)
}
private fun getConfirmationText(selectedItems: SparseArray<QuickWizardEntry>): String { private fun getConfirmationText(selectedItems: SparseArray<QuickWizardEntry>): String {
if (selectedItems.size() == 1) { if (selectedItems.size() == 1) {
val entry = selectedItems.valueAt(0) val entry = selectedItems.valueAt(0)

View file

@ -4,11 +4,7 @@ import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.HandlerThread import android.os.HandlerThread
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.widget.TextView import android.widget.TextView
import androidx.core.view.MenuProvider
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
@ -104,20 +100,6 @@ class StatsActivity : 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
}
})
} }
override fun onPause() { override fun onPause() {

View file

@ -5,9 +5,6 @@ import android.graphics.Rect
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils import android.text.TextUtils
import android.view.KeyEvent import android.view.KeyEvent
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View import android.view.View
import android.view.WindowManager import android.view.WindowManager
@ -17,7 +14,6 @@ import android.widget.EditText
import android.widget.TableLayout import android.widget.TableLayout
import android.widget.TableRow import android.widget.TableRow
import android.widget.TextView import android.widget.TextView
import androidx.core.view.MenuProvider
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.TotalDailyDose import info.nightscout.database.entities.TotalDailyDose
@ -200,20 +196,6 @@ class TDDStatsActivity : TranslatedDaggerAppCompatActivity() {
} }
} }
loadDataFromDB() loadDataFromDB()
// 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
}
})
} }
override fun onResume() { override fun onResume() {

View file

@ -1,10 +1,6 @@
package info.nightscout.ui.activities package info.nightscout.ui.activities
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import androidx.core.view.MenuProvider
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction import androidx.fragment.app.FragmentTransaction
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
@ -64,20 +60,6 @@ class TreatmentsActivity : TranslatedDaggerAppCompatActivity() {
override fun onTabUnselected(tab: TabLayout.Tab) {} override fun onTabUnselected(tab: TabLayout.Tab) {}
override fun onTabReselected(tab: TabLayout.Tab) {} override fun onTabReselected(tab: TabLayout.Tab) {}
}) })
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 setFragment(selectedFragment: Fragment) { private fun setFragment(selectedFragment: Fragment) {