diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/window/ActivityWindowHandler.kt b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/window/ActivityWindowHandler.kt index eadcbe94b..f333bab00 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/window/ActivityWindowHandler.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/window/ActivityWindowHandler.kt @@ -85,15 +85,22 @@ class ActivityWindowHandler(private val activity: Activity) : WindowHandler(acti result.success(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && activity.resources.configuration.isScreenHdr) } - override fun setHdrColorMode(call: MethodCall, result: MethodChannel.Result) { - val on = call.argument("on") - if (on == null) { - result.error("setHdrColorMode-args", "missing arguments", null) + override fun setColorMode(call: MethodCall, result: MethodChannel.Result) { + val wideColorGamut = call.argument("wideColorGamut") + val hdr = call.argument("hdr") + if (wideColorGamut == null || hdr == null) { + result.error("setColorMode-args", "missing arguments", null) return } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - activity.window.colorMode = if (on) ActivityInfo.COLOR_MODE_HDR else ActivityInfo.COLOR_MODE_DEFAULT + activity.window.colorMode = if (hdr) { + ActivityInfo.COLOR_MODE_HDR + } else if (wideColorGamut) { + ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT + } else { + ActivityInfo.COLOR_MODE_DEFAULT + } } result.success(null) } diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/window/ServiceWindowHandler.kt b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/window/ServiceWindowHandler.kt index 0a5eb705e..e0beb2b1e 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/window/ServiceWindowHandler.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/window/ServiceWindowHandler.kt @@ -37,7 +37,7 @@ class ServiceWindowHandler(service: Service) : WindowHandler(service) { result.success(false) } - override fun setHdrColorMode(call: MethodCall, result: MethodChannel.Result) { + override fun setColorMode(call: MethodCall, result: MethodChannel.Result) { result.success(null) } } \ No newline at end of file diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/window/WindowHandler.kt b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/window/WindowHandler.kt index a923a1ea7..2f67a454b 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/window/WindowHandler.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/window/WindowHandler.kt @@ -20,7 +20,7 @@ abstract class WindowHandler(private val contextWrapper: ContextWrapper) : Metho "getCutoutInsets" -> Coresult.safe(call, result, ::getCutoutInsets) "supportsWideGamut" -> Coresult.safe(call, result, ::supportsWideGamut) "supportsHdr" -> Coresult.safe(call, result, ::supportsHdr) - "setHdrColorMode" -> Coresult.safe(call, result, ::setHdrColorMode) + "setColorMode" -> Coresult.safe(call, result, ::setColorMode) else -> result.notImplemented() } } @@ -51,7 +51,7 @@ abstract class WindowHandler(private val contextWrapper: ContextWrapper) : Metho abstract fun supportsHdr(call: MethodCall, result: MethodChannel.Result) - abstract fun setHdrColorMode(call: MethodCall, result: MethodChannel.Result) + abstract fun setColorMode(call: MethodCall, result: MethodChannel.Result) companion object { private val LOG_TAG = LogUtils.createTag() diff --git a/lib/services/window_service.dart b/lib/services/window_service.dart index 2aa2a469e..f0a9b8087 100644 --- a/lib/services/window_service.dart +++ b/lib/services/window_service.dart @@ -22,7 +22,7 @@ abstract class WindowService { Future supportsHdr(); - Future setHdrColorMode(bool on); + Future setColorMode({required bool wideColorGamut, required bool hdr}); } class PlatformWindowService implements WindowService { @@ -153,11 +153,12 @@ class PlatformWindowService implements WindowService { } @override - Future setHdrColorMode(bool on) async { + Future setColorMode({required bool wideColorGamut, required bool hdr}) async { // TODO TLAD [hdr] enable when ready // try { - // await _platform.invokeMethod('setHdrColorMode', { - // 'on': on, + // await _platform.invokeMethod('setColorMode', { + // 'wideColorGamut': wideColorGamut, + // 'hdr': hdr, // }); // } on PlatformException catch (e, stack) { // await reportService.recordError(e, stack); diff --git a/lib/widgets/collection/app_bar.dart b/lib/widgets/collection/app_bar.dart index 3c4e64e57..96560f7c9 100644 --- a/lib/widgets/collection/app_bar.dart +++ b/lib/widgets/collection/app_bar.dart @@ -626,6 +626,9 @@ class _CollectionAppBarState extends State with SingleTickerPr void _onQueryFocusRequest() => _queryBarFocusNode.requestFocus(); void _updateStatusBarHeight() { + if (!context.mounted) { + return; + } _statusBarHeight = MediaQuery.paddingOf(context).top; _updateAppBarHeight(); } diff --git a/lib/widgets/viewer/controls/controller.dart b/lib/widgets/viewer/controls/controller.dart index a71cdce48..78d55c157 100644 --- a/lib/widgets/viewer/controls/controller.dart +++ b/lib/widgets/viewer/controls/controller.dart @@ -70,7 +70,7 @@ class ViewerController with CastMixin { LeakTracking.dispatchObjectDisposed(object: this); } entryNotifier.removeListener(_onEntryChanged); - windowService.setHdrColorMode(false); + windowService.setColorMode(wideColorGamut: false, hdr: false); _autopilotNotifier.dispose(); _clearAutopilotAnimations(); _stopPlayTimer(); @@ -79,8 +79,10 @@ class ViewerController with CastMixin { Future _onEntryChanged() async { if (await windowService.supportsHdr()) { - final enabled = entryNotifier.value?.isHdr ?? false; - await windowService.setHdrColorMode(enabled); + await windowService.setColorMode( + wideColorGamut: false, + hdr: entryNotifier.value?.isHdr ?? false, + ); } } diff --git a/test/fake/window_service.dart b/test/fake/window_service.dart index ab9ddce72..f8976a7ec 100644 --- a/test/fake/window_service.dart +++ b/test/fake/window_service.dart @@ -26,5 +26,5 @@ class FakeWindowService extends Fake implements WindowService { Future supportsHdr() => SynchronousFuture(false); @override - Future setHdrColorMode(bool on) => SynchronousFuture(null); + Future setColorMode({required bool wideColorGamut, required bool hdr}) => SynchronousFuture(null); }