2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-17 15:26:23 +00:00
This commit is contained in:
Gabriel Luong 2021-10-07 13:56:37 -04:00 committed by mergify[bot]
parent 759194a625
commit 45e9bf6693
11 changed files with 8 additions and 99 deletions

View File

@ -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)
}
}

View File

@ -905,8 +905,3 @@ class GleanMetricsService(
return event.wrapper != null return event.wrapper != null
} }
} }
// Helper function for making our booleans fit into the string list formatting
fun Boolean.toStringList(): List<String> {
return listOf(this.toString())
}

View File

@ -11,6 +11,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import org.mozilla.fenix.theme.FirefoxTheme import org.mozilla.fenix.theme.FirefoxTheme
@ -39,6 +40,7 @@ fun TabTitle(
} }
@Composable @Composable
@Preview
private fun TabTitlePreview() { private fun TabTitlePreview() {
FirefoxTheme { FirefoxTheme {
Box(Modifier.background(FirefoxTheme.colors.surface)) { Box(Modifier.background(FirefoxTheme.colors.surface)) {

View File

@ -344,8 +344,7 @@ class HomeFragment : Fragment() {
hideOnboarding = ::hideOnboardingAndOpenSearch, hideOnboarding = ::hideOnboardingAndOpenSearch,
registerCollectionStorageObserver = ::registerCollectionStorageObserver, registerCollectionStorageObserver = ::registerCollectionStorageObserver,
removeCollectionWithUndo = ::removeCollectionWithUndo, removeCollectionWithUndo = ::removeCollectionWithUndo,
showTabTray = ::openTabsTray, showTabTray = ::openTabsTray
handleSwipedItemDeletionCancel = ::handleSwipedItemDeletionCancel
), ),
recentTabController = DefaultRecentTabsController( recentTabController = DefaultRecentTabsController(
selectTabUseCase = components.useCases.tabsUseCases.selectTab, selectTabUseCase = components.useCases.tabsUseCases.selectTab,
@ -1179,11 +1178,6 @@ class HomeFragment : Fragment() {
?.isVisible = tabCount > 0 ?.isVisible = tabCount > 0
} }
@SuppressLint("NotifyDataSetChanged")
private fun handleSwipedItemDeletionCancel() {
binding.sessionControlRecyclerView.adapter?.notifyDataSetChanged()
}
private fun getRecentTabs(components: Components): List<RecentTab> { private fun getRecentTabs(components: Components): List<RecentTab> {
return if (components.settings.showRecentTabsFeature) { return if (components.settings.showRecentTabsFeature) {
components.core.store.state.asRecentTabs() components.core.store.state.asRecentTabs()

View File

@ -63,7 +63,6 @@ class HomeMenu(
private val syncDisconnectedBackgroundColor = private val syncDisconnectedBackgroundColor =
context.getColorFromAttr(R.attr.syncDisconnectedBackground) context.getColorFromAttr(R.attr.syncDisconnectedBackground)
private val shouldUseBottomToolbar = context.settings().shouldUseBottomToolbar
private val accountManager = FenixAccountManager(context) private val accountManager = FenixAccountManager(context)
// 'Reconnect' and 'Quit' items aren't needed most of the time, so we'll only create the if necessary. // 'Reconnect' and 'Quit' items aren't needed most of the time, so we'll only create the if necessary.

View File

@ -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)
}
}

View File

@ -208,8 +208,7 @@ class DefaultSessionControlController(
private val hideOnboarding: () -> Unit, private val hideOnboarding: () -> Unit,
private val registerCollectionStorageObserver: () -> Unit, private val registerCollectionStorageObserver: () -> Unit,
private val removeCollectionWithUndo: (tabCollection: TabCollection) -> Unit, private val removeCollectionWithUndo: (tabCollection: TabCollection) -> Unit,
private val showTabTray: () -> Unit, private val showTabTray: () -> Unit
private val handleSwipedItemDeletionCancel: () -> Unit
) : SessionControlController { ) : SessionControlController {
override fun handleCollectionAddTabTapped(collection: TabCollection) { override fun handleCollectionAddTabTapped(collection: TabCollection) {

View File

@ -174,11 +174,4 @@ class BookmarkView(
if (BookmarkRoot.Mobile.id == root?.guid) context.getString(R.string.library_bookmarks) else root?.title 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
}
} }

View File

@ -6,10 +6,9 @@ package org.mozilla.fenix.library.downloads
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import org.mozilla.fenix.selection.SelectionHolder
import org.mozilla.fenix.library.downloads.viewholders.DownloadsListItemViewHolder import org.mozilla.fenix.library.downloads.viewholders.DownloadsListItemViewHolder
import org.mozilla.fenix.selection.SelectionHolder
class DownloadAdapter( class DownloadAdapter(
private val downloadInteractor: DownloadInteractor private val downloadInteractor: DownloadInteractor
@ -47,20 +46,4 @@ class DownloadAdapter(
fun updatePendingDeletionIds(pendingDeletionIds: Set<String>) { fun updatePendingDeletionIds(pendingDeletionIds: Set<String>) {
this.pendingDeletionIds = pendingDeletionIds this.pendingDeletionIds = pendingDeletionIds
} }
companion object {
private val downloadDiffCallback = object : DiffUtil.ItemCallback<DownloadItem>() {
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
}
}
}
} }

View File

@ -820,28 +820,26 @@ class DefaultSessionControlControllerTest {
hideOnboarding: () -> Unit = { }, hideOnboarding: () -> Unit = { },
registerCollectionStorageObserver: () -> Unit = { }, registerCollectionStorageObserver: () -> Unit = { },
showTabTray: () -> Unit = { }, showTabTray: () -> Unit = { },
handleSwipedItemDeletionCancel: () -> Unit = { },
removeCollectionWithUndo: (tabCollection: TabCollection) -> Unit = { } removeCollectionWithUndo: (tabCollection: TabCollection) -> Unit = { }
): DefaultSessionControlController { ): DefaultSessionControlController {
return DefaultSessionControlController( return DefaultSessionControlController(
activity = activity, activity = activity,
store = store,
settings = settings, settings = settings,
engine = engine, engine = engine,
metrics = metrics, metrics = metrics,
store = store,
tabCollectionStorage = tabCollectionStorage, tabCollectionStorage = tabCollectionStorage,
addTabUseCase = tabsUseCases.addTab, addTabUseCase = tabsUseCases.addTab,
restoreUseCase = mockk(relaxed = true),
reloadUrlUseCase = reloadUrlUseCase.reload, reloadUrlUseCase = reloadUrlUseCase.reload,
selectTabUseCase = selectTabUseCase.selectTab, selectTabUseCase = selectTabUseCase.selectTab,
restoreUseCase = mockk(relaxed = true),
fragmentStore = fragmentStore, fragmentStore = fragmentStore,
navController = navController, navController = navController,
viewLifecycleScope = scope, viewLifecycleScope = scope,
hideOnboarding = hideOnboarding, hideOnboarding = hideOnboarding,
registerCollectionStorageObserver = registerCollectionStorageObserver, registerCollectionStorageObserver = registerCollectionStorageObserver,
removeCollectionWithUndo = removeCollectionWithUndo, removeCollectionWithUndo = removeCollectionWithUndo,
showTabTray = showTabTray, showTabTray = showTabTray
handleSwipedItemDeletionCancel = handleSwipedItemDeletionCancel
) )
} }
} }

View File

@ -7,7 +7,6 @@ package org.mozilla.fenix.library.bookmarks
import io.mockk.mockk import io.mockk.mockk
import io.mockk.verify import io.mockk.verify
import io.mockk.verifyOrder import io.mockk.verifyOrder
import mozilla.appservices.places.BookmarkRoot
import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNodeType import mozilla.components.concept.storage.BookmarkNodeType
import org.junit.Before import org.junit.Before
@ -30,9 +29,6 @@ class BookmarkFragmentInteractorTest {
private val tree: BookmarkNode = BookmarkNode( private val tree: BookmarkNode = BookmarkNode(
BookmarkNodeType.FOLDER, "123", null, 0, "Mobile", null, 0, listOf(item, separator, item, subfolder) 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 @Before
fun setup() { fun setup() {