This commit is contained in:
problematicconsumer
2023-10-07 20:22:21 +03:30
parent e752461ad2
commit f1ebafd766
7 changed files with 41 additions and 29 deletions

View File

@@ -59,7 +59,6 @@ class MainActivity : FlutterFragmentActivity(), ServiceConnection.Callback {
fun startService() {
if (!ServiceNotification.checkPermission()) {
// Log.d(TAG, "missing notification permission")
grantNotificationPermission()
return
}
@@ -81,15 +80,26 @@ class MainActivity : FlutterFragmentActivity(), ServiceConnection.Callback {
}
}
private suspend fun prepare() = withContext(Dispatchers.Main) {
try {
val intent = VpnService.prepare(this@MainActivity)
if (intent != null) {
startActivityForResult(intent, VPN_PERMISSION_REQUEST_CODE)
true
} else {
false
}
} catch (e: Exception) {
onServiceAlert(Alert.RequestVPNPermission, e.message)
false
}
}
override fun onServiceStatusChanged(status: Status) {
Log.d(TAG, "service status changed: $status")
serviceStatus.postValue(status)
}
override fun onServiceAlert(type: Alert, message: String?) {
Log.d(TAG, "service alert: $type")
serviceAlerts.postValue(ServiceEvent(Status.Stopped, type, message))
}
@@ -154,22 +164,6 @@ class MainActivity : FlutterFragmentActivity(), ServiceConnection.Callback {
}
}
private suspend fun prepare() = withContext(Dispatchers.Main) {
try {
val intent = VpnService.prepare(this@MainActivity)
if (intent != null) {
// prepareLauncher.launch(intent)
startActivityForResult(intent, VPN_PERMISSION_REQUEST_CODE)
true
} else {
false
}
} catch (e: Exception) {
onServiceAlert(Alert.RequestVPNPermission, e.message)
false
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == VPN_PERMISSION_REQUEST_CODE) {

View File

@@ -172,5 +172,9 @@ object DefaultNetworkListener {
}
}
private fun unregister() = Application.connectivity.unregisterNetworkCallback(Callback)
private fun unregister() {
runCatching {
Application.connectivity.unregisterNetworkCallback(Callback)
}
}
}

View File

@@ -7,7 +7,7 @@ class ProxyService : Service(), PlatformInterfaceWrapper {
private val service = BoxService(this, this)
override fun onStartCommand(intent: Intent, flags: Int, startId: Int) =
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int) =
service.onStartCommand(intent, flags, startId)
override fun onBind(intent: Intent) = service.onBind(intent)

View File

@@ -63,10 +63,11 @@ class AppUpdateNotifier extends _$AppUpdateNotifier with AppLogger {
return state = AppUpdateState.error(err);
},
(remote) {
if (remote.version == _ignoreReleasePref.getValue()) {
loggy.debug("ignored release [${remote.version}]");
return state = AppUpdateStateIgnored(remote);
} else if (remote.version.compareTo(currentVersion) > 0) {
if (remote.version.compareTo(currentVersion) > 0) {
if (remote.version == _ignoreReleasePref.getValue()) {
loggy.debug("ignored release [${remote.version}]");
return state = AppUpdateStateIgnored(remote);
}
loggy.debug("new version available: $remote");
return state = AppUpdateState.available(remote);
}

View File

@@ -13,9 +13,10 @@ class WindowController extends _$WindowController
@override
Future<bool> build() async {
await windowManager.ensureInitialized();
const size = Size(868, 668);
const windowOptions = WindowOptions(
size: Size(868, 768),
minimumSize: Size(868, 648),
size: size,
minimumSize: size,
center: true,
);
await windowManager.setPreventClose(true);

View File

@@ -1,5 +1,6 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:gap/gap.dart';
import 'package:hiddify/core/core_providers.dart';
import 'package:hiddify/core/prefs/prefs.dart';
@@ -18,6 +19,8 @@ class IntroPage extends HookConsumerWidget with PresLogger {
Widget build(BuildContext context, WidgetRef ref) {
final t = ref.watch(translationsProvider);
final isStarting = useState(false);
return Scaffold(
body: CustomScrollView(
shrinkWrap: true,
@@ -68,6 +71,8 @@ class IntroPage extends HookConsumerWidget with PresLogger {
),
child: FilledButton(
onPressed: () async {
if (isStarting.value) return;
isStarting.value = true;
if (!ref.read(enableAnalyticsProvider)) {
loggy.info("disabling analytics per user request");
try {
@@ -84,7 +89,12 @@ class IntroPage extends HookConsumerWidget with PresLogger {
.read(introCompletedProvider.notifier)
.update(true);
},
child: Text(t.intro.start),
child: isStarting.value
? LinearProgressIndicator(
backgroundColor: Colors.transparent,
color: Theme.of(context).colorScheme.onSurface,
)
: Text(t.intro.start),
),
),
],

View File

@@ -15,6 +15,8 @@ bool canSendEvent(dynamic throwable) {
UnexpectedFailure(:final error) => canSendEvent(error),
DioException _ => false,
SocketException _ => false,
HttpException _ => false,
HandshakeException _ => false,
ExpectedFailure _ => false,
ExpectedMeasuredFailure _ => false,
_ => true,