1
mirror of https://github.com/revanced/revanced-integrations synced 2025-11-19 03:23:27 +01:00

Compare commits

...

19 Commits

Author SHA1 Message Date
semantic-release-bot
d484f35127 chore(release): 1.0.0-dev.3 [skip ci]
# [1.0.0-dev.3](https://github.com/ReVanced/revanced-integrations/compare/v1.0.0-dev.2...v1.0.0-dev.3) (2023-12-03)

### Bug Fixes

* **YouTube - SponsorBlock:** Prevent autoplay from stopping to work ([f4e2d56](f4e2d56b18))
2023-12-03 18:33:33 +00:00
oSumAtrIX
f4e2d56b18 fix(YouTube - SponsorBlock): Prevent autoplay from stopping to work 2023-12-03 19:30:56 +01:00
semantic-release-bot
9394c512ba chore(release): 1.0.0-dev.2 [skip ci]
# [1.0.0-dev.2](https://github.com/ReVanced/revanced-integrations/compare/v1.0.0-dev.1...v1.0.0-dev.2) (2023-12-03)

### Bug Fixes

* **YouTube - Return YouTube Dislike:** Fix dislikes sometimes not showing for non English language ([5d4c8b0](5d4c8b0a1b))
2023-12-03 18:27:44 +00:00
LisoUseInAIKyrios
5d4c8b0a1b fix(YouTube - Return YouTube Dislike): Fix dislikes sometimes not showing for non English language 2023-12-03 20:24:37 +02:00
semantic-release-bot
3a56431a28 chore(release): 1.0.0-dev.1 [skip ci]
# [1.0.0-dev.1](https://github.com/ReVanced/revanced-integrations/compare/v0.125.1-dev.1...v1.0.0-dev.1) (2023-12-02)

### Features

* Allow choosing the vendor of GmsCore via patch options ([#529](https://github.com/ReVanced/revanced-integrations/issues/529)) ([fba7181](fba7181e70))

### BREAKING CHANGES

* The class `MicroGSupport` has been renamed to `GmsCoreSupport`
2023-12-02 21:54:20 +00:00
oSumAtrIX
fba7181e70 feat: Allow choosing the vendor of GmsCore via patch options (#529)
BREAKING CHANGE: The class `MicroGSupport` has been renamed to `GmsCoreSupport`
2023-12-02 22:51:39 +01:00
semantic-release-bot
3b4f0206ad chore(release): 0.125.1-dev.1 [skip ci]
## [0.125.1-dev.1](https://github.com/ReVanced/revanced-integrations/compare/v0.125.0...v0.125.1-dev.1) (2023-12-02)

### Bug Fixes

* **YouTube - SponsorBlock:** Allow autoplay when skipping to the end of the video ([3d660e1](3d660e1b5e))
2023-12-02 21:31:15 +00:00
oSumAtrIX
3d660e1b5e fix(YouTube - SponsorBlock): Allow autoplay when skipping to the end of the video 2023-12-02 17:56:08 +01:00
semantic-release-bot
dd045ad985 chore(release): 0.125.0 [skip ci]
# [0.125.0](https://github.com/ReVanced/revanced-integrations/compare/v0.124.1...v0.125.0) (2023-12-02)

### Features

* Modernize restart logic ([#527](https://github.com/ReVanced/revanced-integrations/issues/527)) ([0ea4e72](0ea4e720ed))
2023-12-02 14:27:11 +00:00
oSumAtrIX
0a15245f41 chore: Merge branch dev to main (#528) 2023-12-02 15:24:33 +01:00
semantic-release-bot
a18c134aaa chore(release): 0.125.0-dev.1 [skip ci]
# [0.125.0-dev.1](https://github.com/ReVanced/revanced-integrations/compare/v0.124.1...v0.125.0-dev.1) (2023-11-29)

### Features

* Modernize restart logic ([#527](https://github.com/ReVanced/revanced-integrations/issues/527)) ([0ea4e72](0ea4e720ed))
2023-11-29 20:51:03 +00:00
LisoUseInAIKyrios
0ea4e720ed feat: Modernize restart logic (#527) 2023-11-29 22:48:23 +02:00
semantic-release-bot
c6a1b9fc59 chore(release): 0.124.1 [skip ci]
## [0.124.1](https://github.com/ReVanced/revanced-integrations/compare/v0.124.0...v0.124.1) (2023-11-27)

### Bug Fixes

* **YouTube - Hide layout components:** Prevent app from crashing on startup ([c2112e0](c2112e066a))
* **YouTube - Return YouTube dislike:** Fix layout of right to left languages ([11abdf1](11abdf162f))
* **YouTube - Spoof signature:** fix error toast when viewing very old YouTube videos ([#525](https://github.com/ReVanced/revanced-integrations/issues/525)) ([eede028](eede028c96))
2023-11-27 19:09:52 +00:00
oSumAtrIX
d6ed0c061c chore: Merge branch dev to main (#526) 2023-11-27 20:07:15 +01:00
semantic-release-bot
3ba3d5108d chore(release): 0.124.1-dev.3 [skip ci]
## [0.124.1-dev.3](https://github.com/ReVanced/revanced-integrations/compare/v0.124.1-dev.2...v0.124.1-dev.3) (2023-11-27)

### Bug Fixes

* **YouTube - Hide layout components:** Prevent app from crashing on startup ([c2112e0](c2112e066a))
2023-11-27 19:06:27 +00:00
oSumAtrIX
c2112e066a fix(YouTube - Hide layout components): Prevent app from crashing on startup
The application crashes sporadically when a field is not initialized yet in a static context.
2023-11-27 20:02:59 +01:00
oSumAtrIX
6520499a27 refactor: Use a newline consistently 2023-11-27 18:40:49 +01:00
semantic-release-bot
b2d9dcd6c0 chore(release): 0.124.1-dev.2 [skip ci]
## [0.124.1-dev.2](https://github.com/ReVanced/revanced-integrations/compare/v0.124.1-dev.1...v0.124.1-dev.2) (2023-11-26)

### Bug Fixes

* **YouTube - Return YouTube dislike:** Fix layout of right to left languages ([11abdf1](11abdf162f))
2023-11-26 22:27:00 +00:00
LisoUseInAIKyrios
11abdf162f fix(YouTube - Return YouTube dislike): Fix layout of right to left languages 2023-11-27 00:24:14 +02:00
15 changed files with 241 additions and 155 deletions

View File

@@ -1,3 +1,73 @@
# [1.0.0-dev.3](https://github.com/ReVanced/revanced-integrations/compare/v1.0.0-dev.2...v1.0.0-dev.3) (2023-12-03)
### Bug Fixes
* **YouTube - SponsorBlock:** Prevent autoplay from stopping to work ([f4e2d56](https://github.com/ReVanced/revanced-integrations/commit/f4e2d56b181fee4d693dea1dfe81974237e4eff7))
# [1.0.0-dev.2](https://github.com/ReVanced/revanced-integrations/compare/v1.0.0-dev.1...v1.0.0-dev.2) (2023-12-03)
### Bug Fixes
* **YouTube - Return YouTube Dislike:** Fix dislikes sometimes not showing for non English language ([5d4c8b0](https://github.com/ReVanced/revanced-integrations/commit/5d4c8b0a1b77e97c7c0c02288927e92f3c9765ce))
# [1.0.0-dev.1](https://github.com/ReVanced/revanced-integrations/compare/v0.125.1-dev.1...v1.0.0-dev.1) (2023-12-02)
### Features
* Allow choosing the vendor of GmsCore via patch options ([#529](https://github.com/ReVanced/revanced-integrations/issues/529)) ([fba7181](https://github.com/ReVanced/revanced-integrations/commit/fba7181e70d695d7fb13c530754dc1db99b87216))
### BREAKING CHANGES
* The class `MicroGSupport` has been renamed to `GmsCoreSupport`
## [0.125.1-dev.1](https://github.com/ReVanced/revanced-integrations/compare/v0.125.0...v0.125.1-dev.1) (2023-12-02)
### Bug Fixes
* **YouTube - SponsorBlock:** Allow autoplay when skipping to the end of the video ([3d660e1](https://github.com/ReVanced/revanced-integrations/commit/3d660e1b5eeab9771f96bd2d26a222b835e2485c))
# [0.125.0](https://github.com/ReVanced/revanced-integrations/compare/v0.124.1...v0.125.0) (2023-12-02)
### Features
* Modernize restart logic ([#527](https://github.com/ReVanced/revanced-integrations/issues/527)) ([0ea4e72](https://github.com/ReVanced/revanced-integrations/commit/0ea4e720edab250aac02b32a8014c24b1127d02f))
# [0.125.0-dev.1](https://github.com/ReVanced/revanced-integrations/compare/v0.124.1...v0.125.0-dev.1) (2023-11-29)
### Features
* Modernize restart logic ([#527](https://github.com/ReVanced/revanced-integrations/issues/527)) ([0ea4e72](https://github.com/ReVanced/revanced-integrations/commit/0ea4e720edab250aac02b32a8014c24b1127d02f))
## [0.124.1](https://github.com/ReVanced/revanced-integrations/compare/v0.124.0...v0.124.1) (2023-11-27)
### Bug Fixes
* **YouTube - Hide layout components:** Prevent app from crashing on startup ([c2112e0](https://github.com/ReVanced/revanced-integrations/commit/c2112e066af31890c5d441870d24f3582e9b1dd1))
* **YouTube - Return YouTube dislike:** Fix layout of right to left languages ([11abdf1](https://github.com/ReVanced/revanced-integrations/commit/11abdf162f1a4c82a2330b16ca42800d8599c215))
* **YouTube - Spoof signature:** fix error toast when viewing very old YouTube videos ([#525](https://github.com/ReVanced/revanced-integrations/issues/525)) ([eede028](https://github.com/ReVanced/revanced-integrations/commit/eede028c96042e6abc18377bf16a75e4806aba4a))
## [0.124.1-dev.3](https://github.com/ReVanced/revanced-integrations/compare/v0.124.1-dev.2...v0.124.1-dev.3) (2023-11-27)
### Bug Fixes
* **YouTube - Hide layout components:** Prevent app from crashing on startup ([c2112e0](https://github.com/ReVanced/revanced-integrations/commit/c2112e066af31890c5d441870d24f3582e9b1dd1))
## [0.124.1-dev.2](https://github.com/ReVanced/revanced-integrations/compare/v0.124.1-dev.1...v0.124.1-dev.2) (2023-11-26)
### Bug Fixes
* **YouTube - Return YouTube dislike:** Fix layout of right to left languages ([11abdf1](https://github.com/ReVanced/revanced-integrations/commit/11abdf162f1a4c82a2330b16ca42800d8599c215))
## [0.124.1-dev.1](https://github.com/ReVanced/revanced-integrations/compare/v0.124.0...v0.124.1-dev.1) (2023-11-25)

View File

@@ -0,0 +1,74 @@
package app.revanced.integrations.patches;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import androidx.annotation.RequiresApi;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
import java.util.Objects;
import static app.revanced.integrations.utils.StringRef.str;
/**
* @noinspection unused
*/
public class GmsCoreSupport {
private static final String GMS_CORE_PACKAGE_NAME
= getGmsCoreVendor() + ".android.gms";
private static final String DONT_KILL_MY_APP_LINK
= "https://dontkillmyapp.com";
private static final Uri GMS_CORE_PROVIDER
= Uri.parse("content://" + getGmsCoreVendor() + ".android.gsf.gservices/prefix");
private static void search(Context context, String uriString, String message) {
ReVancedUtils.showToastLong(message);
var intent = new Intent(Intent.ACTION_WEB_SEARCH);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(SearchManager.QUERY, uriString);
context.startActivity(intent);
}
@RequiresApi(api = Build.VERSION_CODES.N)
public static void checkAvailability() {
var context = Objects.requireNonNull(ReVancedUtils.getContext());
try {
context.getPackageManager().getPackageInfo(GMS_CORE_PACKAGE_NAME, PackageManager.GET_ACTIVITIES);
} catch (PackageManager.NameNotFoundException exception) {
LogHelper.printInfo(() -> "GmsCore was not found", exception);
search(context, getGmsCoreDownloadLink(), str("gms_core_not_installed_warning"));
// Gracefully exit the app, so it does not crash.
System.exit(0);
}
try (var client = context.getContentResolver().acquireContentProviderClient(GMS_CORE_PROVIDER)) {
if (client != null) return;
LogHelper.printInfo(() -> "GmsCore is not running in the background");
search(context, DONT_KILL_MY_APP_LINK, str("gms_core_not_running_warning"));
}
}
private static String getGmsCoreDownloadLink() {
final var vendor = getGmsCoreVendor();
switch (vendor) {
case "com.mgoogle":
return "https://github.com/TeamVanced/VancedMicroG/releases/latest";
case "app.revanced":
return "https://github.com/revanced/gmscore/releases/latest";
default:
return vendor + ".android.gms";
}
}
// Modified by a patch. Do not touch.
private static String getGmsCoreVendor() {
return "app.revanced";
}
}

View File

@@ -1,53 +0,0 @@
package app.revanced.integrations.patches;
import static app.revanced.integrations.utils.StringRef.str;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import java.util.Objects;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
public class MicroGSupport {
private static final String MICROG_VENDOR = "com.mgoogle";
private static final String MICROG_PACKAGE_NAME = MICROG_VENDOR + ".android.gms";
private static final String VANCED_MICROG_DOWNLOAD_LINK = "https://github.com/TeamVanced/VancedMicroG/releases/latest";
private static final String DONT_KILL_MY_APP_LINK = "https://dontkillmyapp.com";
private static final Uri VANCED_MICROG_PROVIDER = Uri.parse("content://" + MICROG_VENDOR + ".android.gsf.gservices/prefix");
private static void startIntent(Context context, String uriString, String message) {
ReVancedUtils.showToastLong(message);
var intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse(uriString));
context.startActivity(intent);
}
@TargetApi(26)
public static void checkAvailability() {
var context = Objects.requireNonNull(ReVancedUtils.getContext());
try {
context.getPackageManager().getPackageInfo(MICROG_PACKAGE_NAME, PackageManager.GET_ACTIVITIES);
} catch (PackageManager.NameNotFoundException exception) {
LogHelper.printInfo(() -> "Vanced MicroG was not found", exception);
startIntent(context, VANCED_MICROG_DOWNLOAD_LINK, str("microg_not_installed_warning"));
// Gracefully exit the app, so it does not crash.
System.exit(0);
}
try (var client = context.getContentResolver().acquireContentProviderClient(VANCED_MICROG_PROVIDER)) {
if (client != null) return;
LogHelper.printInfo(() -> "Vanced MicroG is not running in the background");
startIntent(context, DONT_KILL_MY_APP_LINK, str("microg_not_running_warning"));
}
}
}

View File

@@ -318,8 +318,12 @@ public class ReturnYouTubeDislikePatch {
try {
if (SettingsEnum.RYD_ENABLED.getBoolean() && !SettingsEnum.RYD_COMPACT_LAYOUT.getBoolean()) {
if (ReturnYouTubeDislike.isPreviouslyCreatedSegmentedSpan(text)) {
// +1 pixel is needed for some foreign languages that measure
// the text different from what is used for layout (Greek in particular).
// Probably a bug in Android, but who knows.
// Single line mode is also used as an additional fix for this issue.
return measuredTextWidth + ReturnYouTubeDislike.leftSeparatorBounds.right
+ ReturnYouTubeDislike.leftSeparatorShapePaddingPixels;
+ ReturnYouTubeDislike.leftSeparatorShapePaddingPixels + 1;
}
}
} catch (Exception ex) {
@@ -335,9 +339,17 @@ public class ReturnYouTubeDislikePatch {
// YouTube Rolling Numbers do not use compound drawables or drawable padding.
if (view.getCompoundDrawablePadding() == 0) {
LogHelper.printDebug(() -> "Adding rolling number TextView changes");
ShapeDrawable leftSeparator = ReturnYouTubeDislike.getLeftSeparatorDrawable();
view.setCompoundDrawables(leftSeparator, null, null, null);
view.setCompoundDrawablePadding(ReturnYouTubeDislike.leftSeparatorShapePaddingPixels);
ShapeDrawable separator = ReturnYouTubeDislike.getLeftSeparatorDrawable();
if (ReVancedUtils.isRightToLeftTextLayout()) {
view.setCompoundDrawables(null, null, separator, null);
} else {
view.setCompoundDrawables(separator, null, null, null);
}
// Single line mode does not clip words if the span is larger than the view bounds.
// The styled span applied to the view should always have the same bounds,
// but use this feature just in case the measurements are somehow off by a few pixels.
view.setSingleLine(true);
}
}
@@ -350,6 +362,7 @@ public class ReturnYouTubeDislikePatch {
LogHelper.printDebug(() -> "Removing rolling number TextView changes");
view.setCompoundDrawablePadding(0);
view.setCompoundDrawables(null, null, null, null);
view.setSingleLine(false);
}
}

View File

@@ -135,10 +135,8 @@ public final class VideoInformation {
public static boolean seekTo(final long millisecond) {
final long videoLength = getVideoLength();
// Don't seek more than the video length to prevent issues such as
// Play pause button or autoplay not working.
// TODO: These are arbitrarily chosen values and should be subject to be adjusted.
final long seekToMilliseconds = millisecond <= videoLength - 500 ? millisecond : millisecond - 100;
// Prevent issues such as play/ pause button or autoplay not working.
final long seekToMilliseconds = Math.min(millisecond, VideoInformation.getVideoLength() - 250);
ReVancedUtils.verifyOnMainThread();
try {

View File

@@ -12,8 +12,10 @@ import app.revanced.integrations.utils.StringTrieSearch;
public final class LayoutComponentsFilter extends Filter {
private final StringTrieSearch exceptions = new StringTrieSearch();
private static final StringTrieSearch mixPlaylistsExceptions = new StringTrieSearch();
private static ByteArrayAsStringFilterGroup mixPlaylistsExceptions2;
private static final ByteArrayAsStringFilterGroup mixPlaylistsExceptions2 = new ByteArrayAsStringFilterGroup(
null,
"cell_description_body"
);
private final CustomFilterGroup custom;
private static final ByteArrayAsStringFilterGroup mixPlaylists = new ByteArrayAsStringFilterGroup(
@@ -25,6 +27,13 @@ public final class LayoutComponentsFilter extends Filter {
private final StringFilterGroup notifyMe;
private final StringFilterGroup expandableMetadata;
static {
mixPlaylistsExceptions.addPatterns(
"V.ED", // Playlist browse id.
"java.lang.ref.WeakReference"
);
}
@RequiresApi(api = Build.VERSION_CODES.N)
public LayoutComponentsFilter() {
exceptions.addPatterns(
@@ -35,16 +44,6 @@ public final class LayoutComponentsFilter extends Filter {
"library_recent_shelf"
);
mixPlaylistsExceptions.addPatterns(
"V.ED", // Playlist browse id.
"java.lang.ref.WeakReference"
);
mixPlaylistsExceptions2 = new ByteArrayAsStringFilterGroup(
null,
"cell_description_body"
);
custom = new CustomFilterGroup(
SettingsEnum.CUSTOM_FILTER,
SettingsEnum.CUSTOM_FILTER_STRINGS
@@ -263,14 +262,15 @@ public final class LayoutComponentsFilter extends Filter {
if (mixPlaylistsExceptions.matches(conversionContext.toString()))
return false;
if (!mixPlaylists.check(bytes).isFiltered()) return false;
if (!mixPlaylists.check(bytes).isFiltered())
return false;
// Prevent hiding the description of some videos accidentally.
if (mixPlaylistsExceptions2.check(bytes).isFiltered()) return false;
if (mixPlaylistsExceptions2.check(bytes).isFiltered())
return false;
LogHelper.printDebug(() -> "Filtered mix playlist");
return true;
}
public static boolean showWatermark() {

View File

@@ -85,7 +85,7 @@ public class ImportExportPreference extends EditTextPreference implements Prefer
ReVancedSettingsFragment.settingImportInProgress = true;
final boolean rebootNeeded = SettingsEnum.importJSON(replacementSettings);
if (rebootNeeded) {
ReVancedSettingsFragment.showRebootDialog(getContext());
ReVancedSettingsFragment.showRestartDialog(getContext());
}
} catch (Exception ex) {
LogHelper.printException(() -> "importSettings failure", ex);

View File

@@ -3,15 +3,10 @@ package app.revanced.integrations.settingsmenu;
import static app.revanced.integrations.utils.StringRef.str;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Process;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
@@ -22,13 +17,12 @@ import android.preference.SwitchPreference;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.apps.youtube.app.application.Shell_HomeActivity;
import app.revanced.integrations.patches.playback.speed.CustomPlaybackSpeedPatch;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.settings.SharedPrefCategory;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.shared.settings.SettingsUtils;
public class ReVancedSettingsFragment extends PreferenceFragment {
/**
@@ -37,23 +31,13 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
*/
static boolean settingImportInProgress;
private static void reboot(@NonNull Context activity) {
final int intentFlags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE;
PendingIntent intent = PendingIntent.getActivity(activity, 0,
new Intent(activity, Shell_HomeActivity.class), intentFlags);
AlarmManager systemService = (AlarmManager) activity.getSystemService(Context.ALARM_SERVICE);
systemService.setExact(AlarmManager.ELAPSED_REALTIME, 1500L, intent);
Process.killProcess(Process.myPid());
}
static void showRebootDialog(@NonNull Context activity) {
static void showRestartDialog(@NonNull Context contxt) {
String positiveButton = str("in_app_update_restart_button");
String negativeButton = str("sign_in_cancel");
new AlertDialog.Builder(activity).setMessage(str("pref_refresh_config"))
new AlertDialog.Builder(contxt).setMessage(str("pref_refresh_config"))
.setPositiveButton(positiveButton, (dialog, id) -> {
reboot(activity);
SettingsUtils.restartApp(contxt);
})
.setNegativeButton(negativeButton, null)
.setNegativeButton(android.R.string.cancel, null)
.setCancelable(false)
.show();
}
@@ -110,9 +94,9 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
if (!showingUserDialogMessage) {
if (setting.userDialogMessage != null && ((SwitchPreference) pref).isChecked() != (Boolean) setting.defaultValue) {
showSettingUserDialogConfirmation(getActivity(), (SwitchPreference) pref, setting);
showSettingUserDialogConfirmation(getContext(), (SwitchPreference) pref, setting);
} else if (setting.rebootApp) {
showRebootDialog(getActivity());
showRestartDialog(getContext());
}
}
@@ -188,14 +172,14 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
}
}
private void showSettingUserDialogConfirmation(@NonNull Activity activity, SwitchPreference switchPref, SettingsEnum setting) {
private void showSettingUserDialogConfirmation(@NonNull Context context, SwitchPreference switchPref, SettingsEnum setting) {
showingUserDialogMessage = true;
new AlertDialog.Builder(activity)
new AlertDialog.Builder(context)
.setTitle(str("revanced_settings_confirm_user_dialog_title"))
.setMessage(setting.userDialogMessage.toString())
.setPositiveButton(android.R.string.ok, (dialog, id) -> {
if (setting.rebootApp) {
showRebootDialog(activity);
showRestartDialog(context);
}
})
.setNegativeButton(android.R.string.cancel, (dialog, id) -> {

View File

@@ -0,0 +1,30 @@
package app.revanced.shared.settings;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
/**
* Class is used across multiple target apps.
*
* This entire class can _not_ reference:
* {@link app.revanced.integrations.settings.SettingsEnum}
* {@link app.revanced.twitch.settings.SettingsEnum}
* {@link app.revanced.tiktok.settings.SettingsEnum}
*
* or any other code that references these app specific integration classes.
*/
public class SettingsUtils {
public static void restartApp(@NonNull Context context) {
String packageName = context.getPackageName();
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);
Intent mainIntent = Intent.makeRestartActivityTask(intent.getComponent());
// Required for API 34 and later
// Ref: https://developer.android.com/about/versions/14/behavior-changes-14#safer-intents
mainIntent.setPackage(packageName);
context.startActivity(mainIntent);
System.exit(0);
}
}

View File

@@ -1,17 +1,22 @@
package app.revanced.tiktok.settingsmenu;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Process;
import android.preference.*;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.preference.SwitchPreference;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.shared.settings.SettingsUtils;
import app.revanced.tiktok.settings.SettingsEnum;
import app.revanced.tiktok.settings.SharedPrefCategory;
import app.revanced.tiktok.settingsmenu.preference.DownloadPathPreference;
@@ -21,7 +26,6 @@ import app.revanced.tiktok.settingsmenu.preference.categories.FeedFilterPreferen
import app.revanced.tiktok.settingsmenu.preference.categories.IntegrationsPreferenceCategory;
import app.revanced.tiktok.settingsmenu.preference.categories.SimSpoofPreferenceCategory;
import app.revanced.tiktok.utils.ReVancedUtils;
import com.ss.android.ugc.aweme.splash.SplashActivity;
@SuppressWarnings("deprecation")
public class ReVancedPreferenceFragment extends PreferenceFragment {
@@ -107,13 +111,9 @@ public class ReVancedPreferenceFragment extends PreferenceFragment {
super.onDestroy();
}
private void reboot(Activity activity) {
int intent = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE;
((AlarmManager) activity.getSystemService(Context.ALARM_SERVICE)).setExact(AlarmManager.ELAPSED_REALTIME, 1500L, PendingIntent.getActivity(activity, 0, new Intent(activity, SplashActivity.class), intent));
Process.killProcess(Process.myPid());
}
private void rebootDialog(final Activity activity) {
new AlertDialog.Builder(activity).setMessage("Refresh and restart").setPositiveButton("Restart", (dialog, i) -> reboot(activity)).setNegativeButton("Cancel", null).show();
private void rebootDialog(@NonNull Context context) {
new AlertDialog.Builder(context).setMessage("Refresh and restart")
.setPositiveButton("Restart", (dialog, i) -> SettingsUtils.restartApp(context))
.setNegativeButton(android.R.string.cancel, null).show();
}
}

View File

@@ -1,15 +1,10 @@
package app.revanced.twitch.settingsmenu;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Process;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
@@ -17,12 +12,13 @@ import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.preference.SwitchPreference;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import app.revanced.shared.settings.SettingsUtils;
import app.revanced.twitch.settings.SettingsEnum;
import app.revanced.twitch.utils.LogHelper;
import app.revanced.twitch.utils.ReVancedUtils;
import tv.twitch.android.app.core.LandingActivity;
public class ReVancedSettingsFragment extends PreferenceFragment {
@@ -62,7 +58,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
}
if (ReVancedUtils.getContext() != null && key != null && settingsInitialized && setting.rebootApp) {
rebootDialog(getActivity());
showRestartDialog(getContext());
}
// First onChange event is caused by initial state loading
@@ -122,19 +118,12 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
super.onDestroy();
}
@SuppressLint("MissingPermission")
private void reboot(Activity activity) {
int flags;
flags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE;
((AlarmManager) activity.getSystemService(Context.ALARM_SERVICE)).setExact(AlarmManager.ELAPSED_REALTIME, 1500L, PendingIntent.getActivity(activity, 0, new Intent(activity, LandingActivity.class), flags));
Process.killProcess(Process.myPid());
}
private void rebootDialog(final Activity activity) {
new AlertDialog.Builder(activity).
private void showRestartDialog(@NonNull Context context) {
new AlertDialog.Builder(context).
setMessage(ReVancedUtils.getString("revanced_reboot_message")).
setPositiveButton(ReVancedUtils.getString("revanced_reboot"), (dialog, i) -> reboot(activity))
.setNegativeButton(ReVancedUtils.getString("revanced_cancel"), null)
setPositiveButton(ReVancedUtils.getString("revanced_reboot"),
(dialog, i) -> SettingsUtils.restartApp(context))
.setNegativeButton(android.R.string.cancel, null)
.show();
}
}

View File

@@ -1,5 +0,0 @@
package com.google.android.apps.youtube.app.application;
//dummy class
public class Shell_HomeActivity {
}

View File

@@ -1,9 +0,0 @@
package com.ss.android.ugc.aweme.splash;
import android.annotation.SuppressLint;
import android.app.Activity;
//Dummy class
@SuppressLint("CustomSplashScreen")
public class SplashActivity extends Activity {
}

View File

@@ -1,5 +0,0 @@
package tv.twitch.android.app.core;
import android.app.Activity;
public class LandingActivity extends Activity {}

View File

@@ -1,4 +1,4 @@
org.gradle.parallel = true
org.gradle.caching = true
android.useAndroidX = true
version = 0.124.1-dev.1
version = 1.0.0-dev.3