mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
remove user interaction
This commit is contained in:
parent
96736afb94
commit
02822f4b38
@ -44,19 +44,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ExportSettingsActivity"
|
android:name=".ExportSettingsActivity"
|
||||||
android:exported="true"
|
android:exported="true">
|
||||||
android:launchMode="singleTop"
|
|
||||||
android:theme="@style/ExportSettingsTheme"
|
|
||||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
|
||||||
android:hardwareAccelerated="true"
|
|
||||||
android:windowSoftInputMode="adjustResize">
|
|
||||||
<meta-data
|
|
||||||
android:name="io.flutter.embedding.android.NormalTheme"
|
|
||||||
android:resource="@style/ExportSettingsTheme"/>
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW"/>
|
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
</activity>
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="flutterEmbedding"
|
android:name="flutterEmbedding"
|
||||||
|
@ -1,45 +1,56 @@
|
|||||||
package app.revanced.manager.flutter
|
package app.revanced.manager.flutter
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import android.os.Bundle
|
||||||
import io.flutter.embedding.android.TransparencyMode
|
import android.util.Base64
|
||||||
import io.flutter.embedding.engine.FlutterEngine
|
import org.json.JSONObject
|
||||||
import io.flutter.plugin.common.MethodChannel
|
import java.io.File
|
||||||
import java.io.Serializable
|
|
||||||
|
|
||||||
class ExportSettingsActivity : FlutterActivity() {
|
import android.util.Log
|
||||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
|
||||||
super.configureFlutterEngine(flutterEngine)
|
|
||||||
|
|
||||||
val settingsChannel = "app.revanced.manager.flutter/settings"
|
class ExportSettingsActivity : Activity() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
val mainChannel =
|
val json = JSONObject()
|
||||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, settingsChannel)
|
|
||||||
|
|
||||||
mainChannel.setMethodCallHandler { call, result ->
|
// Default Data
|
||||||
when (call.method) {
|
json.put("keystorePassword", "s3cur3p@ssw0rd")
|
||||||
"accept" -> {
|
|
||||||
val data = call.argument<String>("data")
|
// Load Shared Preferences
|
||||||
val resultIntent = Intent()
|
val sharedPreferences = getSharedPreferences("FlutterSharedPreferences", Context.MODE_PRIVATE)
|
||||||
resultIntent.putExtra("data", data as Serializable)
|
val allEntries: Map<String, *> = sharedPreferences.getAll()
|
||||||
setResult(Activity.RESULT_OK, resultIntent)
|
for ((key, value) in allEntries.entries) {
|
||||||
finish()
|
json.put(
|
||||||
}
|
key.replace("flutter.", ""),
|
||||||
"deny" -> {
|
if (value is Boolean) if (value) 1 else 0 else value
|
||||||
setResult(Activity.RESULT_CANCELED)
|
)
|
||||||
finish()
|
|
||||||
}
|
|
||||||
else -> result.notImplemented()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun getDartEntrypointFunctionName(): String {
|
// Load keystore
|
||||||
return "mainExportSettings"
|
val keystoreFile = File(getExternalFilesDir(null), "/revanced-manager.keystore")
|
||||||
}
|
if (keystoreFile.exists()) {
|
||||||
|
val keystoreBytes = keystoreFile.readBytes()
|
||||||
|
val keystoreBase64 =
|
||||||
|
Base64.encodeToString(keystoreBytes, Base64.DEFAULT).replace("\n", "")
|
||||||
|
json.put("keystore", keystoreBase64)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getTransparencyMode(): TransparencyMode {
|
// Load saved patches
|
||||||
return TransparencyMode.transparent
|
val storedPatchesFile = File(filesDir.parentFile.absolutePath, "/app_flutter/selected-patches.json")
|
||||||
|
if (storedPatchesFile.exists()) {
|
||||||
|
val patchesBytes = storedPatchesFile.readBytes()
|
||||||
|
val patches = String(patchesBytes, Charsets.UTF_8)
|
||||||
|
json.put("patches", patches)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send data back
|
||||||
|
Log.e("ExportSettingsActivity", json.toString())
|
||||||
|
val resultIntent = Intent()
|
||||||
|
resultIntent.putExtra("data", json.toString())
|
||||||
|
setResult(Activity.RESULT_OK, resultIntent)
|
||||||
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,4 @@
|
|||||||
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||||
<item name="android:windowBackground">?android:colorBackground</item>
|
<item name="android:windowBackground">?android:colorBackground</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ExportSettingsTheme" parent="android:Theme.Light.NoTitleBar">
|
|
||||||
<item name="android:windowIsTranslucent">true</item>
|
|
||||||
<item name="android:windowBackground">#52000000</item>
|
|
||||||
<item name="android:windowContentOverlay">@null</item>
|
|
||||||
</style>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -304,11 +304,5 @@
|
|||||||
"integrationsContributors": "Integrations contributors",
|
"integrationsContributors": "Integrations contributors",
|
||||||
"cliContributors": "CLI contributors",
|
"cliContributors": "CLI contributors",
|
||||||
"managerContributors": "Manager contributors"
|
"managerContributors": "Manager contributors"
|
||||||
},
|
|
||||||
"exportSettingsView": {
|
|
||||||
"widgetTitle": "Import settings",
|
|
||||||
"description": "Would you like to import your settings to the previous version of ReVanced Manager?",
|
|
||||||
"exportButton": "Import",
|
|
||||||
"dismissButton": "No thanks"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import 'package:revanced_manager/services/github_api.dart';
|
|||||||
import 'package:revanced_manager/services/manager_api.dart';
|
import 'package:revanced_manager/services/manager_api.dart';
|
||||||
import 'package:revanced_manager/services/revanced_api.dart';
|
import 'package:revanced_manager/services/revanced_api.dart';
|
||||||
import 'package:revanced_manager/ui/theme/dynamic_theme_builder.dart';
|
import 'package:revanced_manager/ui/theme/dynamic_theme_builder.dart';
|
||||||
import 'package:revanced_manager/ui/views/export_settings/export_settings_view.dart';
|
|
||||||
import 'package:revanced_manager/ui/views/navigation/navigation_view.dart';
|
import 'package:revanced_manager/ui/views/navigation/navigation_view.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:stacked_themes/stacked_themes.dart';
|
import 'package:stacked_themes/stacked_themes.dart';
|
||||||
@ -16,14 +15,6 @@ import 'package:timezone/data/latest.dart' as tz;
|
|||||||
|
|
||||||
late SharedPreferences prefs;
|
late SharedPreferences prefs;
|
||||||
Future main() async {
|
Future main() async {
|
||||||
initialize(const NavigationView());
|
|
||||||
}
|
|
||||||
|
|
||||||
Future mainExportSettings() async {
|
|
||||||
initialize(const ExportSettingsView());
|
|
||||||
}
|
|
||||||
|
|
||||||
Future initialize(Widget homeView) async {
|
|
||||||
await ThemeManager.initialise();
|
await ThemeManager.initialise();
|
||||||
await setupLocator();
|
await setupLocator();
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
@ -35,12 +26,11 @@ Future initialize(Widget homeView) async {
|
|||||||
tz.initializeTimeZones();
|
tz.initializeTimeZones();
|
||||||
prefs = await SharedPreferences.getInstance();
|
prefs = await SharedPreferences.getInstance();
|
||||||
|
|
||||||
runApp(MyApp(homeView: homeView));
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
const MyApp({Key? key, required this.homeView}) : super(key: key);
|
const MyApp({Key? key}) : super(key: key);
|
||||||
final Widget homeView;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -52,7 +42,7 @@ class MyApp extends StatelessWidget {
|
|||||||
|
|
||||||
return DynamicThemeBuilder(
|
return DynamicThemeBuilder(
|
||||||
title: 'ReVanced Manager',
|
title: 'ReVanced Manager',
|
||||||
home: homeView,
|
home: const NavigationView(),
|
||||||
localizationsDelegates: [
|
localizationsDelegates: [
|
||||||
FlutterI18nDelegate(
|
FlutterI18nDelegate(
|
||||||
translationLoader: FileTranslationLoader(
|
translationLoader: FileTranslationLoader(
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
|
||||||
import 'package:revanced_manager/ui/views/export_settings/export_settings_viewmodel.dart';
|
|
||||||
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
|
||||||
|
|
||||||
final _exportSettingsViewModel = ExportSettingsViewModel();
|
|
||||||
|
|
||||||
class ExportSettingsView extends StatelessWidget {
|
|
||||||
const ExportSettingsView({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
SystemChrome.setSystemUIOverlayStyle(
|
|
||||||
SystemUiOverlayStyle(
|
|
||||||
systemNavigationBarColor: Colors.black.withOpacity(0.002),
|
|
||||||
statusBarColor: Colors.black.withOpacity(0.002),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
|
||||||
|
|
||||||
return AlertDialog(
|
|
||||||
title: I18nText('exportSettingsView.widgetTitle'),
|
|
||||||
content: I18nText('exportSettingsView.description'),
|
|
||||||
icon: const Icon(Icons.update),
|
|
||||||
actions: <Widget> [
|
|
||||||
CustomMaterialButton(
|
|
||||||
isFilled: false,
|
|
||||||
label: I18nText('exportSettingsView.dismissButton'),
|
|
||||||
onPressed: _exportSettingsViewModel.deny,
|
|
||||||
),
|
|
||||||
CustomMaterialButton(
|
|
||||||
label: I18nText('exportSettingsView.exportButton'),
|
|
||||||
onPressed: () async {
|
|
||||||
await _exportSettingsViewModel.accept();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:dynamic_themes/dynamic_themes.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:injectable/injectable.dart';
|
|
||||||
import 'package:path_provider/path_provider.dart';
|
|
||||||
import 'package:revanced_manager/app/app.locator.dart';
|
|
||||||
import 'package:revanced_manager/services/manager_api.dart';
|
|
||||||
import 'package:stacked/stacked.dart';
|
|
||||||
|
|
||||||
@lazySingleton
|
|
||||||
class ExportSettingsViewModel extends BaseViewModel {
|
|
||||||
final _channel = const MethodChannel('app.revanced.manager.flutter/settings');
|
|
||||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
|
||||||
|
|
||||||
Future<void> accept() async {
|
|
||||||
final externalDir = await getExternalStorageDirectory();
|
|
||||||
|
|
||||||
final Map<String, dynamic> data = {};
|
|
||||||
|
|
||||||
data['themeMode'] = _managerAPI.getThemeMode();
|
|
||||||
data['useDynamicTheme'] = _managerAPI.getUseDynamicTheme() ? 1 : 0;
|
|
||||||
|
|
||||||
data['apiUrl'] = _managerAPI.getApiUrl();
|
|
||||||
data['patchesRepo'] = _managerAPI.getPatchesRepo();
|
|
||||||
data['integrationsRepo'] = _managerAPI.getIntegrationsRepo();
|
|
||||||
|
|
||||||
data['patchesAutoUpdate'] = _managerAPI.isPatchesAutoUpdate() ? 1 : 0;
|
|
||||||
data['patchesChangeEnabled'] = _managerAPI.isPatchesChangeEnabled() ? 1 : 0;
|
|
||||||
data['universalPatchesEnabled'] = _managerAPI.areUniversalPatchesEnabled() ? 1 : 0;
|
|
||||||
data['experimentalPatchesEnabled'] = _managerAPI.areExperimentalPatchesEnabled() ? 1 : 0;
|
|
||||||
|
|
||||||
data['keystorePassword'] = _managerAPI.getKeystorePassword();
|
|
||||||
|
|
||||||
// Load keystore
|
|
||||||
if (externalDir != null) {
|
|
||||||
final keystoreFile = File('${externalDir.path}/revanced-manager.keystore');
|
|
||||||
if (keystoreFile.existsSync()) {
|
|
||||||
final keystoreBytes = keystoreFile.readAsBytesSync();
|
|
||||||
data['keystore'] = base64Encode(keystoreBytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load patches
|
|
||||||
final patchFile = File(_managerAPI.storedPatchesFile);
|
|
||||||
if (patchFile.existsSync()) {
|
|
||||||
data['patches'] = patchFile.readAsStringSync();
|
|
||||||
}
|
|
||||||
|
|
||||||
_channel.invokeMethod('accept', {'data': jsonEncode(data)});
|
|
||||||
}
|
|
||||||
|
|
||||||
void deny() {
|
|
||||||
_channel.invokeMethod('deny');
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user