diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 6b95ea8a8..41abd10c1 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -553,28 +553,27 @@ public class MainActivity extends AppCompatActivity { // In case bottomSheet is not visible on the screen or collapsed we can assume that the user // interacts with a fragment inside fragment_holder so all back presses should be // handled by it + final var fragmentManager = getSupportFragmentManager(); + if (bottomSheetHiddenOrCollapsed()) { - final var fm = getSupportFragmentManager(); - final var fragment = fm.findFragmentById(R.id.fragment_holder); + final var fragment = fragmentManager.findFragmentById(R.id.fragment_holder); // If current fragment implements BackPressable (i.e. can/wanna handle back press) // delegate the back press to it if (fragment instanceof BackPressable backPressable && backPressable.onBackPressed()) { return; } } else { - final var fragmentPlayer = getSupportFragmentManager() - .findFragmentById(R.id.fragment_player_holder); + final var player = fragmentManager.findFragmentById(R.id.fragment_player_holder); // If current fragment implements BackPressable (i.e. can/wanna handle back press) // delegate the back press to it - if (fragmentPlayer instanceof BackPressable backPressable - && !backPressable.onBackPressed()) { + if (player instanceof BackPressable backPressable && !backPressable.onBackPressed()) { BottomSheetBehavior.from(mainBinding.fragmentPlayerHolder) .setState(BottomSheetBehavior.STATE_COLLAPSED); return; } } - if (getSupportFragmentManager().getBackStackEntryCount() == 1) { + if (fragmentManager.getBackStackEntryCount() == 1) { finish(); } else { super.onBackPressed(); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 8fcf1e663..20ea3c710 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -73,7 +73,6 @@ import org.schabi.newpipe.error.ReCaptchaActivity; import org.schabi.newpipe.error.UserAction; import org.schabi.newpipe.extractor.Image; import org.schabi.newpipe.extractor.NewPipe; -import org.schabi.newpipe.extractor.comments.CommentsInfoItem; import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.stream.AudioStream; @@ -1011,19 +1010,6 @@ public final class VideoDetailFragment updateTabLayoutVisibility(); } - public void scrollToComment(final CommentsInfoItem comment) { - final int commentsTabPos = pageAdapter.getItemPositionByTitle(COMMENTS_TAB_TAG); - final var fragment = pageAdapter.getItem(commentsTabPos); - - // TODO: Implement the scrolling with Compose. - // unexpand the app bar only if scrolling to the comment succeeded -// if (fragment instanceof CommentsFragment commentsFragment && -// commentsFragment.scrollToComment(comment)) { -// binding.appBarLayout.setExpanded(false, false); -// binding.viewPager.setCurrentItem(commentsTabPos, false); -// } - } - /*////////////////////////////////////////////////////////////////////////// // Play Utils //////////////////////////////////////////////////////////////////////////*/ diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt index ed4f50dd0..d3be40151 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt @@ -27,6 +27,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf import my.nanihadesuka.compose.LazyColumnScrollbar import org.schabi.newpipe.R +import org.schabi.newpipe.extractor.Page import org.schabi.newpipe.extractor.comments.CommentsInfoItem import org.schabi.newpipe.extractor.stream.Description import org.schabi.newpipe.paging.CommentsDisabledException @@ -91,7 +92,17 @@ private class CommentDataProvider : PreviewParameterProvider