An open-source cross-platform alternative to AirDrop
FEAT #2333 Defaults to System Animations on Initial startup (andriod,ios and macos) (#2338)
Nitheesh Darama1607fe5e325
diff --git a/app/android/app/src/main/kotlin/org/localsend/localsend_app/MainActivity.kt b/app/android/app/src/main/kotlin/org/localsend/localsend_app/MainActivity.ktindex 9ac6ccd1..63d8d586 100644--- a/app/android/app/src/main/kotlin/org/localsend/localsend_app/MainActivity.kt+++ b/app/android/app/src/main/kotlin/org/localsend/localsend_app/MainActivity.kt@@ -6,6 +6,7 @@ import android.content.Intentimport android.database.Cursorimport android.net.Uriimport android.provider.DocumentsContract+import android.provider.Settings;import io.flutter.embedding.android.FlutterActivityimport io.flutter.embedding.engine.FlutterEngineimport 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)diff --git a/app/ios/Runner/AppDelegate.swift b/app/ios/Runner/AppDelegate.swiftindex b6363034..10a47e7b 100644--- a/app/ios/Runner/AppDelegate.swift+++ b/app/ios/Runner/AppDelegate.swift@@ -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)}diff --git a/app/lib/provider/persistence_provider.dart b/app/lib/provider/persistence_provider.dartindex 05e2e7f4..3aa37fca 100644--- a/app/lib/provider/persistence_provider.dart+++ b/app/lib/provider/persistence_provider.dart@@ -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 {diff --git a/app/lib/util/native/channel/android_channel.dart b/app/lib/util/native/channel/android_channel.dartindex 6ec860ff..081fcd47 100644--- a/app/lib/util/native/channel/android_channel.dart+++ b/app/lib/util/native/channel/android_channel.dart@@ -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,diff --git a/app/lib/util/native/ios_channel.dart b/app/lib/util/native/ios_channel.dartnew file mode 100644index 00000000..239be474--- /dev/null+++ b/app/lib/util/native/ios_channel.dart@@ -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;+}diff --git a/app/lib/util/native/macos_channel.dart b/app/lib/util/native/macos_channel.dartindex 962c68e8..4caa2adf 100644--- a/app/lib/util/native/macos_channel.dart+++ b/app/lib/util/native/macos_channel.dart@@ -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 icondiff --git a/app/lib/util/ui/animations_status.dart b/app/lib/util/ui/animations_status.dartnew file mode 100644index 00000000..3e8fbadf--- /dev/null+++ b/app/lib/util/ui/animations_status.dart@@ -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.+}diff --git a/app/macos/Runner/AppDelegate.swift b/app/macos/Runner/AppDelegate.swiftindex 3d7900bc..e1ca4ca3 100644--- a/app/macos/Runner/AppDelegate.swift+++ b/app/macos/Runner/AppDelegate.swift@@ -206,6 +206,8 @@ class AppDelegate: FlutterAppDelegate {}case "isLaunchedAsLoginItem":result(isLaunchedAsLoginItem)+ case "isReduceMotionEnabled":+ result(NSWorkspace.shared.accessibilityDisplayShouldReduceMotion)default:result(FlutterMethodNotImplemented)}