summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOluwatobi Bashir-Bello <nbashirbello@google.com>2014-10-02 11:11:07 -0400
committerOluwatobi Bashir-Bello <nbashirbello@google.com>2014-10-06 14:56:16 -0400
commit615663a62f9097ba2d7cc1e8f16004cc428a2699 (patch)
tree848e41d3ca8d7afe28efdd10deb2e0d26f0938a9
parentb85c8f075b3b429b6660a34db585453d4cc33808 (diff)
downloadlogin-615663a62f9097ba2d7cc1e8f16004cc428a2699.tar.gz
Change the colors of the Google Login panel so that they match the current ide theme.
Let the panel be dark in the Darcula theme and light in the IntelliJ and GTK themes. Same as https://android-review.googlesource.com/#/c/108843/ but moved to login repo (studio/google/login) Change-Id: I5de65b4c6cc42905f2df494bb04ffb17bdde7464
-rw-r--r--resources/icons/google.pngbin5302 -> 0 bytes
-rw-r--r--resources/icons/google@2x.pngbin3626 -> 0 bytes
-rw-r--r--resources/icons/googleColored.pngbin0 -> 2510 bytes
-rw-r--r--resources/icons/googleWhite.pngbin0 -> 984 bytes
-rw-r--r--src/com/google/gct/login/ui/UsersListCellRenderer.java153
5 files changed, 76 insertions, 77 deletions
diff --git a/resources/icons/google.png b/resources/icons/google.png
deleted file mode 100644
index af0beb8..0000000
--- a/resources/icons/google.png
+++ /dev/null
Binary files differ
diff --git a/resources/icons/google@2x.png b/resources/icons/google@2x.png
deleted file mode 100644
index ad846a4..0000000
--- a/resources/icons/google@2x.png
+++ /dev/null
Binary files differ
diff --git a/resources/icons/googleColored.png b/resources/icons/googleColored.png
new file mode 100644
index 0000000..c8ae624
--- /dev/null
+++ b/resources/icons/googleColored.png
Binary files differ
diff --git a/resources/icons/googleWhite.png b/resources/icons/googleWhite.png
new file mode 100644
index 0000000..b37179c
--- /dev/null
+++ b/resources/icons/googleWhite.png
Binary files differ
diff --git a/src/com/google/gct/login/ui/UsersListCellRenderer.java b/src/com/google/gct/login/ui/UsersListCellRenderer.java
index 46df2d1..928eeba 100644
--- a/src/com/google/gct/login/ui/UsersListCellRenderer.java
+++ b/src/com/google/gct/login/ui/UsersListCellRenderer.java
@@ -15,8 +15,10 @@
*/
package com.google.gct.login.ui;
+import com.intellij.ui.ColorUtil;
import com.intellij.ui.JBColor;
import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.Nullable;
import javax.swing.BorderFactory;
import javax.swing.Box;
@@ -50,55 +52,53 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
private final static String CLOUD_LABEL_TEXT = "Open Google Developers Console";
private final static String PLAY_LABEL_TEXT = "Open Play Developer Console";
private final static String DEFAULT_AVATAR = "/icons/loginAvatar@2x.png";
- private final static String GOOGLE_IMG = "/icons/google.png";
+ private final static String GOOGLE_IMG_COL = "/icons/googleColored.png";
+ private final static String GOOGLE_IMG_WHITE = "/icons/googleWhite.png";
private final static String SIGN_IN_TEXT = "<HTML> Sign in with your Google account to start <br> adding "
+ "Cloud functionality to your <br> Android applications from Android Studio. </HTML>";
private final static String LEARN_MORE_TEXT = "Learn more";
- private final Color LEARN_MORE_COLOR;
- private final Color SIGN_IN_COLOR;
- private final Color ACTIVE_COLOR;
- private final Color INACTIVE_COLOR;
- private final int PLAIN_USER_IMAGE_WIDTH = 48;
- private final int PLAIN_USER_IMAGE_HEIGHT = 48;
- private final int ACTIVE_USER_IMAGE_WIDTH = 96;
- private final int ACTIVE_USER_IMAGE_HEIGHT = 96;
- private final int GOOGLE_IMAGE_WIDTH = 96;
- private final int GOOGLE_IMAGE_HEIGHT = 35;
- private final int GOOGLE_IMAGE_NORTH = 18;
- private final int GOOGLE_IMAGE_WEST = 18;
- private final int WELCOME_LABEL_NORTH = 15;
- private final int WELCOME_LABEL_SOUTH = 25;
- private final int WELCOME_LABEL_EAST = 38;
- private final int USER_LABEL_VERTICAL_STRUT = 3;
- private final int HGAP = 10;
- private final int VGAP = 10;
- private final int GENERAL_FONT_HEIGHT;
- private final Font NAME_FONT;
- private final Font GENERAL_FONT;
- private final Dimension MAIN_PANEL_DIMENSION;
- private final Dimension ACTIVE_MAIN_PANEL_DIMENSION;
- private final Dimension CLOUD_LABEL_DIMENSION;
- private final Dimension PLAY_LABEL_DIMENSION;
- private final Dimension LEARN_MORE_LABEL_DIMENSION;
+ private final Color myActiveColor;
+ private final Color myInactiveColor;
+ private static final int PLAIN_USER_IMAGE_WIDTH = 48;
+ private static final int PLAIN_USER_IMAGE_HEIGHT = 48;
+ private static final int ACTIVE_USER_IMAGE_WIDTH = 96;
+ private static final int ACTIVE_USER_IMAGE_HEIGHT = 96;
+ private static final int GOOGLE_IMAGE_WIDTH = 96;
+ private static final int GOOGLE_IMAGE_HEIGHT = 35;
+ private static final int GOOGLE_IMAGE_NORTH = 18;
+ private static final int GOOGLE_IMAGE_WEST = 18;
+ private static final int WELCOME_LABEL_NORTH = 15;
+ private static final int WELCOME_LABEL_SOUTH = 25;
+ private static final int WELCOME_LABEL_EAST = 38;
+ private static final int USER_LABEL_VERTICAL_STRUT = 3;
+ private static final int HGAP = 10;
+ private static final int VGAP = 10;
+ private final int myGeneralFontHeight;
+ private final Font myNameFont;
+ private final Font myGeneralFont;
+ private final Dimension myMainPanelDimension;
+ private final Dimension myActiveMainPanelDimension;
+ private final Dimension myCloudLabelDimension;
+ private final Dimension myPlayLabelDimension;
+ private final Dimension myLearnMoreLabelDimension;
public UsersListCellRenderer() {
- NAME_FONT = new Font("Helvetica", Font.BOLD, 13);
- GENERAL_FONT = new Font("Helvetica", Font.PLAIN, 13);
- MAIN_PANEL_DIMENSION = new Dimension(250, 68);
- ACTIVE_MAIN_PANEL_DIMENSION = new Dimension(250, 116);
- SIGN_IN_COLOR = new Color(666666);
- LEARN_MORE_COLOR = new Color(666);
-
- ACTIVE_COLOR = new Color(0xffffff);
- INACTIVE_COLOR = new Color(0xf5f5f5);
-
- FontMetrics fontMetrics = getFontMetrics(GENERAL_FONT);
- GENERAL_FONT_HEIGHT = fontMetrics.getHeight();
- CLOUD_LABEL_DIMENSION = new Dimension(fontMetrics.stringWidth(CLOUD_LABEL_TEXT), GENERAL_FONT_HEIGHT);
- PLAY_LABEL_DIMENSION = new Dimension(fontMetrics.stringWidth(PLAY_LABEL_TEXT), GENERAL_FONT_HEIGHT);
- LEARN_MORE_LABEL_DIMENSION = new Dimension(fontMetrics.stringWidth(LEARN_MORE_TEXT), GENERAL_FONT_HEIGHT);
+ myNameFont = new Font("Helvetica", Font.BOLD, 13);
+ myGeneralFont = new Font("Helvetica", Font.PLAIN, 13);
+ myMainPanelDimension = new Dimension(250, 68);
+ myActiveMainPanelDimension = new Dimension(250, 116);
+ Color bg = UIUtil.getTextFieldBackground();
+ myActiveColor = UIUtil.isUnderDarcula() ? ColorUtil.shift(bg, 1.4) : new Color(0xffffff);
+ myInactiveColor = UIUtil.isUnderDarcula() ? bg : new Color(0xf5f5f5);
+
+ FontMetrics fontMetrics = getFontMetrics(myGeneralFont);
+ myGeneralFontHeight = fontMetrics.getHeight();
+ myCloudLabelDimension = new Dimension(fontMetrics.stringWidth(CLOUD_LABEL_TEXT), myGeneralFontHeight);
+ myPlayLabelDimension = new Dimension(fontMetrics.stringWidth(PLAY_LABEL_TEXT), myGeneralFontHeight);
+ myLearnMoreLabelDimension = new Dimension(fontMetrics.stringWidth(LEARN_MORE_TEXT), myGeneralFontHeight);
}
+ @Nullable
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if(value instanceof NoUsersListItem) {
@@ -118,11 +118,11 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
}
JPanel mainPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, HGAP, VGAP));
- mainPanel.setMinimumSize(calcIsSelected ? ACTIVE_MAIN_PANEL_DIMENSION : MAIN_PANEL_DIMENSION);
+ mainPanel.setMinimumSize(calcIsSelected ? myActiveMainPanelDimension : myMainPanelDimension);
mainPanel.setAlignmentX(LEFT_ALIGNMENT);
// Update colors
- final Color bg = calcIsSelected ? ACTIVE_COLOR : INACTIVE_COLOR;
+ final Color bg = calcIsSelected ? myActiveColor : myInactiveColor;
final Color fg = calcIsSelected ? UIUtil.getListSelectionForeground() : UIUtil.getListForeground();
mainPanel.setBackground(bg);
mainPanel.setForeground(fg);
@@ -137,7 +137,7 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
int imageWidth = calcIsSelected ? ACTIVE_USER_IMAGE_WIDTH : PLAIN_USER_IMAGE_WIDTH;
int imageHeight = calcIsSelected ? ACTIVE_USER_IMAGE_HEIGHT : PLAIN_USER_IMAGE_HEIGHT;
- Image scaledImage = image.getScaledInstance(imageWidth, imageHeight, java.awt.Image.SCALE_SMOOTH);
+ Image scaledImage = image.getScaledInstance(imageWidth, imageHeight, Image.SCALE_SMOOTH);
JComponent textPanel;
if (calcIsSelected) {
@@ -155,12 +155,12 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
public boolean inPlayConsoleUrl(Point point, int activeIndex) {
// 2 is for the number of labels before this one
- double playYStart = VGAP + ACTIVE_USER_IMAGE_HEIGHT - PLAY_LABEL_DIMENSION.getHeight()
- - CLOUD_LABEL_DIMENSION.getHeight() - 2 + (MAIN_PANEL_DIMENSION.getHeight() * activeIndex)
+ double playYStart = VGAP + ACTIVE_USER_IMAGE_HEIGHT - myPlayLabelDimension.getHeight()
+ - myCloudLabelDimension.getHeight() - 2 + (myMainPanelDimension.getHeight() * activeIndex)
+ USER_LABEL_VERTICAL_STRUT;
- double playYEnd = playYStart + PLAY_LABEL_DIMENSION.getHeight();
+ double playYEnd = playYStart + myPlayLabelDimension.getHeight();
double playXStart = ACTIVE_USER_IMAGE_WIDTH + HGAP + VGAP;
- double playXEnd = playXStart + PLAY_LABEL_DIMENSION.getWidth();
+ double playXEnd = playXStart + myPlayLabelDimension.getWidth();
if((point.getX() > playXStart) && (point.getX() < playXEnd)
&& (point.getY() > playYStart) && (point.getY() < playYEnd)) {
@@ -172,11 +172,11 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
public boolean inCloudConsoleUrl(Point point, int activeIndex) {
// 3 is for the number of labels before this one
- double playYStart = VGAP + ACTIVE_USER_IMAGE_HEIGHT - CLOUD_LABEL_DIMENSION.getHeight()
- - 3 + (MAIN_PANEL_DIMENSION.getHeight() * activeIndex) + (USER_LABEL_VERTICAL_STRUT * 2);
- double playYEnd = playYStart + CLOUD_LABEL_DIMENSION.getHeight();
+ double playYStart = VGAP + ACTIVE_USER_IMAGE_HEIGHT - myCloudLabelDimension.getHeight()
+ - 3 + (myMainPanelDimension.getHeight() * activeIndex) + (USER_LABEL_VERTICAL_STRUT * 2);
+ double playYEnd = playYStart + myCloudLabelDimension.getHeight();
double playXStart = ACTIVE_USER_IMAGE_WIDTH + HGAP + VGAP;
- double playXEnd = playXStart + CLOUD_LABEL_DIMENSION.getWidth();
+ double playXEnd = playXStart + myCloudLabelDimension.getWidth();
if((point.getX() > playXStart) && (point.getX() < playXEnd)
&& (point.getY() > playYStart) && (point.getY() < playYEnd)) {
@@ -189,10 +189,10 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
public boolean inLearnMoreUrl(Point point) {
// 3 is for the number of labels and row of texts
double urlYStart = GOOGLE_IMAGE_NORTH + GOOGLE_IMAGE_HEIGHT + WELCOME_LABEL_NORTH
- + (GENERAL_FONT_HEIGHT * 3) + 3;
- double urlYEnd = urlYStart + LEARN_MORE_LABEL_DIMENSION.getHeight();
+ + (myGeneralFontHeight * 3) + 3;
+ double urlYEnd = urlYStart + myLearnMoreLabelDimension.getHeight();
double urlXStart = GOOGLE_IMAGE_WEST;
- double urlXEnd = urlXStart + LEARN_MORE_LABEL_DIMENSION.getWidth();
+ double urlXEnd = urlXStart + myLearnMoreLabelDimension.getWidth();
if((point.getX() > urlXStart) && (point.getX() < urlXEnd)
&& (point.getY() > urlYStart) && (point.getY() < urlYEnd)) {
@@ -203,30 +203,29 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
}
public int getMainPanelHeight() {
- return (int)MAIN_PANEL_DIMENSION.getHeight();
+ return (int)myMainPanelDimension.getHeight();
}
public int getActivePanelHeight() {
- return (int)ACTIVE_MAIN_PANEL_DIMENSION.getHeight();
+ return (int)myActiveMainPanelDimension.getHeight();
}
private JComponent createTextDisplay(boolean isSelected, UsersListItem usersListItem) {
final JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
- final Color bg = isSelected ? ACTIVE_COLOR : INACTIVE_COLOR;
+ final Color bg = isSelected ? myActiveColor : myInactiveColor;
final Color fg = isSelected ? UIUtil.getListSelectionForeground() : UIUtil.getListForeground();
panel.setBackground(bg);
panel.setForeground(fg);
JLabel nameLabel = new JLabel( usersListItem.getUserName());
- nameLabel.setFont(NAME_FONT);
- nameLabel.setForeground(JBColor.BLACK);
+ nameLabel.setFont(myNameFont);
panel.add(nameLabel);
panel.add(Box.createVerticalStrut(USER_LABEL_VERTICAL_STRUT));
JLabel emailLabel = new JLabel(usersListItem.getUserEmail());
- emailLabel.setFont(GENERAL_FONT);
+ emailLabel.setFont(myGeneralFont);
panel.add(emailLabel);
return panel;
@@ -236,27 +235,27 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new GridBagLayout());
- mainPanel.setBackground(ACTIVE_COLOR);
+ mainPanel.setBackground(myActiveColor);
mainPanel.setForeground(UIUtil.getListSelectionForeground());
mainPanel.setPreferredSize(new Dimension(220, ACTIVE_USER_IMAGE_HEIGHT));
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.PAGE_AXIS));
- bottomPanel.setBackground(ACTIVE_COLOR);
+ bottomPanel.setBackground(myActiveColor);
bottomPanel.setForeground(UIUtil.getListSelectionForeground());
- bottomPanel.setPreferredSize(new Dimension(220, (GENERAL_FONT_HEIGHT * 2) + USER_LABEL_VERTICAL_STRUT));
+ bottomPanel.setPreferredSize(new Dimension(220, (myGeneralFontHeight * 2) + USER_LABEL_VERTICAL_STRUT));
JLabel playLabel = new JLabel(PLAY_LABEL_TEXT);
- playLabel.setFont(GENERAL_FONT);
+ playLabel.setFont(myGeneralFont);
playLabel.setForeground(JBColor.BLUE);
- playLabel.setPreferredSize(PLAY_LABEL_DIMENSION);
+ playLabel.setPreferredSize(myPlayLabelDimension);
bottomPanel.add(playLabel, BOTTOM_ALIGNMENT);
bottomPanel.add(Box.createVerticalStrut(USER_LABEL_VERTICAL_STRUT));
JLabel cloudLabel = new JLabel(CLOUD_LABEL_TEXT);
- cloudLabel.setFont(GENERAL_FONT);
+ cloudLabel.setFont(myGeneralFont);
cloudLabel.setForeground(JBColor.BLUE);
- cloudLabel.setPreferredSize(CLOUD_LABEL_DIMENSION);
+ cloudLabel.setPreferredSize(myCloudLabelDimension);
bottomPanel.add(cloudLabel, BOTTOM_ALIGNMENT);
GridBagConstraints topConstraints = new GridBagConstraints();
@@ -281,25 +280,25 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
JPanel mainPanel = new JPanel();
BoxLayout layout = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
mainPanel.setLayout(layout);
- mainPanel.setBackground(Color.WHITE);
+ mainPanel.setBackground(JBColor.WHITE);
mainPanel.setBorder(BorderFactory.createEmptyBorder(0, GOOGLE_IMAGE_WEST, 0, 0));
- URL url = UsersListCellRenderer.class.getResource(GOOGLE_IMG);
+ String googleIcon = UIUtil.isUnderDarcula() ? GOOGLE_IMG_WHITE : GOOGLE_IMG_COL;
+ URL url = UsersListCellRenderer.class.getResource(googleIcon);
Image image = Toolkit.getDefaultToolkit().getImage(url);
Image scaledImage = image.getScaledInstance(
- GOOGLE_IMAGE_WIDTH, GOOGLE_IMAGE_HEIGHT, java.awt.Image.SCALE_SMOOTH);
+ GOOGLE_IMAGE_WIDTH, GOOGLE_IMAGE_HEIGHT, Image.SCALE_SMOOTH);
JLabel imageLabel = new JLabel(new ImageIcon(scaledImage));
JLabel signInLabel = new JLabel(SIGN_IN_TEXT);
- signInLabel.setFont(GENERAL_FONT);
- signInLabel.setForeground(SIGN_IN_COLOR);
+ signInLabel.setFont(myGeneralFont);
Dimension textSize = signInLabel.getPreferredSize();
signInLabel.setPreferredSize(new Dimension((int)textSize.getWidth() + WELCOME_LABEL_EAST, (int)textSize.getHeight()));
JLabel urlLabel = new JLabel(LEARN_MORE_TEXT);
- urlLabel.setFont(GENERAL_FONT);
- urlLabel.setForeground(LEARN_MORE_COLOR);
- urlLabel.setPreferredSize(LEARN_MORE_LABEL_DIMENSION);
+ urlLabel.setFont(myGeneralFont);
+ urlLabel.setForeground(JBColor.BLUE);
+ urlLabel.setPreferredSize(myLearnMoreLabelDimension);
mainPanel.add(Box.createVerticalStrut(GOOGLE_IMAGE_NORTH));
mainPanel.add(imageLabel);