From 22c201be3967cf98e9c9a0a0f9463d5ec3737e0f Mon Sep 17 00:00:00 2001 From: Stypox Date: Sun, 15 Jan 2023 11:51:07 +0100 Subject: [PATCH] Create text subpackage in util --- .../newpipe/fragments/detail/DescriptionFragment.java | 2 +- .../info_list/holder/CommentsMiniInfoItemHolder.java | 4 ++-- .../java/org/schabi/newpipe/util/ExtractorHelper.java | 2 +- .../util/{ => text}/CommentTextOnTouchListener.java | 5 ++--- .../HashtagLongPressClickableSpan.java | 4 ++-- .../InternalUrlsHandler.java | 2 +- .../{views => util/text}/LongPressClickableSpan.java | 2 +- .../{views => util/text}/LongPressLinkMovementMethod.java | 4 ++-- .../{external_communication => text}/TextLinkifier.java | 8 +++----- .../TimestampExtractor.java | 2 +- .../TimestampLongPressClickableSpan.java | 6 +++--- .../org/schabi/newpipe/util/{ => text}/TouchUtils.java | 2 +- .../UrlLongPressClickableSpan.java | 4 ++-- .../external_communication/TimestampExtractorTest.java | 1 + 14 files changed, 23 insertions(+), 25 deletions(-) rename app/src/main/java/org/schabi/newpipe/util/{ => text}/CommentTextOnTouchListener.java (91%) rename app/src/main/java/org/schabi/newpipe/util/{external_communication => text}/HashtagLongPressClickableSpan.java (90%) rename app/src/main/java/org/schabi/newpipe/util/{external_communication => text}/InternalUrlsHandler.java (99%) rename app/src/main/java/org/schabi/newpipe/{views => util/text}/LongPressClickableSpan.java (86%) rename app/src/main/java/org/schabi/newpipe/{views => util/text}/LongPressLinkMovementMethod.java (95%) rename app/src/main/java/org/schabi/newpipe/util/{external_communication => text}/TextLinkifier.java (98%) rename app/src/main/java/org/schabi/newpipe/util/{external_communication => text}/TimestampExtractor.java (98%) rename app/src/main/java/org/schabi/newpipe/util/{external_communication => text}/TimestampLongPressClickableSpan.java (93%) rename app/src/main/java/org/schabi/newpipe/util/{ => text}/TouchUtils.java (96%) rename app/src/main/java/org/schabi/newpipe/util/{external_communication => text}/UrlLongPressClickableSpan.java (90%) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/DescriptionFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/DescriptionFragment.java index 96e01c622..ea89424ec 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/DescriptionFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/DescriptionFragment.java @@ -29,7 +29,7 @@ import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.external_communication.ShareUtils; -import org.schabi.newpipe.util.external_communication.TextLinkifier; +import org.schabi.newpipe.util.text.TextLinkifier; import icepick.State; import io.reactivex.rxjava3.disposables.CompositeDisposable; 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 92e37afd8..69aba8c4f 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 @@ -20,13 +20,13 @@ 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.util.CommentTextOnTouchListener; +import org.schabi.newpipe.util.text.CommentTextOnTouchListener; import org.schabi.newpipe.util.DeviceUtils; import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.PicassoHelper; import org.schabi.newpipe.util.external_communication.ShareUtils; -import org.schabi.newpipe.util.external_communication.TimestampExtractor; +import org.schabi.newpipe.util.text.TimestampExtractor; import java.util.Objects; 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 27009efd1..2123010aa 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java @@ -51,7 +51,7 @@ import org.schabi.newpipe.extractor.search.SearchInfo; import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor; -import org.schabi.newpipe.util.external_communication.TextLinkifier; +import org.schabi.newpipe.util.text.TextLinkifier; import java.util.Collections; 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/text/CommentTextOnTouchListener.java similarity index 91% rename from app/src/main/java/org/schabi/newpipe/util/CommentTextOnTouchListener.java rename to app/src/main/java/org/schabi/newpipe/util/text/CommentTextOnTouchListener.java index ff8875e5a..4ced4be77 100644 --- a/app/src/main/java/org/schabi/newpipe/util/CommentTextOnTouchListener.java +++ b/app/src/main/java/org/schabi/newpipe/util/text/CommentTextOnTouchListener.java @@ -1,6 +1,6 @@ -package org.schabi.newpipe.util; +package org.schabi.newpipe.util.text; -import static org.schabi.newpipe.util.TouchUtils.getOffsetForHorizontalLine; +import static org.schabi.newpipe.util.text.TouchUtils.getOffsetForHorizontalLine; import android.text.Selection; import android.text.Spannable; @@ -12,7 +12,6 @@ import android.view.View; import android.widget.TextView; import org.schabi.newpipe.util.external_communication.ShareUtils; -import org.schabi.newpipe.util.external_communication.InternalUrlsHandler; import io.reactivex.rxjava3.disposables.CompositeDisposable; diff --git a/app/src/main/java/org/schabi/newpipe/util/external_communication/HashtagLongPressClickableSpan.java b/app/src/main/java/org/schabi/newpipe/util/text/HashtagLongPressClickableSpan.java similarity index 90% rename from app/src/main/java/org/schabi/newpipe/util/external_communication/HashtagLongPressClickableSpan.java rename to app/src/main/java/org/schabi/newpipe/util/text/HashtagLongPressClickableSpan.java index 9acedc12b..4ca6c326e 100644 --- a/app/src/main/java/org/schabi/newpipe/util/external_communication/HashtagLongPressClickableSpan.java +++ b/app/src/main/java/org/schabi/newpipe/util/text/HashtagLongPressClickableSpan.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.util.external_communication; +package org.schabi.newpipe.util.text; import android.content.Context; import android.view.View; @@ -7,7 +7,7 @@ import androidx.annotation.NonNull; import org.schabi.newpipe.extractor.Info; import org.schabi.newpipe.util.NavigationHelper; -import org.schabi.newpipe.views.LongPressClickableSpan; +import org.schabi.newpipe.util.external_communication.ShareUtils; final class HashtagLongPressClickableSpan extends LongPressClickableSpan { diff --git a/app/src/main/java/org/schabi/newpipe/util/external_communication/InternalUrlsHandler.java b/app/src/main/java/org/schabi/newpipe/util/text/InternalUrlsHandler.java similarity index 99% rename from app/src/main/java/org/schabi/newpipe/util/external_communication/InternalUrlsHandler.java rename to app/src/main/java/org/schabi/newpipe/util/text/InternalUrlsHandler.java index c46e6636d..b87618922 100644 --- a/app/src/main/java/org/schabi/newpipe/util/external_communication/InternalUrlsHandler.java +++ b/app/src/main/java/org/schabi/newpipe/util/text/InternalUrlsHandler.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.util.external_communication; +package org.schabi.newpipe.util.text; import android.content.Context; import android.util.Log; diff --git a/app/src/main/java/org/schabi/newpipe/views/LongPressClickableSpan.java b/app/src/main/java/org/schabi/newpipe/util/text/LongPressClickableSpan.java similarity index 86% rename from app/src/main/java/org/schabi/newpipe/views/LongPressClickableSpan.java rename to app/src/main/java/org/schabi/newpipe/util/text/LongPressClickableSpan.java index d6b927a30..5c94a5850 100644 --- a/app/src/main/java/org/schabi/newpipe/views/LongPressClickableSpan.java +++ b/app/src/main/java/org/schabi/newpipe/util/text/LongPressClickableSpan.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.views; +package org.schabi.newpipe.util.text; import android.text.style.ClickableSpan; import android.view.View; diff --git a/app/src/main/java/org/schabi/newpipe/views/LongPressLinkMovementMethod.java b/app/src/main/java/org/schabi/newpipe/util/text/LongPressLinkMovementMethod.java similarity index 95% rename from app/src/main/java/org/schabi/newpipe/views/LongPressLinkMovementMethod.java rename to app/src/main/java/org/schabi/newpipe/util/text/LongPressLinkMovementMethod.java index 5f90284fc..bd57621cb 100644 --- a/app/src/main/java/org/schabi/newpipe/views/LongPressLinkMovementMethod.java +++ b/app/src/main/java/org/schabi/newpipe/util/text/LongPressLinkMovementMethod.java @@ -1,6 +1,6 @@ -package org.schabi.newpipe.views; +package org.schabi.newpipe.util.text; -import static org.schabi.newpipe.util.TouchUtils.getOffsetForHorizontalLine; +import static org.schabi.newpipe.util.text.TouchUtils.getOffsetForHorizontalLine; import android.os.Handler; import android.os.Looper; diff --git a/app/src/main/java/org/schabi/newpipe/util/external_communication/TextLinkifier.java b/app/src/main/java/org/schabi/newpipe/util/text/TextLinkifier.java similarity index 98% rename from app/src/main/java/org/schabi/newpipe/util/external_communication/TextLinkifier.java rename to app/src/main/java/org/schabi/newpipe/util/text/TextLinkifier.java index 1bbd37cf5..b7220d22f 100644 --- a/app/src/main/java/org/schabi/newpipe/util/external_communication/TextLinkifier.java +++ b/app/src/main/java/org/schabi/newpipe/util/text/TextLinkifier.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.util.external_communication; +package org.schabi.newpipe.util.text; import android.content.Context; import android.text.SpannableStringBuilder; @@ -15,8 +15,7 @@ import androidx.core.text.HtmlCompat; import org.schabi.newpipe.extractor.Info; import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.util.NavigationHelper; -import org.schabi.newpipe.views.LongPressClickableSpan; -import org.schabi.newpipe.views.LongPressLinkMovementMethod; +import org.schabi.newpipe.util.external_communication.ShareUtils; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -88,8 +87,7 @@ public final class TextLinkifier { @NonNull final CompositeDisposable disposables) { textView.setAutoLinkMask(Linkify.WEB_URLS); textView.setText(plainTextBlock, TextView.BufferType.SPANNABLE); - changeIntentsOfDescriptionLinks(textView, textView.getText(), relatedInfo, disposables - ); + changeIntentsOfDescriptionLinks(textView, textView.getText(), relatedInfo, disposables); } /** diff --git a/app/src/main/java/org/schabi/newpipe/util/external_communication/TimestampExtractor.java b/app/src/main/java/org/schabi/newpipe/util/text/TimestampExtractor.java similarity index 98% rename from app/src/main/java/org/schabi/newpipe/util/external_communication/TimestampExtractor.java rename to app/src/main/java/org/schabi/newpipe/util/text/TimestampExtractor.java index d0862b750..be603f41a 100644 --- a/app/src/main/java/org/schabi/newpipe/util/external_communication/TimestampExtractor.java +++ b/app/src/main/java/org/schabi/newpipe/util/text/TimestampExtractor.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.util.external_communication; +package org.schabi.newpipe.util.text; import androidx.annotation.NonNull; import androidx.annotation.Nullable; diff --git a/app/src/main/java/org/schabi/newpipe/util/external_communication/TimestampLongPressClickableSpan.java b/app/src/main/java/org/schabi/newpipe/util/text/TimestampLongPressClickableSpan.java similarity index 93% rename from app/src/main/java/org/schabi/newpipe/util/external_communication/TimestampLongPressClickableSpan.java rename to app/src/main/java/org/schabi/newpipe/util/text/TimestampLongPressClickableSpan.java index 0ecbc8367..48110312d 100644 --- a/app/src/main/java/org/schabi/newpipe/util/external_communication/TimestampLongPressClickableSpan.java +++ b/app/src/main/java/org/schabi/newpipe/util/text/TimestampLongPressClickableSpan.java @@ -1,6 +1,6 @@ -package org.schabi.newpipe.util.external_communication; +package org.schabi.newpipe.util.text; -import static org.schabi.newpipe.util.external_communication.InternalUrlsHandler.playOnPopup; +import static org.schabi.newpipe.util.text.InternalUrlsHandler.playOnPopup; import android.content.Context; import android.view.View; @@ -10,7 +10,7 @@ import androidx.annotation.NonNull; import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.stream.StreamInfo; -import org.schabi.newpipe.views.LongPressClickableSpan; +import org.schabi.newpipe.util.external_communication.ShareUtils; import io.reactivex.rxjava3.disposables.CompositeDisposable; diff --git a/app/src/main/java/org/schabi/newpipe/util/TouchUtils.java b/app/src/main/java/org/schabi/newpipe/util/text/TouchUtils.java similarity index 96% rename from app/src/main/java/org/schabi/newpipe/util/TouchUtils.java rename to app/src/main/java/org/schabi/newpipe/util/text/TouchUtils.java index 23bc5a401..5c0db20a3 100644 --- a/app/src/main/java/org/schabi/newpipe/util/TouchUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/text/TouchUtils.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.util; +package org.schabi.newpipe.util.text; import android.text.Layout; import android.view.MotionEvent; diff --git a/app/src/main/java/org/schabi/newpipe/util/external_communication/UrlLongPressClickableSpan.java b/app/src/main/java/org/schabi/newpipe/util/text/UrlLongPressClickableSpan.java similarity index 90% rename from app/src/main/java/org/schabi/newpipe/util/external_communication/UrlLongPressClickableSpan.java rename to app/src/main/java/org/schabi/newpipe/util/text/UrlLongPressClickableSpan.java index f6cee708f..eb0d7425e 100644 --- a/app/src/main/java/org/schabi/newpipe/util/external_communication/UrlLongPressClickableSpan.java +++ b/app/src/main/java/org/schabi/newpipe/util/text/UrlLongPressClickableSpan.java @@ -1,11 +1,11 @@ -package org.schabi.newpipe.util.external_communication; +package org.schabi.newpipe.util.text; import android.content.Context; import android.view.View; import androidx.annotation.NonNull; -import org.schabi.newpipe.views.LongPressClickableSpan; +import org.schabi.newpipe.util.external_communication.ShareUtils; import io.reactivex.rxjava3.disposables.CompositeDisposable; diff --git a/app/src/test/java/org/schabi/newpipe/util/external_communication/TimestampExtractorTest.java b/app/src/test/java/org/schabi/newpipe/util/external_communication/TimestampExtractorTest.java index 10e23883f..47853bd7f 100644 --- a/app/src/test/java/org/schabi/newpipe/util/external_communication/TimestampExtractorTest.java +++ b/app/src/test/java/org/schabi/newpipe/util/external_communication/TimestampExtractorTest.java @@ -3,6 +3,7 @@ package org.schabi.newpipe.util.external_communication; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.schabi.newpipe.util.text.TimestampExtractor; import java.time.Duration; import java.util.Arrays;