Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flutter-idea/src/io/flutter/editor/FlutterColors.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private static String maybeTrimSuffix(String value, String suffix) {
return value;
}

private static Color parseColor(String hexValue) {
static @Nullable Color parseColor(String hexValue) {
if (hexValue == null) {
return null;
}
Expand Down
23 changes: 3 additions & 20 deletions flutter-idea/src/io/flutter/editor/FlutterCupertinoColors.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class FlutterCupertinoColors {
for (Map.Entry<Object, Object> entry : colors.entrySet()) {
final String name = (String)entry.getKey();
final String value = (String)entry.getValue();
final Color color = parseColor(value);
final Color color = FlutterColors.parseColor(value);
if (color != null) {
colorToName.put(color, name);
}
Expand Down Expand Up @@ -90,25 +90,8 @@ private static String maybeTrimSuffix(String value, String suffix) {
return value;
}

private static Color parseColor(String hexValue) {
if (hexValue == null) {
return null;
}

try {
// argb to r, g, b, a
final long value = Long.parseLong(hexValue, 16);

//noinspection UseJBColor
return new Color((int)(value >> 16) & 0xFF, (int)(value >> 8) & 0xFF, (int)value & 0xFF, (int)(value >> 24) & 0xFF);
}
catch (IllegalArgumentException e) {
return null;
}
}

private static Color getColorValue(String name) {
private static @Nullable Color getColorValue(String name) {
final String hexValue = colors.getProperty(name);
return parseColor(hexValue);
return FlutterColors.parseColor(hexValue);
}
}
17 changes: 1 addition & 16 deletions flutter-idea/src/io/flutter/run/SdkAttachConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,7 @@ public LaunchState getState(@NotNull Executor executor, @NotNull ExecutionEnviro
if (device == null) return null;

final GeneralCommandLine command = getCommand(env, device);

final FlutterApp app = FlutterApp.start(env, project, module, mode, device, command,
StringUtil.capitalize(mode.mode()) + "App",
"StopApp");

// Stop the app if the Flutter SDK changes.
final FlutterSdkManager.Listener sdkListener = new FlutterSdkManager.Listener() {
@Override
public void flutterSdkRemoved() {
app.shutdownAsync();
}
};
FlutterSdkManager.getInstance(project).addListener(sdkListener);
Disposer.register(app, () -> FlutterSdkManager.getInstance(project).removeListener(sdkListener));

return app;
return getFlutterApp(env, device, project, module, mode, command);
};

final LaunchState launcher = new AttachState(env, mainFile.getAppDir(), mainFile.getFile(), this, createAppCallback);
Expand Down
39 changes: 24 additions & 15 deletions flutter-idea/src/io/flutter/run/SdkRunConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,28 +187,37 @@ public LaunchState getState(@NotNull Executor executor, @NotNull ExecutionEnviro
}
}

final FlutterApp app = FlutterApp.start(env, project, module, mode, device, command,
StringUtil.capitalize(mode.mode()) + "App",
"StopApp");

// Stop the app if the Flutter SDK changes.
final FlutterSdkManager.Listener sdkListener = new FlutterSdkManager.Listener() {
@Override
public void flutterSdkRemoved() {
app.shutdownAsync();
}
};
FlutterSdkManager.getInstance(project).addListener(sdkListener);
Disposer.register(app, () -> FlutterSdkManager.getInstance(project).removeListener(sdkListener));

return app;
return getFlutterApp(env, device, project, module, mode, command);
};

final LaunchState launcher = new LaunchState(env, mainFile.getAppDir(), mainFile.getFile(), this, createAppCallback);
addConsoleFilters(launcher, env, mainFile, module);
return launcher;
}

static @NotNull FlutterApp getFlutterApp(@NotNull ExecutionEnvironment env,
@NotNull FlutterDevice device,
Project project,
Module module,
RunMode mode,
GeneralCommandLine command) throws ExecutionException {
final FlutterApp app = FlutterApp.start(env, project, module, mode, device, command,
StringUtil.capitalize(mode.mode()) + "App",
"StopApp");

// Stop the app if the Flutter SDK changes.
final FlutterSdkManager.Listener sdkListener = new FlutterSdkManager.Listener() {
@Override
public void flutterSdkRemoved() {
app.shutdownAsync();
}
};
FlutterSdkManager.getInstance(project).addListener(sdkListener);
Disposer.register(app, () -> FlutterSdkManager.getInstance(project).removeListener(sdkListener));

return app;
}

protected void addConsoleFilters(@NotNull LaunchState launcher,
@NotNull ExecutionEnvironment env,
@NotNull MainFile mainFile,
Expand Down