From 79e98db3bd58adfe2bc298ce672e963587facf33 Mon Sep 17 00:00:00 2001 From: TiA4f8R <74829229+TiA4f8R@users.noreply.github.com> Date: Fri, 15 Jan 2021 17:11:04 +0100 Subject: [PATCH] Apply the requested changes and little improvements Apply the requested changes, use ShareUtils.shareText to share an stream in the play queue and optimize imports for Java files, using Android Studio functionality. Apply the requested changes and do little improvements Apply the requested changes, use ShareUtils.shareText to share an stream in the play queue and optimize imports for Java files, using Android Studio functionality. --- .../material/appbar/FlingBehavior.java | 1 + app/src/main/java/org/schabi/newpipe/App.java | 31 +++++----- .../org/schabi/newpipe/DownloaderImpl.java | 2 +- .../org/schabi/newpipe/ImageDownloader.java | 1 + .../java/org/schabi/newpipe/MainActivity.java | 14 +++-- .../org/schabi/newpipe/RouterActivity.java | 2 +- .../schabi/newpipe/about/AboutActivity.java | 9 +-- .../fragments/detail/VideoDetailFragment.java | 8 +-- .../list/channel/ChannelFragment.java | 2 +- .../list/playlist/PlaylistFragment.java | 2 +- .../holder/CommentsMiniInfoItemHolder.java | 3 +- .../holder/StreamInfoItemHolder.java | 3 +- .../newpipe/local/BaseLocalListFragment.java | 5 +- .../local/bookmark/BookmarkFragment.java | 2 +- .../subscription/SubscriptionFragment.kt | 2 +- .../org/schabi/newpipe/player/MainPlayer.java | 2 +- .../newpipe/player/PlayQueueActivity.java | 15 +---- .../org/schabi/newpipe/player/Player.java | 2 +- .../event/CustomBottomSheetBehavior.java | 3 + .../helper/PlaybackParameterDialog.java | 2 +- .../newpipe/player/playqueue/PlayQueue.java | 2 +- .../schabi/newpipe/report/ErrorActivity.java | 4 +- .../settings/BasePreferenceFragment.java | 2 +- .../settings/SelectChannelFragment.java | 2 +- .../custom/NotificationActionsPreference.java | 5 +- .../newpipe/settings/tabs/TabsManager.java | 3 +- .../util/CommentTextOnTouchListener.java | 2 +- .../schabi/newpipe/util/ExtractorHelper.java | 2 +- .../schabi/newpipe/util/FilenameUtils.java | 1 + .../org/schabi/newpipe/util/ListHelper.java | 5 +- .../org/schabi/newpipe/util/Localization.java | 15 +++-- .../schabi/newpipe/util/NavigationHelper.java | 18 ++---- .../schabi/newpipe/util/PeertubeHelper.java | 1 + .../schabi/newpipe/util/ServiceHelper.java | 2 +- .../org/schabi/newpipe/util/ShareUtils.java | 56 +++++++++++++------ .../newpipe/util/StreamDialogEntry.java | 2 +- .../{LinkHelper.java => TextLinkifier.java} | 13 +++-- .../org/schabi/newpipe/util/ThemeHelper.java | 2 +- .../views/CustomCollapsingToolbarLayout.java | 2 + .../newpipe/views/ExpandableSurfaceView.java | 1 + .../newpipe/views/FocusAwareCoordinator.java | 3 +- .../giga/service/DownloadManagerService.java | 7 +-- .../giga/ui/adapter/MissionAdapter.java | 2 +- .../giga/ui/fragment/MissionsFragment.java | 2 +- checkstyle-suppressions.xml | 2 +- 45 files changed, 145 insertions(+), 122 deletions(-) rename app/src/main/java/org/schabi/newpipe/util/{LinkHelper.java => TextLinkifier.java} (92%) diff --git a/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java b/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java index 6106d0437..743ff1ff2 100644 --- a/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java +++ b/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java @@ -10,6 +10,7 @@ import android.widget.OverScroller; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.coordinatorlayout.widget.CoordinatorLayout; + import org.schabi.newpipe.R; import java.lang.reflect.Field; diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index 342ce3498..cd4a04d9a 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -6,26 +6,16 @@ import android.content.Context; import android.content.SharedPreferences; import android.os.Build; import android.util.Log; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.multidex.MultiDexApplication; import androidx.preference.PreferenceManager; + import com.nostra13.universalimageloader.cache.memory.impl.LRULimitedMemoryCache; import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; -import io.reactivex.rxjava3.disposables.Disposable; -import io.reactivex.rxjava3.exceptions.CompositeException; -import io.reactivex.rxjava3.exceptions.MissingBackpressureException; -import io.reactivex.rxjava3.exceptions.OnErrorNotImplementedException; -import io.reactivex.rxjava3.exceptions.UndeliverableException; -import io.reactivex.rxjava3.functions.Consumer; -import io.reactivex.rxjava3.plugins.RxJavaPlugins; -import java.io.IOException; -import java.io.InterruptedIOException; -import java.net.SocketException; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; + import org.acra.ACRA; import org.acra.config.ACRAConfigurationException; import org.acra.config.CoreConfiguration; @@ -41,6 +31,21 @@ import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.ServiceHelper; import org.schabi.newpipe.util.StateSaver; +import java.io.IOException; +import java.io.InterruptedIOException; +import java.net.SocketException; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import io.reactivex.rxjava3.disposables.Disposable; +import io.reactivex.rxjava3.exceptions.CompositeException; +import io.reactivex.rxjava3.exceptions.MissingBackpressureException; +import io.reactivex.rxjava3.exceptions.OnErrorNotImplementedException; +import io.reactivex.rxjava3.exceptions.UndeliverableException; +import io.reactivex.rxjava3.functions.Consumer; +import io.reactivex.rxjava3.plugins.RxJavaPlugins; + /* * Copyright (C) Hans-Christoph Steiner 2016 * App.java is part of NewPipe. diff --git a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java index 431b8034a..50972fb2f 100644 --- a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java +++ b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java @@ -2,10 +2,10 @@ package org.schabi.newpipe; import android.content.Context; import android.os.Build; -import androidx.preference.PreferenceManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.preference.PreferenceManager; import org.schabi.newpipe.extractor.downloader.Downloader; import org.schabi.newpipe.extractor.downloader.Request; diff --git a/app/src/main/java/org/schabi/newpipe/ImageDownloader.java b/app/src/main/java/org/schabi/newpipe/ImageDownloader.java index c2897cff1..ceae11777 100644 --- a/app/src/main/java/org/schabi/newpipe/ImageDownloader.java +++ b/app/src/main/java/org/schabi/newpipe/ImageDownloader.java @@ -4,6 +4,7 @@ import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; + import androidx.preference.PreferenceManager; import com.nostra13.universalimageloader.core.download.BaseImageDownloader; diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 5cecbc6d2..277209211 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -20,8 +20,6 @@ package org.schabi.newpipe; -import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage; - import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -43,6 +41,7 @@ import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.FrameLayout; import android.widget.Spinner; + import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBarDrawerToggle; @@ -53,10 +52,9 @@ import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.preference.PreferenceManager; + import com.google.android.material.bottomsheet.BottomSheetBehavior; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; + import org.schabi.newpipe.databinding.ActivityMainBinding; import org.schabi.newpipe.databinding.DrawerHeaderBinding; import org.schabi.newpipe.databinding.DrawerLayoutBinding; @@ -89,6 +87,12 @@ import org.schabi.newpipe.util.TLSSocketFactoryCompat; import org.schabi.newpipe.util.ThemeHelper; import org.schabi.newpipe.views.FocusOverlayView; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage; + public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; public static final boolean DEBUG = !BuildConfig.BUILD_TYPE.equals("release"); diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index 98a0921e4..7f935d007 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -188,7 +188,7 @@ public class RouterActivity extends AppCompatActivity { .setPositiveButton(R.string.open_in_browser, (dialog, which) -> ShareUtils.openUrlInBrowser(this, url)) .setNegativeButton(R.string.share, - (dialog, which) -> ShareUtils.shareUrl(this, "", url)) // no subject + (dialog, which) -> ShareUtils.shareText(this, "", url)) // no subject .setNeutralButton(R.string.cancel, null) .setOnDismissListener(dialog -> finish()) .show(); diff --git a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java index d11978c6b..ec28be237 100644 --- a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java +++ b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java @@ -146,16 +146,13 @@ public class AboutActivity extends AppCompatActivity { aboutBinding.appVersion.setText(BuildConfig.VERSION_NAME); aboutBinding.githubLink.setOnClickListener(nv -> - openUrlInBrowser(context, context.getString(R.string.github_url), - false)); + openUrlInBrowser(context, context.getString(R.string.github_url), false)); aboutBinding.donationLink.setOnClickListener(v -> - openUrlInBrowser(context, context.getString(R.string.donation_url), - false)); + openUrlInBrowser(context, context.getString(R.string.donation_url), false)); aboutBinding.websiteLink.setOnClickListener(nv -> - openUrlInBrowser(context, context.getString(R.string.website_url), - false)); + openUrlInBrowser(context, context.getString(R.string.website_url), false)); aboutBinding.privacyPolicyLink.setOnClickListener(v -> openUrlInBrowser(context, context.getString(R.string.privacy_policy_url), 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 c9913a808..7ebf66390 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 @@ -95,12 +95,12 @@ import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.DeviceUtils; import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.ImageDisplayConstants; -import org.schabi.newpipe.util.LinkHelper; import org.schabi.newpipe.util.ListHelper; import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.PermissionHelper; import org.schabi.newpipe.util.ShareUtils; +import org.schabi.newpipe.util.TextLinkifier; import org.schabi.newpipe.util.ThemeHelper; import org.schabi.newpipe.views.AnimatedProgressBar; import org.schabi.newpipe.views.LargeTextMovementMethod; @@ -1230,16 +1230,16 @@ public final class VideoDetailFragment } if (description.getType() == Description.HTML) { - LinkHelper.createLinksFromHtmlBlock(requireContext(), description.getContent(), + TextLinkifier.createLinksFromHtmlBlock(requireContext(), description.getContent(), videoDescriptionView, HtmlCompat.FROM_HTML_MODE_LEGACY); videoDescriptionView.setVisibility(View.VISIBLE); } else if (description.getType() == Description.MARKDOWN) { - LinkHelper.createLinksFromMarkdownText(requireContext(), description.getContent(), + TextLinkifier.createLinksFromMarkdownText(requireContext(), description.getContent(), videoDescriptionView); videoDescriptionView.setVisibility(View.VISIBLE); } else { //== Description.PLAIN_TEXT - LinkHelper.createLinksFromPlainText(requireContext(), description.getContent(), + TextLinkifier.createLinksFromPlainText(requireContext(), description.getContent(), videoDescriptionView); videoDescriptionView.setVisibility(View.VISIBLE); } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index 6bcaac630..b4dd45e93 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -206,7 +206,7 @@ public class ChannelFragment extends BaseListInfoFragment break; case R.id.menu_item_share: if (currentInfo != null) { - ShareUtils.shareUrl(requireContext(), name, currentInfo.getOriginalUrl()); + ShareUtils.shareText(requireContext(), name, currentInfo.getOriginalUrl()); } break; default: diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java index 58985e38a..85dea83dc 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java @@ -242,7 +242,7 @@ public class PlaylistFragment extends BaseListInfoFragment { ShareUtils.openUrlInBrowser(requireContext(), url); break; case R.id.menu_item_share: - ShareUtils.shareUrl(requireContext(), name, url); + ShareUtils.shareText(requireContext(), name, url); break; case R.id.menu_item_bookmark: onBookmarkClicked(); diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java index e6cae0c7e..fe35a18c4 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java @@ -13,15 +13,14 @@ import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; import androidx.preference.PreferenceManager; - import org.schabi.newpipe.R; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.comments.CommentsInfoItem; import org.schabi.newpipe.info_list.InfoItemBuilder; import org.schabi.newpipe.local.history.HistoryRecordManager; import org.schabi.newpipe.report.ErrorActivity; -import org.schabi.newpipe.util.DeviceUtils; import org.schabi.newpipe.util.CommentTextOnTouchListener; +import org.schabi.newpipe.util.DeviceUtils; import org.schabi.newpipe.util.ImageDisplayConstants; import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.NavigationHelper; diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamInfoItemHolder.java index 3440fbe3c..1915ff283 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamInfoItemHolder.java @@ -1,10 +1,11 @@ package org.schabi.newpipe.info_list.holder; -import androidx.preference.PreferenceManager; import android.text.TextUtils; import android.view.ViewGroup; import android.widget.TextView; +import androidx.preference.PreferenceManager; + import org.schabi.newpipe.R; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem; diff --git a/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java b/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java index d454da08b..84908e41a 100644 --- a/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java @@ -4,16 +4,15 @@ import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Bundle; - -import androidx.annotation.Nullable; -import androidx.preference.PreferenceManager; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.View; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.fragment.app.Fragment; +import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; diff --git a/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java b/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java index d5241ae02..ee77db89f 100644 --- a/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java @@ -33,9 +33,9 @@ import org.schabi.newpipe.util.OnClickGesture; import java.util.List; import icepick.State; +import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; import io.reactivex.rxjava3.core.Flowable; import io.reactivex.rxjava3.core.Single; -import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; import io.reactivex.rxjava3.disposables.CompositeDisposable; import io.reactivex.rxjava3.disposables.Disposable; diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt index 8be281dc3..a84745dbf 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt @@ -300,7 +300,7 @@ class SubscriptionFragment : BaseStateFragment() { val actions = DialogInterface.OnClickListener { _, i -> when (i) { - 0 -> ShareUtils.shareUrl(requireContext(), selectedItem.name, selectedItem.url) + 0 -> ShareUtils.shareText(requireContext(), selectedItem.name, selectedItem.url) 1 -> deleteChannel(selectedItem) } } diff --git a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java index e9ae1a1db..945bc9a04 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java @@ -34,8 +34,8 @@ import android.view.WindowManager; import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; -import org.schabi.newpipe.databinding.PlayerBinding; import org.schabi.newpipe.App; +import org.schabi.newpipe.databinding.PlayerBinding; import org.schabi.newpipe.util.ThemeHelper; import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage; diff --git a/app/src/main/java/org/schabi/newpipe/player/PlayQueueActivity.java b/app/src/main/java/org/schabi/newpipe/player/PlayQueueActivity.java index 6ea7ecda3..d757a9268 100644 --- a/app/src/main/java/org/schabi/newpipe/player/PlayQueueActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/PlayQueueActivity.java @@ -46,6 +46,7 @@ import java.util.List; import static org.schabi.newpipe.player.helper.PlayerHelper.formatSpeed; import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage; +import static org.schabi.newpipe.util.ShareUtils.shareText; public final class PlayQueueActivity extends AppCompatActivity implements PlayerEventListener, SeekBar.OnSeekBarChangeListener, @@ -311,7 +312,7 @@ public final class PlayQueueActivity extends AppCompatActivity final MenuItem share = popupMenu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 3, Menu.NONE, R.string.share); share.setOnMenuItemClickListener(menuItem -> { - shareUrl(item.getTitle(), item.getUrl()); + shareText(getApplicationContext(), item.getTitle(), item.getUrl()); return true; }); @@ -505,18 +506,6 @@ public final class PlayQueueActivity extends AppCompatActivity () -> PlaylistCreationDialog.newInstance(d).show(getSupportFragmentManager(), TAG)); } - //////////////////////////////////////////////////////////////////////////// - // Share - //////////////////////////////////////////////////////////////////////////// - - private void shareUrl(final String subject, final String url) { - final Intent intent = new Intent(Intent.ACTION_SEND); - intent.setType("text/plain"); - intent.putExtra(Intent.EXTRA_SUBJECT, subject); - intent.putExtra(Intent.EXTRA_TEXT, url); - startActivity(Intent.createChooser(intent, getString(R.string.share_dialog_title))); - } - //////////////////////////////////////////////////////////////////////////// // Binding Service Listener //////////////////////////////////////////////////////////////////////////// diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 2453117f3..b2b65477a 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -3553,7 +3553,7 @@ public final class Player implements && currentMetadata.getMetadata().getServiceId() == YouTube.getServiceId()) { videoUrl += ("&t=" + ts); } - ShareUtils.shareUrl(context, getVideoTitle(), videoUrl); + ShareUtils.shareText(context, getVideoTitle(), videoUrl); } private void onPlayWithKodiClicked() { diff --git a/app/src/main/java/org/schabi/newpipe/player/event/CustomBottomSheetBehavior.java b/app/src/main/java/org/schabi/newpipe/player/event/CustomBottomSheetBehavior.java index 347118de5..00ce3e616 100644 --- a/app/src/main/java/org/schabi/newpipe/player/event/CustomBottomSheetBehavior.java +++ b/app/src/main/java/org/schabi/newpipe/player/event/CustomBottomSheetBehavior.java @@ -6,9 +6,12 @@ import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.widget.FrameLayout; + import androidx.annotation.NonNull; import androidx.coordinatorlayout.widget.CoordinatorLayout; + import com.google.android.material.bottomsheet.BottomSheetBehavior; + import org.schabi.newpipe.R; import java.util.Arrays; diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/PlaybackParameterDialog.java b/app/src/main/java/org/schabi/newpipe/player/helper/PlaybackParameterDialog.java index 253f0fbba..a9a36e2f5 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/PlaybackParameterDialog.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlaybackParameterDialog.java @@ -3,7 +3,6 @@ package org.schabi.newpipe.player.helper; import android.app.Dialog; import android.content.Context; import android.os.Bundle; -import androidx.preference.PreferenceManager; import android.util.Log; import android.view.View; import android.widget.CheckBox; @@ -14,6 +13,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; +import androidx.preference.PreferenceManager; import org.schabi.newpipe.R; import org.schabi.newpipe.util.SliderStrategy; diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java index 90a979872..6131d8565 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java +++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java @@ -21,8 +21,8 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -import io.reactivex.rxjava3.core.BackpressureStrategy; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; +import io.reactivex.rxjava3.core.BackpressureStrategy; import io.reactivex.rxjava3.core.Flowable; import io.reactivex.rxjava3.subjects.BehaviorSubject; diff --git a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java index 0321d197a..e76af3944 100644 --- a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java @@ -244,7 +244,7 @@ public class ErrorActivity extends AppCompatActivity { goToReturnActivity(); break; case R.id.menu_item_share_error: - ShareUtils.shareUrl(this, getString(R.string.error_report_title), buildJson()); + ShareUtils.shareText(this, getString(R.string.error_report_title), buildJson()); break; } return false; @@ -267,7 +267,7 @@ public class ErrorActivity extends AppCompatActivity { .putExtra(Intent.EXTRA_SUBJECT, ERROR_EMAIL_SUBJECT) .putExtra(Intent.EXTRA_TEXT, buildJson()); if (i.resolveActivity(getPackageManager()) != null) { - ShareUtils.openContentInApp(context, i); + ShareUtils.openIntentInApp(context, i); } } else if (action.equals("GITHUB")) { // open the NewPipe issue page on GitHub ShareUtils.openUrlInBrowser(this, ERROR_GITHUB_ISSUE_URL, false); diff --git a/app/src/main/java/org/schabi/newpipe/settings/BasePreferenceFragment.java b/app/src/main/java/org/schabi/newpipe/settings/BasePreferenceFragment.java index 7a42c9bea..b64543d27 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/BasePreferenceFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/BasePreferenceFragment.java @@ -2,12 +2,12 @@ package org.schabi.newpipe.settings; import android.content.SharedPreferences; import android.os.Bundle; -import androidx.preference.PreferenceManager; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.preference.PreferenceFragmentCompat; +import androidx.preference.PreferenceManager; import org.schabi.newpipe.MainActivity; import org.schabi.newpipe.util.ThemeHelper; diff --git a/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java index 90537564a..afe42d5d8 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java @@ -30,8 +30,8 @@ import java.util.List; import java.util.Vector; import de.hdodenhof.circleimageview.CircleImageView; -import io.reactivex.rxjava3.core.Observer; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; +import io.reactivex.rxjava3.core.Observer; import io.reactivex.rxjava3.disposables.Disposable; import io.reactivex.rxjava3.schedulers.Schedulers; diff --git a/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java b/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java index 1fe405552..e50c858ca 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java +++ b/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java @@ -15,6 +15,7 @@ import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.TextView; import android.widget.Toast; + import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.content.res.AppCompatResources; @@ -22,7 +23,7 @@ import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.widget.TextViewCompat; import androidx.preference.Preference; import androidx.preference.PreferenceViewHolder; -import java.util.List; + import org.schabi.newpipe.R; import org.schabi.newpipe.player.MainPlayer; import org.schabi.newpipe.player.NotificationConstants; @@ -30,6 +31,8 @@ import org.schabi.newpipe.util.DeviceUtils; import org.schabi.newpipe.util.ThemeHelper; import org.schabi.newpipe.views.FocusOverlayView; +import java.util.List; + public class NotificationActionsPreference extends Preference { public NotificationActionsPreference(final Context context, final AttributeSet attrs) { diff --git a/app/src/main/java/org/schabi/newpipe/settings/tabs/TabsManager.java b/app/src/main/java/org/schabi/newpipe/settings/tabs/TabsManager.java index 02b0c3df5..2836fe52b 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/tabs/TabsManager.java +++ b/app/src/main/java/org/schabi/newpipe/settings/tabs/TabsManager.java @@ -2,9 +2,10 @@ package org.schabi.newpipe.settings.tabs; import android.content.Context; import android.content.SharedPreferences; -import androidx.preference.PreferenceManager; import android.widget.Toast; +import androidx.preference.PreferenceManager; + import org.schabi.newpipe.R; import java.util.List; diff --git a/app/src/main/java/org/schabi/newpipe/util/CommentTextOnTouchListener.java b/app/src/main/java/org/schabi/newpipe/util/CommentTextOnTouchListener.java index 5c7eb4c3f..d26116139 100644 --- a/app/src/main/java/org/schabi/newpipe/util/CommentTextOnTouchListener.java +++ b/app/src/main/java/org/schabi/newpipe/util/CommentTextOnTouchListener.java @@ -23,8 +23,8 @@ import org.schabi.newpipe.player.playqueue.SinglePlayQueue; import java.util.regex.Matcher; import java.util.regex.Pattern; -import io.reactivex.rxjava3.core.Single; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; +import io.reactivex.rxjava3.core.Single; import io.reactivex.rxjava3.schedulers.Schedulers; public class CommentTextOnTouchListener implements View.OnTouchListener { diff --git a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java index 7046b8e49..6938cf4cc 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java @@ -365,7 +365,7 @@ public final class ExtractorHelper { } } - LinkHelper.createLinksFromHtmlBlock(context, stringBuilder.toString(), + TextLinkifier.createLinksFromHtmlBlock(context, stringBuilder.toString(), metaInfoTextView, HtmlCompat.FROM_HTML_SEPARATOR_LINE_BREAK_HEADING); metaInfoTextView.setMovementMethod(LinkMovementMethod.getInstance()); metaInfoTextView.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/org/schabi/newpipe/util/FilenameUtils.java b/app/src/main/java/org/schabi/newpipe/util/FilenameUtils.java index 27e1f3048..edcb565a0 100644 --- a/app/src/main/java/org/schabi/newpipe/util/FilenameUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/FilenameUtils.java @@ -2,6 +2,7 @@ package org.schabi.newpipe.util; import android.content.Context; import android.content.SharedPreferences; + import androidx.preference.PreferenceManager; import org.schabi.newpipe.R; diff --git a/app/src/main/java/org/schabi/newpipe/util/ListHelper.java b/app/src/main/java/org/schabi/newpipe/util/ListHelper.java index 5f8fb5898..eb3c21827 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ListHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ListHelper.java @@ -4,11 +4,10 @@ import android.content.Context; import android.content.SharedPreferences; import android.net.ConnectivityManager; -import androidx.core.content.ContextCompat; -import androidx.preference.PreferenceManager; - import androidx.annotation.Nullable; import androidx.annotation.StringRes; +import androidx.core.content.ContextCompat; +import androidx.preference.PreferenceManager; import org.schabi.newpipe.R; import org.schabi.newpipe.extractor.MediaFormat; diff --git a/app/src/main/java/org/schabi/newpipe/util/Localization.java b/app/src/main/java/org/schabi/newpipe/util/Localization.java index c235d7d67..f62f959c4 100644 --- a/app/src/main/java/org/schabi/newpipe/util/Localization.java +++ b/app/src/main/java/org/schabi/newpipe/util/Localization.java @@ -9,10 +9,19 @@ import android.icu.text.CompactDecimalFormat; import android.os.Build; import android.text.TextUtils; import android.util.DisplayMetrics; + import androidx.annotation.NonNull; import androidx.annotation.PluralsRes; import androidx.annotation.StringRes; import androidx.preference.PreferenceManager; + +import org.ocpsoft.prettytime.PrettyTime; +import org.ocpsoft.prettytime.units.Decade; +import org.schabi.newpipe.R; +import org.schabi.newpipe.extractor.ListExtractor; +import org.schabi.newpipe.extractor.localization.ContentCountry; +import org.schabi.newpipe.ktx.OffsetDateTimeKt; + import java.math.BigDecimal; import java.math.RoundingMode; import java.text.NumberFormat; @@ -24,12 +33,6 @@ import java.util.Arrays; import java.util.Calendar; import java.util.List; import java.util.Locale; -import org.ocpsoft.prettytime.PrettyTime; -import org.ocpsoft.prettytime.units.Decade; -import org.schabi.newpipe.R; -import org.schabi.newpipe.extractor.ListExtractor; -import org.schabi.newpipe.extractor.localization.ContentCountry; -import org.schabi.newpipe.ktx.OffsetDateTimeKt; /* 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 936b4595c..4f4fd5283 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -2,7 +2,6 @@ package org.schabi.newpipe.util; import android.annotation.SuppressLint; import android.app.Activity; -import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.net.Uri; @@ -46,9 +45,9 @@ import org.schabi.newpipe.local.history.StatisticsPlaylistFragment; import org.schabi.newpipe.local.playlist.LocalPlaylistFragment; import org.schabi.newpipe.local.subscription.SubscriptionFragment; import org.schabi.newpipe.local.subscription.SubscriptionsImportFragment; +import org.schabi.newpipe.player.MainPlayer; import org.schabi.newpipe.player.PlayQueueActivity; import org.schabi.newpipe.player.Player; -import org.schabi.newpipe.player.MainPlayer; import org.schabi.newpipe.player.helper.PlayerHelper; import org.schabi.newpipe.player.helper.PlayerHolder; import org.schabi.newpipe.player.playqueue.PlayQueue; @@ -57,6 +56,8 @@ import org.schabi.newpipe.settings.SettingsActivity; import java.util.ArrayList; +import static org.schabi.newpipe.util.ShareUtils.installApp; + public final class NavigationHelper { public static final String MAIN_FRAGMENT_TAG = "main_fragment_tag"; public static final String SEARCH_FRAGMENT_TAG = "search_fragment_tag"; @@ -246,7 +247,7 @@ public final class NavigationHelper { public static void resolveActivityOrAskToInstall(final Context context, final Intent intent) { if (intent.resolveActivity(context.getPackageManager()) != null) { - ShareUtils.openContentInApp(context, intent); + ShareUtils.openIntentInApp(context, intent); } else { if (context instanceof Activity) { new AlertDialog.Builder(context) @@ -566,17 +567,6 @@ public final class NavigationHelper { return getOpenIntent(context, url, service.getServiceId(), linkType); } - private static void installApp(final Context context, final String packageName) { - try { - // Try market:// scheme - ShareUtils.openUrlInBrowser(context, "market://details?id=" + packageName, false); - } catch (final ActivityNotFoundException e) { - // Fall back to google play URL (don't worry F-Droid can handle it :) - ShareUtils.openUrlInBrowser(context, - "https://play.google.com/store/apps/details?id=" + packageName, false); - } - } - /** * Start an activity to install Kore. * diff --git a/app/src/main/java/org/schabi/newpipe/util/PeertubeHelper.java b/app/src/main/java/org/schabi/newpipe/util/PeertubeHelper.java index e28095798..dcc39eccf 100644 --- a/app/src/main/java/org/schabi/newpipe/util/PeertubeHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/PeertubeHelper.java @@ -2,6 +2,7 @@ package org.schabi.newpipe.util; import android.content.Context; import android.content.SharedPreferences; + import androidx.preference.PreferenceManager; import com.grack.nanojson.JsonArray; diff --git a/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java b/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java index a6756991c..b38edfeb4 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java @@ -2,10 +2,10 @@ package org.schabi.newpipe.util; import android.content.Context; import android.content.SharedPreferences; -import androidx.preference.PreferenceManager; import androidx.annotation.DrawableRes; import androidx.annotation.StringRes; +import androidx.preference.PreferenceManager; import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonParser; diff --git a/app/src/main/java/org/schabi/newpipe/util/ShareUtils.java b/app/src/main/java/org/schabi/newpipe/util/ShareUtils.java index 142b2b20c..ffb965ae7 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ShareUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/ShareUtils.java @@ -6,7 +6,6 @@ import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; import android.net.Uri; import android.widget.Toast; @@ -18,6 +17,27 @@ public final class ShareUtils { private ShareUtils() { } + /** + * Open an Intent to install an app. + *

+ * This method will first try open to Google Play Store with the market scheme and falls back to + * Google Play Store web url if this first cannot be found. + * + * @param context the context to use + * @param packageName the package to be installed + */ + public static void installApp(final Context context, final String packageName) { + try { + // Try market:// scheme + openIntentInApp(context, new Intent(Intent.ACTION_VIEW, + Uri.parse("market://details?id=" + packageName))); + } catch (final ActivityNotFoundException e) { + // Fall back to Google Play Store Web URL (don't worry, F-Droid can handle it :)) + openUrlInBrowser(context, + "https://play.google.com/store/apps/details?id=" + packageName, false); + } + } + /** * Open the url with the system default browser. *

@@ -26,12 +46,11 @@ public final class ShareUtils { * * @param context the context to use * @param url the url to browse - * @param httpDefaultBrowserTest the boolean to set if the - * test for the default browser will be for HTTP protocol - * or for the created intent + * @param httpDefaultBrowserTest the boolean to set if the test for the default browser will be + * for HTTP protocol or for the created intent */ public static void openUrlInBrowser(final Context context, final String url, - final Boolean httpDefaultBrowserTest) { + final boolean httpDefaultBrowserTest) { final String defaultPackageName; final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); @@ -42,14 +61,14 @@ public final class ShareUtils { } if (defaultPackageName.equals("android")) { - // no browser set as default (doesn't work on some devices) + // No browser set as default (doesn't work on some devices) openInDefaultApp(context, intent); } else { try { intent.setPackage(defaultPackageName); context.startActivity(intent); } catch (final ActivityNotFoundException e) { - // not a browser but an app chooser because of OEMs changes + // Not a browser but an app chooser because of OEMs changes intent.setPackage(null); openInDefaultApp(context, intent); } @@ -62,7 +81,7 @@ public final class ShareUtils { * If no browser is set as default, fallbacks to * {@link ShareUtils#openInDefaultApp(Context, Intent)} *

- * This call {@link ShareUtils#openUrlInBrowser(Context, String, Boolean)} with true + * This calls {@link ShareUtils#openUrlInBrowser(Context, String, boolean)} with true * for the boolean parameter * * @param context the context to use @@ -73,26 +92,29 @@ public final class ShareUtils { } /** - * Open a content with the system default browser. + * Open an intent with the system default app. + *

+ * The intent can be of every type, excepted a web intent for which + * {@link ShareUtils#openUrlInBrowser(Context, String, boolean)} should be used. *

* If no app is set as default, fallbacks to * {@link ShareUtils#openInDefaultApp(Context, Intent)} * * @param context the context to use - * @param intent the intent of the file to open + * @param intent the intent to open */ - public static void openContentInApp(final Context context, final Intent intent) { + public static void openIntentInApp(final Context context, final Intent intent) { final String defaultAppPackageName = getDefaultAppPackageName(context, intent); if (defaultAppPackageName.equals("android")) { - // no app set as default (doesn't work on some devices) + // No app set as default (doesn't work on some devices) openInDefaultApp(context, intent); } else { try { intent.setPackage(defaultAppPackageName); context.startActivity(intent); } catch (final ActivityNotFoundException e) { - // not an app to open a file but an app chooser because of OEMs changes + // Not an app to open the intent but an app chooser because of OEMs changes intent.setPackage(null); openInDefaultApp(context, intent); } @@ -143,9 +165,8 @@ public final class ShareUtils { private static String getDefaultBrowserPackageName(final Context context) { final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://")) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - final ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, - PackageManager.MATCH_DEFAULT_ONLY); - return resolveInfo.activityInfo.packageName; + return context.getPackageManager().resolveActivity(intent, + PackageManager.MATCH_DEFAULT_ONLY).activityInfo.packageName; } /** @@ -155,11 +176,12 @@ public final class ShareUtils { * @param subject the url subject, typically the title * @param url the url to share */ - public static void shareUrl(final Context context, final String subject, final String url) { + public static void shareText(final Context context, final String subject, final String url) { final Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject); shareIntent.putExtra(Intent.EXTRA_TEXT, url); + final Intent intent = new Intent(Intent.ACTION_CHOOSER); intent.putExtra(Intent.EXTRA_INTENT, shareIntent); intent.putExtra(Intent.EXTRA_TITLE, context.getString(R.string.share_dialog_title)); diff --git a/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java b/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java index 153ba7cf4..73fee32f7 100644 --- a/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java +++ b/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java @@ -81,7 +81,7 @@ public enum StreamDialogEntry { }), share(R.string.share, (fragment, item) -> - ShareUtils.shareUrl(fragment.getContext(), item.getName(), item.getUrl())); + ShareUtils.shareText(fragment.getContext(), item.getName(), item.getUrl())); /////////////// diff --git a/app/src/main/java/org/schabi/newpipe/util/LinkHelper.java b/app/src/main/java/org/schabi/newpipe/util/TextLinkifier.java similarity index 92% rename from app/src/main/java/org/schabi/newpipe/util/LinkHelper.java rename to app/src/main/java/org/schabi/newpipe/util/TextLinkifier.java index fba30758f..eb7296611 100644 --- a/app/src/main/java/org/schabi/newpipe/util/LinkHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/TextLinkifier.java @@ -14,15 +14,15 @@ import androidx.core.text.HtmlCompat; import io.noties.markwon.Markwon; import io.noties.markwon.linkify.LinkifyPlugin; -public final class LinkHelper { - private LinkHelper() { +public final class TextLinkifier { + private TextLinkifier() { } /** * Create web links for contents with an HTML description. *

* This will call - * {@link LinkHelper#changeIntentsOfDescriptionLinks(Context, CharSequence, TextView)} + * {@link TextLinkifier#changeIntentsOfDescriptionLinks(Context, CharSequence, TextView)} * after linked the URLs with {@link HtmlCompat#fromHtml(String, int)}. * * @param context the context to use @@ -43,7 +43,7 @@ public final class LinkHelper { * Create web links for contents with a plain text description. *

* This will call - * {@link LinkHelper#changeIntentsOfDescriptionLinks(Context, CharSequence, TextView)} + * {@link TextLinkifier#changeIntentsOfDescriptionLinks(Context, CharSequence, TextView)} * after linked the URLs with {@link TextView#setAutoLinkMask(int)} and * {@link TextView#setText(CharSequence, TextView.BufferType)}. * @@ -63,7 +63,7 @@ public final class LinkHelper { * Create web links for contents with a markdown description. *

* This will call - * {@link LinkHelper#changeIntentsOfDescriptionLinks(Context, CharSequence, TextView)} + * {@link TextLinkifier#changeIntentsOfDescriptionLinks(Context, CharSequence, TextView)} * after creating an {@link Markwon} object and using * {@link Markwon#setMarkdown(TextView, String)}. * @@ -84,7 +84,7 @@ public final class LinkHelper { *

* Instead of using an ACTION_VIEW intent in the description of a content, this method will * parse the CharSequence and replace all current web links with - * {@link ShareUtils#openUrlInBrowser(Context, String, Boolean)}. + * {@link ShareUtils#openUrlInBrowser(Context, String, boolean)}. *

* This method is required in order to intercept links and maybe, show a confirmation dialog * before opening a web link. @@ -105,6 +105,7 @@ public final class LinkHelper { ShareUtils.openUrlInBrowser(context, span.getURL(), false); } }; + textBlockLinked.setSpan(clickableSpan, textBlockLinked.getSpanStart(span), textBlockLinked.getSpanEnd(span), textBlockLinked.getSpanFlags(span)); textBlockLinked.removeSpan(span); diff --git a/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java b/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java index a1af0387a..5ac4de84c 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java @@ -22,7 +22,6 @@ package org.schabi.newpipe.util; import android.app.Activity; import android.content.Context; import android.content.res.TypedArray; -import androidx.preference.PreferenceManager; import android.util.TypedValue; import android.view.ContextThemeWrapper; @@ -32,6 +31,7 @@ import androidx.annotation.StyleRes; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.ContextCompat; +import androidx.preference.PreferenceManager; import org.schabi.newpipe.R; import org.schabi.newpipe.extractor.NewPipe; diff --git a/app/src/main/java/org/schabi/newpipe/views/CustomCollapsingToolbarLayout.java b/app/src/main/java/org/schabi/newpipe/views/CustomCollapsingToolbarLayout.java index 23e16ff58..dc667b22a 100644 --- a/app/src/main/java/org/schabi/newpipe/views/CustomCollapsingToolbarLayout.java +++ b/app/src/main/java/org/schabi/newpipe/views/CustomCollapsingToolbarLayout.java @@ -2,10 +2,12 @@ package org.schabi.newpipe.views; import android.content.Context; import android.util.AttributeSet; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; + import com.google.android.material.appbar.CollapsingToolbarLayout; public class CustomCollapsingToolbarLayout extends CollapsingToolbarLayout { diff --git a/app/src/main/java/org/schabi/newpipe/views/ExpandableSurfaceView.java b/app/src/main/java/org/schabi/newpipe/views/ExpandableSurfaceView.java index e7a028d50..cfa17e20c 100644 --- a/app/src/main/java/org/schabi/newpipe/views/ExpandableSurfaceView.java +++ b/app/src/main/java/org/schabi/newpipe/views/ExpandableSurfaceView.java @@ -4,6 +4,7 @@ import android.content.Context; import android.os.Build; import android.util.AttributeSet; import android.view.SurfaceView; + import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; import static com.google.android.exoplayer2.ui.AspectRatioFrameLayout.RESIZE_MODE_FIT; diff --git a/app/src/main/java/org/schabi/newpipe/views/FocusAwareCoordinator.java b/app/src/main/java/org/schabi/newpipe/views/FocusAwareCoordinator.java index f400b62b1..798d08c72 100644 --- a/app/src/main/java/org/schabi/newpipe/views/FocusAwareCoordinator.java +++ b/app/src/main/java/org/schabi/newpipe/views/FocusAwareCoordinator.java @@ -24,11 +24,12 @@ import android.os.Build; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; - import android.view.WindowInsets; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.coordinatorlayout.widget.CoordinatorLayout; + import org.schabi.newpipe.R; public final class FocusAwareCoordinator extends CoordinatorLayout { diff --git a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java index e77196445..568c3497a 100755 --- a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java +++ b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java @@ -24,10 +24,6 @@ import android.os.Handler.Callback; import android.os.IBinder; import android.os.Message; import android.os.Parcelable; - -import androidx.core.app.ServiceCompat; -import androidx.core.content.ContextCompat; -import androidx.preference.PreferenceManager; import android.util.Log; import android.util.SparseArray; import android.widget.Toast; @@ -37,6 +33,9 @@ import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationCompat.Builder; +import androidx.core.app.ServiceCompat; +import androidx.core.content.ContextCompat; +import androidx.preference.PreferenceManager; import org.schabi.newpipe.R; import org.schabi.newpipe.download.DownloadActivity; diff --git a/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java b/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java index 79b91cb57..bea4b6f94 100644 --- a/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java +++ b/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java @@ -364,7 +364,7 @@ public class MissionAdapter extends Adapter implements Handler.Callb //mContext.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); if (intent.resolveActivity(mContext.getPackageManager()) != null) { - ShareUtils.openContentInApp(mContext, intent); + ShareUtils.openIntentInApp(mContext, intent); } else { Toast.makeText(mContext, R.string.toast_no_player, Toast.LENGTH_LONG).show(); } diff --git a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java index 9632c4ae0..3270b2b6f 100644 --- a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java +++ b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java @@ -11,7 +11,6 @@ import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.os.IBinder; -import androidx.preference.PreferenceManager; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -21,6 +20,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; +import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml index 0aca3c4ab..2ff7ae68d 100644 --- a/checkstyle-suppressions.xml +++ b/checkstyle-suppressions.xml @@ -13,7 +13,7 @@ + lines="280,312"/>