color mode setting for wide gamut
This commit is contained in:
parent
f850178afd
commit
1f95506abe
7 changed files with 29 additions and 16 deletions
|
@ -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<Boolean>("on")
|
||||
if (on == null) {
|
||||
result.error("setHdrColorMode-args", "missing arguments", null)
|
||||
override fun setColorMode(call: MethodCall, result: MethodChannel.Result) {
|
||||
val wideColorGamut = call.argument<Boolean>("wideColorGamut")
|
||||
val hdr = call.argument<Boolean>("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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -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<WindowHandler>()
|
||||
|
|
|
@ -22,7 +22,7 @@ abstract class WindowService {
|
|||
|
||||
Future<bool> supportsHdr();
|
||||
|
||||
Future<void> setHdrColorMode(bool on);
|
||||
Future<void> setColorMode({required bool wideColorGamut, required bool hdr});
|
||||
}
|
||||
|
||||
class PlatformWindowService implements WindowService {
|
||||
|
@ -153,11 +153,12 @@ class PlatformWindowService implements WindowService {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<void> setHdrColorMode(bool on) async {
|
||||
Future<void> setColorMode({required bool wideColorGamut, required bool hdr}) async {
|
||||
// TODO TLAD [hdr] enable when ready
|
||||
// try {
|
||||
// await _platform.invokeMethod('setHdrColorMode', <String, dynamic>{
|
||||
// 'on': on,
|
||||
// await _platform.invokeMethod('setColorMode', <String, dynamic>{
|
||||
// 'wideColorGamut': wideColorGamut,
|
||||
// 'hdr': hdr,
|
||||
// });
|
||||
// } on PlatformException catch (e, stack) {
|
||||
// await reportService.recordError(e, stack);
|
||||
|
|
|
@ -626,6 +626,9 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
|||
void _onQueryFocusRequest() => _queryBarFocusNode.requestFocus();
|
||||
|
||||
void _updateStatusBarHeight() {
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
_statusBarHeight = MediaQuery.paddingOf(context).top;
|
||||
_updateAppBarHeight();
|
||||
}
|
||||
|
|
|
@ -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<void> _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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,5 +26,5 @@ class FakeWindowService extends Fake implements WindowService {
|
|||
Future<bool> supportsHdr() => SynchronousFuture(false);
|
||||
|
||||
@override
|
||||
Future<void> setHdrColorMode(bool on) => SynchronousFuture(null);
|
||||
Future<void> setColorMode({required bool wideColorGamut, required bool hdr}) => SynchronousFuture(null);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue