From 8247ce26ba691a240dfe7075384a7ac0463dc837 Mon Sep 17 00:00:00 2001 From: Gary Qian Date: Tue, 25 Sep 2018 13:46:38 -0700 Subject: [PATCH] Implement restore functions on Android and iOS (#6322) This will not be active on the Framework until https://github.com/flutter/flutter/pull/22221 lands. --- .../plugin/platform/PlatformPlugin.java | 7 +++++++ .../framework/Source/FlutterPlatformPlugin.mm | 20 +++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index b05ffe5ec..439678227 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -58,6 +58,9 @@ public class PlatformPlugin implements MethodCallHandler, ActivityLifecycleListe } else if (method.equals("SystemChrome.setEnabledSystemUIOverlays")) { setSystemChromeEnabledSystemUIOverlays((JSONArray) arguments); result.success(null); + } else if (method.equals("SystemChrome.restoreSystemUIOverlays")) { + restoreSystemChromeSystemUIOverlays(); + result.success(null); } else if (method.equals("SystemChrome.setSystemUIOverlayStyle")) { setSystemChromeSystemUIOverlayStyle((JSONObject) arguments); result.success(null); @@ -224,6 +227,10 @@ public class PlatformPlugin implements MethodCallHandler, ActivityLifecycleListe } } + private void restoreSystemChromeSystemUIOverlays() { + updateSystemUiOverlays(); + } + private void setSystemChromeSystemUIOverlayStyle(JSONObject message) { Window window = mActivity.getWindow(); View view = window.getDecorView(); diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm index 445cbc394..ccde195ae 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm @@ -51,6 +51,9 @@ using namespace shell; } else if ([method isEqualToString:@"SystemChrome.setEnabledSystemUIOverlays"]) { [self setSystemChromeEnabledSystemUIOverlays:args]; result(nil); + } else if ([method isEqualToString:@"SystemChrome.restoreSystemUIOverlays"]) { + [self restoreSystemChromeSystemUIOverlays]; + result(nil); } else if ([method isEqualToString:@"SystemChrome.setSystemUIOverlayStyle"]) { [self setSystemChromeSystemUIOverlayStyle:args]; result(nil); @@ -116,11 +119,10 @@ using namespace shell; if (!mask) return; - [[NSNotificationCenter defaultCenter] postNotificationName:@(kOrientationUpdateNotificationName) - object:nil - userInfo:@{ - @(kOrientationUpdateNotificationKey) : @(mask) - }]; + [[NSNotificationCenter defaultCenter] + postNotificationName:@(kOrientationUpdateNotificationName) + object:nil + userInfo:@{@(kOrientationUpdateNotificationKey) : @(mask)}]; } - (void)setSystemChromeApplicationSwitcherDescription:(NSDictionary*)object { @@ -138,6 +140,10 @@ using namespace shell; ![overlays containsObject:@"SystemUiOverlay.top"]; } +- (void)restoreSystemChromeSystemUIOverlays { + // Nothing to do on iOS. +} + - (void)setSystemChromeSystemUIOverlayStyle:(NSDictionary*)message { NSString* style = message[@"statusBarBrightness"]; if (style == (id)[NSNull null]) @@ -160,9 +166,7 @@ using namespace shell; [[NSNotificationCenter defaultCenter] postNotificationName:@(kOverlayStyleUpdateNotificationName) object:nil - userInfo:@{ - @(kOverlayStyleUpdateNotificationKey) : @(statusBarStyle) - }]; + userInfo:@{@(kOverlayStyleUpdateNotificationKey) : @(statusBarStyle)}]; } else { // Note: -[UIApplication setStatusBarStyle] is deprecated in iOS9 // in favor of delegating to the view controller -- GitLab