mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-02 03:40:16 +00:00
This commit is contained in:
parent
598ca17beb
commit
395d6f20d5
@ -29,6 +29,7 @@ import org.mozilla.fenix.components.metrics.Event
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||
import org.mozilla.fenix.library.bookmarks.BookmarkFragmentDirections
|
||||
import org.mozilla.fenix.library.history.HistoryFragmentDirections
|
||||
import org.mozilla.fenix.search.SearchFragmentDirections
|
||||
import org.mozilla.fenix.settings.SettingsFragmentDirections
|
||||
|
||||
@ -168,6 +169,8 @@ open class HomeActivity : AppCompatActivity() {
|
||||
SettingsFragmentDirections.actionSettingsFragmentToBrowserFragment(sessionId)
|
||||
BrowserDirection.FromBookmarks ->
|
||||
BookmarkFragmentDirections.actionBookmarkFragmentToBrowserFragment(sessionId)
|
||||
BrowserDirection.FromHistory ->
|
||||
HistoryFragmentDirections.actionHistoryFragmentToBrowserFragment(sessionId)
|
||||
}
|
||||
|
||||
navHost.navController.navigate(directions)
|
||||
@ -204,5 +207,5 @@ open class HomeActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
enum class BrowserDirection {
|
||||
FromGlobal, FromHome, FromSearch, FromSettings, FromBookmarks
|
||||
FromGlobal, FromHome, FromSearch, FromSettings, FromBookmarks, FromHistory
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import mozilla.appservices.places.BookmarkRoot
|
||||
import mozilla.components.concept.storage.BookmarkNode
|
||||
import mozilla.components.concept.storage.BookmarkNodeType
|
||||
import mozilla.components.support.base.feature.BackHandler
|
||||
import org.mozilla.fenix.BrowserDirection
|
||||
import org.mozilla.fenix.BrowsingModeManager
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.R
|
||||
@ -80,18 +81,8 @@ class BookmarkFragment : Fragment(), CoroutineScope, BackHandler {
|
||||
is BookmarkAction.Open -> {
|
||||
if (it.item.type == BookmarkNodeType.ITEM) {
|
||||
it.item.url?.let { url ->
|
||||
val activity = requireActivity() as HomeActivity
|
||||
Navigation.findNavController(activity, R.id.container)
|
||||
.navigate(BookmarkFragmentDirections.actionBookmarkFragmentToBrowserFragment(null))
|
||||
if (activity.browsingModeManager.isPrivate) {
|
||||
requireComponents.useCases.tabsUseCases.addPrivateTab.invoke(url)
|
||||
activity.browsingModeManager.mode =
|
||||
BrowsingModeManager.Mode.Private
|
||||
} else {
|
||||
requireComponents.useCases.sessionUseCases.loadUrl.invoke(url)
|
||||
activity.browsingModeManager.mode =
|
||||
BrowsingModeManager.Mode.Normal
|
||||
}
|
||||
(activity as HomeActivity)
|
||||
.openToBrowserAndLoad(url, from = BrowserDirection.FromBookmarks)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.NavOptions
|
||||
import androidx.navigation.Navigation
|
||||
import kotlinx.android.synthetic.main.fragment_history.view.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@ -23,6 +22,8 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import mozilla.components.concept.storage.VisitType
|
||||
import mozilla.components.support.base.feature.BackHandler
|
||||
import org.mozilla.fenix.BrowserDirection
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.utils.ItsNotBrokenSnack
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.requireComponents
|
||||
@ -64,14 +65,7 @@ class HistoryFragment : Fragment(), CoroutineScope, BackHandler {
|
||||
}
|
||||
|
||||
private fun selectItem(item: HistoryItem) {
|
||||
Navigation.findNavController(requireActivity(), R.id.container).apply {
|
||||
navigate(
|
||||
HistoryFragmentDirections.actionGlobalBrowser(null),
|
||||
NavOptions.Builder().setPopUpTo(R.id.homeFragment, false).build()
|
||||
)
|
||||
}
|
||||
|
||||
requireComponents.useCases.sessionUseCases.loadUrl.invoke(item.url)
|
||||
(activity as HomeActivity).openToBrowserAndLoad(item.url, from = BrowserDirection.FromHistory)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
@ -98,7 +98,9 @@
|
||||
android:id="@+id/historyFragment"
|
||||
android:name="org.mozilla.fenix.library.history.HistoryFragment"
|
||||
android:label="@string/library_history"
|
||||
tools:layout="@layout/fragment_history" />
|
||||
tools:layout="@layout/fragment_history" >
|
||||
<action android:id="@+id/action_historyFragment_to_browserFragment" app:destination="@id/browserFragment"/>
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/bookmarkFragment"
|
||||
|
Loading…
Reference in New Issue
Block a user