Compare commits

..

5 Commits

Author SHA1 Message Date
semantic-release-bot
aaa97ebb71 chore(release): 1.23.0-dev.6 [skip ci]
# [1.23.0-dev.6](https://github.com/ReVanced/revanced-manager/compare/v1.23.0-dev.5...v1.23.0-dev.6) (2024-11-08)
2024-11-08 17:49:03 +00:00
oSumAtrIX
d99e5af384 build: Fix build 2024-11-08 18:39:02 +01:00
oSumAtrIX
c47c7c0a88 build(Needs bump): Bump dependencies 2024-11-05 20:13:08 +01:00
semantic-release-bot
3e32c0fd90 chore(release): 1.23.0-dev.5 [skip ci]
# [1.23.0-dev.5](https://github.com/ReVanced/revanced-manager/compare/v1.23.0-dev.4...v1.23.0-dev.5) (2024-11-05)

### Features

* Import and export manager settings ([#2268](https://github.com/ReVanced/revanced-manager/issues/2268)) ([a45d959](a45d9598cc))
2024-11-05 18:52:52 +00:00
aAbed
a45d9598cc feat: Import and export manager settings (#2268) 2024-11-05 19:43:35 +01:00
13 changed files with 135 additions and 17 deletions

View File

@@ -7,7 +7,7 @@ plugins {
android {
namespace = "app.revanced.manager.flutter"
compileSdk = 34
compileSdk = 35
ndkVersion = "27.0.12077973"
compileOptions {
@@ -24,9 +24,11 @@ android {
defaultConfig {
applicationId = "app.revanced.manager.flutter"
minSdk = 26
targetSdk = 34
targetSdk = 35
versionCode = flutter.versionCode
versionName = flutter.versionName
resValue("string", "app_name", "ReVanced Manager")
}
buildTypes {
@@ -37,6 +39,7 @@ android {
signingConfig = signingConfigs["debug"]
ndk.abiFilters += setOf("armeabi-v7a", "arm64-v8a", "x86_64")
setProperty("archivesBaseName", "revanced-manager-v${flutter.versionName}")
}
@@ -52,14 +55,16 @@ android {
keyAlias = System.getenv("KEYSTORE_ENTRY_ALIAS")
keyPassword = System.getenv("KEYSTORE_ENTRY_PASSWORD")
}
resValue("string", "app_name", "ReVanced Manager")
} else {
resValue("string", "app_name", "ReVanced Manager (Debug)")
applicationIdSuffix = ".debug"
signingConfig = signingConfigs["debug"]
}
resValue("string", "app_name", "ReVanced Manager")
resValue("string", "app_name", "ReVanced Manager (Debug)")
}
}
debug {
@@ -80,6 +85,7 @@ android {
}
}
flutter {
source = "../.."
}

View File

@@ -3,7 +3,6 @@ package app.revanced.manager.flutter
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.os.Bundle
import android.util.Base64
@@ -17,9 +16,8 @@ import java.security.MessageDigest
class ExportSettingsActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val callingPackageName = getCallingPackage()!!
if (getFingerprint(callingPackageName) == getFingerprint(getPackageName())) {
if (getFingerprint(callingPackage!!) == getFingerprint(packageName)) {
// Create JSON Object
val json = JSONObject()
@@ -64,7 +62,7 @@ class ExportSettingsActivity : Activity() {
fun getFingerprint(packageName: String): String {
// Get the signature of the app that matches the package name
val packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES)
val signature = packageInfo.signatures[0]
val signature = packageInfo.signatures!![0]
// Get the raw certificate data
val rawCert = signature.toByteArray()

View File

@@ -283,7 +283,6 @@ class MainActivity : FlutterActivity() {
tmpDir,
Aapt.binary(applicationContext).absolutePath,
tmpDir.path,
true // TODO: Add option to disable this
)
)

View File

@@ -1,4 +1,5 @@
import com.android.build.api.dsl.CommonExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
allprojects {
repositories {
@@ -17,6 +18,14 @@ allprojects {
layout.buildDirectory = File("../build")
project(":screenshot_callback") {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "17"
}
}
}
subprojects {
afterEvaluate {
extensions.findByName("android")?.let {

View File

@@ -3,6 +3,5 @@ android.useAndroidX=true
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.caching=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false

View File

@@ -1,7 +1,7 @@
[versions]
revanced-patcher = "20.0.2"
revanced-library = "3.0.1"
desugar_jdk_libs = "2.1.2"
revanced-patcher = "21.0.0"
revanced-library = "3.0.2"
desugar_jdk_libs = "2.1.3"
[libraries]
revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" }

View File

@@ -17,7 +17,7 @@ pluginManagement {
plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.5.0" apply false
id("com.android.application") version "8.7.2" apply false
id("org.jetbrains.kotlin.android") version "2.0.20" apply false
}

View File

@@ -197,6 +197,12 @@
"deleteTempDirLabel": "Delete temporary files",
"deleteTempDirHint": "Delete unused temporary files",
"deletedTempDir": "Temporary files deleted",
"exportSettingsLabel": "Export settings",
"exportSettingsHint": "Export settings to a JSON file",
"exportedSettings": "Settings exported",
"importSettingsLabel": "Import settings",
"importSettingsHint": "Import settings from a JSON file",
"importedSettings": "Settings imported",
"exportPatchesLabel": "Export patch selection",
"exportPatchesHint": "Export patch selection to a JSON file",
"exportedPatches": "Patch selection exported",

View File

@@ -50,6 +50,7 @@ Learn how to configure ReVanced Manager.
- 🔑 Keystore used to sign patched apps
- 📄 Remembered selection of patches for each app
- ⚙️ Remembered patch options
- 🛠️ Remembered settings
> Note
> These can be used to backup and restore or reset settings to default in case of issues.

View File

@@ -755,6 +755,36 @@ class ManagerAPI {
return jsonDecode(string);
}
String exportSettings() {
final Map<String, dynamic> settings = _prefs
.getKeys()
.fold<Map<String, dynamic>>({}, (Map<String, dynamic> map, String key) {
map[key] = _prefs.get(key);
return map;
});
return jsonEncode(settings);
}
Future<void> importSettings(String settings) async {
final Map<String, dynamic> settingsMap = jsonDecode(settings);
settingsMap.forEach((key, value) {
if (value is bool) {
_prefs.setBool(key, value);
} else if (value is int) {
_prefs.setInt(key, value);
} else if (value is double) {
_prefs.setDouble(key, value);
} else if (value is String) {
_prefs.setString(key, value);
} else if (value is List<dynamic>) {
_prefs.setStringList(
key,
value.map((a) => json.encode(a.toJson())).toList(),
);
}
});
}
void resetAllOptions() {
_prefs.getKeys().where((key) => key.startsWith('patchOption-')).forEach(
(key) {

View File

@@ -222,6 +222,53 @@ class SettingsViewModel extends BaseViewModel {
notifyListeners();
}
Future<void> exportSettings() async {
try {
final String settings = _managerAPI.exportSettings();
final Directory tempDir = await getTemporaryDirectory();
final String filePath = '${tempDir.path}/manager_settings.json';
final File file = File(filePath);
await file.writeAsString(settings);
final String? result = await FlutterFileDialog.saveFile(
params: SaveFileDialogParams(
sourceFilePath: file.path,
fileName: 'manager_settings.json',
mimeTypesFilter: ['application/json'],
),
);
if (result != null) {
_toast.showBottom(t.settingsView.exportedSettings);
}
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
}
Future<void> importSettings() async {
try {
final String? result = await FlutterFileDialog.pickFile(
params: const OpenFileDialogParams(
fileExtensionsFilter: ['json'],
),
);
if (result != null) {
final File inFile = File(result);
final String settings = inFile.readAsStringSync();
inFile.delete();
_managerAPI.importSettings(settings);
_toast.showBottom(t.settingsView.importedSettings);
_toast.showBottom(t.settingsView.restartAppForChanges);
}
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
_toast.showBottom(t.settingsView.jsonSelectorErrorMessage);
}
}
Future<void> exportPatches() async {
try {
final File outFile = File(_managerAPI.storedPatchesFile);

View File

@@ -14,6 +14,30 @@ class SExportSection extends StatelessWidget {
return SettingsSection(
title: t.settingsView.exportSectionTitle,
children: <Widget>[
ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
title: Text(
t.settingsView.exportSettingsLabel,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
subtitle: Text(t.settingsView.exportSettingsHint),
onTap: () => _settingsViewModel.exportSettings(),
),
ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
title: Text(
t.settingsView.importSettingsLabel,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
subtitle: Text(t.settingsView.importSettingsHint),
onTap: () => _settingsViewModel.importSettings(),
),
ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
title: Text(
@@ -114,7 +138,6 @@ class SExportSection extends StatelessWidget {
subtitle: Text(t.settingsView.regenerateKeystoreHint),
onTap: () => _showDeleteKeystoreDialog(context),
),
// SManageKeystorePasswordUI(),
],
);
}

View File

@@ -4,7 +4,7 @@ homepage: https://revanced.app
publish_to: 'none'
version: 1.23.0-dev.4+101800044
version: 1.23.0-dev.6+101800046
environment:
sdk: ^3.5.3