diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMenuController.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMenuController.kt index 101686648b..fdc87d63c4 100644 --- a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMenuController.kt +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMenuController.kt @@ -49,7 +49,6 @@ import org.mozilla.fenix.ext.nav import org.mozilla.fenix.ext.navigateSafe import org.mozilla.fenix.ext.openSetDefaultBrowserOption import org.mozilla.fenix.settings.deletebrowsingdata.deleteAndQuit -import org.mozilla.fenix.utils.Do import org.mozilla.fenix.utils.Settings /** @@ -95,7 +94,7 @@ class DefaultBrowserToolbarMenuController( val customTabUseCases = activity.components.useCases.customTabsUseCases trackToolbarItemInteraction(item) - Do exhaustive when (item) { + when (item) { // TODO: These can be removed for https://github.com/mozilla-mobile/fenix/issues/17870 // todo === Start === is ToolbarMenu.Item.InstallPwaToHomeScreen -> { diff --git a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractor.kt b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractor.kt index a0da5d34d2..55d8f6111e 100644 --- a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractor.kt +++ b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractor.kt @@ -9,7 +9,6 @@ import mozilla.components.concept.storage.BookmarkNodeType import mozilla.telemetry.glean.private.NoExtras import org.mozilla.fenix.GleanMetrics.BookmarksManagement import org.mozilla.fenix.browser.browsingmode.BrowsingMode -import org.mozilla.fenix.utils.Do /** * Interactor for the Bookmarks screen. @@ -113,7 +112,7 @@ class BookmarkFragmentInteractor( } override fun open(item: BookmarkNode) { - Do exhaustive when (item.type) { + when (item.type) { BookmarkNodeType.ITEM -> { bookmarksController.handleBookmarkTapped(item) BookmarksManagement.open.record(NoExtras()) diff --git a/app/src/main/java/org/mozilla/fenix/library/bookmarks/viewholders/BookmarkNodeViewHolder.kt b/app/src/main/java/org/mozilla/fenix/library/bookmarks/viewholders/BookmarkNodeViewHolder.kt index 265aaa9818..0e5c70f741 100644 --- a/app/src/main/java/org/mozilla/fenix/library/bookmarks/viewholders/BookmarkNodeViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/library/bookmarks/viewholders/BookmarkNodeViewHolder.kt @@ -23,7 +23,6 @@ import org.mozilla.fenix.library.bookmarks.BookmarkItemMenu import org.mozilla.fenix.library.bookmarks.BookmarkPayload import org.mozilla.fenix.library.bookmarks.BookmarkViewInteractor import org.mozilla.fenix.library.bookmarks.inRoots -import org.mozilla.fenix.utils.Do /** * Base class for bookmark node view holders. @@ -39,7 +38,7 @@ class BookmarkNodeViewHolder( init { menu = BookmarkItemMenu(containerView.context) { menuItem -> val item = this.item ?: return@BookmarkItemMenu - Do exhaustive when (menuItem) { + when (menuItem) { BookmarkItemMenu.Item.Edit -> interactor.onEditPressed(item) BookmarkItemMenu.Item.Copy -> interactor.onCopyPressed(item) BookmarkItemMenu.Item.Share -> interactor.onSharePressed(item) diff --git a/app/src/main/java/org/mozilla/fenix/library/history/viewholders/HistoryListItemViewHolder.kt b/app/src/main/java/org/mozilla/fenix/library/history/viewholders/HistoryListItemViewHolder.kt index 6d8226f5eb..5c8eaab39d 100644 --- a/app/src/main/java/org/mozilla/fenix/library/history/viewholders/HistoryListItemViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/library/history/viewholders/HistoryListItemViewHolder.kt @@ -17,7 +17,6 @@ import org.mozilla.fenix.library.history.HistoryFragmentState import org.mozilla.fenix.library.history.HistoryInteractor import org.mozilla.fenix.library.history.HistoryItemTimeGroup import org.mozilla.fenix.selection.SelectionHolder -import org.mozilla.fenix.utils.Do class HistoryListItemViewHolder( view: View, @@ -67,7 +66,7 @@ class HistoryListItemViewHolder( binding.historyLayout.titleView.text = item.title - binding.historyLayout.urlView.text = Do exhaustive when (item) { + binding.historyLayout.urlView.text = when (item) { is History.Regular -> item.url is History.Metadata -> item.url is History.Group -> { diff --git a/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt index 99fa4ca65d..e027124f90 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt @@ -31,7 +31,6 @@ import org.mozilla.fenix.settings.about.AboutItemType.PRIVACY_NOTICE import org.mozilla.fenix.settings.about.AboutItemType.RIGHTS import org.mozilla.fenix.settings.about.AboutItemType.SUPPORT import org.mozilla.fenix.settings.about.AboutItemType.WHATS_NEW -import org.mozilla.fenix.utils.Do import org.mozilla.fenix.whatsnew.WhatsNew import org.mozilla.geckoview.BuildConfig as GeckoViewBuildConfig @@ -189,7 +188,7 @@ class AboutFragment : Fragment(), AboutPageListener { } override fun onAboutItemClicked(item: AboutItem) { - Do exhaustive when (item) { + when (item) { is AboutItem.ExternalLink -> { when (item.type) { WHATS_NEW -> { diff --git a/app/src/main/java/org/mozilla/fenix/share/viewholders/AccountDeviceViewHolder.kt b/app/src/main/java/org/mozilla/fenix/share/viewholders/AccountDeviceViewHolder.kt index bd4a343c5c..56ddbd5266 100644 --- a/app/src/main/java/org/mozilla/fenix/share/viewholders/AccountDeviceViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/share/viewholders/AccountDeviceViewHolder.kt @@ -14,7 +14,6 @@ import org.mozilla.fenix.R import org.mozilla.fenix.databinding.AccountShareListItemBinding import org.mozilla.fenix.share.ShareToAccountDevicesInteractor import org.mozilla.fenix.share.listadapters.SyncShareOption -import org.mozilla.fenix.utils.Do class AccountDeviceViewHolder( itemView: View, @@ -31,7 +30,7 @@ class AccountDeviceViewHolder( private fun bindClickListeners(option: SyncShareOption) { itemView.setOnClickListener { - Do exhaustive when (option) { + when (option) { SyncShareOption.SignIn -> interactor.onSignIn() SyncShareOption.AddNewDevice -> interactor.onAddNewDevice() is SyncShareOption.SendAll -> interactor.onShareToAllDevices(option.devices) diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/MenuIntegration.kt b/app/src/main/java/org/mozilla/fenix/tabstray/MenuIntegration.kt index c3272a0535..7a352b6e9b 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/MenuIntegration.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/MenuIntegration.kt @@ -9,7 +9,6 @@ import androidx.annotation.VisibleForTesting import com.google.android.material.tabs.TabLayout import mozilla.components.browser.menu.BrowserMenuBuilder import mozilla.components.browser.state.store.BrowserStore -import org.mozilla.fenix.utils.Do /** * A wrapper class that building the tabs tray menu that handles item clicks. @@ -40,7 +39,7 @@ class MenuIntegration( @VisibleForTesting internal fun handleMenuClicked(item: TabsTrayMenu.Item) { - Do exhaustive when (item) { + when (item) { is TabsTrayMenu.Item.ShareAllTabs -> navigationInteractor.onShareTabsOfTypeClicked(isPrivateMode) is TabsTrayMenu.Item.OpenAccountSettings -> diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/browser/SelectionMenuIntegration.kt b/app/src/main/java/org/mozilla/fenix/tabstray/browser/SelectionMenuIntegration.kt index d324dcf734..9c796915dc 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/browser/SelectionMenuIntegration.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/browser/SelectionMenuIntegration.kt @@ -8,7 +8,6 @@ import android.content.Context import androidx.annotation.VisibleForTesting import mozilla.components.browser.menu.BrowserMenuBuilder import org.mozilla.fenix.tabstray.TabsTrayInteractor -import org.mozilla.fenix.utils.Do class SelectionMenuIntegration( private val context: Context, @@ -25,7 +24,7 @@ class SelectionMenuIntegration( @VisibleForTesting internal fun handleMenuClicked(item: SelectionMenu.Item) { - Do exhaustive when (item) { + when (item) { is SelectionMenu.Item.BookmarkTabs -> { interactor.onBookmarkSelectedTabsClicked() } diff --git a/app/src/main/java/org/mozilla/fenix/utils/Do.kt b/app/src/main/java/org/mozilla/fenix/utils/Do.kt deleted file mode 100644 index 802c92302a..0000000000 --- a/app/src/main/java/org/mozilla/fenix/utils/Do.kt +++ /dev/null @@ -1,18 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.fenix.utils - -object Do { - - /** - * Indicates to the linter that the following when statement should be exhaustive. - * - * @sample Do exhaustive when (bool) { - * true -> Unit - * false -> Unit - * } - */ - inline infix fun exhaustive(any: T?) = any -}