|
10 | 10 | import com.google.gson.JsonPrimitive;
|
11 | 11 | import com.intellij.ProjectTopics;
|
12 | 12 | import com.intellij.ide.BrowserUtil;
|
| 13 | +import com.intellij.ide.browsers.BrowserLauncher; |
13 | 14 | import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
14 | 15 | import com.intellij.ide.plugins.PluginManagerCore;
|
15 | 16 | import com.intellij.ide.ui.UISettingsListener;
|
|
31 | 32 | import com.intellij.openapi.roots.ProjectRootManager;
|
32 | 33 | import com.intellij.openapi.startup.StartupActivity;
|
33 | 34 | import com.intellij.openapi.vfs.VirtualFile;
|
| 35 | +import com.intellij.openapi.wm.ToolWindow; |
| 36 | +import com.intellij.openapi.wm.ToolWindowManager; |
34 | 37 | import com.intellij.util.messages.MessageBusConnection;
|
35 | 38 | import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService;
|
| 39 | +import com.jetbrains.lang.dart.ide.errorTreeView.DartProblemsView; |
36 | 40 | import com.jetbrains.lang.dart.ide.toolingDaemon.DartToolingDaemonService;
|
37 | 41 | import de.roderick.weberknecht.WebSocketException;
|
38 | 42 | import io.flutter.analytics.Analytics;
|
|
59 | 63 | import io.flutter.run.daemon.DeviceService;
|
60 | 64 | import io.flutter.sdk.FlutterPluginsLibraryManager;
|
61 | 65 | import io.flutter.sdk.FlutterSdk;
|
| 66 | +import io.flutter.sdk.FlutterSdkVersion; |
62 | 67 | import io.flutter.settings.FlutterSettings;
|
63 | 68 | import io.flutter.survey.FlutterSurveyNotifications;
|
64 | 69 | import io.flutter.utils.FlutterModuleUtils;
|
@@ -215,6 +220,9 @@ public void moduleAdded(@NotNull Project project, @NotNull Module module) {
|
215 | 220 | // Initialize notifications for theme changes.
|
216 | 221 | setUpThemeChangeNotifications(project);
|
217 | 222 |
|
| 223 | + // Send unsupported SDK notifications if relevant. |
| 224 | + checkSdkVersionNotification(project); |
| 225 | + |
218 | 226 | setUpDtdAnalytics(project);
|
219 | 227 |
|
220 | 228 | // Initialize analytics.
|
@@ -276,8 +284,7 @@ private void setUpDtdAnalytics(Project project) {
|
276 | 284 | t1.start();
|
277 | 285 | }
|
278 | 286 |
|
279 |
| - private void setUpThemeChangeNotifications(Project project) { |
280 |
| - if (project == null) return; |
| 287 | + private void setUpThemeChangeNotifications(@NotNull Project project) { |
281 | 288 | FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
|
282 | 289 | if (sdk == null || !sdk.getVersion().canUseDtd()) return;
|
283 | 290 | Thread t1 = new Thread(() -> {
|
@@ -354,6 +361,44 @@ private void sendThemeChangedEvent(@NotNull Project project) {
|
354 | 361 | }, 1, TimeUnit.SECONDS);
|
355 | 362 | }
|
356 | 363 |
|
| 364 | + private void checkSdkVersionNotification(@NotNull Project project) { |
| 365 | + FlutterSdk sdk = FlutterSdk.getFlutterSdk(project); |
| 366 | + if (sdk == null) return; |
| 367 | + final FlutterSdkVersion version = sdk.getVersion(); |
| 368 | + |
| 369 | + if (!version.sdkIsSupported() && version.getVersionText() != null) { |
| 370 | + final FlutterSettings settings = FlutterSettings.getInstance(); |
| 371 | + if (settings == null || settings.isSdkVersionOutdatedWarningAcknowledged(version.getVersionText())) return; |
| 372 | + |
| 373 | + ApplicationManager.getApplication().invokeLater(() -> { |
| 374 | + final Notification notification = new Notification("flutter-sdk", |
| 375 | + "Flutter SDK requires update", |
| 376 | + "Support for v" + |
| 377 | + version.getVersionText() + |
| 378 | + " of the Flutter SDK will be removed in an upcoming release of the Flutter plugin. Consider updating to a more recent Flutter SDK", |
| 379 | + NotificationType.WARNING); |
| 380 | + notification.addAction(new AnAction("More Info") { |
| 381 | + @Override |
| 382 | + public void actionPerformed(@NotNull AnActionEvent event) { |
| 383 | + // TODO(helin24): Update with informational URL. |
| 384 | + BrowserLauncher.getInstance().browse("https://www.google.com", null); |
| 385 | + settings.setSdkVersionOutdatedWarningAcknowledged(version.getVersionText(), true); |
| 386 | + notification.expire(); |
| 387 | + } |
| 388 | + }); |
| 389 | + |
| 390 | + notification.addAction(new AnAction("I understand") { |
| 391 | + @Override |
| 392 | + public void actionPerformed(@NotNull AnActionEvent event) { |
| 393 | + settings.setSdkVersionOutdatedWarningAcknowledged(version.getVersionText(), true); |
| 394 | + notification.expire(); |
| 395 | + } |
| 396 | + }); |
| 397 | + Notifications.Bus.notify(notification, project); |
| 398 | + }); |
| 399 | + } |
| 400 | + } |
| 401 | + |
357 | 402 | private static void enableAnalytics(@NotNull Project project) {
|
358 | 403 | ToolWindowTracker.track(project, getAnalytics());
|
359 | 404 | DartAnalysisServerService.getInstance(project).addAnalysisServerListener(FlutterAnalysisServerListener.getInstance(project));
|
|
0 commit comments