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.ext.components
|
||||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||||
import org.mozilla.fenix.library.bookmarks.BookmarkFragmentDirections
|
import org.mozilla.fenix.library.bookmarks.BookmarkFragmentDirections
|
||||||
|
import org.mozilla.fenix.library.history.HistoryFragmentDirections
|
||||||
import org.mozilla.fenix.search.SearchFragmentDirections
|
import org.mozilla.fenix.search.SearchFragmentDirections
|
||||||
import org.mozilla.fenix.settings.SettingsFragmentDirections
|
import org.mozilla.fenix.settings.SettingsFragmentDirections
|
||||||
|
|
||||||
|
@ -168,6 +169,8 @@ open class HomeActivity : AppCompatActivity() {
|
||||||
SettingsFragmentDirections.actionSettingsFragmentToBrowserFragment(sessionId)
|
SettingsFragmentDirections.actionSettingsFragmentToBrowserFragment(sessionId)
|
||||||
BrowserDirection.FromBookmarks ->
|
BrowserDirection.FromBookmarks ->
|
||||||
BookmarkFragmentDirections.actionBookmarkFragmentToBrowserFragment(sessionId)
|
BookmarkFragmentDirections.actionBookmarkFragmentToBrowserFragment(sessionId)
|
||||||
|
BrowserDirection.FromHistory ->
|
||||||
|
HistoryFragmentDirections.actionHistoryFragmentToBrowserFragment(sessionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
navHost.navController.navigate(directions)
|
navHost.navController.navigate(directions)
|
||||||
|
@ -204,5 +207,5 @@ open class HomeActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class BrowserDirection {
|
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.BookmarkNode
|
||||||
import mozilla.components.concept.storage.BookmarkNodeType
|
import mozilla.components.concept.storage.BookmarkNodeType
|
||||||
import mozilla.components.support.base.feature.BackHandler
|
import mozilla.components.support.base.feature.BackHandler
|
||||||
|
import org.mozilla.fenix.BrowserDirection
|
||||||
import org.mozilla.fenix.BrowsingModeManager
|
import org.mozilla.fenix.BrowsingModeManager
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
@ -80,18 +81,8 @@ class BookmarkFragment : Fragment(), CoroutineScope, BackHandler {
|
||||||
is BookmarkAction.Open -> {
|
is BookmarkAction.Open -> {
|
||||||
if (it.item.type == BookmarkNodeType.ITEM) {
|
if (it.item.type == BookmarkNodeType.ITEM) {
|
||||||
it.item.url?.let { url ->
|
it.item.url?.let { url ->
|
||||||
val activity = requireActivity() as HomeActivity
|
(activity as HomeActivity)
|
||||||
Navigation.findNavController(activity, R.id.container)
|
.openToBrowserAndLoad(url, from = BrowserDirection.FromBookmarks)
|
||||||
.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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.navigation.NavOptions
|
|
||||||
import androidx.navigation.Navigation
|
import androidx.navigation.Navigation
|
||||||
import kotlinx.android.synthetic.main.fragment_history.view.*
|
import kotlinx.android.synthetic.main.fragment_history.view.*
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
@ -23,6 +22,8 @@ import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.coroutineScope
|
import kotlinx.coroutines.coroutineScope
|
||||||
import mozilla.components.concept.storage.VisitType
|
import mozilla.components.concept.storage.VisitType
|
||||||
import mozilla.components.support.base.feature.BackHandler
|
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.utils.ItsNotBrokenSnack
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.requireComponents
|
import org.mozilla.fenix.ext.requireComponents
|
||||||
|
@ -64,14 +65,7 @@ class HistoryFragment : Fragment(), CoroutineScope, BackHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun selectItem(item: HistoryItem) {
|
private fun selectItem(item: HistoryItem) {
|
||||||
Navigation.findNavController(requireActivity(), R.id.container).apply {
|
(activity as HomeActivity).openToBrowserAndLoad(item.url, from = BrowserDirection.FromHistory)
|
||||||
navigate(
|
|
||||||
HistoryFragmentDirections.actionGlobalBrowser(null),
|
|
||||||
NavOptions.Builder().setPopUpTo(R.id.homeFragment, false).build()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
requireComponents.useCases.sessionUseCases.loadUrl.invoke(item.url)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
|
|
@ -98,7 +98,9 @@
|
||||||
android:id="@+id/historyFragment"
|
android:id="@+id/historyFragment"
|
||||||
android:name="org.mozilla.fenix.library.history.HistoryFragment"
|
android:name="org.mozilla.fenix.library.history.HistoryFragment"
|
||||||
android:label="@string/library_history"
|
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
|
<fragment
|
||||||
android:id="@+id/bookmarkFragment"
|
android:id="@+id/bookmarkFragment"
|
||||||
|
|
Loading…
Reference in New Issue