|
7 | 7 |
|
8 | 8 | import com.google.gson.JsonObject;
|
9 | 9 | import com.google.gson.JsonPrimitive;
|
| 10 | +import com.intellij.ide.browsers.BrowserLauncher; |
10 | 11 | import com.intellij.ide.plugins.PluginManagerCore;
|
11 | 12 | import com.intellij.ide.ui.UISettingsListener;
|
12 | 13 | import com.intellij.notification.*;
|
@@ -181,6 +182,8 @@ public void moduleAdded(@NotNull Project project, @NotNull Module module) {
|
181 | 182 | // Send unsupported SDK notifications if relevant.
|
182 | 183 | checkSdkVersionNotification(project);
|
183 | 184 |
|
| 185 | + showAndroidStudioBotNotification(project); |
| 186 | + |
184 | 187 | setUpDtdAnalytics(project);
|
185 | 188 | }
|
186 | 189 |
|
@@ -317,6 +320,42 @@ public void actionPerformed(@NotNull AnActionEvent event) {
|
317 | 320 | }
|
318 | 321 | }
|
319 | 322 |
|
| 323 | + private void showAndroidStudioBotNotification(@NotNull Project project) { |
| 324 | + // Return if not a Flutter project |
| 325 | + FlutterSdk sdk = FlutterSdk.getFlutterSdk(project); |
| 326 | + if (sdk == null) return; |
| 327 | + |
| 328 | + // Return if not in Android Studio |
| 329 | + if (!FlutterUtils.isAndroidStudio()) return; |
| 330 | + |
| 331 | + // Return if notification has been shown already |
| 332 | + final FlutterSettings settings = FlutterSettings.getInstance(); |
| 333 | + if (settings == null || settings.isAndroidStudioBotAcknowledged()) return; |
| 334 | + |
| 335 | + ApplicationManager.getApplication().invokeLater(() -> { |
| 336 | + final Notification notification = new Notification(FlutterMessages.FLUTTER_NOTIFICATION_GROUP_ID, |
| 337 | + "Try Gemini in Android Studio", |
| 338 | + "", |
| 339 | + NotificationType.INFORMATION); |
| 340 | + notification.addAction(new AnAction("More Info") { |
| 341 | + @Override |
| 342 | + public void actionPerformed(@NotNull AnActionEvent event) { |
| 343 | + BrowserLauncher.getInstance().browse("https://developer.android.com/gemini-in-android", null); |
| 344 | + settings.setAndroidStudioBotAcknowledgedKey(true); |
| 345 | + notification.expire(); |
| 346 | + } |
| 347 | + }); |
| 348 | + notification.addAction(new AnAction("Dismiss") { |
| 349 | + @Override |
| 350 | + public void actionPerformed(@NotNull AnActionEvent event) { |
| 351 | + settings.setAndroidStudioBotAcknowledgedKey(true); |
| 352 | + notification.expire(); |
| 353 | + } |
| 354 | + }); |
| 355 | + Notifications.Bus.notify(notification, project); |
| 356 | + }); |
| 357 | + } |
| 358 | + |
320 | 359 | private void initializeToolWindows(@NotNull Project project) {
|
321 | 360 | // Start watching for Flutter debug active events.
|
322 | 361 | FlutterViewFactory.init(project);
|
|
0 commit comments