diff options
author | Danny van Heumen <danny@dannyvanheumen.nl> | 2015-07-22 22:56:23 +0200 |
---|---|---|
committer | Danny van Heumen <danny@dannyvanheumen.nl> | 2015-07-22 23:13:27 +0200 |
commit | 897600b91d702207cd28f8afc5856057beb1f0fc (patch) | |
tree | aa4334e95c79d06af7616235b9c9eb7f92818ae3 /src/net | |
parent | c6b42c0b1a016a10164fd4c5c3feec5e7ce3b7f8 (diff) | |
download | jitsi-897600b91d702207cd28f8afc5856057beb1f0fc.zip jitsi-897600b91d702207cd28f8afc5856057beb1f0fc.tar.gz jitsi-897600b91d702207cd28f8afc5856057beb1f0fc.tar.bz2 |
Number of improvements to Google Contacts OAuth dialog after feedback.
* i18n support.
* Show instructions at top of dialog.
* Explicitly say "click here" in hyperlink text for opening approval page.
* Changed text of Done button to "Save". (Depending on i18n.)
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java | 77 |
1 files changed, 62 insertions, 15 deletions
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java b/src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java index cf2cca7..4776e21 100644 --- a/src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java +++ b/src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java @@ -34,6 +34,7 @@ import org.apache.http.client.entity.*; import org.apache.http.client.methods.*; import org.apache.http.impl.client.*; import org.apache.http.message.*; +import org.jitsi.service.resources.*; import com.google.api.client.auth.oauth2.*; import com.google.api.client.http.*; @@ -196,7 +197,12 @@ public class OAuth2TokenStore + " using URL: " + APPROVAL_URL); final OAuthApprovalDialog dialog = new OAuthApprovalDialog(identity); - dialog.setVisible(true); + // Synchronize on OAuth approval dialog CLASS, to ensure that only + // one dialog shows at a time. + synchronized (OAuthApprovalDialog.class) + { + dialog.setVisible(true); + } switch (dialog.getResponse()) { case CONFIRMED: @@ -209,7 +215,8 @@ public class OAuth2TokenStore case CANCELLED: default: // user one time cancellation - // let token remain null, as we do not have new information yet + // let token remain null, as we do not have new information + // yet token = null; break; } @@ -421,40 +428,80 @@ public class OAuth2TokenStore * * @author Danny van Heumen */ - private static class OAuthApprovalDialog extends SIPCommDialog { + private static class OAuthApprovalDialog + extends SIPCommDialog + { private static final long serialVersionUID = 6792589736608633346L; - private final SIPCommLinkButton label; + private final SIPCommLinkButton link; private final SIPCommTextField code = new SIPCommTextField(""); + // Initialize behavior of code input field. + { + code.setFont(code.getFont().deriveFont(Font.BOLD, 12)); + code.setForeground(Color.BLACK); + } + private UserResponseType response = UserResponseType.CANCELLED; public OAuthApprovalDialog(final String identity) { + final ResourceManagementService resources = + GoogleContactsActivator.getResourceManagementService(); + final String instructionsText = + resources.getI18NString("impl.googlecontacts.INSTRUCTIONS"); + + // configure dialog + this.setMinimumSize(new Dimension(20, 20)); + this.setPreferredSize(new Dimension(650, 200)); + this.setBounds(10, 10, this.getWidth() - 20, this.getHeight() - 20); this.setModal(true); - this.label = - new SIPCommLinkButton("Approve Jitsi's access to " + identity); - this.label.addActionListener(new ActionListener() + + // main panel layout + this.setLayout(new BorderLayout()); + final JPanel instructionPanel = new JPanel(new BorderLayout()); + instructionPanel.setOpaque(false); + this.add(instructionPanel, BorderLayout.NORTH); + final JPanel buttonPanel = new JPanel(new BorderLayout()); + buttonPanel.setOpaque(false); + this.add(buttonPanel, BorderLayout.SOUTH); + + // populate instruction dialog + final JLabel instructionLabel = new JLabel(instructionsText); + instructionPanel.add(instructionLabel, + BorderLayout.CENTER); + this.link = + new SIPCommLinkButton(resources.getI18NString( + "impl.googlecontacts.HYPERLINK_TEXT", new String[] + { identity })); + this.link.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - LOGGER.info("Request user for approval via web page: " + LOGGER.info("Requesting user for approval via web page: " + APPROVAL_URL); GoogleContactsActivator.getBrowserLauncherService() .openURL(APPROVAL_URL); } }); - this.setLayout(new BorderLayout()); - this.add(this.label, BorderLayout.NORTH); - this.add(new JLabel("Code"), BorderLayout.WEST); + instructionPanel.add(this.link, BorderLayout.SOUTH); + + // input controls on main panel + final JLabel codeLabel = + new JLabel(resources.getI18NString("impl.googlecontacts.CODE")); + codeLabel.setOpaque(false); + this.add(codeLabel, BorderLayout.WEST); this.add(this.code, BorderLayout.CENTER); + // buttons panel - final JPanel buttonPanel = new JPanel(new BorderLayout()); - final JButton doneButton = new JButton("Done"); - doneButton.addActionListener(new ActionListener() { + final JButton doneButton = + new JButton(resources.getI18NString("service.gui.SAVE")); + doneButton.setMnemonic('s'); + doneButton.addActionListener(new ActionListener() + { @Override public void actionPerformed(ActionEvent e) @@ -465,7 +512,7 @@ public class OAuth2TokenStore } }); buttonPanel.add(doneButton, BorderLayout.EAST); - this.add(buttonPanel, BorderLayout.SOUTH); + this.pack(); } |