21
21
22
22
package processing .mode .android ;
23
23
24
+ import processing .app .Language ;
24
25
import processing .app .Messages ;
25
26
import processing .app .Platform ;
26
27
import processing .app .ui .Toolkit ;
@@ -49,43 +50,6 @@ public class KeyStoreManager extends JFrame {
49
50
50
51
static final String GUIDE_URL =
51
52
"https://developer.android.com/studio/publish/app-signing.html" ;
52
-
53
- static final String KEYSTORE_LABEL_TEXT = "<html>" +
54
- "Please enter the information below so we can generate a private key for you.<br/>" +
55
- "Fields marked <b>bold</b> are required, " +
56
- "though you may consider to fill some of optional fields below those to avoid potential problems.<br/>" +
57
- "More about private keys can be found " +
58
- "<a href=\" " + GUIDE_URL + "\" >here</a>.</body></html>" ;
59
-
60
- static final String OK_BUTTON = "OK" ;
61
- static final String CANCEL_BUTTON = "Cancel" ;
62
- static final String RESET_BUTTON = "Reset password" ;
63
-
64
- static final String RESET_KEYSTORE_TITLE = "Android keystore" ;
65
- static final String RESET_KEYSTORE_MESSAGE1 = "Are you sure you want to reset the password?" ;
66
- static final String RESET_KEYSTORE_MESSAGE2 = "We will have to reset the keystore to do this, which means \n " +
67
- "you won't be able to upload an update for your app signed with\n " +
68
- "the new keystore to Google Play.\n \n " +
69
- "We will make a backup for the old keystore." ;
70
-
71
- static final String FAILED_TO_REMOVE_TITLE = "Android keystore" ;
72
- static final String FAILED_TO_REMOVE_BODY = "Failed to remove keystore" ;
73
-
74
- static final String PASSWORD_MISSMATCH_TITLE = "Passwords" ;
75
- static final String PASSWORD_MISSMATCH_BODY = "Keystore passwords do not match" ;
76
-
77
- static final String PASSWORD_TOO_SHORT_TITLE = "Passwords" ;
78
- static final String PASSWORD_TOO_SHORT_BODY = "Keystore password should be at least 6 characters long" ;
79
-
80
- static final String PASSWORD_LABEL = "Keystore password:" ;
81
- static final String REPEAT_PASSWROD_LABEL = "Repeat keystore password:" ;
82
- static final String ISSUER_CREDENTIALS = "Keystore issuer credentials" ;
83
- static final String COMMON_NAME_LABEL = "First and last name: " ;
84
- static final String ORGANIZATIONAL_UNIT_LABEL = "Organizational unit: " ;
85
- static final String ORGANIZATION_NAME_LABEL = "Organization name: " ;
86
- static final String LOCALITY_NAME_LABEL = "City or locality: " ;
87
- static final String STATE_NAME_LABEL = "State name: " ;
88
- static final String COUNTRY_LABEL = "Country code (XX): " ;
89
53
90
54
File keyStore ;
91
55
AndroidEditor editor ;
@@ -127,7 +91,7 @@ private void createLayout() {
127
91
// buttons
128
92
JPanel buttons = new JPanel ();
129
93
buttons .setAlignmentX (LEFT_ALIGNMENT );
130
- JButton okButton = new JButton (OK_BUTTON );
94
+ JButton okButton = new JButton (Language . text ( "prompt.ok" ) );
131
95
Dimension dim = new Dimension (Toolkit .getButtonWidth (),
132
96
okButton .getPreferredSize ().height );
133
97
okButton .setPreferredSize (dim );
@@ -154,7 +118,7 @@ public void actionPerformed(ActionEvent e) {
154
118
});
155
119
okButton .setEnabled (true );
156
120
157
- JButton cancelButton = new JButton (CANCEL_BUTTON );
121
+ JButton cancelButton = new JButton (Language . text ( "prompt.cancel" ) );
158
122
cancelButton .setPreferredSize (dim );
159
123
cancelButton .addActionListener (new ActionListener () {
160
124
public void actionPerformed (ActionEvent e ) {
@@ -163,21 +127,23 @@ public void actionPerformed(ActionEvent e) {
163
127
});
164
128
cancelButton .setEnabled (true );
165
129
166
- JButton resetKeystoreButton = new JButton (RESET_BUTTON );
130
+ JButton resetKeystoreButton = new JButton (AndroidMode . getTextString ( "keystore_manager.reset_password" ) );
167
131
dim = new Dimension (Toolkit .getButtonWidth ()*2 ,
168
132
resetKeystoreButton .getPreferredSize ().height );
169
133
resetKeystoreButton .setPreferredSize (dim );
170
134
resetKeystoreButton .addActionListener (new ActionListener () {
171
135
public void actionPerformed (ActionEvent e ) {
172
136
setVisible (false );
173
- int result = Messages .showYesNoQuestion (editor , RESET_KEYSTORE_TITLE ,
174
- RESET_KEYSTORE_MESSAGE1 , RESET_KEYSTORE_MESSAGE2 );
137
+ int result = Messages .showYesNoQuestion (editor , AndroidMode .getTextString ("keystore_manager.dialog.reset_keyboard_title" ),
138
+ AndroidMode .getTextString ("keystore_manager.dialog.reset_keyboard_body_part1" ),
139
+ AndroidMode .getTextString ("keystore_manager.dialog.reset_keyboard_body_part2" ));
175
140
176
141
if (result == JOptionPane .NO_OPTION ) {
177
142
setVisible (true );
178
143
} else {
179
144
if (!AndroidKeyStore .resetKeyStore ()) {
180
- Messages .showWarning (FAILED_TO_REMOVE_TITLE , FAILED_TO_REMOVE_BODY );
145
+ Messages .showWarning (AndroidMode .getTextString ("keystore_manager.warn.cannot_remove_keystore_title" ),
146
+ AndroidMode .getTextString ("keystore_manager.warn.cannot_remove_keystore_body" ));
181
147
setVisible (true );
182
148
} else {
183
149
keyStore = null ;
@@ -228,7 +194,7 @@ public void actionPerformed(ActionEvent actionEvent) {
228
194
229
195
private void showKeystorePasswordLayout (Box pain ) {
230
196
passwordField = new JPasswordField (15 );
231
- JLabel passwordLabel = new JLabel ("<html><body><b>" + PASSWORD_LABEL + " </b></body></html>" );
197
+ JLabel passwordLabel = new JLabel ("<html><body><b>" + AndroidMode . getTextString ( "keystore_manager.password_label" ) + " </b></body></html>" );
232
198
passwordLabel .setLabelFor (passwordField );
233
199
234
200
JPanel textPane = new JPanel (new FlowLayout (FlowLayout .TRAILING ));
@@ -245,17 +211,19 @@ private boolean checkRequiredFields() {
245
211
if (Arrays .equals (passwordField .getPassword (), repeatPasswordField .getPassword ())) {
246
212
return true ;
247
213
} else {
248
- Messages .showWarning (PASSWORD_MISSMATCH_TITLE , PASSWORD_MISSMATCH_BODY );
214
+ Messages .showWarning (AndroidMode .getTextString ("keystore_manager.warn.password_missmatch_title" ),
215
+ AndroidMode .getTextString ("keystore_manager.warn.password_missmatch_body" ));
249
216
return false ;
250
217
}
251
218
} else {
252
- Messages .showWarning (PASSWORD_TOO_SHORT_TITLE , PASSWORD_TOO_SHORT_BODY );
219
+ Messages .showWarning (AndroidMode .getTextString ("keystore_manager.warn.short_password_title" ),
220
+ AndroidMode .getTextString ("keystore_manager.warn.short_password_body" ));
253
221
return false ;
254
222
}
255
223
}
256
224
257
225
private void showKeystoreCredentialsLayout (Box box ) {
258
- String labelText = KEYSTORE_LABEL_TEXT ;
226
+ String labelText = AndroidMode . getTextString ( "keystore_manager.top_label" ) ;
259
227
JLabel textarea = new JLabel (labelText );
260
228
textarea .setPreferredSize (new Dimension (LABEL_WIDTH , LABEL_HEIGHT ));
261
229
textarea .addMouseListener (new MouseAdapter () {
@@ -268,7 +236,7 @@ public void mouseClicked(MouseEvent e) {
268
236
269
237
// password field
270
238
passwordField = new JPasswordField (15 );
271
- JLabel passwordLabel = new JLabel ("<html><body><b>" + PASSWORD_LABEL + " </b></body></html>" );
239
+ JLabel passwordLabel = new JLabel ("<html><body><b>" + AndroidMode . getTextString ( "keystore_manager.password_label" ) + " </b></body></html>" );
272
240
passwordLabel .setLabelFor (passwordField );
273
241
274
242
JPanel textPane = new JPanel (new FlowLayout (FlowLayout .TRAILING ));
@@ -279,7 +247,7 @@ public void mouseClicked(MouseEvent e) {
279
247
280
248
// repeat password field
281
249
repeatPasswordField = new JPasswordField (15 );
282
- JLabel repeatPasswordLabel = new JLabel ("<html><body><b>" + REPEAT_PASSWROD_LABEL + " </b></body></html>" );
250
+ JLabel repeatPasswordLabel = new JLabel ("<html><body><b>" + AndroidMode . getTextString ( "keystore_manager.repeat_password_label" ) + " </b></body></html>" );
283
251
repeatPasswordLabel .setLabelFor (passwordField );
284
252
285
253
textPane = new JPanel (new FlowLayout (FlowLayout .TRAILING ));
@@ -290,14 +258,14 @@ public void mouseClicked(MouseEvent e) {
290
258
box .add (textPane );
291
259
292
260
MatteBorder mb = new MatteBorder (1 , 0 , 0 , 0 , Color .LIGHT_GRAY );
293
- TitledBorder tb = new TitledBorder (mb , ISSUER_CREDENTIALS , TitledBorder .LEFT , TitledBorder .DEFAULT_POSITION );
261
+ TitledBorder tb = new TitledBorder (mb , AndroidMode . getTextString ( "keystore_manager.issuer_credentials_header" ) , TitledBorder .LEFT , TitledBorder .DEFAULT_POSITION );
294
262
JPanel separatorPanel = new JPanel ();
295
263
separatorPanel .setBorder (tb );
296
264
box .add (separatorPanel );
297
265
298
266
// common name (CN)
299
267
commonName = new JTextField (15 );
300
- JLabel commonNameLabel = new JLabel (COMMON_NAME_LABEL );
268
+ JLabel commonNameLabel = new JLabel (AndroidMode . getTextString ( "keystore_manager.common_name_label" ) );
301
269
commonNameLabel .setLabelFor (commonName );
302
270
303
271
textPane = new JPanel (new FlowLayout (FlowLayout .TRAILING ));
@@ -308,7 +276,7 @@ public void mouseClicked(MouseEvent e) {
308
276
309
277
// organizational unit (OU)
310
278
organizationalUnit = new JTextField (15 );
311
- JLabel organizationalUnitLabel = new JLabel (ORGANIZATIONAL_UNIT_LABEL );
279
+ JLabel organizationalUnitLabel = new JLabel (AndroidMode . getTextString ( "keystore_manager.organizational_unitl_label" ) );
312
280
organizationalUnitLabel .setLabelFor (organizationalUnit );
313
281
314
282
textPane = new JPanel (new FlowLayout (FlowLayout .TRAILING ));
@@ -319,7 +287,7 @@ public void mouseClicked(MouseEvent e) {
319
287
320
288
// organization name (O)
321
289
organizationName = new JTextField (15 );
322
- JLabel organizationNameLabel = new JLabel (ORGANIZATION_NAME_LABEL );
290
+ JLabel organizationNameLabel = new JLabel (AndroidMode . getTextString ( "keystore_manager.organization_name_label" ) );
323
291
organizationNameLabel .setLabelFor (organizationName );
324
292
325
293
textPane = new JPanel (new FlowLayout (FlowLayout .TRAILING ));
@@ -330,7 +298,7 @@ public void mouseClicked(MouseEvent e) {
330
298
331
299
// locality name (L)
332
300
localityName = new JTextField (15 );
333
- JLabel localityNameLabel = new JLabel (LOCALITY_NAME_LABEL );
301
+ JLabel localityNameLabel = new JLabel (AndroidMode . getTextString ( "keystore_manager.city_name_label" ) );
334
302
localityNameLabel .setLabelFor (localityName );
335
303
336
304
textPane = new JPanel (new FlowLayout (FlowLayout .TRAILING ));
@@ -341,7 +309,7 @@ public void mouseClicked(MouseEvent e) {
341
309
342
310
// state name (S)
343
311
stateName = new JTextField (15 );
344
- JLabel stateNameLabel = new JLabel (STATE_NAME_LABEL );
312
+ JLabel stateNameLabel = new JLabel (AndroidMode . getTextString ( "keystore_manager.state_name_label" ) );
345
313
stateNameLabel .setLabelFor (stateName );
346
314
347
315
textPane = new JPanel (new FlowLayout (FlowLayout .TRAILING ));
@@ -352,7 +320,7 @@ public void mouseClicked(MouseEvent e) {
352
320
353
321
// country (C)
354
322
country = new JTextField (15 );
355
- JLabel countryLabel = new JLabel (COUNTRY_LABEL );
323
+ JLabel countryLabel = new JLabel (AndroidMode . getTextString ( "keystore_manager.country_code_label" ) );
356
324
countryLabel .setLabelFor (country );
357
325
358
326
textPane = new JPanel (new FlowLayout (FlowLayout .TRAILING ));
0 commit comments