summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOluwatobi Bashir-Bello <nbashirbello@google.com>2014-08-07 00:46:53 +0000
committerandroid-build-merger <android-build-merger@google.com>2014-08-07 00:46:53 +0000
commitfbb00a81fbc812994023e85a85e3a0458b20a581 (patch)
treed7e60a7fc48949539b0d33b3f7e2cee2dbdae74e
parent839eb097c5fc73f91a722f1457a2e8e11eb4e1a5 (diff)
parenta90316fd5c1d0e2a1e3075cc293631706dc812b3 (diff)
downloadcloud-fbb00a81fbc812994023e85a85e3a0458b20a581.tar.gz
Merge "In the Google Login widget, change the non-signed in buttons from "Add Account" and "Sign Out" to a single "Sign in..." button" into idea133
automerge: a90316f * commit 'a90316fd5c1d0e2a1e3075cc293631706dc812b3': In the Google Login widget, change the non-signed in buttons from "Add Account" and "Sign Out" to a single "Sign in..." button
-rw-r--r--login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java25
1 files changed, 7 insertions, 18 deletions
diff --git a/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java b/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java
index 71c0627..6211e52 100644
--- a/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java
+++ b/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java
@@ -51,6 +51,7 @@ public class GoogleLoginUsersPanel extends JPanel implements ListSelectionListen
private DefaultListModel listModel;
private static final int MAX_VISIBLE_ROW_COUNT = 3;
private static final String addAccountString = "Add Account";
+ private static final String signInString = "Sign In";
private static final String signOutString = "Sign Out";
private JButton signOutButton;
private JButton addAccountButton;
@@ -117,7 +118,8 @@ public class GoogleLoginUsersPanel extends JPanel implements ListSelectionListen
}
});
- addAccountButton = new JButton(addAccountString);
+ boolean noUsersAvailable = (listModel.getSize() == 1) && (listModel.get(0) instanceof NoUsersListItem);
+ addAccountButton = new JButton(noUsersAvailable ? signInString : addAccountString);
AddAccountListener addAccountListener = new AddAccountListener();
addAccountButton.addActionListener(addAccountListener);
addAccountButton.setHorizontalAlignment(SwingConstants.LEFT);
@@ -129,9 +131,9 @@ public class GoogleLoginUsersPanel extends JPanel implements ListSelectionListen
signOutButton.setEnabled(false);
} else {
// If list contains the NoUsersListItem place holder
- // sign out button should be disabled
- if(listModel.get(0) instanceof NoUsersListItem) {
- signOutButton.setEnabled(false);
+ // sign out button should be hidden
+ if(noUsersAvailable) {
+ signOutButton.setVisible(false);
} else {
signOutButton.setEnabled(true);
}
@@ -155,20 +157,7 @@ public class GoogleLoginUsersPanel extends JPanel implements ListSelectionListen
class SignOutListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
- //This method can be called only if there's a valid selection
- int index = list.getSelectedIndex();
-
- boolean signedOut = GoogleLogin.getInstance().logOut();
- if(signedOut) {
- // remove logged out user
- listModel.remove(index);
- if (listModel.getSize() == 0) {
- signOutButton.setEnabled(false);
-
- // Add no user panel
- listModel.addElement(NoUsersListItem.INSTANCE);
- }
- }
+ GoogleLogin.getInstance().logOut();
}
}