Skip to content
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
41 changes: 35 additions & 6 deletions src/io/flutter/actions/DeviceSelectorAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
import com.intellij.icons.AllIcons;
import com.intellij.ide.ActivityTracker;
import com.intellij.ide.DataManager;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.actionSystem.Separator;
import com.intellij.openapi.actionSystem.ex.CustomComponentAction;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
Expand All @@ -31,6 +40,8 @@
import com.intellij.util.ui.UIUtil;
import icons.FlutterIcons;
import io.flutter.FlutterBundle;
import io.flutter.analytics.Analytics;
import io.flutter.analytics.AnalyticsData;
import io.flutter.logging.PluginLogger;
import io.flutter.run.FlutterDevice;
import io.flutter.run.daemon.DeviceService;
Expand All @@ -39,12 +50,28 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.awt.*;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

public class DeviceSelectorAction extends AnAction implements CustomComponentAction, DumbAware {
private static final @NotNull Logger LOG = PluginLogger.createLogger(DeviceSelectorAction.class);
Expand Down Expand Up @@ -89,7 +116,7 @@ public class DeviceSelectorAction extends AnAction implements CustomComponentAct
* </p>
*
* @return A {@link Color} suitable for toolbar text that adapts to the current theme,
* including configurations like light themes with dark headers.
* including configurations like light themes with dark headers.
*/
@NotNull Color getToolbarForegroundColor() {
return JBColor.namedColor(TOOLBAR_FOREGROUND_KEY, UIUtil.getLabelForeground());
Expand All @@ -105,7 +132,7 @@ public class DeviceSelectorAction extends AnAction implements CustomComponentAct
* </p>
*
* @return A {@link Color} suitable for toolbar icon button hover states that adapts to the
* current theme, ensuring consistency with other toolbar actions.
* current theme, ensuring consistency with other toolbar actions.
*/
@NotNull Color getToolbarHoverBackgroundColor() {
return JBColor.namedColor(TOOLBAR_ICON_HOVER_BACKGROUND_KEY, JBUI.CurrentTheme.ActionButton.hoverBackground());
Expand All @@ -122,6 +149,8 @@ public void actionPerformed(@NotNull AnActionEvent e) {
return;
}

Analytics.report(AnalyticsData.forAction(this, e));

final DefaultActionGroup group = new DefaultActionGroup();
group.addAll(actions);

Expand Down
9 changes: 6 additions & 3 deletions src/io/flutter/actions/DeviceSelectorRefresherAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import io.flutter.analytics.Analytics;
import io.flutter.analytics.AnalyticsData;
import io.flutter.run.daemon.DeviceService;
import io.flutter.utils.FlutterModuleUtils;
import org.jetbrains.annotations.NotNull;
Expand All @@ -17,9 +19,10 @@ public class DeviceSelectorRefresherAction extends AnAction {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final Project project = e.getProject();
if (project != null) {
DeviceService.getInstance(project).restart();
}
if (project == null) return;

Analytics.report(AnalyticsData.forAction(this, e));
DeviceService.getInstance(project).restart();
}

public @NotNull ActionUpdateThread getActionUpdateThread() {
Expand Down