Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'dev' into fix/yt-spoof-stream
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Sep 17, 2024
2 parents 390b6fc + ca50665 commit 502d29f
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 20 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
# [1.14.0-dev.11](https://github.com/ReVanced/revanced-integrations/compare/v1.14.0-dev.10...v1.14.0-dev.11) (2024-09-17)


### Features

* **YouTube - Hide Shorts components:** Hide 'Use this sound' button ([#691](https://github.com/ReVanced/revanced-integrations/issues/691)) ([6f3d2ff](https://github.com/ReVanced/revanced-integrations/commit/6f3d2ffb0d65ec819038050dfabe1432f87ce360))

# [1.14.0-dev.10](https://github.com/ReVanced/revanced-integrations/compare/v1.14.0-dev.9...v1.14.0-dev.10) (2024-09-11)


### Bug Fixes

* **YouTube - Return YouTube Dislike:** Show correct value when swiping back to prior Short and disliking ([2eb5e3a](https://github.com/ReVanced/revanced-integrations/commit/2eb5e3afebe374a86e9da521d6441402130f0fd0))

# [1.14.0-dev.9](https://github.com/ReVanced/revanced-integrations/compare/v1.14.0-dev.8...v1.14.0-dev.9) (2024-09-09)


### Bug Fixes

* **YouTube - SponsorBlock:** Add summary text to 'view my segments' button ([0f5dfb4](https://github.com/ReVanced/revanced-integrations/commit/0f5dfb4e76337da7e086a08b59aed7881de56a31))


### Features

* **YouTube:** Add donation link to settings about screen ([#688](https://github.com/ReVanced/revanced-integrations/issues/688)) ([b816c45](https://github.com/ReVanced/revanced-integrations/commit/b816c45838769c6b3df7147d091696cb3ee9789e))

# [1.14.0-dev.8](https://github.com/ReVanced/revanced-integrations/compare/v1.14.0-dev.7...v1.14.0-dev.8) (2024-09-06)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package app.revanced.integrations.shared.settings.preference;

import static app.revanced.integrations.shared.StringRef.sf;
import static app.revanced.integrations.shared.StringRef.str;
import static app.revanced.integrations.youtube.requests.Route.Method.GET;

Expand Down Expand Up @@ -71,7 +72,7 @@ protected int getDarkColor() {
return Color.BLACK;
}

private String createDialogHtml(ReVancedSocialLink[] socialLinks) {
private String createDialogHtml(WebLink[] socialLinks) {
final boolean isNetworkConnected = Utils.isNetworkConnected();

StringBuilder builder = new StringBuilder();
Expand Down Expand Up @@ -122,7 +123,7 @@ private String createDialogHtml(ReVancedSocialLink[] socialLinks) {
.append("</h2>");

builder.append("<div>");
for (ReVancedSocialLink social : socialLinks) {
for (WebLink social : socialLinks) {
builder.append("<div style=\"margin-bottom: 20px;\">");
builder.append(String.format("<a href=\"%s\">%s</a>", social.url, social.name));
builder.append("</div>");
Expand Down Expand Up @@ -151,7 +152,7 @@ private String createDialogHtml(ReVancedSocialLink[] socialLinks) {
}

private void fetchLinksAndShowDialog(@Nullable ProgressDialog progress) {
ReVancedSocialLink[] socialLinks = SocialLinksRoutes.fetchSocialLinks();
WebLink[] socialLinks = SocialLinksRoutes.fetchSocialLinks();
String htmlDialog = createDialogHtml(socialLinks);

Utils.runOnMainThreadNowOrLater(() -> {
Expand Down Expand Up @@ -221,19 +222,19 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
}
}

class ReVancedSocialLink {
class WebLink {
final boolean preferred;
final String name;
final String url;

ReVancedSocialLink(JSONObject json) throws JSONException {
WebLink(JSONObject json) throws JSONException {
this(json.getBoolean("preferred"),
json.getString("name"),
json.getString("url")
);
}

ReVancedSocialLink(boolean preferred, String name, String url) {
WebLink(boolean preferred, String name, String url) {
this.preferred = preferred;
this.name = name;
this.url = url;
Expand All @@ -251,24 +252,33 @@ public String toString() {
}

class SocialLinksRoutes {
/**
* Simple link to the website donate page,
* rather than fetching and parsing the donation links using the API.
*/
public static final WebLink DONATE_LINK = new WebLink(true,
sf("revanced_settings_about_links_donate").toString(),
"https://revanced.app/donate");

/**
* Links to use if fetch links api call fails.
*/
private static final ReVancedSocialLink[] NO_CONNECTION_STATIC_LINKS = {
new ReVancedSocialLink(true, "ReVanced.app", "https://revanced.app")
private static final WebLink[] NO_CONNECTION_STATIC_LINKS = {
new WebLink(true, "ReVanced.app", "https://revanced.app"),
DONATE_LINK,
};

private static final String SOCIAL_LINKS_PROVIDER = "https://api.revanced.app/v2";
private static final Route.CompiledRoute GET_SOCIAL = new Route(GET, "/socials").compile();

@Nullable
private static volatile ReVancedSocialLink[] fetchedLinks;
private static volatile WebLink[] fetchedLinks;

static boolean hasFetchedLinks() {
return fetchedLinks != null;
}

static ReVancedSocialLink[] fetchSocialLinks() {
static WebLink[] fetchSocialLinks() {
try {
if (hasFetchedLinks()) return fetchedLinks;

Expand All @@ -290,14 +300,17 @@ static ReVancedSocialLink[] fetchSocialLinks() {
JSONObject json = Requester.parseJSONObjectAndDisconnect(connection);
JSONArray socials = json.getJSONArray("socials");

List<ReVancedSocialLink> links = new ArrayList<>();
List<WebLink> links = new ArrayList<>();

links.add(DONATE_LINK); // Show donate link first.
for (int i = 0, length = socials.length(); i < length; i++) {
ReVancedSocialLink link = new ReVancedSocialLink(socials.getJSONObject(i));
WebLink link = new WebLink(socials.getJSONObject(i));
links.add(link);
}

Logger.printDebug(() -> "links: " + links);

return fetchedLinks = links.toArray(new ReVancedSocialLink[0]);
return fetchedLinks = links.toArray(new WebLink[0]);

} catch (SocketTimeoutException ex) {
Logger.printInfo(() -> "Could not fetch social links", ex); // No toast.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ public static void setLastLithoShortsVideoId(@Nullable String videoId) {
if (videoIdIsSame(lastLithoShortsVideoData, videoId)) {
return;
}

if (videoId == null) {
// Litho filter did not detect the video id. App is in incognito mode,
// or the proto buffer structure was changed and the video id is no longer present.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,23 @@ public static void newPlayerResponseVideoId(String videoId, boolean isShortAndOp
private final ByteArrayFilterGroupList videoIdFilterGroup = new ByteArrayFilterGroupList();

public ReturnYouTubeDislikeFilterPatch() {
// Likes always seems to load before the dislikes, but if this
// ever changes then both likes and dislikes need callbacks.
// When a new Short is opened, the like buttons always seem to load before the dislike.
// But if swiping back to a previous video and liking/disliking, then only that single button reloads.
// So must check for both buttons.
addPathCallbacks(
new StringFilterGroup(null, "|shorts_like_button.eml")
new StringFilterGroup(null, "|shorts_like_button.eml"),
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.
videoIdFilterGroup.addAll(
// Video was previously liked before video was opened.
// 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"),
// Video was not already liked.
new ByteArrayFilterGroup(null, "ic_right_like_off_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")
);
}

Expand Down Expand Up @@ -111,6 +116,7 @@ private String findVideoId(byte[] protobufBufferArray) {
return videoId;
}
}

return null;
}
}
Expand All @@ -132,6 +138,7 @@ private static boolean byteArrayContainsString(@NonNull byte[] array, @NonNull S
return true;
}
}

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ public ShortsFilter() {
new ByteArrayFilterGroup(
Settings.HIDE_SHORTS_SUPER_THANKS_BUTTON,
"yt_outline_dollar_sign_heart_"
),
new ByteArrayFilterGroup(
Settings.HIDE_SHORTS_USE_THIS_SOUND_BUTTON,
"yt_outline_camera_"
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public class Settings extends BaseSettings {
public static final BooleanSetting HIDE_SHORTS_LOCATION_LABEL = new BooleanSetting("revanced_hide_shorts_location_label", FALSE);
// Save sound to playlist and Search suggestions may have been A/B tests that were abandoned by YT, and it's not clear if these are still used.
public static final BooleanSetting HIDE_SHORTS_SAVE_SOUND_BUTTON = new BooleanSetting("revanced_hide_shorts_save_sound_button", FALSE);
public static final BooleanSetting HIDE_SHORTS_USE_THIS_SOUND_BUTTON = new BooleanSetting("revanced_hide_shorts_use_this_sound_button", TRUE);
public static final BooleanSetting HIDE_SHORTS_SEARCH_SUGGESTIONS = new BooleanSetting("revanced_hide_shorts_search_suggestions", FALSE);
public static final BooleanSetting HIDE_SHORTS_SUPER_THANKS_BUTTON = new BooleanSetting("revanced_hide_shorts_super_thanks_button", TRUE);
public static final BooleanSetting HIDE_SHORTS_LIKE_BUTTON = new BooleanSetting("revanced_hide_shorts_like_button", FALSE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ private void addUserStats(@NonNull Preference loadingPlaceholder, @Nullable User
statsCategory.addPreference(preference);
String formatted = SponsorBlockUtils.getNumberOfSkipsString(stats.segmentCount);
preference.setTitle(fromHtml(str("revanced_sb_stats_submissions", formatted)));
preference.setSummary(str("revanced_sb_stats_submissions_sum"));
if (stats.totalSegmentCountIncludingIgnored == 0) {
preference.setSelectable(false);
} else {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.parallel = true
org.gradle.caching = true
android.useAndroidX = true
version = 1.14.0-dev.8
version = 1.14.0-dev.11

0 comments on commit 502d29f

Please sign in to comment.