Skip to content

Commit

Permalink
chore: Merge branch dev to main (#4041)
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX authored Dec 6, 2024
2 parents 69ec47c + 35db935 commit 6359f72
Show file tree
Hide file tree
Showing 316 changed files with 388 additions and 160 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [5.2.2-dev.1](https://github.com/ReVanced/revanced-patches/compare/v5.2.1...v5.2.2-dev.1) (2024-12-05)


### Bug Fixes

* **YouTube - Spoof video streams:** Use system language as default iOS audio stream ([#4042](https://github.com/ReVanced/revanced-patches/issues/4042)) ([4017185](https://github.com/ReVanced/revanced-patches/commit/4017185e760c0569e6644b94bbe66a84fa245b4b))

## [5.2.1](https://github.com/ReVanced/revanced-patches/compare/v5.2.0...v5.2.1) (2024-12-04)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
android.namespace = "app.revanced.extension"

dependencies {
compileOnly(libs.annotation)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<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.ACCESS_NETWORK_STATE"/>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
android.namespace = "app.revanced.extension"

dependencies {
compileOnly(libs.annotation)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
android.namespace = "app.revanced.extension"
4 changes: 4 additions & 0 deletions extensions/boostforreddit/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies {
compileOnly(project(":extensions:shared:library"))
compileOnly(project(":extensions:boostforreddit:stub"))
}
1 change: 1 addition & 0 deletions extensions/boostforreddit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest/>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import app.revanced.extension.shared.fixes.slink.BaseFixSLinksPatch;

/** @noinspection unused*/
/**
* @noinspection unused
*/
public class FixSLinksPatch extends BaseFixSLinksPatch {
static {
INSTANCE = new FixSLinksPatch();
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest/>
File renamed without changes.
3 changes: 3 additions & 0 deletions extensions/reddit/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies {
compileOnly(project(":extensions:reddit:stub"))
}
1 change: 1 addition & 0 deletions extensions/reddit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest/>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.revanced.extension.reddit.patches;
package app.revanced.extension.patches;

import com.reddit.domain.model.ILink;

Expand Down
17 changes: 17 additions & 0 deletions extensions/reddit/stub/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
id(libs.plugins.android.library.get().pluginId)
}

android {
namespace = "app.revanced.extension"
compileSdk = 33

defaultConfig {
minSdk = 24
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
1 change: 1 addition & 0 deletions extensions/reddit/stub/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest/>
11 changes: 0 additions & 11 deletions extensions/remove-screen-capture-restriction/build.gradle.kts

This file was deleted.

7 changes: 0 additions & 7 deletions extensions/remove-screenshot-restriction/build.gradle.kts

This file was deleted.

21 changes: 1 addition & 20 deletions extensions/shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
extension {
name = "extensions/shared.rve"
}

android {
namespace = "app.revanced.extension"

buildTypes {
release {
isMinifyEnabled = true
}
}
}

dependencies {
compileOnly(libs.appcompat)
compileOnly(libs.annotation)
compileOnly(libs.okhttp)
compileOnly(libs.retrofit)

compileOnly(project(":extensions:shared:stub"))
implementation(project(":extensions:shared:library"))
}
21 changes: 21 additions & 0 deletions extensions/shared/library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
id("com.android.library")
}

android {
namespace = "app.revanced.extension"
compileSdk = 34

defaultConfig {
minSdk = 23
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}

dependencies {
compileOnly(libs.annotation)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import app.revanced.extension.shared.Logger;
import app.revanced.extension.shared.Utils;
import app.revanced.extension.youtube.settings.Settings;
import app.revanced.extension.shared.settings.BaseSettings;

abstract class Check {
private static final int NUMBER_OF_TIMES_TO_IGNORE_WARNING_BEFORE_DISABLING = 2;
Expand All @@ -46,11 +46,11 @@ abstract class Check {
/**
* For debugging and development only.
* Forces all checks to be performed and the check failed dialog to be shown.
* Can be enabled by importing settings text with {@link Settings#CHECK_ENVIRONMENT_WARNINGS_ISSUED}
* Can be enabled by importing settings text with {@link BaseSettings#CHECK_ENVIRONMENT_WARNINGS_ISSUED}
* set to -1.
*/
static boolean debugAlwaysShowWarning() {
final boolean alwaysShowWarning = Settings.CHECK_ENVIRONMENT_WARNINGS_ISSUED.get() < 0;
final boolean alwaysShowWarning = BaseSettings.CHECK_ENVIRONMENT_WARNINGS_ISSUED.get() < 0;
if (alwaysShowWarning) {
Logger.printInfo(() -> "Debug forcing environment check warning to show");
}
Expand All @@ -59,14 +59,14 @@ static boolean debugAlwaysShowWarning() {
}

static boolean shouldRun() {
return Settings.CHECK_ENVIRONMENT_WARNINGS_ISSUED.get()
return BaseSettings.CHECK_ENVIRONMENT_WARNINGS_ISSUED.get()
< NUMBER_OF_TIMES_TO_IGNORE_WARNING_BEFORE_DISABLING;
}

static void disableForever() {
Logger.printInfo(() -> "Environment checks disabled forever");

Settings.CHECK_ENVIRONMENT_WARNINGS_ISSUED.save(Integer.MAX_VALUE);
BaseSettings.CHECK_ENVIRONMENT_WARNINGS_ISSUED.save(Integer.MAX_VALUE);
}

@SuppressLint("NewApi")
Expand Down Expand Up @@ -107,8 +107,8 @@ static void issueWarning(Activity activity, Collection<Check> failedChecks) {
" ",
(dialog, which) -> {
// Cleanup data if the user incorrectly imported a huge negative number.
final int current = Math.max(0, Settings.CHECK_ENVIRONMENT_WARNINGS_ISSUED.get());
Settings.CHECK_ENVIRONMENT_WARNINGS_ISSUED.save(current + 1);
final int current = Math.max(0, BaseSettings.CHECK_ENVIRONMENT_WARNINGS_ISSUED.get());
BaseSettings.CHECK_ENVIRONMENT_WARNINGS_ISSUED.save(current + 1);

dialog.dismiss();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.revanced.extension.youtube.requests;
package app.revanced.extension.shared.requests;

import app.revanced.extension.shared.Utils;
import org.json.JSONArray;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.revanced.extension.youtube.requests;
package app.revanced.extension.shared.requests;

public class Route {
private final String route;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public class BaseSettings {
public static final BooleanSetting DEBUG = new BooleanSetting("revanced_debug", FALSE);
public static final BooleanSetting DEBUG_STACKTRACE = new BooleanSetting("revanced_debug_stacktrace", FALSE, parent(DEBUG));
public static final BooleanSetting DEBUG_TOAST_ON_ERROR = new BooleanSetting("revanced_debug_toast_on_error", TRUE, "revanced_debug_toast_on_error_user_dialog_message");

public static final IntegerSetting CHECK_ENVIRONMENT_WARNINGS_ISSUED = new IntegerSetting("revanced_check_environment_warnings_issued", 0, true, false);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import app.revanced.extension.shared.StringRef;
import app.revanced.extension.shared.Utils;
import app.revanced.extension.shared.settings.preference.SharedPrefCategory;
import app.revanced.extension.youtube.sponsorblock.SponsorBlockSettings;
import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -62,6 +61,30 @@ public static Availability parentsAny(@NonNull BooleanSetting... parents) {
};
}

/**
* Callback for importing/exporting settings.
*/
public interface ImportExportCallback {
/**
* Called after all settings have been imported.
*/
void settingsImported(@Nullable Context context);

/**
* Called after all settings have been exported.
*/
void settingsExported(@Nullable Context context);
}

private static final List<ImportExportCallback> importExportCallbacks = new ArrayList<>();

/**
* Adds a callback for {@link #importFromJSON(Context, String)} and {@link #exportToJson(Context)}.
*/
public static void addImportExportCallback(@NonNull ImportExportCallback callback) {
importExportCallbacks.add(Objects.requireNonNull(callback));
}

/**
* All settings that were instantiated.
* When a new setting is created, it is automatically added to this list.
Expand Down Expand Up @@ -365,7 +388,10 @@ public static String exportToJson(@Nullable Context alertDialogContext) {
setting.writeToJSON(json, importExportKey);
}
}
SponsorBlockSettings.showExportWarningIfNeeded(alertDialogContext);

for (ImportExportCallback callback : importExportCallbacks) {
callback.settingsExported(alertDialogContext);
}

if (json.length() == 0) {
return "";
Expand All @@ -385,7 +411,7 @@ public static String exportToJson(@Nullable Context alertDialogContext) {
/**
* @return if any settings that require a reboot were changed.
*/
public static boolean importFromJSON(@NonNull String settingsJsonString) {
public static boolean importFromJSON(@NonNull Context alertDialogContext, @NonNull String settingsJsonString) {
try {
if (!settingsJsonString.matches("[\\s\\S]*\\{")) {
settingsJsonString = '{' + settingsJsonString + '}'; // Restore outer JSON braces
Expand All @@ -411,12 +437,9 @@ public static boolean importFromJSON(@NonNull String settingsJsonString) {
}
}

// SB Enum categories are saved using StringSettings.
// Which means they need to reload again if changed by other code (such as here).
// This call could be removed by creating a custom Setting class that manages the
// "String <-> Enum" logic or by adding an event hook of when settings are imported.
// But for now this is simple and works.
SponsorBlockSettings.updateFromImportedSettings();
for (ImportExportCallback callback : importExportCallbacks) {
callback.settingsImported(alertDialogContext);
}

Utils.showToastLong(numberOfSettingsImported == 0
? str("revanced_settings_import_reset")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,21 @@ protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
builder.setNeutralButton(str("revanced_settings_import_copy"), (dialog, which) -> {
Utils.setClipboard(getEditText().getText().toString());
}).setPositiveButton(str("revanced_settings_import"), (dialog, which) -> {
importSettings(getEditText().getText().toString());
importSettings(builder.getContext(), getEditText().getText().toString());
});
} catch (Exception ex) {
Logger.printException(() -> "onPrepareDialogBuilder failure", ex);
}
}

private void importSettings(String replacementSettings) {
private void importSettings(Context context, String replacementSettings) {
try {
if (replacementSettings.equals(existingSettings)) {
return;
}
AbstractPreferenceFragment.settingImportInProgress = true;
final boolean rebootNeeded = Setting.importFromJSON(replacementSettings);

final boolean rebootNeeded = Setting.importFromJSON(context, replacementSettings);
if (rebootNeeded) {
AbstractPreferenceFragment.showRestartDialog(getContext());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package app.revanced.extension.shared.settings.preference;

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

import android.annotation.SuppressLint;
import android.app.Dialog;
Expand Down Expand Up @@ -34,8 +34,8 @@

import app.revanced.extension.shared.Logger;
import app.revanced.extension.shared.Utils;
import app.revanced.extension.youtube.requests.Requester;
import app.revanced.extension.youtube.requests.Route;
import app.revanced.extension.shared.requests.Requester;
import app.revanced.extension.shared.requests.Route;

/**
* Opens a dialog showing official links.
Expand Down
5 changes: 1 addition & 4 deletions extensions/shared/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
</manifest>
<manifest/>
2 changes: 0 additions & 2 deletions extensions/shared/stub/src/main/AndroidManifest.xml

This file was deleted.

11 changes: 0 additions & 11 deletions extensions/spoof-wifi/build.gradle.kts

This file was deleted.

5 changes: 5 additions & 0 deletions extensions/syncforreddit/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dependencies {
compileOnly(project(":extensions:shared:library"))
compileOnly(project(":extensions:syncforreddit:stub"))
compileOnly(libs.annotation)
}
1 change: 1 addition & 0 deletions extensions/syncforreddit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest/>
17 changes: 17 additions & 0 deletions extensions/syncforreddit/stub/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
id(libs.plugins.android.library.get().pluginId)
}

android {
namespace = "app.revanced.extension"
compileSdk = 33

defaultConfig {
minSdk = 24
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
1 change: 1 addition & 0 deletions extensions/syncforreddit/stub/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest/>
5 changes: 5 additions & 0 deletions extensions/tiktok/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dependencies {
compileOnly(project(":extensions:shared:library"))
compileOnly(project(":extensions:tiktok:stub"))
compileOnly(libs.annotation)
}
Loading

0 comments on commit 6359f72

Please sign in to comment.