diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 933efa22..d2d6e8f3 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -11,6 +11,7 @@ env: jobs: pull-request: + name: Open pull request runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7870c45a..c10e9feb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,8 @@ on: - dev jobs: - build: + release: + name: Release runs-on: ubuntu-latest steps: - name: Cancel previou runs @@ -30,8 +31,8 @@ jobs: node-version: "latest" cache: 'npm' - name: Setup semantic-release - run: npm install semantic-release @saithodev/semantic-release-backmerge @semantic-release/git @semantic-release/changelog gradle-semantic-release-plugin -D + run: npm install semantic-release@19.0.5 @saithodev/semantic-release-backmerge @semantic-release/git @semantic-release/changelog gradle-semantic-release-plugin@1.7.4 -D - name: Release env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.REPOSITORY_PUSH_ACCESS }} run: npx semantic-release diff --git a/CHANGELOG.md b/CHANGELOG.md index af319b9b..58902b26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# [0.93.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.92.2...v0.93.0-dev.1) (2023-01-10) + + +### Features + +* `remove-screenshot-restriction` patch ([#285](https://github.com/revanced/revanced-integrations/issues/285)) ([c3eff91](https://github.com/revanced/revanced-integrations/commit/c3eff913ddb076dc86efd0398e34d04336a655ec)) +* **youtube/return-youtube-dislike:** better matching color for separators ([#281](https://github.com/revanced/revanced-integrations/issues/281)) ([2a16da1](https://github.com/revanced/revanced-integrations/commit/2a16da15d9a8d37ca65973671f0b4edff0078b47)) +* **youtube/return-youtube-dislike:** style for minimum width ([#284](https://github.com/revanced/revanced-integrations/issues/284)) ([a80fab7](https://github.com/revanced/revanced-integrations/commit/a80fab7070be203aa8aaf4c8422ea8e998843e67)) +* **youtube:** `spoof-app-version` patch ([#282](https://github.com/revanced/revanced-integrations/issues/282)) ([fd818a3](https://github.com/revanced/revanced-integrations/commit/fd818a35f5252fc0a37e12b528e020cdfac0ab53)) + ## [0.92.2](https://github.com/revanced/revanced-integrations/compare/v0.92.1...v0.92.2) (2023-01-07) diff --git a/app/src/main/java/app/revanced/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch.java b/app/src/main/java/app/revanced/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch.java new file mode 100644 index 00000000..8c3eeecb --- /dev/null +++ b/app/src/main/java/app/revanced/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch.java @@ -0,0 +1,11 @@ +package app.revanced.all.screenshot.removerestriction; + +import android.view.Window; +import android.view.WindowManager; + +public class RemoveScreenshotRestrictionPatch { + + public static void setFlags(Window window, int flags, int mask) { + window.setFlags(flags & ~WindowManager.LayoutParams.FLAG_SECURE, mask & ~WindowManager.LayoutParams.FLAG_SECURE); + } +} diff --git a/app/src/main/java/app/revanced/integrations/patches/SpoofAppVersionPatch.java b/app/src/main/java/app/revanced/integrations/patches/SpoofAppVersionPatch.java new file mode 100644 index 00000000..21cb5d07 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/SpoofAppVersionPatch.java @@ -0,0 +1,15 @@ +package app.revanced.integrations.patches; + +import app.revanced.integrations.settings.SettingsEnum; + +public class SpoofAppVersionPatch { + + public static String getYouTubeVersionOverride(String version) { + if (SettingsEnum.SPOOF_APP_VERSION.getBoolean()){ + // Override with the most recent version that does not show the new UI player layout. + // If the new UI shows up for some users, then change this to an older version (such as 17.29.34). + return "17.30.34"; + } + return version; + } +} diff --git a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java index e9ae1f98..89e2463c 100644 --- a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java +++ b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java @@ -254,9 +254,11 @@ public class ReturnYouTubeDislike { } replacementSpannable = newSpannableWithDislikes(oldSpannable, voteData); } else { - String leftSegmentedSeparatorString = ReVancedUtils.isRightToLeftTextLayout() ? "\u200F| " : "| "; + final boolean useCompactLayout = SettingsEnum.RYD_USE_COMPACT_LAYOUT.getBoolean(); + // if compact layout, use a "half space" character + String middleSegmentedSeparatorString = useCompactLayout ? "\u2009 • \u2009" : " • "; - if (oldLikesString.contains(leftSegmentedSeparatorString)) { + if (oldLikesString.contains(middleSegmentedSeparatorString)) { return false; // dislikes was previously added } @@ -287,14 +289,11 @@ public class ReturnYouTubeDislike { } else { Spannable likesSpan = newSpanUsingStylingOfAnotherSpan(oldSpannable, oldLikesString); - // left and middle separator - String middleSegmentedSeparatorString = " • "; - Spannable leftSeparatorSpan = newSpanUsingStylingOfAnotherSpan(oldSpannable, leftSegmentedSeparatorString); + // middle separator Spannable middleSeparatorSpan = newSpanUsingStylingOfAnotherSpan(oldSpannable, middleSegmentedSeparatorString); final int separatorColor = ThemeHelper.isDarkTheme() - ? 0x37A0A0A0 // transparent dark gray + ? 0x29AAAAAA // transparent dark gray : 0xFFD9D9D9; // light gray - addSpanStyling(leftSeparatorSpan, new ForegroundColorSpan(separatorColor)); addSpanStyling(middleSeparatorSpan, new ForegroundColorSpan(separatorColor)); CharacterStyle noAntiAliasingStyle = new CharacterStyle() { @Override @@ -302,43 +301,49 @@ public class ReturnYouTubeDislike { tp.setAntiAlias(false); // draw without anti-aliasing, to give a sharper edge } }; - addSpanStyling(leftSeparatorSpan, noAntiAliasingStyle); addSpanStyling(middleSeparatorSpan, noAntiAliasingStyle); Spannable dislikeSpan = newSpannableWithDislikes(oldSpannable, voteData); - // Increase the size of the left separator, so it better matches the stock separator on the right. - // But when using a larger font, the entire span (including the like/dislike text) becomes shifted downward. - // To correct this, use additional spans to move the alignment back upward by a relative amount. - setSegmentedAdjustmentValues(); - class RelativeVerticalOffsetSpan extends CharacterStyle { - final float relativeVerticalShiftRatio; - - RelativeVerticalOffsetSpan(float relativeVerticalShiftRatio) { - this.relativeVerticalShiftRatio = relativeVerticalShiftRatio; - } - - @Override - public void updateDrawState(TextPaint tp) { - tp.baselineShift -= (int) (relativeVerticalShiftRatio * tp.getFontMetrics().top); - } - } - // shift everything up, to compensate for the vertical movement caused by the font change below - // each section needs it's own Relative span, otherwise alignment is wrong - addSpanStyling(leftSeparatorSpan, new RelativeVerticalOffsetSpan(segmentedLeftSeparatorVerticalShiftRatio)); - - addSpanStyling(likesSpan, new RelativeVerticalOffsetSpan(segmentedVerticalShiftRatio)); - addSpanStyling(middleSeparatorSpan, new RelativeVerticalOffsetSpan(segmentedVerticalShiftRatio)); - addSpanStyling(dislikeSpan, new RelativeVerticalOffsetSpan(segmentedVerticalShiftRatio)); - - // important: must add size scaling after vertical offset (otherwise alignment gets off) - addSpanStyling(leftSeparatorSpan, new RelativeSizeSpan(segmentedLeftSeparatorFontRatio)); - addSpanStyling(leftSeparatorSpan, new ScaleXSpan(segmentedLeftSeparatorHorizontalScaleRatio)); - // middle separator does not need resizing - - // put everything together SpannableStringBuilder builder = new SpannableStringBuilder(); - builder.append(leftSeparatorSpan); + + if (!useCompactLayout) { + String leftSegmentedSeparatorString = ReVancedUtils.isRightToLeftTextLayout() ? "\u200F| " : "| "; + Spannable leftSeparatorSpan = newSpanUsingStylingOfAnotherSpan(oldSpannable, leftSegmentedSeparatorString); + addSpanStyling(leftSeparatorSpan, new ForegroundColorSpan(separatorColor)); + addSpanStyling(leftSeparatorSpan, noAntiAliasingStyle); + + // Use a left separator with a larger font and visually match the stock right separator. + // But with a larger font, the entire span (including the like/dislike text) becomes shifted downward. + // To correct this, use additional spans to move the alignment back upward by a relative amount. + setSegmentedAdjustmentValues(); + class RelativeVerticalOffsetSpan extends CharacterStyle { + final float relativeVerticalShiftRatio; + + RelativeVerticalOffsetSpan(float relativeVerticalShiftRatio) { + this.relativeVerticalShiftRatio = relativeVerticalShiftRatio; + } + + @Override + public void updateDrawState(TextPaint tp) { + tp.baselineShift -= (int) (relativeVerticalShiftRatio * tp.getFontMetrics().top); + } + } + // each section needs it's own Relative span, otherwise alignment is wrong + addSpanStyling(leftSeparatorSpan, new RelativeVerticalOffsetSpan(segmentedLeftSeparatorVerticalShiftRatio)); + + addSpanStyling(likesSpan, new RelativeVerticalOffsetSpan(segmentedVerticalShiftRatio)); + addSpanStyling(middleSeparatorSpan, new RelativeVerticalOffsetSpan(segmentedVerticalShiftRatio)); + addSpanStyling(dislikeSpan, new RelativeVerticalOffsetSpan(segmentedVerticalShiftRatio)); + + // important: must add size scaling after vertical offset (otherwise alignment gets off) + addSpanStyling(leftSeparatorSpan, new RelativeSizeSpan(segmentedLeftSeparatorFontRatio)); + addSpanStyling(leftSeparatorSpan, new ScaleXSpan(segmentedLeftSeparatorHorizontalScaleRatio)); + // middle separator does not need resizing + + builder.append(leftSeparatorSpan); + } + builder.append(likesSpan); builder.append(middleSeparatorSpan); builder.append(dislikeSpan); @@ -369,9 +374,9 @@ public class ReturnYouTubeDislike { LogHelper.printDebug(() -> "Device manufacturer: '" + deviceManufacturer + "' SDK: " + deviceSdkVersion); // - // IMPORTANT: configurations must be with the default system font size setting. + // Important: configurations must be with the device default system font, and default font size. // - // In generally, a single configuration will give perfect layout for all devices of the same manufacturer + // In general, a single configuration will give perfect layout for all devices of the same manufacturer. final String configManufacturer; final int configSdk; switch (deviceManufacturer) { @@ -394,7 +399,7 @@ public class ReturnYouTubeDislike { segmentedLeftSeparatorHorizontalScaleRatio = 0.7f; break; case "OnePlus": - configManufacturer = "oneplus"; + configManufacturer = "OnePlus"; configSdk = 33; // tested on OnePlus 8 Pro segmentedLeftSeparatorVerticalShiftRatio = -0.075f; @@ -402,7 +407,6 @@ public class ReturnYouTubeDislike { segmentedLeftSeparatorFontRatio = 1.87f; segmentedLeftSeparatorHorizontalScaleRatio = 0.50f; break; - } LogHelper.printDebug(() -> "Using layout adjustments based on manufacturer: '" + configManufacturer + "' SDK: " + configSdk); diff --git a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java index 575eda70..8d376386 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -1,7 +1,6 @@ package app.revanced.integrations.settings; import android.content.Context; -import android.util.Log; import java.util.ArrayList; import java.util.List; @@ -68,6 +67,7 @@ public enum SettingsEnum { DISABLE_STARTUP_SHORTS_PLAYER("revanced_startup_shorts_player_enabled", false, ReturnType.BOOLEAN), PLAYER_POPUP_PANELS("revanced_player_popup_panels_enabled", false, ReturnType.BOOLEAN), USE_TABLET_MINIPLAYER("revanced_tablet_miniplayer", false, ReturnType.BOOLEAN, true), + SPOOF_APP_VERSION("revanced_spoof_app_version", false, ReturnType.BOOLEAN, true), WIDE_SEARCHBAR("revanced_wide_searchbar", false, ReturnType.BOOLEAN, true), HIDE_ALBUM_CARDS("revanced_hide_album_cards", false, ReturnType.BOOLEAN, true), HIDE_ARTIST_CARD("revanced_hide_artist_card", false, ReturnType.BOOLEAN), @@ -126,6 +126,7 @@ public enum SettingsEnum { RYD_USER_ID("ryd_userId", null, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.STRING), RYD_ENABLED("ryd_enabled", true, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.BOOLEAN), RYD_SHOW_DISLIKE_PERCENTAGE("ryd_show_dislike_percentage", false, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.BOOLEAN), + RYD_USE_COMPACT_LAYOUT("ryd_use_compact_layout", false, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.BOOLEAN), // SponsorBlock settings SB_ENABLED("sb-enabled", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN), diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/ReturnYouTubeDislikeSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/ReturnYouTubeDislikeSettingsFragment.java index 1211a678..d1bc4d26 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/ReturnYouTubeDislikeSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/ReturnYouTubeDislikeSettingsFragment.java @@ -29,18 +29,27 @@ public class ReturnYouTubeDislikeSettingsFragment extends PreferenceFragment { */ private SwitchPreference percentagePreference; + /** + * If segmented like/dislike button uses smaller compact layout + */ + private SwitchPreference compactLayoutPreference; + private void updateUIState() { final boolean rydIsEnabled = SettingsEnum.RYD_ENABLED.getBoolean(); - final boolean dislikePercentageEnabled = SettingsEnum.RYD_SHOW_DISLIKE_PERCENTAGE.getBoolean(); enabledPreference.setSummary(rydIsEnabled ? str("revanced_ryd_enable_summary_on") : str("revanced_ryd_enable_summary_off")); - percentagePreference.setSummary(dislikePercentageEnabled + percentagePreference.setSummary(SettingsEnum.RYD_SHOW_DISLIKE_PERCENTAGE.getBoolean() ? str("revanced_ryd_dislike_percentage_summary_on") : str("revanced_ryd_dislike_percentage_summary_off")); percentagePreference.setEnabled(rydIsEnabled); + + compactLayoutPreference.setSummary(SettingsEnum.RYD_USE_COMPACT_LAYOUT.getBoolean() + ? str("revanced_ryd_compact_layout_summary_on") + : str("revanced_ryd_compact_layout_summary_off")); + compactLayoutPreference.setEnabled(rydIsEnabled); } @Override @@ -80,6 +89,19 @@ public class ReturnYouTubeDislikeSettingsFragment extends PreferenceFragment { }); preferenceScreen.addPreference(percentagePreference); + compactLayoutPreference = new SwitchPreference(context); + compactLayoutPreference.setKey(SettingsEnum.RYD_USE_COMPACT_LAYOUT.getPath()); + compactLayoutPreference.setDefaultValue(SettingsEnum.RYD_USE_COMPACT_LAYOUT.getDefaultValue()); + compactLayoutPreference.setChecked(SettingsEnum.RYD_USE_COMPACT_LAYOUT.getBoolean()); + compactLayoutPreference.setTitle(str("revanced_ryd_compact_layout_title")); + compactLayoutPreference.setOnPreferenceChangeListener((pref, newValue) -> { + SettingsEnum.RYD_USE_COMPACT_LAYOUT.saveValue((Boolean)newValue); + + updateUIState(); + return true; + }); + preferenceScreen.addPreference(compactLayoutPreference); + updateUIState(); diff --git a/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java b/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java index f95a2c81..ee083a51 100644 --- a/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java +++ b/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java @@ -133,12 +133,15 @@ public class ReVancedUtils { return context.getResources().getConfiguration().smallestScreenWidthDp >= 600; } - private static final boolean isRightToLeftTextLayout = - new Bidi(Locale.getDefault().getDisplayLanguage(), Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT).isRightToLeft(); + private static Boolean isRightToLeftTextLayout; /** * If the device language uses right to left text layout (hebrew, arabic, etc) */ public static boolean isRightToLeftTextLayout() { + if (isRightToLeftTextLayout == null) { + String displayLanguage = Locale.getDefault().getDisplayLanguage(); + isRightToLeftTextLayout = new Bidi(displayLanguage, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT).isRightToLeft(); + } return isRightToLeftTextLayout; } diff --git a/gradle.properties b/gradle.properties index 17d9d793..0ae4524b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.jvmargs = -Xmx2048m android.useAndroidX = true -version = 0.92.2 +version = 0.93.0-dev.1