mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-07 10:35:49 +01:00
chore: Merge branch dev
to main
(#528)
This commit is contained in:
commit
0a15245f41
@ -1,3 +1,10 @@
|
|||||||
|
# [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)
|
## [0.124.1](https://github.com/ReVanced/revanced-integrations/compare/v0.124.0...v0.124.1) (2023-11-27)
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class ImportExportPreference extends EditTextPreference implements Prefer
|
|||||||
ReVancedSettingsFragment.settingImportInProgress = true;
|
ReVancedSettingsFragment.settingImportInProgress = true;
|
||||||
final boolean rebootNeeded = SettingsEnum.importJSON(replacementSettings);
|
final boolean rebootNeeded = SettingsEnum.importJSON(replacementSettings);
|
||||||
if (rebootNeeded) {
|
if (rebootNeeded) {
|
||||||
ReVancedSettingsFragment.showRebootDialog(getContext());
|
ReVancedSettingsFragment.showRestartDialog(getContext());
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LogHelper.printException(() -> "importSettings failure", ex);
|
LogHelper.printException(() -> "importSettings failure", ex);
|
||||||
|
@ -3,15 +3,10 @@ package app.revanced.integrations.settingsmenu;
|
|||||||
import static app.revanced.integrations.utils.StringRef.str;
|
import static app.revanced.integrations.utils.StringRef.str;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlarmManager;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Process;
|
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
@ -22,13 +17,12 @@ import android.preference.SwitchPreference;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
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.patches.playback.speed.CustomPlaybackSpeedPatch;
|
||||||
import app.revanced.integrations.settings.SettingsEnum;
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
import app.revanced.integrations.settings.SharedPrefCategory;
|
import app.revanced.integrations.settings.SharedPrefCategory;
|
||||||
import app.revanced.integrations.utils.LogHelper;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import app.revanced.integrations.utils.ReVancedUtils;
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
|
import app.revanced.shared.settings.SettingsUtils;
|
||||||
|
|
||||||
public class ReVancedSettingsFragment extends PreferenceFragment {
|
public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||||
/**
|
/**
|
||||||
@ -37,23 +31,13 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
|||||||
*/
|
*/
|
||||||
static boolean settingImportInProgress;
|
static boolean settingImportInProgress;
|
||||||
|
|
||||||
private static void reboot(@NonNull Context activity) {
|
static void showRestartDialog(@NonNull Context contxt) {
|
||||||
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) {
|
|
||||||
String positiveButton = str("in_app_update_restart_button");
|
String positiveButton = str("in_app_update_restart_button");
|
||||||
String negativeButton = str("sign_in_cancel");
|
new AlertDialog.Builder(contxt).setMessage(str("pref_refresh_config"))
|
||||||
new AlertDialog.Builder(activity).setMessage(str("pref_refresh_config"))
|
|
||||||
.setPositiveButton(positiveButton, (dialog, id) -> {
|
.setPositiveButton(positiveButton, (dialog, id) -> {
|
||||||
reboot(activity);
|
SettingsUtils.restartApp(contxt);
|
||||||
})
|
})
|
||||||
.setNegativeButton(negativeButton, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
@ -110,9 +94,9 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
|||||||
|
|
||||||
if (!showingUserDialogMessage) {
|
if (!showingUserDialogMessage) {
|
||||||
if (setting.userDialogMessage != null && ((SwitchPreference) pref).isChecked() != (Boolean) setting.defaultValue) {
|
if (setting.userDialogMessage != null && ((SwitchPreference) pref).isChecked() != (Boolean) setting.defaultValue) {
|
||||||
showSettingUserDialogConfirmation(getActivity(), (SwitchPreference) pref, setting);
|
showSettingUserDialogConfirmation(getContext(), (SwitchPreference) pref, setting);
|
||||||
} else if (setting.rebootApp) {
|
} 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;
|
showingUserDialogMessage = true;
|
||||||
new AlertDialog.Builder(activity)
|
new AlertDialog.Builder(context)
|
||||||
.setTitle(str("revanced_settings_confirm_user_dialog_title"))
|
.setTitle(str("revanced_settings_confirm_user_dialog_title"))
|
||||||
.setMessage(setting.userDialogMessage.toString())
|
.setMessage(setting.userDialogMessage.toString())
|
||||||
.setPositiveButton(android.R.string.ok, (dialog, id) -> {
|
.setPositiveButton(android.R.string.ok, (dialog, id) -> {
|
||||||
if (setting.rebootApp) {
|
if (setting.rebootApp) {
|
||||||
showRebootDialog(activity);
|
showRestartDialog(context);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, (dialog, id) -> {
|
.setNegativeButton(android.R.string.cancel, (dialog, id) -> {
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,22 @@
|
|||||||
package app.revanced.tiktok.settingsmenu;
|
package app.revanced.tiktok.settingsmenu;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlarmManager;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Process;
|
import android.preference.EditTextPreference;
|
||||||
import android.preference.*;
|
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 androidx.annotation.Nullable;
|
||||||
|
|
||||||
import app.revanced.integrations.utils.LogHelper;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.shared.settings.SettingsUtils;
|
||||||
import app.revanced.tiktok.settings.SettingsEnum;
|
import app.revanced.tiktok.settings.SettingsEnum;
|
||||||
import app.revanced.tiktok.settings.SharedPrefCategory;
|
import app.revanced.tiktok.settings.SharedPrefCategory;
|
||||||
import app.revanced.tiktok.settingsmenu.preference.DownloadPathPreference;
|
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.IntegrationsPreferenceCategory;
|
||||||
import app.revanced.tiktok.settingsmenu.preference.categories.SimSpoofPreferenceCategory;
|
import app.revanced.tiktok.settingsmenu.preference.categories.SimSpoofPreferenceCategory;
|
||||||
import app.revanced.tiktok.utils.ReVancedUtils;
|
import app.revanced.tiktok.utils.ReVancedUtils;
|
||||||
import com.ss.android.ugc.aweme.splash.SplashActivity;
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class ReVancedPreferenceFragment extends PreferenceFragment {
|
public class ReVancedPreferenceFragment extends PreferenceFragment {
|
||||||
@ -107,13 +111,9 @@ public class ReVancedPreferenceFragment extends PreferenceFragment {
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reboot(Activity activity) {
|
private void rebootDialog(@NonNull Context context) {
|
||||||
int intent = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE;
|
new AlertDialog.Builder(context).setMessage("Refresh and restart")
|
||||||
((AlarmManager) activity.getSystemService(Context.ALARM_SERVICE)).setExact(AlarmManager.ELAPSED_REALTIME, 1500L, PendingIntent.getActivity(activity, 0, new Intent(activity, SplashActivity.class), intent));
|
.setPositiveButton("Restart", (dialog, i) -> SettingsUtils.restartApp(context))
|
||||||
Process.killProcess(Process.myPid());
|
.setNegativeButton(android.R.string.cancel, null).show();
|
||||||
}
|
|
||||||
|
|
||||||
private void rebootDialog(final Activity activity) {
|
|
||||||
new AlertDialog.Builder(activity).setMessage("Refresh and restart").setPositiveButton("Restart", (dialog, i) -> reboot(activity)).setNegativeButton("Cancel", null).show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,10 @@
|
|||||||
package app.revanced.twitch.settingsmenu;
|
package app.revanced.twitch.settingsmenu;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlarmManager;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Process;
|
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
@ -17,12 +12,13 @@ import android.preference.PreferenceFragment;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.preference.SwitchPreference;
|
import android.preference.SwitchPreference;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import app.revanced.shared.settings.SettingsUtils;
|
||||||
import app.revanced.twitch.settings.SettingsEnum;
|
import app.revanced.twitch.settings.SettingsEnum;
|
||||||
import app.revanced.twitch.utils.LogHelper;
|
import app.revanced.twitch.utils.LogHelper;
|
||||||
import app.revanced.twitch.utils.ReVancedUtils;
|
import app.revanced.twitch.utils.ReVancedUtils;
|
||||||
import tv.twitch.android.app.core.LandingActivity;
|
|
||||||
|
|
||||||
public class ReVancedSettingsFragment extends PreferenceFragment {
|
public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||||
|
|
||||||
@ -62,7 +58,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ReVancedUtils.getContext() != null && key != null && settingsInitialized && setting.rebootApp) {
|
if (ReVancedUtils.getContext() != null && key != null && settingsInitialized && setting.rebootApp) {
|
||||||
rebootDialog(getActivity());
|
showRestartDialog(getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
// First onChange event is caused by initial state loading
|
// First onChange event is caused by initial state loading
|
||||||
@ -122,19 +118,12 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
private void showRestartDialog(@NonNull Context context) {
|
||||||
private void reboot(Activity activity) {
|
new AlertDialog.Builder(context).
|
||||||
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).
|
|
||||||
setMessage(ReVancedUtils.getString("revanced_reboot_message")).
|
setMessage(ReVancedUtils.getString("revanced_reboot_message")).
|
||||||
setPositiveButton(ReVancedUtils.getString("revanced_reboot"), (dialog, i) -> reboot(activity))
|
setPositiveButton(ReVancedUtils.getString("revanced_reboot"),
|
||||||
.setNegativeButton(ReVancedUtils.getString("revanced_cancel"), null)
|
(dialog, i) -> SettingsUtils.restartApp(context))
|
||||||
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
package com.google.android.apps.youtube.app.application;
|
|
||||||
|
|
||||||
//dummy class
|
|
||||||
public class Shell_HomeActivity {
|
|
||||||
}
|
|
@ -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 {
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
package tv.twitch.android.app.core;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
|
|
||||||
public class LandingActivity extends Activity {}
|
|
@ -1,4 +1,4 @@
|
|||||||
org.gradle.parallel = true
|
org.gradle.parallel = true
|
||||||
org.gradle.caching = true
|
org.gradle.caching = true
|
||||||
android.useAndroidX = true
|
android.useAndroidX = true
|
||||||
version = 0.124.1
|
version = 0.125.0-dev.1
|
||||||
|
Loading…
Reference in New Issue
Block a user