diff --git a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.kt b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.kt index a8555abaea6..5dd0755c59a 100644 --- a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.kt +++ b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.kt @@ -228,24 +228,26 @@ class ErrorActivity : AppCompatActivity() { // Collapse all logs to a single paragraph when there are more than one // to keep the GitHub issue clean. - if (errorInfo.stackTraces.isNotEmpty()) { + if (errorInfo.stackTraces.size > 1) { append("
Exceptions (") append(errorInfo.stackTraces.size) append(")

\n") + } - // add the logs - errorInfo.stackTraces.forEachIndexed { index, stacktrace -> - append("

Crash log ") - if (errorInfo.stackTraces.isNotEmpty()) { - append(index + 1) - } - append("") - append("

\n") - append("\n```\n${stacktrace}\n```\n") - append("

\n") + // add the logs + errorInfo.stackTraces.forEachIndexed { index, stacktrace -> + append("
Crash log ") + if (errorInfo.stackTraces.size > 1) { + append(index + 1) } + append("") + append("

\n") + append("\n```\n${stacktrace}\n```\n") + append("

\n") + } - // make sure to close everything + // make sure to close everything + if (errorInfo.stackTraces.size > 1) { append("

\n") } 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 ef9fa1137ff..31a4967116e 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 @@ -646,6 +646,12 @@ protected void initViews(final View rootView, final Bundle savedInstanceState) { protected void initListeners() { super.initListeners(); + // Workaround for #5600 + // Forcefully catch click events uncaught by children because otherwise + // they will be caught by underlying view and "click through" will happen + binding.getRoot().setOnClickListener(v -> { }); + binding.getRoot().setOnLongClickListener(v -> true); + setOnClickListeners(); setOnLongClickListeners(); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 8cb5f649734..5c0d7d321fd 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -1009,7 +1009,11 @@ public void handleSuggestions(@NonNull final List suggestions) { Log.d(TAG, "handleSuggestions() called with: suggestions = [" + suggestions + "]"); } suggestionListAdapter.submitList(suggestions, - () -> searchBinding.suggestionsList.scrollToPosition(0)); + () -> { + if (searchBinding != null) { + searchBinding.suggestionsList.scrollToPosition(0); + } + }); if (suggestionsPanelVisible && isErrorPanelVisible()) { hideLoading(); diff --git a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java index f702c5bd52e..bfdf6a02cdf 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -501,6 +501,7 @@ public static void openCommentAuthorIfPresent(@NonNull final FragmentActivity ac public static void openCommentRepliesFragment(@NonNull final FragmentActivity activity, @NonNull final CommentsInfoItem comment) { + closeCommentRepliesFragments(activity); defaultTransaction(activity.getSupportFragmentManager()) .replace(R.id.fragment_holder, new CommentRepliesFragment(comment), CommentRepliesFragment.TAG) @@ -508,6 +509,41 @@ public static void openCommentRepliesFragment(@NonNull final FragmentActivity ac .commit(); } + /** + * Closes all open {@link CommentRepliesFragment}s in {@code activity}, + * including those that are not at the top of the back stack. + * This is needed to prevent multiple open CommentRepliesFragments + * Ideally there should only be one since we remove existing before opening a new one. + * @param activity the activity in which to close the CommentRepliesFragments + */ + public static void closeCommentRepliesFragments(@NonNull final FragmentActivity activity) { + final FragmentManager fm = activity.getSupportFragmentManager(); + + // Remove all existing fragment instances tagged as CommentRepliesFragment + final FragmentTransaction tx = defaultTransaction(fm); + boolean removed = false; + for (final Fragment fragment : fm.getFragments()) { + if (fragment != null && CommentRepliesFragment.TAG.equals(fragment.getTag())) { + tx.remove(fragment); + removed = true; + } + } + if (removed) { + tx.commit(); + } + + // Only pop back stack entries named CommentRepliesFragment.TAG if they are at the top. + while (fm.getBackStackEntryCount() > 0 + && CommentRepliesFragment.TAG.equals( + fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName() + ) + ) { + fm.popBackStackImmediate(CommentRepliesFragment.TAG, + FragmentManager.POP_BACK_STACK_INCLUSIVE); + } + + } + public static void openPlaylistFragment(final FragmentManager fragmentManager, final int serviceId, final String url, @NonNull final String name) { diff --git a/app/src/main/java/us/shandian/giga/postprocessing/TtmlConverter.java b/app/src/main/java/us/shandian/giga/postprocessing/TtmlConverter.java index 8ed0dfae5de..d723bfb4561 100644 --- a/app/src/main/java/us/shandian/giga/postprocessing/TtmlConverter.java +++ b/app/src/main/java/us/shandian/giga/postprocessing/TtmlConverter.java @@ -29,9 +29,12 @@ int process(SharpStream out, SharpStream... sources) throws IOException { try { writer.build(sources[0]); + } catch (IOException err) { + Log.e(TAG, "subtitle conversion failed due to I/O error", err); + throw err; } catch (Exception err) { - Log.e(TAG, "subtitle parse failed", err); - return err instanceof IOException ? 1 : 8; + Log.e(TAG, "subtitle conversion failed", err); + throw new IOException("TTML to SRT conversion failed", err); } return OK_RESULT;