Skip to content

Commit 1cfe645

Browse files
committed
New notification to nudge users to try Gemini in Android Studio
1 parent f4cf901 commit 1cfe645

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

flutter-idea/src/io/flutter/FlutterInitializer.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.google.gson.JsonObject;
99
import com.google.gson.JsonPrimitive;
10+
import com.intellij.ide.browsers.BrowserLauncher;
1011
import com.intellij.ide.plugins.PluginManagerCore;
1112
import com.intellij.ide.ui.UISettingsListener;
1213
import com.intellij.notification.*;
@@ -52,6 +53,7 @@
5253
import io.flutter.view.FlutterViewFactory;
5354
import org.jetbrains.annotations.NotNull;
5455

56+
import java.time.LocalDate;
5557
import java.util.List;
5658
import java.util.concurrent.ExecutionException;
5759
import java.util.concurrent.Executors;
@@ -181,6 +183,8 @@ public void moduleAdded(@NotNull Project project, @NotNull Module module) {
181183
// Send unsupported SDK notifications if relevant.
182184
checkSdkVersionNotification(project);
183185

186+
showAndroidStudioBotNotification(project);
187+
184188
setUpDtdAnalytics(project);
185189
}
186190

@@ -317,6 +321,47 @@ public void actionPerformed(@NotNull AnActionEvent event) {
317321
}
318322
}
319323

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+
320365
private void initializeToolWindows(@NotNull Project project) {
321366
// Start watching for Flutter debug active events.
322367
FlutterViewFactory.init(project);

flutter-idea/src/io/flutter/settings/FlutterSettings.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class FlutterSettings {
3535
private static final String allowTestsInSourcesRootKey = "io.flutter.allowTestsInSources";
3636
private static final String showBazelIosRunNotificationKey = "io.flutter.hideBazelIosRunNotification";
3737
private static final String sdkVersionOutdatedWarningAcknowledgedKey = "io.flutter.sdkVersionOutdatedWarningAcknowledged";
38+
private static final String androidStudioBotAcknowledgedKey = "io.flutter.androidStudioBotAcknowledgedKey";
3839

3940
// TODO(helin24): This is to change the embedded browser setting back to true only once for Big Sur users. If we
4041
// switch to enabling the embedded browser for everyone, then delete this key.
@@ -317,4 +318,12 @@ public void setSdkVersionOutdatedWarningAcknowledged(String versionText, boolean
317318
private String getSdkVersionKey(String versionText) {
318319
return sdkVersionOutdatedWarningAcknowledgedKey + "_" + versionText;
319320
}
321+
322+
public boolean isAndroidStudioBotAcknowledged() {
323+
return getPropertiesComponent().getBoolean(androidStudioBotAcknowledgedKey, false);
324+
}
325+
326+
public void setAndroidStudioBotAcknowledgedKey(boolean value) {
327+
getPropertiesComponent().setValue(androidStudioBotAcknowledgedKey, value);
328+
}
320329
}

0 commit comments

Comments
 (0)