Skip to content

New notification to nudge users to try Gemini in Android Studio #8138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions flutter-idea/src/io/flutter/FlutterInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.intellij.ide.browsers.BrowserLauncher;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.ide.ui.UISettingsListener;
import com.intellij.notification.*;
Expand Down Expand Up @@ -52,6 +53,7 @@
import io.flutter.view.FlutterViewFactory;
import org.jetbrains.annotations.NotNull;

import java.time.LocalDate;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -181,6 +183,8 @@ public void moduleAdded(@NotNull Project project, @NotNull Module module) {
// Send unsupported SDK notifications if relevant.
checkSdkVersionNotification(project);

showAndroidStudioBotNotification(project);

setUpDtdAnalytics(project);
}

Expand Down Expand Up @@ -317,6 +321,47 @@ public void actionPerformed(@NotNull AnActionEvent event) {
}
}

private void showAndroidStudioBotNotification(@NotNull Project project) {
// Return if not a Flutter project
FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
if (sdk == null) return;

// Return if not in Android Studio
if (!FlutterUtils.isAndroidStudio()) return;

// Return if notification has been shown already
final FlutterSettings settings = FlutterSettings.getInstance();
if (settings == null || settings.isAndroidStudioBotAcknowledged()) return;

// Return if the current date is not after May 16th, 2025
LocalDate targetLocalDate = LocalDate.of(2025, 5, 16);
LocalDate nowLocalDate = LocalDate.now();
if (nowLocalDate.isBefore(targetLocalDate)) return;

ApplicationManager.getApplication().invokeLater(() -> {
final Notification notification = new Notification(FlutterMessages.FLUTTER_NOTIFICATION_GROUP_ID,
"Try Gemini in Android Studio",
"",
NotificationType.INFORMATION);
notification.addAction(new AnAction("More Info") {
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
BrowserLauncher.getInstance().browse("https://developer.android.com/gemini-in-android", null);
settings.setAndroidStudioBotAcknowledgedKey(true);
notification.expire();
}
});
notification.addAction(new AnAction("Dismiss") {
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
settings.setAndroidStudioBotAcknowledgedKey(true);
notification.expire();
}
});
Notifications.Bus.notify(notification, project);
});
}

private void initializeToolWindows(@NotNull Project project) {
// Start watching for Flutter debug active events.
FlutterViewFactory.init(project);
Expand Down
9 changes: 9 additions & 0 deletions flutter-idea/src/io/flutter/settings/FlutterSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class FlutterSettings {
private static final String allowTestsInSourcesRootKey = "io.flutter.allowTestsInSources";
private static final String showBazelIosRunNotificationKey = "io.flutter.hideBazelIosRunNotification";
private static final String sdkVersionOutdatedWarningAcknowledgedKey = "io.flutter.sdkVersionOutdatedWarningAcknowledged";
private static final String androidStudioBotAcknowledgedKey = "io.flutter.androidStudioBotAcknowledgedKey";

// TODO(helin24): This is to change the embedded browser setting back to true only once for Big Sur users. If we
// switch to enabling the embedded browser for everyone, then delete this key.
Expand Down Expand Up @@ -317,4 +318,12 @@ public void setSdkVersionOutdatedWarningAcknowledged(String versionText, boolean
private String getSdkVersionKey(String versionText) {
return sdkVersionOutdatedWarningAcknowledgedKey + "_" + versionText;
}

public boolean isAndroidStudioBotAcknowledged() {
return getPropertiesComponent().getBoolean(androidStudioBotAcknowledgedKey, false);
}

public void setAndroidStudioBotAcknowledgedKey(boolean value) {
getPropertiesComponent().setValue(androidStudioBotAcknowledgedKey, value);
}
}