|
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.*;
|
|
52 | 53 | import io.flutter.view.FlutterViewFactory;
|
53 | 54 | import org.jetbrains.annotations.NotNull;
|
54 | 55 |
|
| 56 | +import java.time.LocalDate; |
55 | 57 | import java.util.List;
|
56 | 58 | import java.util.concurrent.ExecutionException;
|
57 | 59 | import java.util.concurrent.Executors;
|
@@ -181,6 +183,8 @@ public void moduleAdded(@NotNull Project project, @NotNull Module module) {
|
181 | 183 | // Send unsupported SDK notifications if relevant.
|
182 | 184 | checkSdkVersionNotification(project);
|
183 | 185 |
|
| 186 | + showAndroidStudioBotNotification(project); |
| 187 | + |
184 | 188 | setUpDtdAnalytics(project);
|
185 | 189 | }
|
186 | 190 |
|
@@ -317,6 +321,47 @@ public void actionPerformed(@NotNull AnActionEvent event) {
|
317 | 321 | }
|
318 | 322 | }
|
319 | 323 |
|
| 324 | + private void showAndroidStudioBotNotification(@NotNull Project project) { |
| 325 | + // Return if not a Flutter project |
| 326 | + FlutterSdk sdk = FlutterSdk.getFlutterSdk(project); |
| 327 | + if (sdk == null) return; |
| 328 | + |
| 329 | + // Return if not in Android Studio |
| 330 | + if (!FlutterUtils.isAndroidStudio()) return; |
| 331 | + |
| 332 | + // Return if notification has been shown already |
| 333 | + final FlutterSettings settings = FlutterSettings.getInstance(); |
| 334 | + if (settings == null || settings.isAndroidStudioBotAcknowledged()) return; |
| 335 | + |
| 336 | + // Return if the current date is not after May 16th, 2025 |
| 337 | + LocalDate targetLocalDate = LocalDate.of(2025, 5, 16); |
| 338 | + LocalDate nowLocalDate = LocalDate.now(); |
| 339 | + if (nowLocalDate.isBefore(targetLocalDate)) return; |
| 340 | + |
| 341 | + ApplicationManager.getApplication().invokeLater(() -> { |
| 342 | + final Notification notification = new Notification(FlutterMessages.FLUTTER_NOTIFICATION_GROUP_ID, |
| 343 | + "Try Gemini in Android Studio", |
| 344 | + "", |
| 345 | + NotificationType.INFORMATION); |
| 346 | + notification.addAction(new AnAction("More Info") { |
| 347 | + @Override |
| 348 | + public void actionPerformed(@NotNull AnActionEvent event) { |
| 349 | + BrowserLauncher.getInstance().browse("https://developer.android.com/gemini-in-android", null); |
| 350 | + settings.setAndroidStudioBotAcknowledgedKey(true); |
| 351 | + notification.expire(); |
| 352 | + } |
| 353 | + }); |
| 354 | + notification.addAction(new AnAction("Dismiss") { |
| 355 | + @Override |
| 356 | + public void actionPerformed(@NotNull AnActionEvent event) { |
| 357 | + settings.setAndroidStudioBotAcknowledgedKey(true); |
| 358 | + notification.expire(); |
| 359 | + } |
| 360 | + }); |
| 361 | + Notifications.Bus.notify(notification, project); |
| 362 | + }); |
| 363 | + } |
| 364 | + |
320 | 365 | private void initializeToolWindows(@NotNull Project project) {
|
321 | 366 | // Start watching for Flutter debug active events.
|
322 | 367 | FlutterViewFactory.init(project);
|
|
0 commit comments