1
mirror of https://github.com/revanced/revanced-integrations synced 2025-11-21 18:35:37 +01:00

Compare commits

...

20 Commits

Author SHA1 Message Date
semantic-release-bot
0c325c093b chore(release): 0.19.1-dev.1 [skip ci]
## [0.19.1-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.19.0...v0.19.1-dev.1) (2022-07-02)

### Bug Fixes

* add missing dummy task `publish` ([3a2655b](3a2655b38b))
* prepare for hide-suggestions patch ([#35](https://github.com/revanced/revanced-integrations/issues/35)) ([b2d08e9](b2d08e9e9f))
2022-07-02 11:58:16 +00:00
oSumAtrIX
e1145a65e0 Merge branch 'main' into dev 2022-07-02 13:56:25 +02:00
oSumAtrIX
3a2655b38b fix: add missing dummy task publish 2022-07-02 13:40:06 +02:00
oSumAtrIX
7fe30d550e build: semantic-release (#38) 2022-07-02 06:18:52 +02:00
Joey Peter
5f5b1cace9 refactor: remove no longer used feature. was added from youtube already (#36) 2022-07-02 00:42:22 +02:00
Joey Peter
b2d08e9e9f fix: prepare for hide-suggestions patch (#35) 2022-07-02 00:26:02 +02:00
Joey Peter
cfb4132ed1 refactor: rename XSwipe and XSettingsActivity (#33) 2022-06-30 13:54:00 +02:00
OxrxL
7a9c61b71b refactor: Strings
closes #29
2022-06-30 13:32:08 +02:00
Joey Peter
aecafc5380 refactor: dialogs and seperate RYD from SB (#31) 2022-06-30 12:38:28 +02:00
OxrxL
d9268bc0fa refactor: use containsAny helper method (#27) 2022-06-27 23:12:28 +02:00
Joey Peter
9b1dce42ed fix: some more refactoring and cleanup (#21)
* refactor: integrations and prepare new patches

* bugfixes

* fix critical bug

* prepare BrandingWaterMark patch

* fixing create button

* dont use Strings in ReVancedSettingsFragment when we have a wonderful enum for that

* rename classes from fenster to Swipe

* push

* exclude android packages from build
2022-06-27 22:08:50 +02:00
OxrxL
0938f6c59f fix: home ads (#24)
* Ads test

* refactor: cleanup code

Co-authored-by: Sculas <contact@sculas.xyz>
2022-06-27 22:08:24 +02:00
bogadana
a2bb4a5f03 refactor: move whole speeds array to new class (#22) 2022-06-25 15:15:59 +02:00
oSumAtrIX
773357d6e6 feat: workflow_dispatch 2022-06-24 00:55:50 +02:00
Joey Peter
d26b9339fb refactor: integrations (#17) 2022-06-24 00:16:32 +02:00
bogadana
61ed39722e feat: add array for custom-playback-speed patch (#20) 2022-06-23 01:54:37 +02:00
Robert
54baa3c2e5 Fix: ./gradlew: 23: cd: can't cd to "./ (#19) 2022-06-22 16:55:45 +02:00
Oskar
5dd10f6978 ci: chmod +x gradlew is not required (#15) 2022-06-21 15:08:19 +02:00
Canny1913
9bf804219e feat: hide cast button by default (#12) 2022-06-16 00:09:28 +02:00
oSumAtrIX
d7631f371b fix: info panel removal 2022-06-15 11:05:42 +02:00
141 changed files with 3590 additions and 5603 deletions

View File

@@ -1,12 +1,15 @@
name: Release
on:
workflow_dispatch:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
jobs:
build:
@@ -16,34 +19,22 @@ jobs:
uses: styfle/cancel-workflow-action@0.9.0
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Repo
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'zulu'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "lts/*"
- name: Build with Gradle
run: ./gradlew --no-daemon build
- name: Github Tag Bump
uses: anothrNick/github-tag-action@1.39.0
- name: Setup semantic-release
run: npm install -g semantic-release @semantic-release/git @semantic-release/changelog gradle-semantic-release-plugin -D
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
id: bump_version
- name: Upload APKs to Release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./app/build/outputs/apk/release/*.apk
tag: ${{ steps.bump_version.outputs.new_tag }}
token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
run: npx semantic-release

34
.releaserc Normal file
View File

@@ -0,0 +1,34 @@
{
"branches": [
"main",
{
"name": "dev",
"prerelease": true
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"gradle-semantic-release-plugin",
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md",
"gradle.properties"
]
}
],
[
"@semantic-release/github",
{
"assets": [
{
"path": "app/build/outputs/apk/release/*.apk"
}
]
}
]
]
}

7
CHANGELOG.md Normal file
View File

@@ -0,0 +1,7 @@
## [0.19.1-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.19.0...v0.19.1-dev.1) (2022-07-02)
### Bug Fixes
* add missing dummy task `publish` ([3a2655b](https://github.com/revanced/revanced-integrations/commit/3a2655b38b7e2994ece550ccefadbc70a31f7fa4))
* prepare for hide-suggestions patch ([#35](https://github.com/revanced/revanced-integrations/issues/35)) ([b2d08e9](https://github.com/revanced/revanced-integrations/commit/b2d08e9e9fbb1df69ceb5234d3f092027904c1e1))

View File

@@ -2,10 +2,10 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 32
namespace 'vanced.integrations'
namespace 'app.revanced.integrations'
defaultConfig {
applicationId "revanced.integrationsapp"
applicationId "app.revanced.integrations"
minSdkVersion 23
targetSdkVersion 32
versionCode 1
@@ -27,13 +27,13 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}
dependencies {
implementation 'androidx.annotation:annotation:1.3.0'
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
compileOnly 'androidx.annotation:annotation:1.4.0'
compileOnly 'androidx.constraintlayout:constraintlayout:2.1.4'
}

View File

@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
</manifest>

View File

@@ -1,16 +0,0 @@
package app.revanced.integrations;
import android.content.Context;
import android.util.Log;
public class Globals {
public static Context context;
public static Context getAppContext() {
if (context != null) {
return context;
}
Log.e("Globals", "Context is null!");
return null;
}
}

View File

@@ -0,0 +1,143 @@
package app.revanced.integrations.adremover;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toolbar;
import app.revanced.integrations.patches.HideShortsButtonPatch;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
/**
* API Class that provides the logic to the Patch classes. All methods in here should be protected/private and only be accessed from a Patch class.
*/
public class AdRemoverAPI {
/**
* Removes Reels and Home ads
*
* @param view
*/
public static void HideViewWithLayout1dp(View view) {
if (view instanceof LinearLayout) {
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(1, 1);
view.setLayoutParams(layoutParams);
} else if (view instanceof FrameLayout) {
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(1, 1);
view.setLayoutParams(layoutParams2);
} else if (view instanceof RelativeLayout) {
RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(1, 1);
view.setLayoutParams(layoutParams3);
} else if (view instanceof Toolbar) {
Toolbar.LayoutParams layoutParams4 = new Toolbar.LayoutParams(1, 1);
view.setLayoutParams(layoutParams4);
} else if (view instanceof ViewGroup) {
ViewGroup.LayoutParams layoutParams5 = new ViewGroup.LayoutParams(1, 1);
view.setLayoutParams(layoutParams5);
} else {
LogHelper.debug(AdRemoverAPI.class, "HideViewWithLayout1dp - Id: " + view.getId() + " Type: " + view.getClass().getName());
}
}
/**
* Removes the Create button
*
* @param view
*/
public static void hideCreateButton(View view) {
String message = SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Create button: Shown" : "Create button: Hidden";
LogHelper.debug(AdRemoverAPI.class, message);
if (SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
view.setVisibility(View.VISIBLE);
} else {
view.setVisibility(View.GONE);
}
}
/**
* Removes the shorts button
*
* @param view
*/
public static void hideShortsButton(View view) {
if (HideShortsButtonPatch.lastPivotTab != null && HideShortsButtonPatch.lastPivotTab.name() == "TAB_SHORTS") {
String message = SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Shorts button: shown" : "Shorts button: hidden";
LogHelper.debug(AdRemoverAPI.class, message);
if (!SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
view.setVisibility(View.GONE);
}
}
}
/*
private static void inspectComponentHost(Object item) {
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
if (stackTraceElements.length <= 3) {
LogHelper.debug("Litho", "Couldn't locate the method called from.");
} else {
String sb = "Called from method: " +
stackTraceElements[3].toString() + "\n";
LogHelper.debug("Litho", sb);
}
if (item == null) {
LogHelper.debug("Litho", "Item is null.");
} else if (item.getClass().getSimpleName().contains("cwl")) {
LogHelper.debug("Litho", "Item is a cwl item.");
LogHelper.debug("Litho", getViewHierarchy((ViewGroup) item));
} else {
LogHelper.debug("Litho", "Item is not a cwl item.");
}
}
private static String getViewHierarchy(ViewGroup v) {
StringBuffer buf = new StringBuffer();
printViews(v, buf, 0);
return buf.toString();
}
private static String printViews(ViewGroup v, StringBuffer buf, int level) {
int childCount = v.getChildCount();
v.getId();
indent(buf, level);
buf.append(v.getClass().getName());
buf.append(" children:");
buf.append(childCount);
buf.append(" id:").append(v.getId());
buf.append("\n");
for (int i = 0; i < childCount; i++) {
View child = v.getChildAt(i);
if (child instanceof ViewGroup) {
printViews((ViewGroup) child, buf, level + 1);
} else {
indent(buf, level + 1);
buf.append(child.getClass().getName());
buf.append(" id:").append(child.getId());
buf.append("\n");
}
}
return buf.toString();
}
private static void indent(StringBuffer buf, int level) {
for (int i = 0; i < level; i++) {
buf.append(" ");
}
}
private static void recursiveLoopChildren(ViewGroup parent) {
for (int i = 0; i < parent.getChildCount(); i++) {
View child = parent.getChildAt(i);
if (child instanceof ViewGroup) {
recursiveLoopChildren((ViewGroup) child);
child.setVisibility(View.GONE);
} else if (child != null) {
child.setVisibility(View.GONE);
}
}
}*/
}

View File

@@ -1,24 +1,24 @@
package fi.razerman.youtube.litho;
package app.revanced.integrations.adremover;
import android.os.Build;
import android.util.Log;
import androidx.annotation.RequiresApi;
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import fi.razerman.youtube.Helpers.SharedPrefs;
import fi.razerman.youtube.XGlobals;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.SharedPrefHelper;
public class LithoAdRemoval {
private static boolean getBoolean(String key, boolean _default) {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), key, _default);
return SharedPrefHelper.getBoolean(Objects.requireNonNull(ReVancedUtils.getContext()), SharedPrefHelper.SharedPrefNames.YOUTUBE, key, _default);
}
private static boolean isExperimentalInfoPanelRemoval() {
@@ -33,43 +33,43 @@ public class LithoAdRemoval {
return getBoolean("experimental_emergency_box", true);
}
public static boolean isExperimentalAdRemoval() {
private static boolean isExperimentalAdRemoval() {
return getBoolean("experimental_ad_removal", true);
}
public static boolean isExperimentalMerchandiseRemoval() {
private static boolean isExperimentalMerchandiseRemoval() {
return getBoolean("experimental_merchandise", true);
}
public static boolean isExperimentalCommunityPostRemoval() {
private static boolean isExperimentalCommunityPostRemoval() {
return getBoolean("experimental_community_posts", false);
}
public static boolean isExperimentalMovieRemoval() {
private static boolean isExperimentalMovieRemoval() {
return getBoolean("experimental_movie", true);
}
public static boolean isExperimentalCompactBannerRemoval() {
private static boolean isExperimentalCompactBannerRemoval() {
return getBoolean("experimental_compact_banner", false);
}
public static boolean isExperimentalPaidContentRemoval() {
private static boolean isExperimentalPaidContentRemoval() {
return getBoolean("experimental_paid_content", true);
}
public static boolean isExperimentalCommentsRemoval() {
private static boolean isExperimentalCommentsRemoval() {
return getBoolean("experimental_comments", false);
}
public static boolean isInFeedSurvey() {
private static boolean isInFeedSurvey() {
return getBoolean("experimental_in_feed_survey", false);
}
public static boolean isShortsShelf() {
private static boolean isShortsShelf() {
return getBoolean("experimental_shorts_shelf", true);
}
public static boolean isCommunityGuidelines() {
private static boolean isCommunityGuidelines() {
return getBoolean("experimental_community_guidelines", true);
}
@@ -112,22 +112,16 @@ public class LithoAdRemoval {
bufferBlockList.add("YouTube Movies");
}
if (
value.contains("related_video_with_context") &&
bufferBlockList
.stream()
.anyMatch(StandardCharsets.UTF_8.decode(buffer).toString()::contains)
if (containsAny(value, "home_video_with_context", "related_video_with_context") &&
bufferBlockList.stream().anyMatch(StandardCharsets.UTF_8.decode(buffer).toString()::contains)
) return true;
if (isExperimentalMerchandiseRemoval()) {
blockList.add("product_carousel");
}
if (isExperimentalCommunityPostRemoval()) {
blockList.add("post_base_wrapper");
}
if (isExperimentalPaidContentRemoval()) {
blockList.add("paid_content_overlay");
}
@@ -139,6 +133,7 @@ public class LithoAdRemoval {
}
if (isExperimentalInfoPanelRemoval()) {
blockList.add("single_item_information_panel");
blockList.add("publisher_transparency_panel");
}
if (isExperimentalCompactBannerRemoval()) {
blockList.add("compact_banner");
@@ -168,20 +163,20 @@ public class LithoAdRemoval {
)) return false;
if (blockList.stream().anyMatch(value::contains)) {
if (XGlobals.debug) Log.d("TemplateBlocked", value);
LogHelper.debug(LithoAdRemoval.class, value);
return true;
}
if (!XGlobals.debug) return false;
if (!SettingsEnum.DEBUG_BOOLEAN.getBoolean()) return false;
if (value.contains("related_video_with_context")) {
Log.d("Template", value + " | " + bytesToHex(buffer.array()));
LogHelper.debug(LithoAdRemoval.class, value + " | " + bytesToHex(buffer.array()));
return false;
}
Log.d("Template", value);
LogHelper.debug(LithoAdRemoval.class, value);
return false;
} catch (
Exception ex) {
Log.e("Template", ex.getMessage(), ex);
LogHelper.printException(LithoAdRemoval.class, ex.getMessage(), ex);
return false;
}

View File

@@ -1,18 +1,14 @@
package fi.vanced.libraries.youtube.whitelisting;
package app.revanced.integrations.adremover.whitelist;
import static fi.razerman.youtube.XGlobals.debug;
import static fi.vanced.libraries.youtube.player.VideoInformation.channelName;
import static fi.vanced.libraries.youtube.ui.SlimButtonContainer.adBlockButton;
import static fi.vanced.libraries.youtube.ui.SlimButtonContainer.sbWhitelistButton;
import static fi.vanced.utils.VancedUtils.getPreferences;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.sponsorblock.player.VideoInformation.channelName;
import static app.revanced.integrations.sponsorblock.player.ui.SlimButtonContainer.adBlockButton;
import static app.revanced.integrations.sponsorblock.player.ui.SlimButtonContainer.sbWhitelistButton;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import android.widget.Toast;
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import android.widget.Toast;
import java.io.IOException;
import java.util.ArrayList;
@@ -22,18 +18,21 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import fi.vanced.libraries.youtube.player.ChannelModel;
import fi.vanced.libraries.youtube.player.VideoInformation;
import fi.vanced.utils.ObjectSerializer;
import fi.vanced.utils.SharedPrefUtils;
import fi.vanced.utils.VancedUtils;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.player.ChannelModel;
import app.revanced.integrations.sponsorblock.player.VideoInformation;
import app.revanced.integrations.utils.ObjectSerializer;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.SharedPrefHelper;
public class Whitelist {
private static final String TAG = "VI - Whitelisting";
private static final Map<WhitelistType, ArrayList<ChannelModel>> whitelistMap = parseWhitelist(YouTubeTikTokRoot_Application.getAppContext());
private static final Map<WhitelistType, Boolean> enabledMap = parseEnabledMap(YouTubeTikTokRoot_Application.getAppContext());
private Whitelist() {}
private static final Map<WhitelistType, ArrayList<ChannelModel>> whitelistMap = parseWhitelist(ReVancedUtils.getContext());
private static final Map<WhitelistType, Boolean> enabledMap = parseEnabledMap(ReVancedUtils.getContext());
private Whitelist() {
}
// injected calls
@@ -42,9 +41,7 @@ public class Whitelist {
}
public static void setChannelName(String channelName) {
if (debug) {
Log.d(TAG, "channel name set to " + channelName);
}
LogHelper.debug(Whitelist.class, "channel name set to " + channelName);
VideoInformation.channelName = channelName;
if (enabledMap.get(WhitelistType.ADS) && adBlockButton != null) {
@@ -69,26 +66,23 @@ public class Whitelist {
Map<WhitelistType, ArrayList<ChannelModel>> whitelistMap = new EnumMap<>(WhitelistType.class);
for (WhitelistType whitelistType : whitelistTypes) {
SharedPreferences preferences = VancedUtils.getPreferences(context, whitelistType.getPreferencesName());
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, whitelistType.getPreferencesName());
String serializedChannels = preferences.getString("channels", null);
if (serializedChannels == null) {
if (debug) {
Log.d(TAG, String.format("channels string was null for %s whitelisting", whitelistType));
}
LogHelper.debug(Whitelist.class, String.format("channels string was null for %s whitelisting", whitelistType));
whitelistMap.put(whitelistType, new ArrayList<>());
continue;
}
try {
ArrayList<ChannelModel> deserializedChannels = (ArrayList<ChannelModel>) ObjectSerializer.deserialize(serializedChannels);
if (debug) {
Log.d(TAG, serializedChannels);
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
LogHelper.debug(Whitelist.class, serializedChannels);
for (ChannelModel channel : deserializedChannels) {
Log.d(TAG, String.format("Whitelisted channel %s (%s) for type %s", channel.getAuthor(), channel.getChannelId(), whitelistType));
LogHelper.debug(Whitelist.class, String.format("Whitelisted channel %s (%s) for type %s", channel.getAuthor(), channel.getChannelId(), whitelistType));
}
}
whitelistMap.put(whitelistType, deserializedChannels);
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
}
}
@@ -101,7 +95,7 @@ public class Whitelist {
}
Map<WhitelistType, Boolean> enabledMap = new EnumMap<>(WhitelistType.class);
for (WhitelistType whitelistType : WhitelistType.values()) {
enabledMap.put(whitelistType, SharedPrefUtils.getBoolean(context, whitelistType.getSharedPreferencesName(), whitelistType.getPreferenceEnabledName()));
enabledMap.put(whitelistType, SharedPrefHelper.getBoolean(context, whitelistType.getSharedPreferencesName(), whitelistType.getPreferenceEnabledName()));
}
return enabledMap;
}
@@ -112,17 +106,14 @@ public class Whitelist {
return false;
}
if (channelName == null || channelName.trim().isEmpty()) {
if (debug) {
Log.d(TAG, String.format("Can't check whitelist status for %s because channel name was missing", whitelistType));
}
LogHelper.debug(Whitelist.class, String.format("Can't check whitelist status for %s because channel name was missing", whitelistType));
return false;
}
List<ChannelModel> whitelistedChannels = whitelistMap.get(whitelistType);
for (ChannelModel channel : whitelistedChannels) {
if (channel.getAuthor().equals(channelName)) {
if (debug) {
Log.d(TAG, String.format("Whitelist for channel %s for type %s", channelName, whitelistType));
}
LogHelper.debug(Whitelist.class, String.format("Whitelist for channel %s for type %s", channelName, whitelistType));
return true;
}
}
@@ -134,10 +125,8 @@ public class Whitelist {
for (ChannelModel whitelistedChannel : whitelisted) {
String channelId = channel.getChannelId();
if (whitelistedChannel.getChannelId().equals(channelId)) {
if (debug) {
Log.d(TAG, String.format("Tried whitelisting an existing channel again. Old info (%1$s | %2$s) - New info (%3$s | %4$s)",
whitelistedChannel.getAuthor(), channelId, channelName, channelId));
}
LogHelper.debug(Whitelist.class, String.format("Tried whitelisting an existing channel again. Old info (%1$s | %2$s) - New info (%3$s | %4$s)",
whitelistedChannel.getAuthor(), channelId, channelName, channelId));
return true;
}
}
@@ -158,10 +147,9 @@ public class Whitelist {
boolean success = updateWhitelist(whitelistType, channels, context);
String friendlyName = whitelistType.getFriendlyName();
if (success) {
Toast.makeText(context, str("vanced_whitelisting_removed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(context, str("vanced_whitelisting_remove_failed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
Toast.makeText(context, str("revanced_whitelisting_removed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(context, str("revanced_whitelisting_remove_failed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
}
}
@@ -169,7 +157,7 @@ public class Whitelist {
if (context == null) {
return false;
}
SharedPreferences preferences = getPreferences(context, whitelistType.getPreferencesName());
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, whitelistType.getPreferencesName());
SharedPreferences.Editor editor = preferences.edit();
try {

View File

@@ -0,0 +1,38 @@
package app.revanced.integrations.adremover.whitelist;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import app.revanced.integrations.utils.SharedPrefHelper;
public enum WhitelistType {
ADS(SharedPrefHelper.SharedPrefNames.YOUTUBE, "revanced_whitelist_ads_enabled"),
SPONSORBLOCK(SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, "revanced_whitelist_sb_enabled");
private final String friendlyName;
private final String preferencesName;
private final String preferenceEnabledName;
private final SharedPrefHelper.SharedPrefNames name;
WhitelistType(SharedPrefHelper.SharedPrefNames name, String preferenceEnabledName) {
this.friendlyName = str("revanced_whitelisting_" + name().toLowerCase());
this.name = name;
this.preferencesName = "whitelist_" + name();
this.preferenceEnabledName = preferenceEnabledName;
}
public String getFriendlyName() {
return friendlyName;
}
public SharedPrefHelper.SharedPrefNames getSharedPreferencesName() {
return name;
}
public String getPreferencesName() {
return preferencesName;
}
public String getPreferenceEnabledName() {
return preferenceEnabledName;
}
}

View File

@@ -1,4 +1,4 @@
package fi.vanced.utils.requests;
package app.revanced.integrations.adremover.whitelist.requests;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -10,10 +10,9 @@ import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import fi.vanced.libraries.youtube.whitelisting.requests.WhitelistRoutes;
public class Requester {
private Requester() {}
private Requester() {
}
public static HttpURLConnection getConnectionFromRoute(String apiUrl, Route route, String... params) throws IOException {
String url = apiUrl + route.compile(params).getCompiledRoute();

View File

@@ -1,6 +1,4 @@
package fi.vanced.utils.requests;
import fi.vanced.utils.VancedUtils;
package app.revanced.integrations.adremover.whitelist.requests;
public class Route {
private final String route;
@@ -10,9 +8,9 @@ public class Route {
public Route(Route.Method method, String route) {
this.method = method;
this.route = route;
this.paramCount = VancedUtils.countMatches(route, '{');
this.paramCount = countMatches(route, '{');
if (paramCount != VancedUtils.countMatches(route, '}'))
if (paramCount != countMatches(route, '}'))
throw new IllegalArgumentException("Not enough parameters");
}
@@ -52,6 +50,15 @@ public class Route {
}
}
private int countMatches(CharSequence seq, char c) {
int count = 0;
for (int i = 0; i < seq.length(); i++) {
if (seq.charAt(i) == c)
count++;
}
return count;
}
public enum Method {
GET,
POST

View File

@@ -1,13 +1,13 @@
package fi.vanced.libraries.youtube.whitelisting.requests;
package app.revanced.integrations.adremover.whitelist.requests;
import static fi.razerman.youtube.XGlobals.debug;
import static fi.vanced.libraries.youtube.player.VideoInformation.currentVideoId;
import static fi.vanced.libraries.youtube.ui.AdButton.TAG;
import static fi.vanced.utils.VancedUtils.runOnMainThread;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.sponsorblock.player.VideoInformation.currentVideoId;
import static app.revanced.integrations.utils.ReVancedUtils.runOnMainThread;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import android.content.Context;
import android.util.Log;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
@@ -19,18 +19,17 @@ import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import fi.vanced.libraries.youtube.player.ChannelModel;
import fi.vanced.libraries.youtube.whitelisting.Whitelist;
import fi.vanced.libraries.youtube.whitelisting.WhitelistType;
import fi.vanced.utils.VancedUtils;
import fi.vanced.utils.requests.Requester;
import fi.vanced.utils.requests.Route;
import vanced.integrations.BuildConfig;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.player.ChannelModel;
import app.revanced.integrations.adremover.whitelist.Whitelist;
import app.revanced.integrations.adremover.whitelist.WhitelistType;
import app.revanced.integrations.BuildConfig;
public class WhitelistRequester {
private static final String YT_API_URL = "https://www.youtube.com/youtubei/v1/";
private WhitelistRequester() {}
private WhitelistRequester() {
}
public static void addChannelToWhitelist(WhitelistType whitelistType, View view, ImageView buttonIcon, Context context) {
try {
@@ -40,9 +39,9 @@ public class WhitelistRequester {
connection.setDoOutput(true);
connection.setConnectTimeout(2 * 1000);
String versionName = VancedUtils.getVersionName(context);
String versionName = getVersionName(context);
String jsonInputString = "{\"context\": {\"client\": { \"clientName\": \"Android\", \"clientVersion\": \"" + versionName + "\" } }, \"videoId\": \"" + currentVideoId + "\"}";
try(OutputStream os = connection.getOutputStream()) {
try (OutputStream os = connection.getOutputStream()) {
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
@@ -52,38 +51,31 @@ public class WhitelistRequester {
JSONObject videoInfo = json.getJSONObject("videoDetails");
ChannelModel channelModel = new ChannelModel(videoInfo.getString("author"), videoInfo.getString("channelId"));
String author = channelModel.getAuthor();
if (debug) {
Log.d(TAG, "channelId " + channelModel.getChannelId() + " fetched for author " + author);
}
LogHelper.debug(WhitelistRequester.class, "channelId " + channelModel.getChannelId() + " fetched for author " + author);
boolean success = Whitelist.addToWhitelist(whitelistType, context, channelModel);
String whitelistTypeName = whitelistType.getFriendlyName();
runOnMainThread(() -> {
if (success) {
buttonIcon.setEnabled(whitelistType != WhitelistType.SPONSORBLOCK);
Toast.makeText(context, str("vanced_whitelisting_added", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(context, str("revanced_whitelisting_added", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
} else {
buttonIcon.setEnabled(whitelistType == WhitelistType.SPONSORBLOCK);
Toast.makeText(context, str("vanced_whitelisting_add_failed", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
Toast.makeText(context, str("revanced_whitelisting_add_failed", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
}
view.setEnabled(true);
});
}
else {
if (debug) {
Log.d(TAG, "player fetch response was " + responseCode);
}
} else {
LogHelper.debug(WhitelistRequester.class, "player fetch response was " + responseCode);
runOnMainThread(() -> {
Toast.makeText(context, str("vanced_whitelisting_fetch_failed", responseCode), Toast.LENGTH_SHORT).show();
Toast.makeText(context, str("revanced_whitelisting_fetch_failed", responseCode), Toast.LENGTH_SHORT).show();
buttonIcon.setEnabled(true);
view.setEnabled(true);
});
}
connection.disconnect();
}
catch (Exception ex) {
Log.e(TAG, "Failed to fetch channelId", ex);
} catch (Exception ex) {
LogHelper.printException(WhitelistRequester.class, "Failed to fetch channelId", ex);
runOnMainThread(() -> view.setEnabled(true));
}
}
@@ -97,4 +89,15 @@ public class WhitelistRequester {
private static JSONObject getJSONObject(HttpURLConnection connection) throws Exception {
return Requester.getJSONObject(connection);
}
private static String getVersionName(Context context) {
try {
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
String version = pInfo.versionName;
return (version);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return ("17.24.34");
}
}

View File

@@ -0,0 +1,10 @@
package app.revanced.integrations.adremover.whitelist.requests;
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.POST;
public class WhitelistRoutes {
public static final Route GET_CHANNEL_DETAILS = new Route(POST, "player?key={api_key}");
private WhitelistRoutes() {
}
}

View File

@@ -0,0 +1,12 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class AutoRepeatPatch {
//Used by app.revanced.patches.youtube.layout.autorepeat.patch.AutoRepeatPatch
public static boolean shouldAutoRepeat() {
return SettingsEnum.PREFERRED_AUTO_REPEAT_BOOLEAN.getBoolean();
}
}

View File

@@ -0,0 +1,12 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.adremover.AdRemoverAPI;
import app.revanced.integrations.settings.SettingsEnum;
public class BrandingWaterMarkPatch {
//Used by: app.revanced.patches.youtube.layout.watermark.patch.HideWatermarkPatch
public static boolean isBrandingWatermarkShown() {
return SettingsEnum.BRANDING_SHOWN_BOOLEAN.getBoolean();
}
}

View File

@@ -0,0 +1,19 @@
package app.revanced.integrations.patches;
import android.os.Build;
import androidx.annotation.RequiresApi;
import java.nio.ByteBuffer;
import app.revanced.integrations.adremover.LithoAdRemoval;
public class GeneralBytecodeAdsPatch {
//Used by app.revanced.patches.youtube.ad.general.bytecode.patch.GeneralBytecodeAdsPatch
@RequiresApi(api = Build.VERSION_CODES.N)
public static boolean containsAd(String value, ByteBuffer buffer) {
return LithoAdRemoval.containsAd(value, buffer);
}
}

View File

@@ -0,0 +1,14 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.videoswipecontrols.helpers.BrightnessHelper;
public class HDRMaxBrightnessPatch {
//Used by app/revanced/patches/youtube/misc/hdrbrightness/patch/HDRBrightnessPatch
public static float getHDRBrightness(float original) {
if (!SettingsEnum.USE_HDR_BRIGHTNESS_BOOLEAN.getBoolean()) return original;
return SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() ? BrightnessHelper.getBrightness() : -1.0f;
}
}

View File

@@ -0,0 +1,11 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class HideCastButtonPatch {
//Used by app.revanced.patches.youtube.layout.castbutton.patch.HideCastButonPatch
public static int getCastButtonOverrideV2(int original) {
return SettingsEnum.CAST_BUTTON_SHOWN_BOOLEAN.getBoolean() ? original : 8;
}
}

View File

@@ -0,0 +1,14 @@
package app.revanced.integrations.patches;
import android.view.View;
import app.revanced.integrations.adremover.AdRemoverAPI;
public class HideCreateButtonPatch {
//Todo: Switch BooleanPreferences to Settings class
//Used by app.revanced.patches.youtube.layout.createbutton.patch.CreateButtonRemoverPatch
public static void hideCreateButton(View view) {
AdRemoverAPI.hideCreateButton(view);
}
}

View File

@@ -0,0 +1,21 @@
package app.revanced.integrations.patches;
import android.view.View;
import app.revanced.integrations.adremover.AdRemoverAPI;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.settings.SettingsEnum;
public class HideHomeAdsPatch {
/**
* Used by package app.revanced.extensions.Extensions
* @param view
*/
public static void HideHomeAds(View view) {
if (!SettingsEnum.HOME_ADS_SHOWN_BOOLEAN.getBoolean()) {
AdRemoverAPI.HideViewWithLayout1dp(view);
}
}
}

View File

@@ -0,0 +1,10 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class HideInfoCardSuggestionsPatch {
public static int hideInfoCardSuggestions() {
return SettingsEnum.INFO_CARDS_SHOWN_BOOLEAN.getBoolean() ? 0 : 8;
}
}

View File

@@ -0,0 +1,21 @@
package app.revanced.integrations.patches;
import android.view.View;
import app.revanced.integrations.adremover.AdRemoverAPI;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.settings.SettingsEnum;
public class HideReelsPatch {
/**
* Used by app.revanced.patches.youtube.layout.reels.patch.HideReelsPatch
*
* @param view
*/
public static void HideReel(View view) {
if (!SettingsEnum.REEL_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
AdRemoverAPI.HideViewWithLayout1dp(view);
}
}
}

View File

@@ -0,0 +1,18 @@
package app.revanced.integrations.patches;
import android.view.View;
import app.revanced.integrations.adremover.AdRemoverAPI;
public class HideShortsButtonPatch {
//Todo: Switch BooleanPreferences to Settings class
//Used by app.revanced.patches.youtube.layout.shorts.button.patch.ShortsButtonRemoverPatch
public static void hideShortsButton(View view) {
AdRemoverAPI.hideShortsButton(view);
}
//Needed for the ShortsButtonRemoverPatch
public static Enum lastPivotTab;
}

View File

@@ -0,0 +1,14 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class MiniplayerOverridePatch {
//ToDo: Write Patch for it.
//See https://drive.google.com/file/d/1G7jn2EdWgNls0Htgs-wPPjjObZL1emzK/view?usp=sharing
//And https://drive.google.com/file/d/1-QlgSiKzqQ5lHXQnvRUpijk0GH9T1Sn7/view?usp=sharing
// for where it needs to be used.
public static boolean getTabletMiniplayerOverride() {
return SettingsEnum.USE_TABLET_MINIPLAYER_BOOLEAN.getBoolean();
}
}

View File

@@ -0,0 +1,13 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class NewActionbarPatch {
//ToDo: Write Patch for it.
//See https://drive.google.com/file/d/1Jg2WK9wwSABCiIcqclzhedy3J3RCf3Hn/view?usp=sharing for where it needs to be used.
public static boolean getNewActionBar() {
return SettingsEnum.USE_NEW_ACTIONBAR_BOOLEAN.getBoolean();
}
}

View File

@@ -0,0 +1,11 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class OldStyleQualityPatch {
//Used by app.revanced.patches.youtube.layout.oldqualitylayout.patch.OldQualityLayoutPatch
public static boolean useOldStyleQualitySettings() {
return SettingsEnum.OLD_STYLE_QUALITY_SETTINGS_BOOLEAN.getBoolean();
}
}

View File

@@ -0,0 +1,13 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class OverrideCodecPatch {
//ToDo: Write Patch for it.
//See https://drive.google.com/file/d/14d2R-5JF97gOZggoobVEVazPWbORbZVp/view?usp=sharing for where it needs to be used.
public static boolean isOverrideCodedUsed() {
return SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean();
}
}

View File

@@ -0,0 +1,12 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class SeekbarTappingPatch {
//Used by app.revanced.patches.youtube.interaction.seekbar.patch.EnableSeekbarTappingPatch
public static boolean isTapSeekingEnabled() {
return SettingsEnum.TAP_SEEKING_ENABLED_BOOLEAN.getBoolean();
}
}

View File

@@ -0,0 +1,12 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.adremover.whitelist.Whitelist;
public class VideoAdsPatch {
//Used by app.revanced.patches.youtube.ad.general.video.patch.VideoAdsPatch
public static boolean shouldShowAds() {
return Whitelist.shouldShowAds();
}
}

View File

@@ -0,0 +1,26 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class VideoBufferPatch {
//ToDo: Write Patch for it.
//See https://drive.google.com/file/d/1LSZZX4NgBIlN0dDCzyI7cECtgbXVg_1j/view?usp=sharing for where it needs to be used.
public static int getMaxBuffer(int original) {
return SettingsEnum.MAX_BUFFER_INTEGER.getInt();
}
//ToDo: Write Patch for it.
//See https://drive.google.com/file/d/1gIUqPIMq-XP-edT_9wQN1RbmVnk9tJN8/view?usp=sharing for where it needs to be used.
public static int getPlaybackBuffer(int original) {
return SettingsEnum.PLAYBACK_MAX_BUFFER_INTEGER.getInt();
}
//ToDo: Write Patch for it.
//See https://drive.google.com/file/d/1ywL7SxvWrBIIbuZ1YoUIKdZM-U8H_w-p/view?usp=sharing for where it needs to be used.
public static int getReBuffer(int original) {
return SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER.getInt();
}
}

View File

@@ -0,0 +1,17 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.videoplayer.videosettings.VideoQuality;
public class VideoQualityPatch {
//ToDo: Write Patch for it.
//See https://drive.google.com/file/d/1goodaU0JWrO9BAOUn6El-Id1SNuMGHR9/view?usp=sharing for where it needs to be used.
public static int setVideoQuality(Object[] qualities, int quality, Object qInterface) {
return VideoQuality.setVideoQuality(qualities, quality, qInterface);
}
//See https://drive.google.com/file/d/1_cgCf603XKk4gEbbsmWGtndNt5UJ0np7/view?usp=sharing for usage
public static void userChangedQuality() {
VideoQuality.userChangedQuality();
}
}

Some files were not shown because too many files have changed in this diff Show More