Loading app/src/main/java/org/mozilla/fenix/HomeActivity.kt +3 −3 Original line number Diff line number Diff line Loading @@ -63,8 +63,8 @@ import org.mozilla.fenix.exceptions.ExceptionsFragmentDirections import org.mozilla.fenix.ext.alreadyOnDestination import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.nav import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.resetPoliciesAfter import org.mozilla.fenix.ext.settings import org.mozilla.fenix.home.HomeFragmentDirections import org.mozilla.fenix.home.intent.CrashReporterIntentProcessor import org.mozilla.fenix.home.intent.DeepLinkIntentProcessor Loading Loading @@ -100,7 +100,7 @@ import org.mozilla.fenix.utils.RunWhenReadyQueue * - browser screen */ @SuppressWarnings("TooManyFunctions", "LargeClass") open class HomeActivity : LocaleAwareAppCompatActivity() { open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { private var webExtScope: CoroutineScope? = null lateinit var themeManager: ThemeManager Loading Loading @@ -392,7 +392,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity() { * Returns the [supportActionBar], inflating it if necessary. * Everyone should call this instead of supportActionBar. */ fun getSupportActionBarAndInflateIfNecessary(): ActionBar { override fun getSupportActionBarAndInflateIfNecessary(): ActionBar { if (!isToolbarInflated) { navigationToolbar = navigationToolbarStub.inflate() as Toolbar Loading app/src/main/java/org/mozilla/fenix/NavHostActivity.kt 0 → 100644 +20 −0 Original line number Diff line number Diff line /* 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 import androidx.appcompat.app.ActionBar /** * Interface for the main activity in a single-activity architecture. * All fragments will be displayed inside this activity. */ interface NavHostActivity { /** * Returns the support action bar, inflating it if necessary. * Everyone should call this instead of supportActionBar. */ fun getSupportActionBarAndInflateIfNecessary(): ActionBar } app/src/main/java/org/mozilla/fenix/addons/AddonPermissionsDetailsFragment.kt +7 −9 Original line number Diff line number Diff line Loading @@ -5,10 +5,11 @@ package org.mozilla.fenix.addons import android.content.Intent import android.net.Uri import android.content.Intent.ACTION_VIEW import android.os.Bundle import android.view.View import androidx.annotation.StringRes import androidx.core.net.toUri import androidx.fragment.app.Fragment import androidx.navigation.fragment.navArgs import androidx.recyclerview.widget.LinearLayoutManager Loading @@ -26,7 +27,7 @@ private const val LEARN_MORE_URL = /** * A fragment to show the permissions of an add-on. */ class AddonPermissionsDetailsFragment : Fragment(R.layout.fragment_add_on_permissions), View.OnClickListener { class AddonPermissionsDetailsFragment : Fragment(R.layout.fragment_add_on_permissions) { private val args by navArgs<AddonPermissionsDetailsFragmentArgs>() Loading Loading @@ -55,12 +56,9 @@ class AddonPermissionsDetailsFragment : Fragment(R.layout.fragment_add_on_permis } private fun bindLearnMore(view: View) { view.learn_more_label.setOnClickListener(this) } override fun onClick(v: View?) { val intent = Intent(Intent.ACTION_VIEW).setData(Uri.parse(LEARN_MORE_URL)) view.learn_more_label.setOnClickListener { val intent = Intent(ACTION_VIEW, LEARN_MORE_URL.toUri()) startActivity(intent) } } } app/src/main/java/org/mozilla/fenix/ext/Fragment.kt +2 −2 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ import androidx.navigation.NavOptions import androidx.navigation.Navigator import androidx.navigation.fragment.NavHostFragment.findNavController import androidx.navigation.fragment.findNavController import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.NavHostActivity import org.mozilla.fenix.R import org.mozilla.fenix.components.Components Loading Loading @@ -43,7 +43,7 @@ fun Fragment.getPreferenceKey(@StringRes resourceId: Int): String = getString(re */ fun Fragment.showToolbar(title: String) { (requireActivity() as AppCompatActivity).title = title (activity as HomeActivity).getSupportActionBarAndInflateIfNecessary().show() (activity as NavHostActivity).getSupportActionBarAndInflateIfNecessary().show() } /** Loading app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt +2 −2 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNodeType import mozilla.components.lib.state.ext.consumeFrom import mozilla.components.support.base.feature.UserInteractionHandler import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.NavHostActivity import org.mozilla.fenix.R import org.mozilla.fenix.components.FenixSnackbar import org.mozilla.fenix.components.StoreProvider Loading Loading @@ -147,7 +147,7 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), UserInteractionHan override fun onResume() { super.onResume() (activity as HomeActivity).getSupportActionBarAndInflateIfNecessary().show() (activity as NavHostActivity).getSupportActionBarAndInflateIfNecessary().show() // Reload bookmarks when returning to this fragment in case they have been edited val args by navArgs<BookmarkFragmentArgs>() Loading Loading
app/src/main/java/org/mozilla/fenix/HomeActivity.kt +3 −3 Original line number Diff line number Diff line Loading @@ -63,8 +63,8 @@ import org.mozilla.fenix.exceptions.ExceptionsFragmentDirections import org.mozilla.fenix.ext.alreadyOnDestination import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.nav import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.resetPoliciesAfter import org.mozilla.fenix.ext.settings import org.mozilla.fenix.home.HomeFragmentDirections import org.mozilla.fenix.home.intent.CrashReporterIntentProcessor import org.mozilla.fenix.home.intent.DeepLinkIntentProcessor Loading Loading @@ -100,7 +100,7 @@ import org.mozilla.fenix.utils.RunWhenReadyQueue * - browser screen */ @SuppressWarnings("TooManyFunctions", "LargeClass") open class HomeActivity : LocaleAwareAppCompatActivity() { open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { private var webExtScope: CoroutineScope? = null lateinit var themeManager: ThemeManager Loading Loading @@ -392,7 +392,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity() { * Returns the [supportActionBar], inflating it if necessary. * Everyone should call this instead of supportActionBar. */ fun getSupportActionBarAndInflateIfNecessary(): ActionBar { override fun getSupportActionBarAndInflateIfNecessary(): ActionBar { if (!isToolbarInflated) { navigationToolbar = navigationToolbarStub.inflate() as Toolbar Loading
app/src/main/java/org/mozilla/fenix/NavHostActivity.kt 0 → 100644 +20 −0 Original line number Diff line number Diff line /* 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 import androidx.appcompat.app.ActionBar /** * Interface for the main activity in a single-activity architecture. * All fragments will be displayed inside this activity. */ interface NavHostActivity { /** * Returns the support action bar, inflating it if necessary. * Everyone should call this instead of supportActionBar. */ fun getSupportActionBarAndInflateIfNecessary(): ActionBar }
app/src/main/java/org/mozilla/fenix/addons/AddonPermissionsDetailsFragment.kt +7 −9 Original line number Diff line number Diff line Loading @@ -5,10 +5,11 @@ package org.mozilla.fenix.addons import android.content.Intent import android.net.Uri import android.content.Intent.ACTION_VIEW import android.os.Bundle import android.view.View import androidx.annotation.StringRes import androidx.core.net.toUri import androidx.fragment.app.Fragment import androidx.navigation.fragment.navArgs import androidx.recyclerview.widget.LinearLayoutManager Loading @@ -26,7 +27,7 @@ private const val LEARN_MORE_URL = /** * A fragment to show the permissions of an add-on. */ class AddonPermissionsDetailsFragment : Fragment(R.layout.fragment_add_on_permissions), View.OnClickListener { class AddonPermissionsDetailsFragment : Fragment(R.layout.fragment_add_on_permissions) { private val args by navArgs<AddonPermissionsDetailsFragmentArgs>() Loading Loading @@ -55,12 +56,9 @@ class AddonPermissionsDetailsFragment : Fragment(R.layout.fragment_add_on_permis } private fun bindLearnMore(view: View) { view.learn_more_label.setOnClickListener(this) } override fun onClick(v: View?) { val intent = Intent(Intent.ACTION_VIEW).setData(Uri.parse(LEARN_MORE_URL)) view.learn_more_label.setOnClickListener { val intent = Intent(ACTION_VIEW, LEARN_MORE_URL.toUri()) startActivity(intent) } } }
app/src/main/java/org/mozilla/fenix/ext/Fragment.kt +2 −2 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ import androidx.navigation.NavOptions import androidx.navigation.Navigator import androidx.navigation.fragment.NavHostFragment.findNavController import androidx.navigation.fragment.findNavController import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.NavHostActivity import org.mozilla.fenix.R import org.mozilla.fenix.components.Components Loading Loading @@ -43,7 +43,7 @@ fun Fragment.getPreferenceKey(@StringRes resourceId: Int): String = getString(re */ fun Fragment.showToolbar(title: String) { (requireActivity() as AppCompatActivity).title = title (activity as HomeActivity).getSupportActionBarAndInflateIfNecessary().show() (activity as NavHostActivity).getSupportActionBarAndInflateIfNecessary().show() } /** Loading
app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt +2 −2 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNodeType import mozilla.components.lib.state.ext.consumeFrom import mozilla.components.support.base.feature.UserInteractionHandler import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.NavHostActivity import org.mozilla.fenix.R import org.mozilla.fenix.components.FenixSnackbar import org.mozilla.fenix.components.StoreProvider Loading Loading @@ -147,7 +147,7 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), UserInteractionHan override fun onResume() { super.onResume() (activity as HomeActivity).getSupportActionBarAndInflateIfNecessary().show() (activity as NavHostActivity).getSupportActionBarAndInflateIfNecessary().show() // Reload bookmarks when returning to this fragment in case they have been edited val args by navArgs<BookmarkFragmentArgs>() Loading