From 45e9bf66930c620cb163fd7127130968c685f936 Mon Sep 17 00:00:00 2001 From: Gabriel Luong Date: Thu, 7 Oct 2021 13:56:37 -0400 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/21776 - Remove unused symbols --- .../fenix/components/SearchWidgetCreator.kt | 29 ------------------- .../components/metrics/GleanMetricsService.kt | 5 ---- .../org/mozilla/fenix/compose/TabTitle.kt | 2 ++ .../org/mozilla/fenix/home/HomeFragment.kt | 8 +---- .../java/org/mozilla/fenix/home/HomeMenu.kt | 1 - .../mozilla/fenix/home/ImageViewTopCrop.kt | 21 -------------- .../SessionControlController.kt | 3 +- .../fenix/library/bookmarks/BookmarkView.kt | 7 ----- .../library/downloads/DownloadAdapter.kt | 19 +----------- .../DefaultSessionControlControllerTest.kt | 8 ++--- .../BookmarkFragmentInteractorTest.kt | 4 --- 11 files changed, 8 insertions(+), 99 deletions(-) delete mode 100644 app/src/main/java/org/mozilla/fenix/components/SearchWidgetCreator.kt delete mode 100644 app/src/main/java/org/mozilla/fenix/home/ImageViewTopCrop.kt diff --git a/app/src/main/java/org/mozilla/fenix/components/SearchWidgetCreator.kt b/app/src/main/java/org/mozilla/fenix/components/SearchWidgetCreator.kt deleted file mode 100644 index 5e50a961c6..0000000000 --- a/app/src/main/java/org/mozilla/fenix/components/SearchWidgetCreator.kt +++ /dev/null @@ -1,29 +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.components - -import android.annotation.TargetApi -import android.appwidget.AppWidgetManager -import android.content.ComponentName -import android.content.Context -import android.os.Build -import org.mozilla.gecko.search.SearchWidgetProvider - -/** - * Handles the creation of the pinning search widget dialog. - */ -object SearchWidgetCreator { - - /** - * Attempts to display a prompt requesting the user pin the search widget - * Returns true if the prompt is displayed successfully, and false otherwise. - */ - @TargetApi(Build.VERSION_CODES.O) - fun createSearchWidget(context: Context): Boolean { - val appWidgetManager: AppWidgetManager = context.getSystemService(AppWidgetManager::class.java) - val myProvider = ComponentName(context, SearchWidgetProvider::class.java) - return appWidgetManager.requestPinAppWidget(myProvider, null, null) - } -} diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt index 4b295a8b1b..bd06e7988a 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt @@ -905,8 +905,3 @@ class GleanMetricsService( return event.wrapper != null } } - -// Helper function for making our booleans fit into the string list formatting -fun Boolean.toStringList(): List { - return listOf(this.toString()) -} diff --git a/app/src/main/java/org/mozilla/fenix/compose/TabTitle.kt b/app/src/main/java/org/mozilla/fenix/compose/TabTitle.kt index bcca9ebf2f..25516f36b5 100644 --- a/app/src/main/java/org/mozilla/fenix/compose/TabTitle.kt +++ b/app/src/main/java/org/mozilla/fenix/compose/TabTitle.kt @@ -11,6 +11,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.sp import org.mozilla.fenix.theme.FirefoxTheme @@ -39,6 +40,7 @@ fun TabTitle( } @Composable +@Preview private fun TabTitlePreview() { FirefoxTheme { Box(Modifier.background(FirefoxTheme.colors.surface)) { diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt index dc9ee4ef33..b71a69b65a 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -344,8 +344,7 @@ class HomeFragment : Fragment() { hideOnboarding = ::hideOnboardingAndOpenSearch, registerCollectionStorageObserver = ::registerCollectionStorageObserver, removeCollectionWithUndo = ::removeCollectionWithUndo, - showTabTray = ::openTabsTray, - handleSwipedItemDeletionCancel = ::handleSwipedItemDeletionCancel + showTabTray = ::openTabsTray ), recentTabController = DefaultRecentTabsController( selectTabUseCase = components.useCases.tabsUseCases.selectTab, @@ -1179,11 +1178,6 @@ class HomeFragment : Fragment() { ?.isVisible = tabCount > 0 } - @SuppressLint("NotifyDataSetChanged") - private fun handleSwipedItemDeletionCancel() { - binding.sessionControlRecyclerView.adapter?.notifyDataSetChanged() - } - private fun getRecentTabs(components: Components): List { return if (components.settings.showRecentTabsFeature) { components.core.store.state.asRecentTabs() diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeMenu.kt b/app/src/main/java/org/mozilla/fenix/home/HomeMenu.kt index d63618e43f..3c60983308 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeMenu.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeMenu.kt @@ -63,7 +63,6 @@ class HomeMenu( private val syncDisconnectedBackgroundColor = context.getColorFromAttr(R.attr.syncDisconnectedBackground) - private val shouldUseBottomToolbar = context.settings().shouldUseBottomToolbar private val accountManager = FenixAccountManager(context) // 'Reconnect' and 'Quit' items aren't needed most of the time, so we'll only create the if necessary. diff --git a/app/src/main/java/org/mozilla/fenix/home/ImageViewTopCrop.kt b/app/src/main/java/org/mozilla/fenix/home/ImageViewTopCrop.kt deleted file mode 100644 index 50f5e57188..0000000000 --- a/app/src/main/java/org/mozilla/fenix/home/ImageViewTopCrop.kt +++ /dev/null @@ -1,21 +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.home - -import android.content.Context -import android.util.AttributeSet -import androidx.appcompat.widget.AppCompatImageView - -class ImageViewTopCrop(context: Context, attrs: AttributeSet) : AppCompatImageView(context, attrs) { - override fun setFrame(l: Int, t: Int, r: Int, b: Int): Boolean { - val scaleFactor = width / drawable.intrinsicWidth.toFloat() - val matrix = imageMatrix - - matrix.setScale(scaleFactor, scaleFactor, 0f, 0f) - imageMatrix = matrix - - return super.setFrame(l, t, r, b) - } -} diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt index 0028195a08..3f0051f792 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt @@ -208,8 +208,7 @@ class DefaultSessionControlController( private val hideOnboarding: () -> Unit, private val registerCollectionStorageObserver: () -> Unit, private val removeCollectionWithUndo: (tabCollection: TabCollection) -> Unit, - private val showTabTray: () -> Unit, - private val handleSwipedItemDeletionCancel: () -> Unit + private val showTabTray: () -> Unit ) : SessionControlController { override fun handleCollectionAddTabTapped(collection: TabCollection) { diff --git a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkView.kt b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkView.kt index 7c7925079c..dcbf80948e 100644 --- a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkView.kt +++ b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkView.kt @@ -174,11 +174,4 @@ class BookmarkView( if (BookmarkRoot.Mobile.id == root?.guid) context.getString(R.string.library_bookmarks) else root?.title ) } - - /** - * Returns true if [root] matches the bookmark root ID. - */ - private fun BookmarkRoot.matches(root: BookmarkNode?): Boolean { - return root == null || id == root.guid - } } diff --git a/app/src/main/java/org/mozilla/fenix/library/downloads/DownloadAdapter.kt b/app/src/main/java/org/mozilla/fenix/library/downloads/DownloadAdapter.kt index 70c0fd5a26..3e6a14e4d4 100644 --- a/app/src/main/java/org/mozilla/fenix/library/downloads/DownloadAdapter.kt +++ b/app/src/main/java/org/mozilla/fenix/library/downloads/DownloadAdapter.kt @@ -6,10 +6,9 @@ package org.mozilla.fenix.library.downloads import android.view.LayoutInflater import android.view.ViewGroup -import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView -import org.mozilla.fenix.selection.SelectionHolder import org.mozilla.fenix.library.downloads.viewholders.DownloadsListItemViewHolder +import org.mozilla.fenix.selection.SelectionHolder class DownloadAdapter( private val downloadInteractor: DownloadInteractor @@ -47,20 +46,4 @@ class DownloadAdapter( fun updatePendingDeletionIds(pendingDeletionIds: Set) { this.pendingDeletionIds = pendingDeletionIds } - - companion object { - private val downloadDiffCallback = object : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: DownloadItem, newItem: DownloadItem): Boolean { - return oldItem == newItem - } - - override fun areContentsTheSame(oldItem: DownloadItem, newItem: DownloadItem): Boolean { - return oldItem == newItem - } - - override fun getChangePayload(oldItem: DownloadItem, newItem: DownloadItem): Any? { - return newItem - } - } - } } diff --git a/app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt b/app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt index 408bfd9353..bad1f61243 100644 --- a/app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt @@ -820,28 +820,26 @@ class DefaultSessionControlControllerTest { hideOnboarding: () -> Unit = { }, registerCollectionStorageObserver: () -> Unit = { }, showTabTray: () -> Unit = { }, - handleSwipedItemDeletionCancel: () -> Unit = { }, removeCollectionWithUndo: (tabCollection: TabCollection) -> Unit = { } ): DefaultSessionControlController { return DefaultSessionControlController( activity = activity, - store = store, settings = settings, engine = engine, metrics = metrics, + store = store, tabCollectionStorage = tabCollectionStorage, addTabUseCase = tabsUseCases.addTab, + restoreUseCase = mockk(relaxed = true), reloadUrlUseCase = reloadUrlUseCase.reload, selectTabUseCase = selectTabUseCase.selectTab, - restoreUseCase = mockk(relaxed = true), fragmentStore = fragmentStore, navController = navController, viewLifecycleScope = scope, hideOnboarding = hideOnboarding, registerCollectionStorageObserver = registerCollectionStorageObserver, removeCollectionWithUndo = removeCollectionWithUndo, - showTabTray = showTabTray, - handleSwipedItemDeletionCancel = handleSwipedItemDeletionCancel + showTabTray = showTabTray ) } } diff --git a/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractorTest.kt b/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractorTest.kt index f965d18078..fac5b2b60d 100644 --- a/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractorTest.kt +++ b/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractorTest.kt @@ -7,7 +7,6 @@ package org.mozilla.fenix.library.bookmarks import io.mockk.mockk import io.mockk.verify import io.mockk.verifyOrder -import mozilla.appservices.places.BookmarkRoot import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNodeType import org.junit.Before @@ -30,9 +29,6 @@ class BookmarkFragmentInteractorTest { private val tree: BookmarkNode = BookmarkNode( BookmarkNodeType.FOLDER, "123", null, 0, "Mobile", null, 0, listOf(item, separator, item, subfolder) ) - private val root = BookmarkNode( - BookmarkNodeType.FOLDER, BookmarkRoot.Root.id, null, 0, BookmarkRoot.Root.name, null, 0, null - ) @Before fun setup() {