mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Revert "Enables system chrome customization on Android O and greater" (#5167)
* Revert "Roll dart sdk to e6d7d67f4b35556805dd083fed15bf3ed41f7e33. (#5165)" This reverts commit 9e4c5d0e1f9daf0c46fdc7e5d1e81ce9c36b65c4. * Revert "Enables system chrome customization on Android M/O and greater (#5112)" This reverts commit f2db5dfd30f12407acab57f04acc8af7c6158891.
This commit is contained in:
parent
c7477c910f
commit
3c583f81d9
@ -15,8 +15,6 @@ import android.os.Build;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.SoundEffectConstants;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.util.Log;
|
||||
|
||||
import io.flutter.plugin.common.ActivityLifecycleListener;
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
|
||||
@ -32,7 +30,6 @@ import org.json.JSONObject;
|
||||
*/
|
||||
public class PlatformPlugin implements MethodCallHandler, ActivityLifecycleListener {
|
||||
private final Activity mActivity;
|
||||
private JSONObject mCurrentTheme;
|
||||
public static final int DEFAULT_SYSTEM_UI = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
|
||||
private static final String kTextPlainFormat = "text/plain";
|
||||
@ -63,7 +60,7 @@ public class PlatformPlugin implements MethodCallHandler, ActivityLifecycleListe
|
||||
setSystemChromeEnabledSystemUIOverlays((JSONArray) arguments);
|
||||
result.success(null);
|
||||
} else if (method.equals("SystemChrome.setSystemUIOverlayStyle")) {
|
||||
setSystemChromeSystemUIOverlayStyle((JSONObject) arguments);
|
||||
setSystemChromeSystemUIOverlayStyle((String) arguments);
|
||||
result.success(null);
|
||||
} else if (method.equals("SystemNavigator.pop")) {
|
||||
popSystemNavigator();
|
||||
@ -221,70 +218,14 @@ public class PlatformPlugin implements MethodCallHandler, ActivityLifecycleListe
|
||||
updateSystemUiOverlays();
|
||||
}
|
||||
|
||||
private void updateSystemUiOverlays(){
|
||||
private void updateSystemUiOverlays() {
|
||||
mActivity.getWindow().getDecorView().setSystemUiVisibility(mEnabledOverlays);
|
||||
if (mCurrentTheme != null) {
|
||||
setSystemChromeSystemUIOverlayStyle(mCurrentTheme);
|
||||
}
|
||||
}
|
||||
|
||||
private void setSystemChromeSystemUIOverlayStyle(JSONObject message) {
|
||||
Window window = mActivity.getWindow();
|
||||
View view = window.getDecorView();
|
||||
int flags = view.getSystemUiVisibility();
|
||||
try {
|
||||
// You can change the navigation bar color (including translucent colors)
|
||||
// in Android, but you can't change the color of the navigation buttons until Android O.
|
||||
// LIGHT vs DARK effectively isn't supported until then.
|
||||
// Build.VERSION_CODES.O
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
if (!message.isNull("systemNavigationBarIconBrightness")) {
|
||||
String systemNavigationBarIconBrightness = message.getString("systemNavigationBarIconBrightness");
|
||||
switch (systemNavigationBarIconBrightness) {
|
||||
case "Brightness.dark":
|
||||
//View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||
flags |= 0x10;
|
||||
break;
|
||||
case "Brightness.light":
|
||||
if ((flags & 0x10) == 0x10) {
|
||||
flags ^= 0x10;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!message.isNull("systemNavigationBarColor")) {
|
||||
window.setNavigationBarColor(message.getInt("systemNavigationBarColor"));
|
||||
}
|
||||
}
|
||||
// Build.VERSION_CODES.M
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (!message.isNull("statusBarIconBrightness")) {
|
||||
String statusBarIconBrightness = message.getString("statusBarIconBrightness");
|
||||
switch (statusBarIconBrightness) {
|
||||
case "Brightness.dark":
|
||||
// View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||
flags |= 0x2000;
|
||||
break;
|
||||
case "Brightness.light":
|
||||
if ((flags & 0x2000) == 0x2000) {
|
||||
flags ^= 0x2000;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!message.isNull("statusBarColor")) {
|
||||
window.setStatusBarColor(message.getInt("statusBarColor"));
|
||||
}
|
||||
}
|
||||
if (!message.isNull("systemNavigationBarDividerColor")) {
|
||||
// Not availible until Android P.
|
||||
// window.setNavigationBarDividerColor(systemNavigationBarDividerColor);
|
||||
}
|
||||
view.setSystemUiVisibility(flags);
|
||||
mCurrentTheme = message;
|
||||
} catch (JSONException err) {
|
||||
Log.i("PlatformPlugin", err.toString());
|
||||
}
|
||||
private void setSystemChromeSystemUIOverlayStyle(String style) {
|
||||
// You can change the navigation bar color (including translucent colors)
|
||||
// in Android, but you can't change the color of the navigation buttons,
|
||||
// so LIGHT vs DARK effectively isn't supported in Android.
|
||||
}
|
||||
|
||||
private void popSystemNavigator() {
|
||||
|
||||
@ -137,12 +137,11 @@ using namespace shell;
|
||||
![overlays containsObject:@"SystemUiOverlay.top"];
|
||||
}
|
||||
|
||||
- (void)setSystemChromeSystemUIOverlayStyle:(NSDictionary*)message {
|
||||
NSString* style = message[@"statusBarBrightness"]
|
||||
UIStatusBarStyle statusBarStyle
|
||||
if ([style isEqualToString:@"Brightness.light"])
|
||||
- (void)setSystemChromeSystemUIOverlayStyle:(NSString*)style {
|
||||
UIStatusBarStyle statusBarStyle;
|
||||
if ([style isEqualToString:@"SystemUiOverlayStyle.light"])
|
||||
statusBarStyle = UIStatusBarStyleLightContent;
|
||||
else if ([style isEqualToString:@"Brightness.dark"])
|
||||
else if ([style isEqualToString:@"SystemUiOverlayStyle.dark"])
|
||||
statusBarStyle = UIStatusBarStyleDefault;
|
||||
else
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user