-
-
Notifications
You must be signed in to change notification settings - Fork 779
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96736af
commit 02822f4
Showing
7 changed files
with
51 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 47 additions & 36 deletions
83
android/app/src/main/kotlin/app/revanced/manager/flutter/ExportSettingsActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
58 changes: 0 additions & 58 deletions
58
lib/ui/views/export_settings/export_settings_viewmodel.dart
This file was deleted.
Oops, something went wrong.