From 04f82332a764d2b35f9c79a75253573dbc2e7940 Mon Sep 17 00:00:00 2001 From: Lorelai L Date: Thu, 11 May 2023 23:46:34 +0200 Subject: [PATCH] use MenuCompat --- app/src/main/java/info/nightscout/androidaps/MainActivity.kt | 5 +++-- .../main/java/info/nightscout/core/utils/ActionModeHelper.kt | 3 ++- .../main/java/info/nightscout/plugins/aps/OpenAPSFragment.kt | 3 ++- .../java/info/nightscout/plugins/aps/loop/LoopFragment.kt | 5 +++-- .../java/info/nightscout/automation/AutomationFragment.kt | 5 +++-- .../nightscout/plugins/sync/nsShared/NSClientFragment.kt | 3 ++- .../nightscout/plugins/sync/tidepool/TidepoolFragment.kt | 5 +++-- .../java/info/nightscout/plugins/sync/xdrip/XdripFragment.kt | 3 ++- 8 files changed, 20 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index b42a51e8be..1a7bd16cfe 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -24,6 +24,7 @@ import android.widget.TextView import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.widget.Toolbar import androidx.core.view.GravityCompat +import androidx.core.view.MenuCompat import androidx.viewpager2.widget.ViewPager2 import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.tabs.TabLayoutMediator @@ -302,7 +303,7 @@ class MainActivity : DaggerAppCompatActivityWithResult() { override fun onCreateOptionsMenu(menu: Menu): Boolean { super.onCreateOptionsMenu(menu) - menu.setGroupDividerEnabled(true) + MenuCompat.setGroupDividerEnabled(menu, true) this.menu = menu menuInflater.inflate(R.menu.menu_main, menu) pluginPreferencesMenuItem = menu.findItem(R.id.nav_plugin_preferences) @@ -477,4 +478,4 @@ class MainActivity : DaggerAppCompatActivityWithResult() { ToastUtils.okToast(context, context.getString(info.nightscout.core.ui.R.string.password_set)) } } -} +} \ No newline at end of file diff --git a/core/utils/src/main/java/info/nightscout/core/utils/ActionModeHelper.kt b/core/utils/src/main/java/info/nightscout/core/utils/ActionModeHelper.kt index 8de965d99e..fc79710d7f 100644 --- a/core/utils/src/main/java/info/nightscout/core/utils/ActionModeHelper.kt +++ b/core/utils/src/main/java/info/nightscout/core/utils/ActionModeHelper.kt @@ -5,6 +5,7 @@ import android.view.ActionMode import android.view.Menu import android.view.MenuInflater import android.view.MenuItem +import androidx.core.view.MenuCompat import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity import info.nightscout.shared.interfaces.ResourceHelper @@ -68,7 +69,7 @@ class ActionModeHelper(val rh: ResourceHelper, val activity: FragmentActivity } else if (fragment?.isResumed == true) { menu.add(Menu.FIRST, R.id.nav_remove_items, 0, rh.gs(R.string.remove_items)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) menu.add(Menu.FIRST, R.id.nav_sort_items, 0, rh.gs(R.string.sort_items)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) - menu.setGroupDividerEnabled(true) + MenuCompat.setGroupDividerEnabled(menu, true) } } diff --git a/plugins/aps/src/main/java/info/nightscout/plugins/aps/OpenAPSFragment.kt b/plugins/aps/src/main/java/info/nightscout/plugins/aps/OpenAPSFragment.kt index 5bc4c7d367..293e048e61 100644 --- a/plugins/aps/src/main/java/info/nightscout/plugins/aps/OpenAPSFragment.kt +++ b/plugins/aps/src/main/java/info/nightscout/plugins/aps/OpenAPSFragment.kt @@ -10,6 +10,7 @@ import android.view.MenuInflater import android.view.MenuItem import android.view.View import android.view.ViewGroup +import androidx.core.view.MenuCompat import androidx.core.view.MenuProvider import androidx.lifecycle.Lifecycle import dagger.android.support.DaggerFragment @@ -72,7 +73,7 @@ class OpenAPSFragment : DaggerFragment(), MenuProvider { override fun onCreateMenu(menu: Menu, inflater: MenuInflater) { menu.add(Menu.FIRST, ID_MENU_RUN, 0, rh.gs(R.string.openapsma_run)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) - menu.setGroupDividerEnabled(true) + MenuCompat.setGroupDividerEnabled(menu, true) } override fun onMenuItemSelected(item: MenuItem): Boolean = diff --git a/plugins/aps/src/main/java/info/nightscout/plugins/aps/loop/LoopFragment.kt b/plugins/aps/src/main/java/info/nightscout/plugins/aps/loop/LoopFragment.kt index d49c72cab4..e6ca338044 100644 --- a/plugins/aps/src/main/java/info/nightscout/plugins/aps/loop/LoopFragment.kt +++ b/plugins/aps/src/main/java/info/nightscout/plugins/aps/loop/LoopFragment.kt @@ -9,6 +9,7 @@ import android.view.MenuInflater import android.view.MenuItem import android.view.View import android.view.ViewGroup +import androidx.core.view.MenuCompat import androidx.core.view.MenuProvider import androidx.lifecycle.Lifecycle import dagger.android.support.DaggerFragment @@ -74,7 +75,7 @@ class LoopFragment : DaggerFragment(), MenuProvider { override fun onCreateMenu(menu: Menu, inflater: MenuInflater) { menu.add(Menu.FIRST, ID_MENU_RUN, 0, rh.gs(R.string.run_now)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) - menu.setGroupDividerEnabled(true) + MenuCompat.setGroupDividerEnabled(menu, true) } override fun onMenuItemSelected(item: MenuItem): Boolean = @@ -169,4 +170,4 @@ class LoopFragment : DaggerFragment(), MenuProvider { binding.smbsetbypump.text = "" binding.swipeRefresh.isRefreshing = false } -} +} \ No newline at end of file diff --git a/plugins/automation/src/main/java/info/nightscout/automation/AutomationFragment.kt b/plugins/automation/src/main/java/info/nightscout/automation/AutomationFragment.kt index 5afc7495ba..610ae67a12 100644 --- a/plugins/automation/src/main/java/info/nightscout/automation/AutomationFragment.kt +++ b/plugins/automation/src/main/java/info/nightscout/automation/AutomationFragment.kt @@ -16,6 +16,7 @@ import android.widget.ImageView import android.widget.LinearLayout import androidx.annotation.DrawableRes import androidx.core.util.forEach +import androidx.core.view.MenuCompat import androidx.core.view.MenuProvider import androidx.lifecycle.Lifecycle import androidx.recyclerview.widget.ItemTouchHelper @@ -97,7 +98,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener, MenuProvider { actionHelper.onCreateOptionsMenu(menu, inflater) menu.add(Menu.FIRST, ID_MENU_ADD, 0, rh.gs(R.string.add_automation)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) menu.add(Menu.FIRST, ID_MENU_RUN, 0, rh.gs(R.string.run_automations)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) - menu.setGroupDividerEnabled(true) + MenuCompat.setGroupDividerEnabled(menu, true) } override fun onMenuItemSelected(item: MenuItem): Boolean = @@ -309,4 +310,4 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener, MenuProvider { } }.show(childFragmentManager, "EditEventDialog") } -} +} \ No newline at end of file diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsShared/NSClientFragment.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsShared/NSClientFragment.kt index 1feb719779..1960ffb2b8 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsShared/NSClientFragment.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsShared/NSClientFragment.kt @@ -11,6 +11,7 @@ import android.view.MenuItem import android.view.View import android.view.ViewGroup import androidx.core.text.toSpanned +import androidx.core.view.MenuCompat import androidx.core.view.MenuProvider import androidx.lifecycle.Lifecycle import androidx.recyclerview.widget.LinearLayoutManager @@ -113,7 +114,7 @@ class NSClientFragment : DaggerFragment(), MenuProvider, PluginFragment { menu.add(Menu.FIRST, ID_MENU_RESTART, 0, rh.gs(R.string.restart)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) menu.add(Menu.FIRST, ID_MENU_SEND_NOW, 0, rh.gs(R.string.deliver_now)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) menu.add(Menu.FIRST, ID_MENU_FULL_SYNC, 0, rh.gs(R.string.full_sync)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) - menu.setGroupDividerEnabled(true) + MenuCompat.setGroupDividerEnabled(menu, true) } override fun onMenuItemSelected(item: MenuItem): Boolean = diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/tidepool/TidepoolFragment.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/tidepool/TidepoolFragment.kt index 827d8c5a2c..2a32b3b643 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/tidepool/TidepoolFragment.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/tidepool/TidepoolFragment.kt @@ -8,6 +8,7 @@ import android.view.MenuItem import android.view.View import android.view.ViewGroup import android.widget.ScrollView +import androidx.core.view.MenuCompat import androidx.core.view.MenuProvider import androidx.lifecycle.Lifecycle import dagger.android.support.DaggerFragment @@ -63,7 +64,7 @@ class TidepoolFragment : DaggerFragment(), MenuProvider { menu.add(Menu.FIRST, ID_MENU_SEND_NOW, 0, rh.gs(R.string.upload_now)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) menu.add(Menu.FIRST, ID_MENU_REMOVE_ALL, 0, rh.gs(R.string.remove_all)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) menu.add(Menu.FIRST, ID_MENU_FULL_SYNC, 0, rh.gs(R.string.full_sync)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) - menu.setGroupDividerEnabled(true) + MenuCompat.setGroupDividerEnabled(menu, true) } override fun onMenuItemSelected(item: MenuItem): Boolean = @@ -120,4 +121,4 @@ class TidepoolFragment : DaggerFragment(), MenuProvider { super.onDestroyView() _binding = null } -} +} \ No newline at end of file diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/xdrip/XdripFragment.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/xdrip/XdripFragment.kt index 7e838af329..ca3f64e0ca 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/xdrip/XdripFragment.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/xdrip/XdripFragment.kt @@ -9,6 +9,7 @@ import android.view.MenuInflater import android.view.MenuItem import android.view.View import android.view.ViewGroup +import androidx.core.view.MenuCompat import androidx.core.view.MenuProvider import androidx.lifecycle.Lifecycle import dagger.android.support.DaggerFragment @@ -67,7 +68,7 @@ class XdripFragment : DaggerFragment(), MenuProvider, PluginFragment { override fun onCreateMenu(menu: Menu, inflater: MenuInflater) { menu.add(Menu.FIRST, ID_MENU_CLEAR_LOG, 0, rh.gs(R.string.clear_log)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) menu.add(Menu.FIRST, ID_MENU_FULL_SYNC, 0, rh.gs(R.string.full_sync)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) - menu.setGroupDividerEnabled(true) + MenuCompat.setGroupDividerEnabled(menu, true) } override fun onMenuItemSelected(item: MenuItem): Boolean =