Skip to content

Commit a3fd255

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

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

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

Lines changed: 39 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.*;
@@ -181,6 +182,8 @@ public void moduleAdded(@NotNull Project project, @NotNull Module module) {
181182
// Send unsupported SDK notifications if relevant.
182183
checkSdkVersionNotification(project);
183184

185+
showAndroidStudioBotNotification(project);
186+
184187
setUpDtdAnalytics(project);
185188
}
186189

@@ -317,6 +320,42 @@ public void actionPerformed(@NotNull AnActionEvent event) {
317320
}
318321
}
319322

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+
320359
private void initializeToolWindows(@NotNull Project project) {
321360
// Start watching for Flutter debug active events.
322361
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)