diff --git a/app/src/main/java/org/lineageos/glimpse/MainActivity.kt b/app/src/main/java/org/lineageos/glimpse/MainActivity.kt index b552a2b..151df87 100644 --- a/app/src/main/java/org/lineageos/glimpse/MainActivity.kt +++ b/app/src/main/java/org/lineageos/glimpse/MainActivity.kt @@ -8,15 +8,8 @@ package org.lineageos.glimpse import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.core.view.WindowCompat -import androidx.navigation.fragment.NavHostFragment -import org.lineageos.glimpse.utils.CommonNavigationArguments class MainActivity : AppCompatActivity() { - // Fragments - private val navHostFragment by lazy { supportFragmentManager.findFragmentById(R.id.navHostFragment) as NavHostFragment } - - private val navController by lazy { navHostFragment.navController } - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -28,11 +21,5 @@ class MainActivity : AppCompatActivity() { WindowCompat.getInsetsController(window, window.decorView) windowInsetsController.isAppearanceLightNavigationBars = true - - navController.addOnDestinationChangedListener { _, _, bundle -> - val commonNavigationArguments = bundle?.let { - CommonNavigationArguments.fromBundle(it) - } ?: CommonNavigationArguments() - } } } diff --git a/app/src/main/java/org/lineageos/glimpse/fragments/AlbumFragment.kt b/app/src/main/java/org/lineageos/glimpse/fragments/AlbumFragment.kt index f9cefcb..2fb8eab 100644 --- a/app/src/main/java/org/lineageos/glimpse/fragments/AlbumFragment.kt +++ b/app/src/main/java/org/lineageos/glimpse/fragments/AlbumFragment.kt @@ -13,6 +13,7 @@ import android.view.View import android.view.ViewGroup import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts +import androidx.core.os.bundleOf import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat import androidx.core.view.updateLayoutParams @@ -34,7 +35,6 @@ import org.lineageos.glimpse.ext.getViewProperty import org.lineageos.glimpse.models.Album import org.lineageos.glimpse.thumbnail.ThumbnailAdapter import org.lineageos.glimpse.thumbnail.ThumbnailLayoutManager -import org.lineageos.glimpse.utils.CommonNavigationArguments import org.lineageos.glimpse.utils.MediaStoreRequests import org.lineageos.glimpse.utils.PermissionsUtils @@ -184,9 +184,9 @@ class AlbumFragment : Fragment(R.layout.fragment_album), LoaderManager.LoaderCal fun createBundle( album: Album, - ) = CommonNavigationArguments().toBundle().apply { - putParcelable(KEY_ALBUM_ID, album) - } + ) = bundleOf( + KEY_ALBUM_ID to album, + ) /** * Use this factory method to create a new instance of diff --git a/app/src/main/java/org/lineageos/glimpse/fragments/AlbumsFragment.kt b/app/src/main/java/org/lineageos/glimpse/fragments/AlbumsFragment.kt index 0169a00..070c6e7 100644 --- a/app/src/main/java/org/lineageos/glimpse/fragments/AlbumsFragment.kt +++ b/app/src/main/java/org/lineageos/glimpse/fragments/AlbumsFragment.kt @@ -14,6 +14,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.view.ViewGroup.MarginLayoutParams +import androidx.core.os.bundleOf import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat import androidx.core.view.updateLayoutParams @@ -29,7 +30,6 @@ import org.lineageos.glimpse.R import org.lineageos.glimpse.ext.getViewProperty import org.lineageos.glimpse.models.Album import org.lineageos.glimpse.thumbnail.AlbumThumbnailAdapter -import org.lineageos.glimpse.utils.CommonNavigationArguments import org.lineageos.glimpse.utils.MediaStoreRequests /** @@ -166,7 +166,7 @@ class AlbumsFragment : Fragment(), LoaderManager.LoaderCallbacks { } companion object { - private fun createBundle() = CommonNavigationArguments().toBundle() + private fun createBundle() = bundleOf() /** * Use this factory method to create a new instance of diff --git a/app/src/main/java/org/lineageos/glimpse/fragments/MediaViewerFragment.kt b/app/src/main/java/org/lineageos/glimpse/fragments/MediaViewerFragment.kt index 78390d9..969ad58 100644 --- a/app/src/main/java/org/lineageos/glimpse/fragments/MediaViewerFragment.kt +++ b/app/src/main/java/org/lineageos/glimpse/fragments/MediaViewerFragment.kt @@ -19,6 +19,7 @@ import android.widget.TextView import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.os.bundleOf import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat import androidx.core.view.updateLayoutParams @@ -37,7 +38,6 @@ import org.lineageos.glimpse.ext.* import org.lineageos.glimpse.models.Album import org.lineageos.glimpse.models.Media import org.lineageos.glimpse.thumbnail.MediaViewerAdapter -import org.lineageos.glimpse.utils.CommonNavigationArguments import org.lineageos.glimpse.utils.MediaStoreRequests import org.lineageos.glimpse.utils.PermissionsUtils import java.text.SimpleDateFormat @@ -311,11 +311,11 @@ class MediaViewerFragment : Fragment( album: Album?, media: Media, position: Int, - ) = CommonNavigationArguments().toBundle().apply { - putParcelable(KEY_ALBUM, album) - putParcelable(KEY_MEDIA, media) - putInt(KEY_POSITION, position) - } + ) = bundleOf( + KEY_ALBUM to album, + KEY_MEDIA to media, + KEY_POSITION to position, + ) /** * Use this factory method to create a new instance of diff --git a/app/src/main/java/org/lineageos/glimpse/fragments/ReelsFragment.kt b/app/src/main/java/org/lineageos/glimpse/fragments/ReelsFragment.kt index 81ced2c..01c274b 100644 --- a/app/src/main/java/org/lineageos/glimpse/fragments/ReelsFragment.kt +++ b/app/src/main/java/org/lineageos/glimpse/fragments/ReelsFragment.kt @@ -13,6 +13,7 @@ import android.view.View import android.view.ViewGroup import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts +import androidx.core.os.bundleOf import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat import androidx.core.view.updateLayoutParams @@ -27,7 +28,6 @@ import org.lineageos.glimpse.R import org.lineageos.glimpse.ext.getViewProperty import org.lineageos.glimpse.thumbnail.ThumbnailAdapter import org.lineageos.glimpse.thumbnail.ThumbnailLayoutManager -import org.lineageos.glimpse.utils.CommonNavigationArguments import org.lineageos.glimpse.utils.MediaStoreRequests import org.lineageos.glimpse.utils.PermissionsUtils @@ -155,7 +155,7 @@ class ReelsFragment : Fragment(R.layout.fragment_reels), LoaderManager.LoaderCal } companion object { - private fun createBundle() = CommonNavigationArguments().toBundle() + private fun createBundle() = bundleOf() /** * Use this factory method to create a new instance of diff --git a/app/src/main/java/org/lineageos/glimpse/utils/CommonNavigationArguments.kt b/app/src/main/java/org/lineageos/glimpse/utils/CommonNavigationArguments.kt deleted file mode 100644 index a4591b0..0000000 --- a/app/src/main/java/org/lineageos/glimpse/utils/CommonNavigationArguments.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The LineageOS Project - * SPDX-License-Identifier: Apache-2.0 - */ - -package org.lineageos.glimpse.utils - -import android.os.Bundle -import androidx.core.os.bundleOf - -/** - * Common navigation arguments for all fragments. - * It is recommended to create a bundle from there and then add fragment-specific - * arguments to it. - */ -data class CommonNavigationArguments( - var title: String? = null, -) { - fun toBundle() = bundleOf( - KEY_TITLE to title, - ) - - companion object { - private const val KEY_TITLE = "title" - - fun fromBundle(bundle: Bundle) = CommonNavigationArguments( - bundle.getString(KEY_TITLE), - ) - } -}