Commit d5c34330 authored by Tiger Oakes's avatar Tiger Oakes Committed by Emily Kager
Browse files

Use the new fragment constructor

parent bb7caa63
......@@ -149,7 +149,6 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
}
final override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
browserInitialized = initializeUI(view) != null
}
......
......@@ -5,9 +5,7 @@
package org.mozilla.fenix.crashes
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
......@@ -21,13 +19,7 @@ import org.mozilla.fenix.ext.settings
/**
* Fragment shown when a tab crashes.
*/
class CrashReporterFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.fragment_crash_reporter, container, false)
class CrashReporterFragment : Fragment(R.layout.fragment_crash_reporter) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
......
......@@ -7,12 +7,10 @@ package org.mozilla.fenix.library
import android.graphics.PorterDuff.Mode.SRC_IN
import android.graphics.PorterDuffColorFilter
import android.os.Bundle
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
......@@ -25,15 +23,10 @@ import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.requireComponents
class LibraryFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_library, container, false)
}
/**
* Displays buttons to navigate to library sections, such as bookmarks and history.
*/
class LibraryFragment : Fragment(R.layout.fragment_library) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
......
......@@ -5,12 +5,9 @@
package org.mozilla.fenix.library.bookmarks.addfolder
import android.os.Bundle
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
......@@ -28,7 +25,10 @@ import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.library.bookmarks.BookmarksSharedViewModel
class AddBookmarkFolderFragment : Fragment() {
/**
* Menu to create a new bookmark folder.
*/
class AddBookmarkFolderFragment : Fragment(R.layout.fragment_add_bookmark_folder) {
private val sharedViewModel: BookmarksSharedViewModel by activityViewModels {
ViewModelProvider.NewInstanceFactory() // this is a workaround for #4652
......@@ -39,10 +39,6 @@ class AddBookmarkFolderFragment : Fragment() {
setHasOptionsMenu(true)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_add_bookmark_folder, container, false)
}
override fun onResume() {
super.onResume()
(activity as AppCompatActivity).title =
......
......@@ -6,12 +6,10 @@ package org.mozilla.fenix.library.bookmarks.edit
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
......@@ -48,7 +46,10 @@ import org.mozilla.fenix.library.bookmarks.BookmarksSharedViewModel
import org.mozilla.fenix.library.bookmarks.DesktopFolders
import java.util.concurrent.TimeUnit
class EditBookmarkFragment : Fragment() {
/**
* Menu to edit the name, URL, and location of a bookmark item.
*/
class EditBookmarkFragment : Fragment(R.layout.fragment_edit_bookmark) {
private lateinit var guidToEdit: String
private val sharedViewModel: BookmarksSharedViewModel by activityViewModels {
......@@ -62,10 +63,6 @@ class EditBookmarkFragment : Fragment() {
setHasOptionsMenu(true)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_edit_bookmark, container, false)
}
override fun onResume() {
super.onResume()
......
......@@ -9,9 +9,7 @@ import android.content.pm.PackageManager
import android.os.Build
import android.os.Build.VERSION.SDK_INT
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.RequiresApi
import androidx.core.content.pm.PackageInfoCompat
import androidx.fragment.app.Fragment
......@@ -29,11 +27,7 @@ import org.mozilla.geckoview.BuildConfig as GeckoViewBuildConfig
/**
* Displays the logo and information about the app, including library versions.
*/
class AboutFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_about, container, false)
}
class AboutFragment : Fragment(R.layout.fragment_about) {
/**
* Sets the activity title, displays library version strings, and sets up the [view_licenses_button].
......
......@@ -5,9 +5,7 @@
package org.mozilla.fenix.settings
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.core.text.HtmlCompat
import androidx.fragment.app.Fragment
......@@ -20,16 +18,9 @@ import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.requireComponents
class PairFragment : Fragment(), BackHandler {
private val qrFeature = ViewBoundFeatureWrapper<QrFeature>()
class PairFragment : Fragment(R.layout.fragment_pair), BackHandler {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_pair, container, false)
}
private val qrFeature = ViewBoundFeatureWrapper<QrFeature>()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
......
......@@ -6,9 +6,7 @@ package org.mozilla.fenix.settings.deletebrowsingdata
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
......@@ -28,18 +26,11 @@ import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.requireComponents
@SuppressWarnings("TooManyFunctions")
class DeleteBrowsingDataFragment : Fragment() {
class DeleteBrowsingDataFragment : Fragment(R.layout.fragment_delete_browsing_data) {
private lateinit var sessionObserver: SessionManager.Observer
private var tabCollections: List<TabCollection> = listOf()
private lateinit var controller: DeleteBrowsingDataController
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? =
inflater.inflate(R.layout.fragment_delete_browsing_data, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
......
......@@ -37,8 +37,8 @@ import org.mozilla.fenix.ext.nav
private const val MAX_ITEMS_PER_PAGE = 50
@SuppressWarnings("TooManyFunctions")
class SitePermissionsExceptionsFragment : Fragment(), View.OnClickListener {
class SitePermissionsExceptionsFragment :
Fragment(R.layout.fragment_site_permissions_exceptions), View.OnClickListener {
private lateinit var emptyContainerMessage: View
private lateinit var recyclerView: RecyclerView
private lateinit var clearButton: Button
......@@ -48,10 +48,6 @@ class SitePermissionsExceptionsFragment : Fragment(), View.OnClickListener {
(activity as AppCompatActivity).supportActionBar?.show()
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_site_permissions_exceptions, container, false)
}
override fun onViewCreated(rootView: View, savedInstanceState: Bundle?) {
super.onViewCreated(rootView, savedInstanceState)
bindEmptyContainerMess(rootView)
......
......@@ -5,9 +5,7 @@
package org.mozilla.fenix.share
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
......@@ -15,12 +13,7 @@ import kotlinx.android.synthetic.main.fragment_add_new_device.*
import org.mozilla.fenix.R
import org.mozilla.fenix.settings.SupportUtils
class AddNewDeviceFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.fragment_add_new_device, container, false)
class AddNewDeviceFragment : Fragment(R.layout.fragment_add_new_device) {
override fun onResume() {
super.onResume()
......
......@@ -5,43 +5,28 @@
package org.mozilla.fenix.trackingprotection
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.navArgs
import kotlinx.android.synthetic.main.fragment_tracking_protection_blocking.*
import org.mozilla.fenix.R
class TrackingProtectionBlockingFragment : Fragment() {
private val safeArguments get() = requireNotNull(arguments)
class TrackingProtectionBlockingFragment : Fragment(R.layout.fragment_tracking_protection_blocking) {
private val isStrict: Boolean by lazy {
TrackingProtectionBlockingFragmentArgs.fromBundle(safeArguments).strictMode
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_tracking_protection_blocking, container, false)
}
private val args: TrackingProtectionBlockingFragmentArgs by navArgs()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
if (isStrict) {
category_tracking_content.visibility = View.VISIBLE
} else {
category_tracking_content.visibility = View.GONE
}
category_tracking_content.isVisible = args.strictMode
}
override fun onResume() {
super.onResume()
(activity as AppCompatActivity).title =
getString(
if (isStrict) R.string.preference_enhanced_tracking_protection_strict else
if (args.strictMode) R.string.preference_enhanced_tracking_protection_strict else
R.string.preference_enhanced_tracking_protection_standard
)
(activity as AppCompatActivity).supportActionBar?.show()
......
......@@ -3,36 +3,36 @@
- 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/. -->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="org.mozilla.fenix.library.LibraryFragment">
<org.mozilla.fenix.library.LibraryListItem
android:id="@+id/libraryBookmarks"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="org.mozilla.fenix.library.LibraryFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:contentDescription="@string/library_bookmarks"
android:focusable="true"
app:listItemIcon="@drawable/bookmarks_circle_background_outline"
app:listItemTitle="@string/library_bookmarks" />
android:orientation="vertical">
<org.mozilla.fenix.library.LibraryListItem
android:id="@+id/libraryHistory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
app:listItemIcon="@drawable/library_icon_history_circle_background"
app:listItemTitle="@string/library_history" />
</LinearLayout>
<org.mozilla.fenix.library.LibraryListItem
android:id="@+id/libraryBookmarks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:contentDescription="@string/library_bookmarks"
android:focusable="true"
app:listItemIcon="@drawable/bookmarks_circle_background_outline"
app:listItemTitle="@string/library_bookmarks" />
<org.mozilla.fenix.library.LibraryListItem
android:id="@+id/libraryHistory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
app:listItemIcon="@drawable/library_icon_history_circle_background"
app:listItemTitle="@string/library_history" />
</LinearLayout>
</ScrollView>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment