From b4ebace8090b2e0e6fb56a2266bdcc9d6c27b48f Mon Sep 17 00:00:00 2001 From: Armand <4831c0@proton.me> Date: Sun, 17 Aug 2025 11:22:12 +0200 Subject: [PATCH] android: remove dynamic icons from debug Dynamic icons break flutter run, the debugger, etc. So it's easier to just remove them from debug, and only enable them in the release build. --- .../android/app/src/debug/AndroidManifest.xml | 526 +----------------- .../android/app/src/main/AndroidManifest.xml | 523 +++++++++++++++++ .../kotlin/app/firka/naplo/MainActivity.kt | 7 +- .../app/firka/naplo/debug/MainActivity.kt | 101 ---- .../app/src/release/AndroidManifest.xml | 526 +----------------- firka/lib/helpers/settings/setting.dart | 9 + 6 files changed, 538 insertions(+), 1154 deletions(-) delete mode 100644 firka/android/app/src/main/kotlin/app/firka/naplo/debug/MainActivity.kt diff --git a/firka/android/app/src/debug/AndroidManifest.xml b/firka/android/app/src/debug/AndroidManifest.xml index c469f0a..0f06c9a 100644 --- a/firka/android/app/src/debug/AndroidManifest.xml +++ b/firka/android/app/src/debug/AndroidManifest.xml @@ -5,529 +5,5 @@ --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:usesCleartextTraffic="true" /> diff --git a/firka/android/app/src/main/AndroidManifest.xml b/firka/android/app/src/main/AndroidManifest.xml index 94e2549..5a0cc03 100644 --- a/firka/android/app/src/main/AndroidManifest.xml +++ b/firka/android/app/src/main/AndroidManifest.xml @@ -10,6 +10,529 @@ android:name=".AppMain" android:icon="@mipmap/launcher_icon"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/firka/android/app/src/main/kotlin/app/firka/naplo/MainActivity.kt b/firka/android/app/src/main/kotlin/app/firka/naplo/MainActivity.kt index d891395..ad687aa 100644 --- a/firka/android/app/src/main/kotlin/app/firka/naplo/MainActivity.kt +++ b/firka/android/app/src/main/kotlin/app/firka/naplo/MainActivity.kt @@ -33,6 +33,10 @@ class MainActivity : FlutterActivity() { "set_icon" -> { try { val pn = context.packageName + if (pn.endsWith(".debug")) { + result.success(true) + return@setMethodCallHandler + } val icon = call.argument("icon") val icons = call.argument("icons")!!.split(",") @@ -86,9 +90,6 @@ class MainActivity : FlutterActivity() { } } } - - - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) window.clearFlags(android.view.WindowManager.LayoutParams.FLAG_SECURE) diff --git a/firka/android/app/src/main/kotlin/app/firka/naplo/debug/MainActivity.kt b/firka/android/app/src/main/kotlin/app/firka/naplo/debug/MainActivity.kt deleted file mode 100644 index 0cc7524..0000000 --- a/firka/android/app/src/main/kotlin/app/firka/naplo/debug/MainActivity.kt +++ /dev/null @@ -1,101 +0,0 @@ -package app.firka.naplo.debug - -import android.content.ComponentName -import android.content.Intent -import android.util.Log -import android.content.pm.PackageManager -import android.os.Bundle -import io.flutter.embedding.android.FlutterActivity -import io.flutter.embedding.engine.FlutterEngine -import io.flutter.plugin.common.MethodChannel - -class MainActivity : FlutterActivity() { - - private val channel = "firka.app/main" - - private fun forceIconUpdate() { - try { - val intent = Intent("android.intent.action.MAIN") - intent.addCategory("android.intent.category.HOME") - intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK - context.startActivity(intent) - - } catch (_: Exception) { - Thread.sleep(2000) - } - } - - override fun configureFlutterEngine(flutterEngine: FlutterEngine) { - super.configureFlutterEngine(flutterEngine) - - MethodChannel(flutterEngine.dartExecutor.binaryMessenger, channel).setMethodCallHandler { - call, result -> - when (call.method) { - "set_icon" -> { - try { - val pn = context.packageName - val icon = call.argument("icon") - val icons = call.argument("icons")!!.split(",") - - if (icon != null) { - for (ic in icons) { - if (ic != icon) { - Log.d("firka", "disable: $ic") - packageManager.setComponentEnabledSetting( - ComponentName(pn, "$pn.$ic"), - PackageManager.COMPONENT_ENABLED_STATE_DISABLED, - PackageManager.DONT_KILL_APP - ) - } - } - - Log.d("firka", "enable: $icon") - packageManager.setComponentEnabledSetting( - ComponentName(pn, "$pn.$icon"), - PackageManager.COMPONENT_ENABLED_STATE_ENABLED, - PackageManager.DONT_KILL_APP - ) - - Log.d("firka", "disable: MainActivity") - packageManager.setComponentEnabledSetting( - ComponentName(pn, "$pn.MainActivity"), - PackageManager.COMPONENT_ENABLED_STATE_DISABLED, - 0 - ) - } else { - for (ic in icons) { - packageManager.setComponentEnabledSetting( - ComponentName(pn, "$pn.$ic"), - PackageManager.COMPONENT_ENABLED_STATE_DISABLED, - PackageManager.DONT_KILL_APP - ) - } - - packageManager.setComponentEnabledSetting( - ComponentName(pn, "$pn.MainActivity"), - PackageManager.COMPONENT_ENABLED_STATE_ENABLED, - 0 - ) - } - - forceIconUpdate() - } catch (e: Exception) { - e.printStackTrace() - } - result.success(true) - } - else -> { - result.notImplemented() - } - } - } - } - - - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - window.clearFlags(android.view.WindowManager.LayoutParams.FLAG_SECURE) - } - -} diff --git a/firka/android/app/src/release/AndroidManifest.xml b/firka/android/app/src/release/AndroidManifest.xml index 832949f..e0eea99 100644 --- a/firka/android/app/src/release/AndroidManifest.xml +++ b/firka/android/app/src/release/AndroidManifest.xml @@ -4,529 +4,5 @@ to allow setting breakpoints, to provide hot reload, etc. --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/firka/lib/helpers/settings/setting.dart b/firka/lib/helpers/settings/setting.dart index 3b7683f..702d2bc 100644 --- a/firka/lib/helpers/settings/setting.dart +++ b/firka/lib/helpers/settings/setting.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:firka/helpers/db/models/app_settings_model.dart'; import 'package:firka/ui/widget/firka_icon.dart'; +import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; import 'package:majesticons_flutter/majesticons_flutter.dart'; @@ -69,6 +70,10 @@ bool isAndroid() { return Platform.isAndroid; } +bool isDebug() { + return kDebugMode; +} + class SettingsStore { LinkedHashMap items = LinkedHashMap.of({}); @@ -137,6 +142,10 @@ class SettingsStore { "Ikon cseréje", LinkedHashMap.of({ "icon_header": SettingsHeader(0, "App ikon", always), + "warning_header": SettingsHeader( + 0, + "[!] Debug nem fog működni az ikon megváltoztatása", + isDebug), "icon_subtitle": SettingsSubtitle( 0, "Válassz egy csodaszép app ikont, ha már unod a zöldet.",