mirror of
https://github.com/localsend/localsend.git
synced 2026-06-23 04:10:07 +00:00
This commit is contained in:
@@ -6,6 +6,7 @@ import android.content.Intent
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
import android.provider.DocumentsContract
|
||||
import android.provider.Settings;
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
@@ -54,11 +55,20 @@ class MainActivity : FlutterActivity() {
|
||||
result.success(null)
|
||||
}
|
||||
|
||||
"isAnimationsEnabled" -> {
|
||||
result.success(isAnimationsEnabled())
|
||||
}
|
||||
|
||||
else -> result.notImplemented()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun isAnimationsEnabled() : Boolean {
|
||||
return Settings.Global.getFloat(this.getContentResolver(),
|
||||
Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f) != 0.0f;
|
||||
}
|
||||
|
||||
private fun openDirectoryPicker(onlyPath: Boolean) {
|
||||
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION)
|
||||
|
||||
@@ -7,6 +7,18 @@ import Flutter
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||
) -> Bool {
|
||||
|
||||
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
|
||||
let channel = FlutterMethodChannel(name: "ios-delegate-channel",
|
||||
binaryMessenger: controller.engine.binaryMessenger)
|
||||
channel.setMethodCallHandler({
|
||||
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
|
||||
if call.method == "isReduceMotionEnabled" {
|
||||
result(UIAccessibility.isReduceMotionEnabled)
|
||||
} else {
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
})
|
||||
GeneratedPluginRegistrant.register(with: self)
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import 'package:localsend_app/util/native/platform_check.dart';
|
||||
import 'package:localsend_app/util/security_helper.dart';
|
||||
import 'package:localsend_app/util/shared_preferences/shared_preferences_file.dart';
|
||||
import 'package:localsend_app/util/shared_preferences/shared_preferences_portable.dart';
|
||||
import 'package:localsend_app/util/ui/animations_status.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:refena_flutter/refena_flutter.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -164,6 +165,11 @@ class PersistenceService {
|
||||
await prefs.setString(_securityContext, jsonEncode(generateSecurityContext()));
|
||||
}
|
||||
|
||||
if (isFirstAppStart) {
|
||||
_logger.info('Is FirstStartUp');
|
||||
await prefs.setBool(_enableAnimations, await getSystemAnimationsStatus());
|
||||
}
|
||||
|
||||
if (prefs.getString(_colorKey) == null) {
|
||||
await _initColorSetting(prefs, supportsDynamicColors);
|
||||
} else {
|
||||
|
||||
@@ -40,6 +40,10 @@ Future<List<FileInfo>?> pickFilesAndroid() async {
|
||||
return result.map((e) => FileInfoMapper.fromJson((e as Map).cast<String, dynamic>())).toList();
|
||||
}
|
||||
|
||||
Future<bool> getSystemAnimationsStatusAndroid() async {
|
||||
return await _methodChannel.invokeMethod('isAnimationsEnabled') ?? true;
|
||||
}
|
||||
|
||||
Future<void> createDirectory({
|
||||
required String documentUri,
|
||||
required String directoryName,
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
const _methodChannel = MethodChannel('ios-delegate-channel');
|
||||
|
||||
Future<bool> isReduceMotionEnabledIOS() async {
|
||||
return await _methodChannel.invokeMethod('isReduceMotionEnabled') ?? false;
|
||||
}
|
||||
@@ -50,6 +50,10 @@ Future<void> setDockIcon(TaskbarIcon icon) async {
|
||||
await _methodChannel.invokeMethod('setDockIcon', icon.index);
|
||||
}
|
||||
|
||||
Future<bool> isReduceMotionEnabledMacOs() async {
|
||||
return await _methodChannel.invokeMethod('isReduceMotionEnabled') ?? false;
|
||||
}
|
||||
|
||||
// This happens:
|
||||
/// - on macOS when text is dropped onto the app Dock icon
|
||||
/// - on macOS when text is dropped onto the app menu bar icon
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'dart:io';
|
||||
import 'package:localsend_app/util/native/channel/android_channel.dart';
|
||||
import 'package:localsend_app/util/native/ios_channel.dart';
|
||||
import 'package:localsend_app/util/native/macos_channel.dart';
|
||||
|
||||
Future<bool> getSystemAnimationsStatus() async {
|
||||
if (Platform.isAndroid) {
|
||||
return await getSystemAnimationsStatusAndroid();
|
||||
} else if (Platform.isIOS) {
|
||||
bool isReduceMotionEnabledBool = await isReduceMotionEnabledIOS();
|
||||
return !isReduceMotionEnabledBool;
|
||||
} else if (Platform.isMacOS) {
|
||||
bool isReduceMotionEnabledBool = await isReduceMotionEnabledMacOs();
|
||||
return !isReduceMotionEnabledBool;
|
||||
}
|
||||
|
||||
return true; // Default to true for other platforms.
|
||||
}
|
||||
@@ -206,6 +206,8 @@ class AppDelegate: FlutterAppDelegate {
|
||||
}
|
||||
case "isLaunchedAsLoginItem":
|
||||
result(isLaunchedAsLoginItem)
|
||||
case "isReduceMotionEnabled":
|
||||
result(NSWorkspace.shared.accessibilityDisplayShouldReduceMotion)
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user