Compare commits
1 Commits
v0.8.88-pr
...
v0.8.88-pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61465f5178 |
@@ -1,7 +1,5 @@
|
||||
package com.follow.clash
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.follow.clash.plugins.AppPlugin
|
||||
import com.follow.clash.plugins.ServicePlugin
|
||||
import com.follow.clash.plugins.TilePlugin
|
||||
@@ -15,14 +13,10 @@ import kotlinx.coroutines.launch
|
||||
class MainActivity : FlutterActivity(),
|
||||
CoroutineScope by CoroutineScope(SupervisorJob() + Dispatchers.Default) {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
lifecycleScope.launch {
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
launch {
|
||||
State.destroyServiceEngine()
|
||||
}
|
||||
}
|
||||
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
flutterEngine.plugins.add(AppPlugin())
|
||||
flutterEngine.plugins.add(ServicePlugin())
|
||||
|
||||
@@ -285,12 +285,9 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
||||
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
|
||||
NOTIFICATION_PERMISSION_REQUEST_CODE
|
||||
)
|
||||
return
|
||||
}
|
||||
return
|
||||
} else {
|
||||
invokeRequestNotificationCallback()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun invokeRequestNotificationCallback() {
|
||||
|
||||
@@ -6,12 +6,9 @@ import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.filterNotNull
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.retryWhen
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withTimeoutOrNull
|
||||
|
||||
@@ -54,17 +51,12 @@ class ServiceDelegate<T>(
|
||||
}
|
||||
}
|
||||
|
||||
suspend inline fun <R> useService(
|
||||
crossinline block: (T) -> R
|
||||
): Result<R> {
|
||||
suspend inline fun <R> useService(crossinline block: (T) -> R): Result<R> {
|
||||
return withTimeoutOrNull(10_000) {
|
||||
service.filterNotNull().retryWhen { _, _ ->
|
||||
delay(200)
|
||||
true
|
||||
}.first()
|
||||
}?.let { s ->
|
||||
service.first { it != null }
|
||||
}?.let { service ->
|
||||
try {
|
||||
Result.success(block(s))
|
||||
Result.success(block(service))
|
||||
} catch (e: Exception) {
|
||||
Result.failure(e)
|
||||
}
|
||||
|
||||
@@ -14,15 +14,16 @@ extension ArchiveExt on Archive {
|
||||
final data = entity.readAsBytesSync();
|
||||
final archiveFile = ArchiveFile(relativePath, data.length, data);
|
||||
addFile(archiveFile);
|
||||
} else if (entity is Directory) {
|
||||
addDirectoryToArchive(entity.path, parentPath);
|
||||
}
|
||||
// else if (entity is Directory) {
|
||||
// addDirectoryToArchive(entity.path, parentPath);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
void addTextFile<T>(String name, T raw) {
|
||||
final data = json.encode(raw);
|
||||
addFile(ArchiveFile.string(name, data));
|
||||
addFile(
|
||||
ArchiveFile.string(name, data),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,14 +77,13 @@ class AppPath {
|
||||
return join(directory, '$id.yaml');
|
||||
}
|
||||
|
||||
Future<String> getProvidersRootPath() async {
|
||||
final directory = await profilesPath;
|
||||
return join(directory, 'providers');
|
||||
}
|
||||
|
||||
Future<String> getProvidersDirPath(String id) async {
|
||||
final directory = await profilesPath;
|
||||
return join(directory, 'providers', id);
|
||||
return join(
|
||||
directory,
|
||||
'providers',
|
||||
id,
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> getProvidersFilePath(
|
||||
@@ -93,7 +92,13 @@ class AppPath {
|
||||
String url,
|
||||
) async {
|
||||
final directory = await profilesPath;
|
||||
return join(directory, 'providers', id, type, url.toMd5());
|
||||
return join(
|
||||
directory,
|
||||
'providers',
|
||||
id,
|
||||
type,
|
||||
url.toMd5(),
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> get tempPath async {
|
||||
|
||||
Reference in New Issue
Block a user