From 4d9396873effef53c5beea31e7e807d2cfa999aa Mon Sep 17 00:00:00 2001 From: Prathamesh More Date: Wed, 12 Jan 2022 00:23:37 +0530 Subject: [PATCH] Removed finishing activity on BackPressed On Android 12, back button works just like Home button when saving activity state, so, activity isn't finished/destroyed when back button is pressed, just like home button on previous Android versions. --- .../name/monkey/retromusic/fragments/albums/AlbumsFragment.kt | 2 +- .../name/monkey/retromusic/fragments/artists/ArtistsFragment.kt | 2 +- .../name/monkey/retromusic/fragments/folder/FoldersFragment.kt | 2 +- .../name/monkey/retromusic/fragments/genres/GenresFragment.kt | 2 +- .../code/name/monkey/retromusic/fragments/home/HomeFragment.kt | 2 +- .../monkey/retromusic/fragments/playlists/PlaylistsFragment.kt | 2 +- .../name/monkey/retromusic/fragments/songs/SongsFragment.kt | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt index a7422951b..e35a7a311 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt @@ -57,7 +57,7 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment(), }) requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) { remove() - mainActivity.finish() + requireActivity().onBackPressed() } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/home/HomeFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/home/HomeFragment.kt index 1108a416b..aee1b041f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/home/HomeFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/home/HomeFragment.kt @@ -94,7 +94,7 @@ class HomeFragment : binding.toolbar.drawNextToNavbar() requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) { remove() - mainActivity.finish() + requireActivity().onBackPressed() } view.doOnLayout { adjustPlaylistButtons() diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistsFragment.kt index 094c146bc..ff17c2ad4 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistsFragment.kt @@ -48,7 +48,7 @@ class PlaylistsFragment : }) requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) { remove() - mainActivity.finish() + requireActivity().onBackPressed() } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsFragment.kt index ab20c8e7b..02df97f72 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsFragment.kt @@ -51,7 +51,7 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment