removed dependencies on some trivial packages
This commit is contained in:
parent
d91111e947
commit
18a15d617f
11 changed files with 98 additions and 36 deletions
|
@ -32,11 +32,13 @@ class MainActivity : FlutterActivity() {
|
||||||
|
|
||||||
MethodChannel(messenger, AppAdapterHandler.CHANNEL).setMethodCallHandler(AppAdapterHandler(this))
|
MethodChannel(messenger, AppAdapterHandler.CHANNEL).setMethodCallHandler(AppAdapterHandler(this))
|
||||||
MethodChannel(messenger, AppShortcutHandler.CHANNEL).setMethodCallHandler(AppShortcutHandler(this))
|
MethodChannel(messenger, AppShortcutHandler.CHANNEL).setMethodCallHandler(AppShortcutHandler(this))
|
||||||
|
MethodChannel(messenger, DebugHandler.CHANNEL).setMethodCallHandler(DebugHandler(this))
|
||||||
MethodChannel(messenger, ImageFileHandler.CHANNEL).setMethodCallHandler(ImageFileHandler(this))
|
MethodChannel(messenger, ImageFileHandler.CHANNEL).setMethodCallHandler(ImageFileHandler(this))
|
||||||
MethodChannel(messenger, MediaStoreHandler.CHANNEL).setMethodCallHandler(MediaStoreHandler(this))
|
MethodChannel(messenger, MediaStoreHandler.CHANNEL).setMethodCallHandler(MediaStoreHandler(this))
|
||||||
MethodChannel(messenger, MetadataHandler.CHANNEL).setMethodCallHandler(MetadataHandler(this))
|
MethodChannel(messenger, MetadataHandler.CHANNEL).setMethodCallHandler(MetadataHandler(this))
|
||||||
MethodChannel(messenger, StorageHandler.CHANNEL).setMethodCallHandler(StorageHandler(this))
|
MethodChannel(messenger, StorageHandler.CHANNEL).setMethodCallHandler(StorageHandler(this))
|
||||||
MethodChannel(messenger, DebugHandler.CHANNEL).setMethodCallHandler(DebugHandler(this))
|
MethodChannel(messenger, TimeHandler.CHANNEL).setMethodCallHandler(TimeHandler())
|
||||||
|
MethodChannel(messenger, WindowHandler.CHANNEL).setMethodCallHandler(WindowHandler(this))
|
||||||
|
|
||||||
StreamsChannel(messenger, ImageByteStreamHandler.CHANNEL).setStreamHandlerFactory { args -> ImageByteStreamHandler(this, args) }
|
StreamsChannel(messenger, ImageByteStreamHandler.CHANNEL).setStreamHandlerFactory { args -> ImageByteStreamHandler(this, args) }
|
||||||
StreamsChannel(messenger, ImageOpStreamHandler.CHANNEL).setStreamHandlerFactory { args -> ImageOpStreamHandler(this, args) }
|
StreamsChannel(messenger, ImageOpStreamHandler.CHANNEL).setStreamHandlerFactory { args -> ImageOpStreamHandler(this, args) }
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package deckers.thibault.aves.channel.calls
|
||||||
|
|
||||||
|
import io.flutter.plugin.common.MethodCall
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class TimeHandler() : MethodCallHandler {
|
||||||
|
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
|
||||||
|
when (call.method) {
|
||||||
|
"getDefaultTimeZone" -> result.success(TimeZone.getDefault().id)
|
||||||
|
else -> result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val CHANNEL = "deckers.thibault/aves/time"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package deckers.thibault.aves.channel.calls
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.view.WindowManager
|
||||||
|
import deckers.thibault.aves.channel.calls.Coresult.Companion.safe
|
||||||
|
import io.flutter.plugin.common.MethodCall
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
||||||
|
|
||||||
|
class WindowHandler(private val activity: Activity) : MethodCallHandler {
|
||||||
|
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
|
||||||
|
when (call.method) {
|
||||||
|
"keepScreenOn" -> safe(call, result, ::keepScreenOn)
|
||||||
|
else -> result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun keepScreenOn(call: MethodCall, result: MethodChannel.Result) {
|
||||||
|
val on = call.argument<Boolean>("on")
|
||||||
|
if (on == null) {
|
||||||
|
result.error("keepOn-args", "failed because of missing arguments", null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val window = activity.window
|
||||||
|
val flag = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||||
|
if (on) {
|
||||||
|
window.addFlags(flag)
|
||||||
|
} else {
|
||||||
|
window.clearFlags(flag)
|
||||||
|
}
|
||||||
|
result.success(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val CHANNEL = "deckers.thibault/aves/window"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
import 'package:screen/screen.dart';
|
import 'package:aves/services/window_service.dart';
|
||||||
|
|
||||||
enum KeepScreenOn { never, viewerOnly, always }
|
enum KeepScreenOn { never, viewerOnly, always }
|
||||||
|
|
||||||
|
@ -17,6 +17,6 @@ extension ExtraKeepScreenOn on KeepScreenOn {
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply() {
|
void apply() {
|
||||||
Screen.keepOn(this == KeepScreenOn.always);
|
WindowService.keepScreenOn(this == KeepScreenOn.always);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,11 @@ import 'package:aves/model/settings/settings.dart';
|
||||||
import 'package:aves/model/source/collection_source.dart';
|
import 'package:aves/model/source/collection_source.dart';
|
||||||
import 'package:aves/services/image_file_service.dart';
|
import 'package:aves/services/image_file_service.dart';
|
||||||
import 'package:aves/services/media_store_service.dart';
|
import 'package:aves/services/media_store_service.dart';
|
||||||
|
import 'package:aves/services/time_service.dart';
|
||||||
import 'package:aves/utils/android_file_utils.dart';
|
import 'package:aves/utils/android_file_utils.dart';
|
||||||
import 'package:aves/utils/math_utils.dart';
|
import 'package:aves/utils/math_utils.dart';
|
||||||
import 'package:firebase_analytics/firebase_analytics.dart';
|
import 'package:firebase_analytics/firebase_analytics.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_native_timezone/flutter_native_timezone.dart';
|
|
||||||
import 'package:pedantic/pedantic.dart';
|
import 'package:pedantic/pedantic.dart';
|
||||||
|
|
||||||
class MediaStoreSource extends CollectionSource {
|
class MediaStoreSource extends CollectionSource {
|
||||||
|
@ -27,7 +27,7 @@ class MediaStoreSource extends CollectionSource {
|
||||||
stateNotifier.value = SourceState.loading;
|
stateNotifier.value = SourceState.loading;
|
||||||
await metadataDb.init();
|
await metadataDb.init();
|
||||||
await favourites.init();
|
await favourites.init();
|
||||||
final currentTimeZone = await FlutterNativeTimezone.getLocalTimezone();
|
final currentTimeZone = await TimeService.getDefaultTimeZone();
|
||||||
final catalogTimeZone = settings.catalogTimeZone;
|
final catalogTimeZone = settings.catalogTimeZone;
|
||||||
if (currentTimeZone != catalogTimeZone) {
|
if (currentTimeZone != catalogTimeZone) {
|
||||||
// clear catalog metadata to get correct date/times when moving to a different time zone
|
// clear catalog metadata to get correct date/times when moving to a different time zone
|
||||||
|
|
15
lib/services/time_service.dart
Normal file
15
lib/services/time_service.dart
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
class TimeService {
|
||||||
|
static const platform = MethodChannel('deckers.thibault/aves/time');
|
||||||
|
|
||||||
|
static Future<String> getDefaultTimeZone() async {
|
||||||
|
try {
|
||||||
|
return await platform.invokeMethod('getDefaultTimeZone');
|
||||||
|
} on PlatformException catch (e) {
|
||||||
|
debugPrint('getDefaultTimeZone failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
16
lib/services/window_service.dart
Normal file
16
lib/services/window_service.dart
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
class WindowService {
|
||||||
|
static const platform = MethodChannel('deckers.thibault/aves/window');
|
||||||
|
|
||||||
|
static Future<void> keepScreenOn(bool on) async {
|
||||||
|
try {
|
||||||
|
await platform.invokeMethod('keepScreenOn', <String, dynamic>{
|
||||||
|
'on': on,
|
||||||
|
});
|
||||||
|
} on PlatformException catch (e) {
|
||||||
|
debugPrint('keepScreenOn failed with code=${e.code}, exception=${e.message}, details=${e.details}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -143,12 +143,6 @@ class Constants {
|
||||||
licenseUrl: 'https://github.com/flutter/flutter_markdown/blob/master/LICENSE',
|
licenseUrl: 'https://github.com/flutter/flutter_markdown/blob/master/LICENSE',
|
||||||
sourceUrl: 'https://github.com/flutter/flutter_markdown',
|
sourceUrl: 'https://github.com/flutter/flutter_markdown',
|
||||||
),
|
),
|
||||||
Dependency(
|
|
||||||
name: 'Flutter Native Timezone',
|
|
||||||
license: 'Apache 2.0',
|
|
||||||
licenseUrl: 'https://github.com/pinkfish/flutter_native_timezone/blob/master/LICENSE',
|
|
||||||
sourceUrl: 'https://github.com/pinkfish/flutter_native_timezone',
|
|
||||||
),
|
|
||||||
Dependency(
|
Dependency(
|
||||||
name: 'Flutter Staggered Animations',
|
name: 'Flutter Staggered Animations',
|
||||||
license: 'MIT',
|
license: 'MIT',
|
||||||
|
@ -257,12 +251,6 @@ class Constants {
|
||||||
licenseUrl: 'https://github.com/rrousselGit/provider/blob/master/LICENSE',
|
licenseUrl: 'https://github.com/rrousselGit/provider/blob/master/LICENSE',
|
||||||
sourceUrl: 'https://github.com/rrousselGit/provider',
|
sourceUrl: 'https://github.com/rrousselGit/provider',
|
||||||
),
|
),
|
||||||
Dependency(
|
|
||||||
name: 'Screen',
|
|
||||||
license: 'MIT',
|
|
||||||
licenseUrl: 'https://github.com/clovisnicolas/flutter_screen/blob/master/LICENSE',
|
|
||||||
sourceUrl: 'https://github.com/clovisnicolas/flutter_screen',
|
|
||||||
),
|
|
||||||
Dependency(
|
Dependency(
|
||||||
name: 'Shared Preferences',
|
name: 'Shared Preferences',
|
||||||
license: 'BSD 3-Clause',
|
license: 'BSD 3-Clause',
|
||||||
|
|
|
@ -6,6 +6,7 @@ import 'package:aves/model/filters/filters.dart';
|
||||||
import 'package:aves/model/settings/screen_on.dart';
|
import 'package:aves/model/settings/screen_on.dart';
|
||||||
import 'package:aves/model/settings/settings.dart';
|
import 'package:aves/model/settings/settings.dart';
|
||||||
import 'package:aves/model/source/collection_lens.dart';
|
import 'package:aves/model/source/collection_lens.dart';
|
||||||
|
import 'package:aves/services/window_service.dart';
|
||||||
import 'package:aves/theme/durations.dart';
|
import 'package:aves/theme/durations.dart';
|
||||||
import 'package:aves/utils/change_notifier.dart';
|
import 'package:aves/utils/change_notifier.dart';
|
||||||
import 'package:aves/widgets/collection/collection_page.dart';
|
import 'package:aves/widgets/collection/collection_page.dart';
|
||||||
|
@ -26,7 +27,6 @@ import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_ijkplayer/flutter_ijkplayer.dart';
|
import 'package:flutter_ijkplayer/flutter_ijkplayer.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:screen/screen.dart';
|
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
class EntryViewerStack extends StatefulWidget {
|
class EntryViewerStack extends StatefulWidget {
|
||||||
|
@ -111,7 +111,7 @@ class _EntryViewerStackState extends State<EntryViewerStack> with SingleTickerPr
|
||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance.addObserver(this);
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) => _initOverlay());
|
WidgetsBinding.instance.addPostFrameCallback((_) => _initOverlay());
|
||||||
if (settings.keepScreenOn == KeepScreenOn.viewerOnly) {
|
if (settings.keepScreenOn == KeepScreenOn.viewerOnly) {
|
||||||
Screen.keepOn(true);
|
WindowService.keepScreenOn(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ class _EntryViewerStackState extends State<EntryViewerStack> with SingleTickerPr
|
||||||
void _onLeave() {
|
void _onLeave() {
|
||||||
_showSystemUI();
|
_showSystemUI();
|
||||||
if (settings.keepScreenOn == KeepScreenOn.viewerOnly) {
|
if (settings.keepScreenOn == KeepScreenOn.viewerOnly) {
|
||||||
Screen.keepOn(false);
|
WindowService.keepScreenOn(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
pubspec.lock
14
pubspec.lock
|
@ -330,13 +330,6 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.2"
|
version: "0.5.2"
|
||||||
flutter_native_timezone:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_native_timezone
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.4"
|
|
||||||
flutter_plugin_android_lifecycle:
|
flutter_plugin_android_lifecycle:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -779,13 +772,6 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.5"
|
version: "2.1.5"
|
||||||
screen:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: screen
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.0.5"
|
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -51,7 +51,6 @@ dependencies:
|
||||||
url: git://github.com/deckerst/flutter_ijkplayer.git
|
url: git://github.com/deckerst/flutter_ijkplayer.git
|
||||||
flutter_map:
|
flutter_map:
|
||||||
flutter_markdown:
|
flutter_markdown:
|
||||||
flutter_native_timezone:
|
|
||||||
flutter_staggered_animations:
|
flutter_staggered_animations:
|
||||||
flutter_svg:
|
flutter_svg:
|
||||||
geocoder:
|
geocoder:
|
||||||
|
@ -71,7 +70,6 @@ dependencies:
|
||||||
permission_handler:
|
permission_handler:
|
||||||
printing:
|
printing:
|
||||||
provider:
|
provider:
|
||||||
screen:
|
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
sqflite:
|
sqflite:
|
||||||
streams_channel:
|
streams_channel:
|
||||||
|
|
Loading…
Reference in a new issue