Skip to content

Commit 2fbb96f

Browse files
committed
Add sqlite store
Optimize android quick action Optimize backup and restore Optimize more details
1 parent 243b303 commit 2fbb96f

File tree

214 files changed

+16723
-11815
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+16723
-11815
lines changed

.gitignore

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ migrate_working_dir/
2121
# The .vscode folder contains launch configuration and tasks you configure in
2222
# VS Code which you may wish to be included in version control, so this line
2323
# is commented out by default.
24-
#.vscode/
24+
.vscode/
2525

2626
# Flutter/Dart/Pub related
2727
**/doc/api/
@@ -41,6 +41,11 @@ app.*.symbols
4141
# Obfuscation related
4242
app.*.map.json
4343

44+
#AI generated
45+
CLAUDE.md
46+
/.claude
47+
48+
4449
# Android Studio will place build artifacts here
4550
/android/app/debug
4651
/android/app/profile
@@ -53,11 +58,13 @@ app.*.map.json
5358
/android/core/**/cmake-build-*/
5459
/android/core/**/jniLibs/
5560

56-
5761
#FlClash
5862
/libclash/
5963
/android/app/src/main/jniLibs/
6064
/services/helper/target
6165
/macos/**/Package.resolved
6266
devtools_options.yaml
6367

68+
# FVM Version Cache
69+
.fvm/
70+
.fvmrc

.metadata

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,23 @@
11
# This file tracks properties of this Flutter project.
22
# Used by Flutter tool to assess capabilities and perform upgrades etc.
33
#
4-
# This file should be version controlled.
4+
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: 796c8ef79279f9c774545b3771238c3098dbefab
8-
channel: stable
7+
revision: "adc901062556672b4138e18a4dc62a4be8f4b3c2"
8+
channel: "stable"
99

1010
project_type: app
1111

1212
# Tracks metadata for the flutter migrate command
1313
migration:
1414
platforms:
1515
- platform: root
16-
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
17-
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
18-
- platform: android
19-
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
20-
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
21-
- platform: ios
22-
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
23-
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
24-
- platform: linux
25-
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
26-
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
27-
- platform: macos
28-
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
29-
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
30-
- platform: web
31-
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
32-
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
16+
create_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
17+
base_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
3318
- platform: windows
34-
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
35-
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
19+
create_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
20+
base_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
3621

3722
# User provided section
3823

.run/main.dart.run.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="main.dart" type="FlutterRunConfigurationType" factoryName="Flutter">
3+
<option name="additionalArgs" value="--dart-define-from-file env.json" />
4+
<option name="filePath" value="$PROJECT_DIR$/lib/main.dart" />
5+
<method v="2" />
6+
</configuration>
7+
</component>

Makefile

Lines changed: 0 additions & 10 deletions
This file was deleted.

android/app/build.gradle.kts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,17 @@ android {
6464
buildTypes {
6565
debug {
6666
isMinifyEnabled = false
67-
applicationIdSuffix = ".debug"
67+
applicationIdSuffix = ".dev"
6868
}
6969

7070
release {
7171
isMinifyEnabled = true
7272
isShrinkResources = true
73-
signingConfig = if (isRelease) {
74-
signingConfigs.getByName("release")
73+
if (isRelease) {
74+
signingConfig = signingConfigs.getByName("release")
7575
} else {
76-
signingConfigs.getByName("debug")
76+
signingConfig = signingConfigs.getByName("debug")
77+
applicationIdSuffix = ".dev"
7778
}
7879

7980
proguardFiles(

android/app/google-services.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@
4141
"other_platform_oauth_client": []
4242
}
4343
}
44+
},
45+
{
46+
"client_info": {
47+
"mobilesdk_app_id": "1:000000000000:android:0000000000000000",
48+
"android_client_info": {
49+
"package_name": "com.follow.clash.dev"
50+
}
51+
},
52+
"oauth_client": [],
53+
"api_key": [
54+
{
55+
"current_key": "0"
56+
}
57+
],
58+
"services": {
59+
"appinvite_service": {
60+
"other_platform_oauth_client": []
61+
}
62+
}
4463
}
4564
]
4665
}

android/app/src/main/kotlin/com/follow/clash/Ext.kt

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
package com.follow.clash
22

3+
import android.app.Application
4+
import android.content.Context.MODE_PRIVATE
35
import android.content.pm.PackageManager
46
import android.graphics.Bitmap
57
import android.graphics.drawable.Drawable
68
import android.os.Build
79
import android.os.Handler
810
import android.os.Looper
11+
import android.widget.Toast
912
import androidx.core.graphics.drawable.toBitmap
1013
import com.follow.clash.common.GlobalState
14+
import com.follow.clash.models.SharedState
15+
import com.google.gson.Gson
1116
import io.flutter.embedding.engine.FlutterEngine
1217
import io.flutter.embedding.engine.plugins.FlutterPlugin
1318
import io.flutter.plugin.common.MethodChannel
@@ -21,6 +26,30 @@ import kotlin.coroutines.resume
2126

2227
private const val ICON_TTL_DAYS = 1L
2328

29+
val Application.sharedState: SharedState
30+
get() {
31+
try {
32+
val sp = getSharedPreferences("FlutterSharedPreferences", MODE_PRIVATE)
33+
val res = sp.getString("flutter.sharedState", "")
34+
return Gson().fromJson(res, SharedState::class.java)
35+
} catch (_: Exception) {
36+
return SharedState()
37+
}
38+
}
39+
40+
41+
private var lastToast: Toast? = null
42+
43+
fun Application.showToast(text: String?) {
44+
Handler(Looper.getMainLooper()).post {
45+
lastToast?.cancel()
46+
lastToast = Toast.makeText(this, text, Toast.LENGTH_LONG).apply {
47+
show()
48+
}
49+
}
50+
51+
}
52+
2453
suspend fun PackageManager.getPackageIconPath(packageName: String): String =
2554
withContext(Dispatchers.IO) {
2655
val cacheDir = GlobalState.application.cacheDir
@@ -118,4 +147,4 @@ fun <T> MethodChannel.invokeMethodOnMainThread(
118147
}
119148
})
120149
}
121-
}
150+
}

android/app/src/main/kotlin/com/follow/clash/MainActivity.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.follow.clash
22

33
import android.os.Bundle
4-
import androidx.lifecycle.lifecycleScope
54
import com.follow.clash.common.GlobalState
65
import com.follow.clash.plugins.AppPlugin
76
import com.follow.clash.plugins.ServicePlugin
@@ -18,9 +17,6 @@ class MainActivity : FlutterActivity(),
1817

1918
override fun onCreate(savedInstanceState: Bundle?) {
2019
super.onCreate(savedInstanceState)
21-
lifecycleScope.launch {
22-
State.destroyServiceEngine()
23-
}
2420
}
2521

2622
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {

android/app/src/main/kotlin/com/follow/clash/Service.kt

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.follow.clash
22

3+
import com.follow.clash.common.GlobalState
34
import com.follow.clash.common.ServiceDelegate
45
import com.follow.clash.common.formatString
56
import com.follow.clash.common.intent
@@ -8,6 +9,7 @@ import com.follow.clash.service.ICallbackInterface
89
import com.follow.clash.service.IEventInterface
910
import com.follow.clash.service.IRemoteInterface
1011
import com.follow.clash.service.IResultInterface
12+
import com.follow.clash.service.IVoidInterface
1113
import com.follow.clash.service.RemoteService
1214
import com.follow.clash.service.models.NotificationParams
1315
import com.follow.clash.service.models.VpnOptions
@@ -40,7 +42,7 @@ object Service {
4042
delegate.unbind()
4143
}
4244

43-
suspend fun invokeAction(data: String, cb: (result: String) -> Unit): Result<Unit> {
45+
suspend fun invokeAction(data: String, cb: ((result: String) -> Unit)?): Result<Unit> {
4446
val res = mutableListOf<ByteArray>()
4547
return delegate.useService {
4648
it.invokeAction(
@@ -51,38 +53,75 @@ object Service {
5153
res.add(result ?: byteArrayOf())
5254
ack?.onAck()
5355
if (isSuccess) {
54-
cb(res.formatString())
56+
cb?.let { cb ->
57+
cb(res.formatString())
58+
}
5559
}
5660
}
5761
})
5862
}
5963
}
6064

65+
suspend fun quickSetup(
66+
initParamsString: String,
67+
setupParamsString: String,
68+
onStarted: (() -> Unit)?,
69+
onResult: ((result: String) -> Unit)?,
70+
): Result<Unit> {
71+
val res = mutableListOf<ByteArray>()
72+
return delegate.useService {
73+
it.quickSetup(
74+
initParamsString,
75+
setupParamsString,
76+
object : ICallbackInterface.Stub() {
77+
override fun onResult(
78+
result: ByteArray?, isSuccess: Boolean, ack: IAckInterface?
79+
) {
80+
res.add(result ?: byteArrayOf())
81+
ack?.onAck()
82+
if (isSuccess) {
83+
onResult?.let { cb ->
84+
cb(res.formatString())
85+
}
86+
}
87+
}
88+
},
89+
object : IVoidInterface.Stub() {
90+
override fun invoke() {
91+
onStarted?.let { onStarted ->
92+
onStarted()
93+
}
94+
}
95+
}
96+
)
97+
}
98+
}
99+
61100
suspend fun setEventListener(
62101
cb: ((result: String?) -> Unit)?
63102
): Result<Unit> {
64103
val results = HashMap<String, MutableList<ByteArray>>()
65104
return delegate.useService {
66105
it.setEventListener(
67106
when (cb != null) {
68-
true -> object : IEventInterface.Stub() {
69-
override fun onEvent(
70-
id: String, data: ByteArray?, isSuccess: Boolean, ack: IAckInterface?
71-
) {
72-
if (results[id] == null) {
73-
results[id] = mutableListOf()
74-
}
75-
results[id]?.add(data ?: byteArrayOf())
76-
ack?.onAck()
77-
if (isSuccess) {
78-
cb(results[id]?.formatString())
79-
results.remove(id)
107+
true -> object : IEventInterface.Stub() {
108+
override fun onEvent(
109+
id: String, data: ByteArray?, isSuccess: Boolean, ack: IAckInterface?
110+
) {
111+
if (results[id] == null) {
112+
results[id] = mutableListOf()
113+
}
114+
results[id]?.add(data ?: byteArrayOf())
115+
ack?.onAck()
116+
if (isSuccess) {
117+
cb(results[id]?.formatString())
118+
results.remove(id)
119+
}
80120
}
81121
}
82-
}
83122

84-
false -> null
85-
})
123+
false -> null
124+
})
86125
}
87126
}
88127

@@ -116,6 +155,7 @@ object Service {
116155
try {
117156
block(callback)
118157
} catch (e: Exception) {
158+
GlobalState.log("awaitIResultInterface $e")
119159
if (continuation.isActive) {
120160
continuation.resumeWithException(e)
121161
}

0 commit comments

Comments
 (0)