Skip to content

Commit

Permalink
remove user interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminHalko committed Sep 27, 2023
1 parent 96736af commit 02822f4
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 173 deletions.
14 changes: 1 addition & 13 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,7 @@
</activity>
<activity
android:name=".ExportSettingsActivity"
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>
android:exported="true">
</activity>
<meta-data
android:name="flutterEmbedding"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,56 @@
package app.revanced.manager.flutter

import android.app.Activity
import android.content.Context
import android.content.Intent
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.TransparencyMode
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import java.io.Serializable

class ExportSettingsActivity : FlutterActivity() {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)

val settingsChannel = "app.revanced.manager.flutter/settings"

val mainChannel =
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, settingsChannel)

mainChannel.setMethodCallHandler { call, result ->
when (call.method) {
"accept" -> {
val data = call.argument<String>("data")
val resultIntent = Intent()
resultIntent.putExtra("data", data as Serializable)
setResult(Activity.RESULT_OK, resultIntent)
finish()
}
"deny" -> {
setResult(Activity.RESULT_CANCELED)
finish()
}
else -> result.notImplemented()
}
import android.os.Bundle
import android.util.Base64
import org.json.JSONObject
import java.io.File

import android.util.Log

class ExportSettingsActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val json = JSONObject()

// Default Data
json.put("keystorePassword", "s3cur3p@ssw0rd")

// Load Shared Preferences
val sharedPreferences = getSharedPreferences("FlutterSharedPreferences", Context.MODE_PRIVATE)
val allEntries: Map<String, *> = sharedPreferences.getAll()
for ((key, value) in allEntries.entries) {
json.put(
key.replace("flutter.", ""),
if (value is Boolean) if (value) 1 else 0 else value
)
}
}

override fun getDartEntrypointFunctionName(): String {
return "mainExportSettings"
}
// Load keystore
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)
}

// Load saved patches
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)
}

override fun getTransparencyMode(): TransparencyMode {
return TransparencyMode.transparent
// Send data back
Log.e("ExportSettingsActivity", json.toString())
val resultIntent = Intent()
resultIntent.putExtra("data", json.toString())
setResult(Activity.RESULT_OK, resultIntent)
finish()
}
}
6 changes: 0 additions & 6 deletions android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,4 @@
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</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>
6 changes: 0 additions & 6 deletions assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,5 @@
"integrationsContributors": "Integrations contributors",
"cliContributors": "CLI 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"
}
}
16 changes: 3 additions & 13 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,13 @@ import 'package:revanced_manager/services/github_api.dart';
import 'package:revanced_manager/services/manager_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/views/export_settings/export_settings_view.dart';
import 'package:revanced_manager/ui/views/navigation/navigation_view.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:stacked_themes/stacked_themes.dart';
import 'package:timezone/data/latest.dart' as tz;

late SharedPreferences prefs;
Future main() async {
initialize(const NavigationView());
}

Future mainExportSettings() async {
initialize(const ExportSettingsView());
}

Future initialize(Widget homeView) async {
await ThemeManager.initialise();
await setupLocator();
WidgetsFlutterBinding.ensureInitialized();
Expand All @@ -35,12 +26,11 @@ Future initialize(Widget homeView) async {
tz.initializeTimeZones();
prefs = await SharedPreferences.getInstance();

runApp(MyApp(homeView: homeView));
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({Key? key, required this.homeView}) : super(key: key);
final Widget homeView;
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
Expand All @@ -52,7 +42,7 @@ class MyApp extends StatelessWidget {

return DynamicThemeBuilder(
title: 'ReVanced Manager',
home: homeView,
home: const NavigationView(),
localizationsDelegates: [
FlutterI18nDelegate(
translationLoader: FileTranslationLoader(
Expand Down
41 changes: 0 additions & 41 deletions lib/ui/views/export_settings/export_settings_view.dart

This file was deleted.

58 changes: 0 additions & 58 deletions lib/ui/views/export_settings/export_settings_viewmodel.dart

This file was deleted.

0 comments on commit 02822f4

Please sign in to comment.