41
41
42
42
@ SuppressWarnings ("serial" )
43
43
public class KeyStoreManager extends JFrame {
44
+ final static private int BOX_BORDER = Toolkit .zoom (13 );
45
+ final static private int PASS_BORDER = Toolkit .zoom (15 );
46
+ final static private int LABEL_WIDTH = Toolkit .zoom (400 );
47
+ final static private int LABEL_HEIGHT = Toolkit .zoom (100 );
48
+ final static private int GAP = Toolkit .zoom (13 );
49
+
44
50
static final String GUIDE_URL =
45
51
"https://developer.android.com/studio/publish/app-signing.html" ;
46
52
@@ -68,23 +74,25 @@ private void createLayout() {
68
74
Container outer = getContentPane ();
69
75
outer .removeAll ();
70
76
71
- Box pain = Box .createVerticalBox ();
72
- pain .setBorder (new EmptyBorder (13 , 13 , 13 , 13 ));
73
- outer .add (pain );
77
+ Box vbox = Box .createVerticalBox ();
78
+ vbox .setBorder (new EmptyBorder (BOX_BORDER , BOX_BORDER , BOX_BORDER , BOX_BORDER ));
79
+ outer .add (vbox );
74
80
75
81
keyStore = AndroidKeyStore .getKeyStore ();
76
82
if (keyStore != null ) {
77
- showKeystorePasswordLayout (pain );
83
+ showKeystorePasswordLayout (vbox );
78
84
} else {
79
- showKeystoreCredentialsLayout (pain );
85
+ showKeystoreCredentialsLayout (vbox );
80
86
}
81
87
88
+ vbox .add (Box .createVerticalStrut (GAP ));
89
+
82
90
// buttons
83
91
JPanel buttons = new JPanel ();
84
92
buttons .setAlignmentX (LEFT_ALIGNMENT );
85
93
JButton okButton = new JButton ("OK" );
86
94
Dimension dim = new Dimension (Toolkit .getButtonWidth (),
87
- okButton .getPreferredSize ().height );
95
+ Toolkit . zoom ( okButton .getPreferredSize ().height ) );
88
96
okButton .setPreferredSize (dim );
89
97
okButton .addActionListener (new ActionListener () {
90
98
public void actionPerformed (ActionEvent e ) {
@@ -120,14 +128,16 @@ public void actionPerformed(ActionEvent e) {
120
128
121
129
JButton resetKeystoreButton = new JButton ("Reset password" );
122
130
dim = new Dimension (Toolkit .getButtonWidth ()*2 ,
123
- okButton . getPreferredSize ().height );
131
+ Toolkit . zoom ( resetKeystoreButton . getPreferredSize ().height ) );
124
132
resetKeystoreButton .setPreferredSize (dim );
125
133
resetKeystoreButton .addActionListener (new ActionListener () {
126
134
public void actionPerformed (ActionEvent e ) {
127
135
setVisible (false );
128
136
int result = Messages .showYesNoQuestion (editor , "Android keystore" ,
129
- "Are you sure you want to reset the password?" , "We will have to reset the keystore to do this, " +
130
- "which means you won't be able to upload an update for your app signed with the new keystore to Google Play.\n \n " +
137
+ "Are you sure you want to reset the password?" ,
138
+ "We will have to reset the keystore to do this, which means \n " +
139
+ "you won't be able to upload an update for your app signed with\n " +
140
+ "the new keystore to Google Play.\n \n " +
131
141
"We will make a backup for the old keystore." );
132
142
133
143
if (result == JOptionPane .NO_OPTION ) {
@@ -160,7 +170,7 @@ public void actionPerformed(ActionEvent e) {
160
170
buttons .add (cancelButton );
161
171
}
162
172
// buttons.setMaximumSize(new Dimension(300, buttons.getPreferredSize().height));
163
- pain .add (buttons );
173
+ vbox .add (buttons );
164
174
165
175
JRootPane root = getRootPane ();
166
176
root .setDefaultButton (okButton );
@@ -211,7 +221,7 @@ private boolean checkRequiredFields() {
211
221
}
212
222
}
213
223
214
- private void showKeystoreCredentialsLayout (Box pain ) {
224
+ private void showKeystoreCredentialsLayout (Box box ) {
215
225
String labelText =
216
226
"<html>" +
217
227
"Please enter the information below so we can generate a private key for you.<br/>" +
@@ -220,14 +230,14 @@ private void showKeystoreCredentialsLayout(Box pain) {
220
230
"More about private keys can be found " +
221
231
"<a href=\" " + GUIDE_URL + "\" >here</a>.</body></html>" ;
222
232
JLabel textarea = new JLabel (labelText );
223
- textarea .setPreferredSize (new Dimension (400 , 100 ));
233
+ textarea .setPreferredSize (new Dimension (LABEL_WIDTH , LABEL_HEIGHT ));
224
234
textarea .addMouseListener (new MouseAdapter () {
225
235
public void mouseClicked (MouseEvent e ) {
226
236
Platform .openURL (GUIDE_URL );
227
237
}
228
238
});
229
239
textarea .setAlignmentX (LEFT_ALIGNMENT );
230
- pain .add (textarea );
240
+ box .add (textarea );
231
241
232
242
// password field
233
243
passwordField = new JPasswordField (15 );
@@ -238,7 +248,7 @@ public void mouseClicked(MouseEvent e) {
238
248
textPane .add (passwordLabel );
239
249
textPane .add (passwordField );
240
250
textPane .setAlignmentX (LEFT_ALIGNMENT );
241
- pain .add (textPane );
251
+ box .add (textPane );
242
252
243
253
// repeat password field
244
254
repeatPasswordField = new JPasswordField (15 );
@@ -249,14 +259,14 @@ public void mouseClicked(MouseEvent e) {
249
259
textPane .add (repeatPasswordLabel );
250
260
textPane .add (repeatPasswordField );
251
261
textPane .setAlignmentX (LEFT_ALIGNMENT );
252
- textPane .setBorder (new EmptyBorder (0 , 0 , 15 , 0 ));
253
- pain .add (textPane );
262
+ textPane .setBorder (new EmptyBorder (0 , 0 , PASS_BORDER , 0 ));
263
+ box .add (textPane );
254
264
255
265
MatteBorder mb = new MatteBorder (1 , 0 , 0 , 0 , Color .LIGHT_GRAY );
256
266
TitledBorder tb = new TitledBorder (mb , "Keystore issuer credentials" , TitledBorder .LEFT , TitledBorder .DEFAULT_POSITION );
257
267
JPanel separatorPanel = new JPanel ();
258
268
separatorPanel .setBorder (tb );
259
- pain .add (separatorPanel );
269
+ box .add (separatorPanel );
260
270
261
271
// common name (CN)
262
272
commonName = new JTextField (15 );
@@ -267,7 +277,7 @@ public void mouseClicked(MouseEvent e) {
267
277
textPane .add (commonNameLabel );
268
278
textPane .add (commonName );
269
279
textPane .setAlignmentX (LEFT_ALIGNMENT );
270
- pain .add (textPane );
280
+ box .add (textPane );
271
281
272
282
// organizational unit (OU)
273
283
organizationalUnit = new JTextField (15 );
@@ -278,7 +288,7 @@ public void mouseClicked(MouseEvent e) {
278
288
textPane .add (organizationalUnitLabel );
279
289
textPane .add (organizationalUnit );
280
290
textPane .setAlignmentX (LEFT_ALIGNMENT );
281
- pain .add (textPane );
291
+ box .add (textPane );
282
292
283
293
// organization name (O)
284
294
organizationName = new JTextField (15 );
@@ -289,7 +299,7 @@ public void mouseClicked(MouseEvent e) {
289
299
textPane .add (organizationNameLabel );
290
300
textPane .add (organizationName );
291
301
textPane .setAlignmentX (LEFT_ALIGNMENT );
292
- pain .add (textPane );
302
+ box .add (textPane );
293
303
294
304
// locality name (L)
295
305
localityName = new JTextField (15 );
@@ -300,7 +310,7 @@ public void mouseClicked(MouseEvent e) {
300
310
textPane .add (localityNameLabel );
301
311
textPane .add (localityName );
302
312
textPane .setAlignmentX (LEFT_ALIGNMENT );
303
- pain .add (textPane );
313
+ box .add (textPane );
304
314
305
315
// state name (S)
306
316
stateName = new JTextField (15 );
@@ -311,7 +321,7 @@ public void mouseClicked(MouseEvent e) {
311
321
textPane .add (stateNameLabel );
312
322
textPane .add (stateName );
313
323
textPane .setAlignmentX (LEFT_ALIGNMENT );
314
- pain .add (textPane );
324
+ box .add (textPane );
315
325
316
326
// country (C)
317
327
country = new JTextField (15 );
@@ -322,6 +332,6 @@ public void mouseClicked(MouseEvent e) {
322
332
textPane .add (countryLabel );
323
333
textPane .add (country );
324
334
textPane .setAlignmentX (LEFT_ALIGNMENT );
325
- pain .add (textPane );
335
+ box .add (textPane );
326
336
}
327
337
}
0 commit comments