Compare commits

...

9 Commits

Author SHA1 Message Date
semantic-release-bot
6e75ffd5f1 chore: Release v5.0.0-dev.4 [skip ci]
# [5.0.0-dev.4](https://github.com/ReVanced/revanced-patches/compare/v5.0.0-dev.3...v5.0.0-dev.4) (2024-11-09)

### Bug Fixes

* **YouTube - Remember video quality:** Correctly set default quality when changing from a low quality video ([#3879](https://github.com/ReVanced/revanced-patches/issues/3879)) ([75d661f](75d661fcdc))
2024-11-09 18:56:29 +00:00
LisoUseInAIKyrios
75d661fcdc fix(YouTube - Remember video quality): Correctly set default quality when changing from a low quality video (#3879) 2024-11-09 22:53:01 +04:00
semantic-release-bot
4d1de6bc50 chore: Release v5.0.0-dev.3 [skip ci]
# [5.0.0-dev.3](https://github.com/ReVanced/revanced-patches/compare/v5.0.0-dev.2...v5.0.0-dev.3) (2024-11-09)

### Bug Fixes

* Add missing dependency to patch ([327ebd3](327ebd3649))
2024-11-09 04:20:45 +00:00
oSumAtrIX
327ebd3649 fix: Add missing dependency to patch 2024-11-09 05:17:06 +01:00
LisoUseInAIKyrios
34e98a54e0 chore(YouTube - Announcements): Remove language parameter of API call (#3874) 2024-11-08 22:11:31 -04:00
semantic-release-bot
bc3c61a6a0 chore: Release v5.0.0-dev.2 [skip ci]
# [5.0.0-dev.2](https://github.com/ReVanced/revanced-patches/compare/v5.0.0-dev.1...v5.0.0-dev.2) (2024-11-09)

### Bug Fixes

* **YouTube - Return YouTube Dislike:** Show Shorts dislikes with new A/B button icons ([a0c227f](a0c227f1a0))
2024-11-09 01:21:00 +00:00
LisoUseInAIKyrios
a0c227f1a0 fix(YouTube - Return YouTube Dislike): Show Shorts dislikes with new A/B button icons 2024-11-08 21:17:02 -04:00
LisoUseInAIKyrios
87fcf3135d refactor(YouTube - Theme): Cleanup 2024-11-07 08:27:20 -04:00
LisoUseInAIKyrios
4b4670cd4f refactor(YouTube - Theme): Use more robust gradient theme insert index 2024-11-07 08:20:39 -04:00
11 changed files with 86 additions and 70 deletions

View File

@@ -1,3 +1,24 @@
# [5.0.0-dev.4](https://github.com/ReVanced/revanced-patches/compare/v5.0.0-dev.3...v5.0.0-dev.4) (2024-11-09)
### Bug Fixes
* **YouTube - Remember video quality:** Correctly set default quality when changing from a low quality video ([#3879](https://github.com/ReVanced/revanced-patches/issues/3879)) ([ddb73e8](https://github.com/ReVanced/revanced-patches/commit/ddb73e857d7c26fd27ea995a27f53f5660d3f71c))
# [5.0.0-dev.3](https://github.com/ReVanced/revanced-patches/compare/v5.0.0-dev.2...v5.0.0-dev.3) (2024-11-09)
### Bug Fixes
* Add missing dependency to patch ([97f5240](https://github.com/ReVanced/revanced-patches/commit/97f5240d53b9978fb3745170fe03619c7c90274a))
# [5.0.0-dev.2](https://github.com/ReVanced/revanced-patches/compare/v5.0.0-dev.1...v5.0.0-dev.2) (2024-11-09)
### Bug Fixes
* **YouTube - Return YouTube Dislike:** Show Shorts dislikes with new A/B button icons ([084e0a5](https://github.com/ReVanced/revanced-patches/commit/084e0a527b1c75d1ef15dc706c429aa48d0ffe6b))
# [5.0.0-dev.1](https://github.com/ReVanced/revanced-patches/compare/v4.18.0-dev.6...v5.0.0-dev.1) (2024-11-06)

View File

@@ -15,13 +15,10 @@ import android.widget.TextView;
import androidx.annotation.RequiresApi;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.time.LocalDateTime;
import java.util.Locale;
import java.util.logging.Level;
import app.revanced.extension.shared.Logger;
import app.revanced.extension.shared.Utils;
@@ -84,8 +81,8 @@ public final class AnnouncementsPatch {
try {
if (isLatestAlready()) return;
HttpURLConnection connection = AnnouncementsRoutes.getAnnouncementsConnectionFromRoute(
GET_LATEST_ANNOUNCEMENTS, Locale.getDefault().toLanguageTag());
HttpURLConnection connection = AnnouncementsRoutes
.getAnnouncementsConnectionFromRoute(GET_LATEST_ANNOUNCEMENTS);
Logger.printDebug(() -> "Get latest announcements route connection url: " + connection.getURL());
@@ -98,11 +95,11 @@ public final class AnnouncementsPatch {
LocalDateTime archivedAt = LocalDateTime.MAX;
Level level = Level.INFO;
try {
final var announcement = new JSONObject(jsonString);
final var announcement = new JSONArray(jsonString).getJSONObject(0);
id = announcement.getInt("id");
title = announcement.getString("title");
message = announcement.getJSONObject("content").getString("message");
message = announcement.getString("content");
if (!announcement.isNull("archived_at")) {
archivedAt = LocalDateTime.parse(announcement.getString("archived_at"));
}

View File

@@ -9,9 +9,9 @@ import java.net.HttpURLConnection;
import static app.revanced.extension.youtube.requests.Route.Method.GET;
public class AnnouncementsRoutes {
public static final Route GET_LATEST_ANNOUNCEMENTS = new Route(GET, "/announcements/latest?tag=youtube");
public static final Route GET_LATEST_ANNOUNCEMENT_IDS = new Route(GET, "/announcements/latest/id?tag=youtube");
private static final String ANNOUNCEMENTS_PROVIDER = "https://api.revanced.app/v4";
public static final Route GET_LATEST_ANNOUNCEMENT_IDS = new Route(GET, "/announcements/latest/id?tag=youtube");
public static final Route GET_LATEST_ANNOUNCEMENTS = new Route(GET, "/announcements/latest?tag=youtube");
private AnnouncementsRoutes() {
}

View File

@@ -76,15 +76,10 @@ public final class ReturnYouTubeDislikeFilterPatch extends Filter {
new StringFilterGroup(null, "|shorts_dislike_button.eml")
);
// After the likes icon name is some binary data and then the video id for that specific short.
// After the button identifiers is binary data and then the video id for that specific short.
videoIdFilterGroup.addAll(
// on_shadowed = Video was previously like/disliked before opening.
// off_shadowed = Video was not previously liked/disliked before opening.
new ByteArrayFilterGroup(null, "ic_right_like_on_shadowed"),
new ByteArrayFilterGroup(null, "ic_right_like_off_shadowed"),
new ByteArrayFilterGroup(null, "ic_right_dislike_on_shadowed"),
new ByteArrayFilterGroup(null, "ic_right_dislike_off_shadowed")
new ByteArrayFilterGroup(null, "id.reel_like_button"),
new ByteArrayFilterGroup(null, "id.reel_dislike_button")
);
}

View File

@@ -416,7 +416,6 @@ public final class ShortsFilter extends Filter {
// endregion
public static void setNavigationBar(PivotBar view) {
Logger.printDebug(() -> "Setting navigation bar");
pivotBarRef = new WeakReference<>(view);
}

View File

@@ -62,19 +62,12 @@ public class RememberVideoQualityPatch {
*/
public static int setVideoQuality(Object[] qualities, final int originalQualityIndex, Object qInterface, String qIndexMethod) {
try {
if (!(qualityNeedsUpdating || userChangedDefaultQuality) || qInterface == null) {
return originalQualityIndex;
}
qualityNeedsUpdating = false;
final int preferredQuality = Utils.getNetworkType() == NetworkType.MOBILE
? mobileQualitySetting.get()
: wifiQualitySetting.get();
final int preferredQuality;
if (Utils.getNetworkType() == NetworkType.MOBILE) {
preferredQuality = mobileQualitySetting.get();
} else {
preferredQuality = wifiQualitySetting.get();
}
if (!userChangedDefaultQuality && preferredQuality == AUTOMATIC_VIDEO_QUALITY_VALUE) {
return originalQualityIndex; // nothing to do
return originalQualityIndex; // Nothing to do.
}
if (videoQualities == null || videoQualities.size() != qualities.length) {
@@ -87,7 +80,11 @@ public class RememberVideoQualityPatch {
}
}
}
Logger.printDebug(() -> "videoQualities: " + videoQualities);
// After changing videos the qualities can initially be for the prior video.
// So if the qualities have changed an update is needed.
qualityNeedsUpdating = true;
Logger.printDebug(() -> "VideoQualities: " + videoQualities);
}
if (userChangedDefaultQuality) {
@@ -98,7 +95,12 @@ public class RememberVideoQualityPatch {
return userSelectedQualityIndex;
}
// find the highest quality that is equal to or less than the preferred
if (!qualityNeedsUpdating) {
return originalQualityIndex;
}
qualityNeedsUpdating = false;
// Find the highest quality that is equal to or less than the preferred.
int qualityToUse = videoQualities.get(0); // first element is automatic mode
int qualityIndexToUse = 0;
int i = 0;
@@ -112,20 +114,18 @@ public class RememberVideoQualityPatch {
// If the desired quality index is equal to the original index,
// then the video is already set to the desired default quality.
//
// The method could return here, but the UI video quality flyout will still
// show 'Auto' (ie: Auto (480p))
// It appears that "Auto" picks the resolution on video load,
// and it does not appear to change the resolution during playback.
//
// To prevent confusion, set the video index anyways (even if it matches the existing index)
// As that will force the UI picker to not display "Auto" which may confuse the user.
final int qualityToUseFinal = qualityToUse;
if (qualityIndexToUse == originalQualityIndex) {
Logger.printDebug(() -> "Video is already preferred quality: " + preferredQuality);
// On first load of a new video, if the UI video quality flyout menu
// is not updated then it will still show 'Auto' (ie: Auto (480p)),
// even though it's already set to the desired resolution.
//
// To prevent confusion, set the video index anyways (even if it matches the existing index)
// as that will force the UI picker to not display "Auto".
Logger.printDebug(() -> "Video is already preferred quality: " + qualityToUseFinal);
} else {
final int qualityToUseLog = qualityToUse;
Logger.printDebug(() -> "Quality changed from: "
+ videoQualities.get(originalQualityIndex) + " to: " + qualityToUseLog);
Logger.printDebug(() -> "Changing video quality from: "
+ videoQualities.get(originalQualityIndex) + " to: " + qualityToUseFinal);
}
Method m = qInterface.getClass().getMethod(qIndexMethod, Integer.TYPE);

View File

@@ -1,8 +1,8 @@
package app.revanced.extension.youtube.patches.theme;
import app.revanced.extension.youtube.settings.Settings;
import app.revanced.extension.shared.Utils;
import app.revanced.extension.youtube.ThemeHelper;
import app.revanced.extension.youtube.settings.Settings;
@SuppressWarnings("unused")
public class ThemePatch {
@@ -21,12 +21,15 @@ public class ThemePatch {
-98492127 // video chapters list background
};
// background colors
private static int whiteColor = 0;
private static int blackColor = 0;
// Background colors.
private static final int WHITE_COLOR = Utils.getResourceColor("yt_white1");
private static final int BLACK_COLOR = Utils.getResourceColor("yt_black1");
private static final boolean GRADIENT_LOADING_SCREEN_ENABLED = Settings.GRADIENT_LOADING_SCREEN.get();
// Used by app.revanced.patches.youtube.layout.theme.patch.LithoThemePatch
/**
* Injection point.
*
* Change the color of Litho components.
* If the color of the component matches one of the values, return the background color .
*
@@ -35,29 +38,24 @@ public class ThemePatch {
*/
public static int getValue(int originalValue) {
if (ThemeHelper.isDarkTheme()) {
if (anyEquals(originalValue, DARK_VALUES)) return getBlackColor();
if (anyEquals(originalValue, DARK_VALUES)) return BLACK_COLOR;
} else {
if (anyEquals(originalValue, WHITE_VALUES)) return getWhiteColor();
if (anyEquals(originalValue, WHITE_VALUES)) return WHITE_COLOR;
}
return originalValue;
}
public static boolean gradientLoadingScreenEnabled() {
return Settings.GRADIENT_LOADING_SCREEN.get();
}
private static int getBlackColor() {
if (blackColor == 0) blackColor = Utils.getResourceColor("yt_black1");
return blackColor;
}
private static int getWhiteColor() {
if (whiteColor == 0) whiteColor = Utils.getResourceColor("yt_white1");
return whiteColor;
}
private static boolean anyEquals(int value, int... of) {
for (int v : of) if (value == v) return true;
return false;
}
/**
* Injection point.
*/
public static boolean gradientLoadingScreenEnabled() {
return GRADIENT_LOADING_SCREEN_ENABLED;
}
}

View File

@@ -80,7 +80,7 @@ public class Settings extends BaseSettings {
// Uncategorized layout related settings. Do not add to this section, and instead move these out and categorize them.
public static final BooleanSetting DISABLE_SUGGESTED_VIDEO_END_SCREEN = new BooleanSetting("revanced_disable_suggested_video_end_screen", FALSE, true);
public static final BooleanSetting GRADIENT_LOADING_SCREEN = new BooleanSetting("revanced_gradient_loading_screen", FALSE);
public static final BooleanSetting GRADIENT_LOADING_SCREEN = new BooleanSetting("revanced_gradient_loading_screen", FALSE, true);
public static final BooleanSetting HIDE_HORIZONTAL_SHELVES = new BooleanSetting("revanced_hide_horizontal_shelves", TRUE);
public static final BooleanSetting HIDE_CAPTIONS_BUTTON = new BooleanSetting("revanced_hide_captions_button", FALSE);
public static final BooleanSetting HIDE_CHANNEL_BAR = new BooleanSetting("revanced_hide_channel_bar", FALSE);

View File

@@ -3,4 +3,4 @@ org.gradle.jvmargs = -Xms512M -Xmx2048M
org.gradle.parallel = true
android.useAndroidX = true
kotlin.code.style = official
version = 5.0.0-dev.1
version = 5.0.0-dev.4

View File

@@ -17,7 +17,9 @@ import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.util.forEachChildElement
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.indexOfFirstLiteralInstructionOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import org.w3c.dom.Element
@@ -210,18 +212,19 @@ val themePatch = bytecodePatch(
)
useGradientLoadingScreenFingerprint.method.apply {
val isEnabledIndex = indexOfFirstLiteralInstructionOrThrow(GRADIENT_LOADING_SCREEN_AB_CONSTANT) + 3
val isEnabledRegister = getInstruction<OneRegisterInstruction>(isEnabledIndex - 1).registerA
val literalIndex = indexOfFirstLiteralInstructionOrThrow(GRADIENT_LOADING_SCREEN_AB_CONSTANT)
val isEnabledIndex = indexOfFirstInstructionOrThrow(literalIndex, Opcode.MOVE_RESULT)
val isEnabledRegister = getInstruction<OneRegisterInstruction>(isEnabledIndex).registerA
addInstructions(
isEnabledIndex,
isEnabledIndex + 1,
"""
invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->gradientLoadingScreenEnabled()Z
move-result v$isEnabledRegister
""",
)
}
mapOf(
themeHelperLightColorFingerprint to lightThemeBackgroundColor,
themeHelperDarkColorFingerprint to darkThemeBackgroundColor,

View File

@@ -3,6 +3,7 @@ package app.revanced.patches.youtube.misc.dns
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.youtube.shared.mainActivityOnCreateFingerprint
private const val EXTENSION_CLASS_DESCRIPTOR =
@@ -13,6 +14,8 @@ val checkWatchHistoryDomainNameResolutionPatch = bytecodePatch(
name = "Check watch history domain name resolution",
description = "Checks if the device DNS server is preventing user watch history from being saved.",
) {
dependsOn(addResourcesPatch)
compatibleWith(
"com.google.android.youtube"(
"18.38.44",