Skip to content

Commit a6c05d9

Browse files
committed
done with strings for sdk and sys image downloaders
1 parent 1961d67 commit a6c05d9

File tree

3 files changed

+61
-97
lines changed

3 files changed

+61
-97
lines changed

mode/languages/mode.properties

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -235,38 +235,35 @@ permissions.dialog.url = "<html>More about permissions can be found <a href=\"%s
235235
# ---------------------------------------
236236
# SDK Downloader
237237

238+
sdk_downloader.error_cannot_find_platform_files = Cannot find the platform files
239+
sdk_downloader.error_cannot_find_platform_tools = Cannot find the platform-tools
240+
sdk_downloader.error_cannot_find_build_tools = Cannot find the build-tools
241+
sdk_downloader.error_cannot_find_tools = Cannot find the tools
242+
sdk_downloader.error_cannot_find_emulator = Cannot find the emulator
238243
sdk_downloader.error.cannot_unpack_platform = Error unpacking platform to "%s"
244+
sdk_downloader.download_title = SDK download
245+
sdk_downloader.download_sdk_label = Downloading Android SDK...
239246

240247
# ---------------------------------------
241248
# System image downloader
242249

243-
SYS_IMAGE_SELECTION_MESSAGE =
244-
"The Android emulator requires a system image to run. " +
245-
"There are two types of system images available:<br><br>" +
246-
"<b>1) ARM image -</b> slow but compatible with all computers, no extra configuration needed.<br><br>" +
247-
"<b>2) x86 image -</b> fast but compatible only with Intel CPUs, extra configuration may be needed, see " +
248-
"<a href=\"" + EMULATOR_GUIDE_URL + "\">this guide</a> for more details.";
249-
250-
HAXM_INSTALL_TITLE = "Some words of caution..."
251-
HAXM_INSTALL_MESSAGE =
252-
"Processing will install x86 images in the emulator. These images are fast, but " +
253-
"also need the Intel Hardware Accelerated Execution Manager (Intel HAXM).<br><br>" +
254-
"Processing will try to run the HAXM installer now, which may ask for your " +
255-
"administrator password or additional permissions.";
256-
257-
258-
KVM_LINUX_GUIDE_URL =
259-
"https://developer.android.com/studio/run/emulator-acceleration.html#vm-linux";
260-
KVM_INSTALL_MESSAGE =
261-
"You chose to run x86 images in the emulator. This is great but you need " +
262-
"to configure VM acceleration on Linux using the KVM package.<br><br>" +
263-
"Follow <a href=\"" + KVM_LINUX_GUIDE_URL + "\">these instructions</a> " +
264-
"to configure KVM.";
265-
266-
IA32LIBS_TITLE = "Additional setup may be required...";
267-
IA32LIBS_MESSAGE =
268-
"Looks like you are running a 64-bit version of Linux. In order<br>" +
269-
"to create the SD card in the emulator, Processing needs the<br>" +
270-
"ia32-libs compatibility package. On Ubuntu Linux, you can<br>" +
271-
"install it by runing the following command: <br><br>" +
272-
"sudo apt-get install lib32stdc++6";
250+
sys_image_downloader.dialog.select_image_title = Choose system image type to download...
251+
sys_image_downloader.dialog.select_image_body = The Android emulator requires a system image to run. There are two types of system images available:<br><br><b>1) ARM image -</b> slow but compatible with all computers, no extra configuration needed.<br><br><b>2) x86 image -</b> fast but compatible only with Intel CPUs, extra configuration may be needed, see <a href=\"%s\">this guide</a> for more details.
252+
sys_image_downloader.dialog.accel_images_title = Some words of caution...
253+
sys_image_downloader.dialog.haxm_install_body = Processing will install x86 images in the emulator. These images are fast, but also need the Intel Hardware Accelerated Execution Manager (Intel HAXM).<br><br>Processing will try to run the HAXM installer now, which may ask for your administrator password or additional permissions.
254+
sys_image_downloader.dialog.kvm_config_body = You chose to run x86 images in the emulator. This is great but you need to configure VM acceleration on Linux using the KVM package.<br><br>Follow <a href=\"%s\">these instructions</a> to configure KVM.
255+
sys_image_downloader.dialog.ia32libs_title = Additional setup may be required...
256+
sys_image_downloader.dialog.ia32libs_body = Looks like you are running a 64-bit version of Linux. In order<br>to create the SD card in the emulator, Processing needs the<br>ia32-libs compatibility package. On Ubuntu Linux, you can<br>install it by runing the following command: <br><br>sudo apt-get install lib32stdc++6
257+
sys_image_downloader.option.x86_image = Use x86 image
258+
sys_image_downloader.option.arm_image = Use ARM image
259+
sys_image_downloader.download_title = System image download
260+
sys_image_downloader.download_watch_label = Downloading watch system image...
261+
sys_image_downloader.download_phone_label = Downloading phone system image...
262+
263+
# ---------------------------------------
264+
# Download strings
265+
266+
download_property.change_event_total = total
267+
download_property.change_event_downloaded = downloaded
268+
download_prompt.cancel = Cancel download
269+

mode/src/processing/mode/android/SDKDownloader.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ public class SDKDownloader extends JDialog implements PropertyChangeListener {
6565
private static final String HAXM_URL = "https://dl.google.com/android/repository/extras/intel/";
6666
private static final String REPOSITORY_LIST = "repository2-1.xml";
6767
private static final String ADDON_LIST = "addon2-1.xml";
68-
69-
private static final String PROPERTY_CHANGE_EVENT_TOTAL = "total";
70-
private static final String PROPERTY_CHANGE_EVENT_DOWNLOADED = "downloaded";
7168

7269
private JProgressBar progressBar;
7370
private JLabel downloadedTextArea;
@@ -133,7 +130,7 @@ protected Object doInBackground() throws Exception {
133130
getMainDownloadUrls(downloadUrls, repositoryUrl, Platform.getName());
134131
getExtrasDownloadUrls(downloadUrls, addonUrl, Platform.getName());
135132
getHaxmDownloadUrl(downloadUrls, haxmUrl, Platform.getName());
136-
firePropertyChange(PROPERTY_CHANGE_EVENT_TOTAL, 0, downloadUrls.totalSize);
133+
firePropertyChange(AndroidMode.getTextString("download_property.change_event_total"), 0, downloadUrls.totalSize);
137134

138135
// tools
139136
File downloadedTools = new File(tempFolder, downloadUrls.toolsFilename);
@@ -237,7 +234,7 @@ private void downloadAndUnpack(String urlString, File saveTo,
237234
outputStream.write(b, 0, count);
238235
downloadedSize += count;
239236

240-
firePropertyChange(PROPERTY_CHANGE_EVENT_DOWNLOADED, 0, downloadedSize);
237+
firePropertyChange(AndroidMode.getTextString("download_property.change_event_downloaded"), 0, downloadedSize);
241238
}
242239
outputStream.flush(); outputStream.close(); inputStream.close();
243240

@@ -283,7 +280,7 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
283280
urlHolder.platformUrl = REPOSITORY_URL + urlHolder.platformFilename;
284281
urlHolder.totalSize += Integer.parseInt(size.item(0).getTextContent());
285282
} else {
286-
throw new IOException("Cannot find the platform files");
283+
throw new IOException(AndroidMode.getTextString("sdk_downloader.error_cannot_find_platform_files"));
287284
}
288285

289286
// Difference between platform tools, build tools, and SDK tools:
@@ -297,7 +294,7 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
297294
if (remotePackages != null) {
298295
parseAndSet(urlHolder, remotePackages, requiredHostOs, PLATFORM_TOOLS);
299296
} else {
300-
throw new IOException("Cannot find the platform-tools");
297+
throw new IOException(AndroidMode.getTextString("sdk_downloader.error_cannot_find_platform_tools"));
301298
}
302299

303300
// -----------------------------------------------------------------------
@@ -343,7 +340,7 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
343340
}
344341
}
345342
if (!found) {
346-
throw new IOException("Cannot find the build-tools");
343+
throw new IOException(AndroidMode.getTextString("sdk_downloader.error_cannot_find_build_tools"));
347344
}
348345

349346
// -----------------------------------------------------------------------
@@ -373,7 +370,7 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
373370
}
374371
}
375372
if (!found) {
376-
throw new IOException("Cannot find the tools");
373+
throw new IOException(AndroidMode.getTextString("sdk_downloader.error_cannot_find_tools"));
377374
}
378375

379376
// -----------------------------------------------------------------------
@@ -411,7 +408,7 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
411408
}
412409
}
413410
if (!found) {
414-
throw new IOException("Cannot find the emulator");
411+
throw new IOException(AndroidMode.getTextString("sdk_downloader.error_cannot_find_emulator"));
415412
}
416413
}
417414
}
@@ -548,11 +545,11 @@ private void renameFolder(File baseFolder, String expected, String actual)
548545

549546
@Override
550547
public void propertyChange(PropertyChangeEvent evt) {
551-
if (evt.getPropertyName().equals(PROPERTY_CHANGE_EVENT_TOTAL)) {
548+
if (evt.getPropertyName().equals(AndroidMode.getTextString("download_property.change_event_total"))) {
552549
progressBar.setIndeterminate(false);
553550
totalSize = (Integer) evt.getNewValue();
554551
progressBar.setMaximum(totalSize);
555-
} else if (evt.getPropertyName().equals(PROPERTY_CHANGE_EVENT_DOWNLOADED)) {
552+
} else if (evt.getPropertyName().equals(AndroidMode.getTextString("download_property.change_event_downloaded"))) {
556553
downloadedTextArea.setText(humanReadableByteCount((Integer) evt.getNewValue(), true)
557554
+ " / " + humanReadableByteCount(totalSize, true));
558555
progressBar.setValue((Integer) evt.getNewValue());
@@ -569,7 +566,7 @@ public static String humanReadableByteCount(long bytes, boolean si) {
569566
}
570567

571568
public SDKDownloader(Frame editor) {
572-
super(editor, "SDK download", true);
569+
super(editor, AndroidMode.getTextString("sdk_downloader.download_title"), true);
573570
this.editor = editor;
574571
this.sdk = null;
575572
createLayout();
@@ -600,7 +597,7 @@ private void createLayout() {
600597
vbox.setBorder(new EmptyBorder(BOX_BORDER, BOX_BORDER, BOX_BORDER, BOX_BORDER));
601598
outer.add(vbox);
602599

603-
String labelText = "Downloading Android SDK...";
600+
String labelText = AndroidMode.getTextString("sdk_downloader.download_sdk_label");
604601
JLabel textarea = new JLabel(labelText);
605602
textarea.setAlignmentX(LEFT_ALIGNMENT);
606603
vbox.add(textarea);
@@ -641,7 +638,7 @@ private void createLayout() {
641638

642639
// Box buttons = Box.createHorizontalBox();
643640
buttons.setAlignmentX(LEFT_ALIGNMENT);
644-
JButton cancelButton = new JButton("Cancel download");
641+
JButton cancelButton = new JButton(AndroidMode.getTextString("download_prompt.cancel"));
645642
Dimension dim = new Dimension(Toolkit.getButtonWidth()*2,
646643
Toolkit.zoom(cancelButton.getPreferredSize().height));
647644

mode/src/processing/mode/android/SysImageDownloader.java

Lines changed: 22 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -58,51 +58,19 @@ public class SysImageDownloader extends JDialog implements PropertyChangeListene
5858
final static private int TEXT_MARGIN = Toolkit.zoom(8);
5959
final static private int TEXT_WIDTH = Toolkit.zoom(300);
6060

61-
private static final String EMULATOR_GUIDE_URL =
62-
"https://developer.android.com/studio/run/emulator-acceleration.html";
63-
64-
private static final String SYS_IMAGE_SELECTION_MESSAGE =
65-
"The Android emulator requires a system image to run. " +
66-
"There are two types of system images available:<br><br>" +
67-
"<b>1) ARM image -</b> slow but compatible with all computers, no extra configuration needed.<br><br>" +
68-
"<b>2) x86 image -</b> fast but compatible only with Intel CPUs, extra configuration may be needed, see " +
69-
"<a href=\"" + EMULATOR_GUIDE_URL + "\">this guide</a> for more details.";
70-
71-
private static final String HAXM_INSTALL_TITLE = "Some words of caution...";
72-
73-
private static final String HAXM_INSTALL_MESSAGE =
74-
"Processing will install x86 images in the emulator. These images are fast, but " +
75-
"also need the Intel Hardware Accelerated Execution Manager (Intel HAXM).<br><br>" +
76-
"Processing will try to run the HAXM installer now, which may ask for your " +
77-
"administrator password or additional permissions.";
78-
79-
private static final String KVM_LINUX_GUIDE_URL =
80-
"https://developer.android.com/studio/run/emulator-acceleration.html#vm-linux";
81-
82-
private static final String KVM_INSTALL_MESSAGE =
83-
"You chose to run x86 images in the emulator. This is great but you need " +
84-
"to configure VM acceleration on Linux using the KVM package.<br><br>" +
85-
"Follow <a href=\"" + KVM_LINUX_GUIDE_URL + "\">these instructions</a> " +
86-
"to configure KVM.";
87-
88-
private static final String IA32LIBS_TITLE = "Additional setup may be required...";
89-
private static final String IA32LIBS_MESSAGE =
90-
"Looks like you are running a 64-bit version of Linux. In order<br>" +
91-
"to create the SD card in the emulator, Processing needs the<br>" +
92-
"ia32-libs compatibility package. On Ubuntu Linux, you can<br>" +
93-
"install it by runing the following command: <br><br>" +
94-
"sudo apt-get install lib32stdc++6";
95-
9661
private static final String SYS_IMAGES_ARM_URL = "https://dl.google.com/android/repository/sys-img/android/";
9762

9863
private static final String SYS_IMAGES_PHONE_URL = "https://dl.google.com/android/repository/sys-img/google_apis/";
9964
private static final String SYS_IMAGES_PHONE_LIST = "sys-img2-1.xml";
10065

10166
private static final String SYS_IMAGES_WEAR_URL = "https://dl.google.com/android/repository/sys-img/android-wear/";
10267
private static final String SYS_IMAGES_WEAR_LIST = "sys-img2-1.xml";
68+
69+
private static final String EMULATOR_GUIDE_URL =
70+
"https://developer.android.com/studio/run/emulator-acceleration.html";
10371

104-
private static final String PROPERTY_CHANGE_EVENT_TOTAL = "total";
105-
private static final String PROPERTY_CHANGE_EVENT_DOWNLOADED = "downloaded";
72+
private static final String KVM_LINUX_GUIDE_URL =
73+
"https://developer.android.com/studio/run/emulator-acceleration.html#vm-linux";
10674

10775
private JProgressBar progressBar;
10876
private JLabel downloadedTextArea;
@@ -168,7 +136,7 @@ protected Object doInBackground() throws Exception {
168136

169137
UrlHolder downloadUrls = new UrlHolder();
170138
getDownloadUrls(downloadUrls, repo, Platform.getName());
171-
firePropertyChange(PROPERTY_CHANGE_EVENT_TOTAL, 0, downloadUrls.totalSize);
139+
firePropertyChange(AndroidMode.getTextString("download_property.change_event_total"), 0, downloadUrls.totalSize);
172140
totalSize = downloadUrls.totalSize;
173141

174142
if (wear) {
@@ -202,7 +170,7 @@ protected Object doInBackground() throws Exception {
202170
tempFolder.delete();
203171

204172
if (Platform.isLinux() && Platform.getVariant().equals("64")) {
205-
AndroidUtil.showMessage(IA32LIBS_TITLE, IA32LIBS_MESSAGE);
173+
AndroidUtil.showMessage(AndroidMode.getTextString("sys_image_downloader.dialog.ia32libs_title"), AndroidMode.getTextString("sys_image_downloader.dialog.ia32libs_body"));
206174
}
207175

208176
result = true;
@@ -244,8 +212,7 @@ private void downloadAndUnpack(String urlString, File saveTo,
244212
while ((count = inputStream.read(b)) >= 0) {
245213
outputStream.write(b, 0, count);
246214
downloadedSize += count;
247-
248-
firePropertyChange(PROPERTY_CHANGE_EVENT_DOWNLOADED, 0, downloadedSize);
215+
firePropertyChange(AndroidMode.getTextString("download_property.change_event_downloaded"), 0, downloadedSize);
249216
}
250217
outputStream.flush(); outputStream.close(); inputStream.close();
251218

@@ -344,11 +311,11 @@ private void getDownloadUrls(UrlHolder urlHolder,
344311

345312
@Override
346313
public void propertyChange(PropertyChangeEvent evt) {
347-
if (evt.getPropertyName().equals(PROPERTY_CHANGE_EVENT_TOTAL)) {
314+
if (evt.getPropertyName().equals(AndroidMode.getTextString("download_property.change_event_total"))) {
348315
progressBar.setIndeterminate(false);
349316
totalSize = (Integer) evt.getNewValue();
350317
progressBar.setMaximum(totalSize);
351-
} else if (evt.getPropertyName().equals(PROPERTY_CHANGE_EVENT_DOWNLOADED)) {
318+
} else if (evt.getPropertyName().equals(AndroidMode.getTextString("download_property.change_event_downloaded"))) {
352319
downloadedTextArea.setText(humanReadableByteCount((Integer) evt.getNewValue(), true)
353320
+ " / " + humanReadableByteCount(totalSize, true));
354321
progressBar.setValue((Integer) evt.getNewValue());
@@ -371,8 +338,8 @@ static public int showSysImageMessage() {
371338
"margin: " + TEXT_MARGIN + "px; " +
372339
"width: " + TEXT_WIDTH + "px }" +
373340
"</style> </head>";
374-
htmlString += "<body> <p> " + SYS_IMAGE_SELECTION_MESSAGE + " </p> </body> </html>";
375-
String title = "Choose system image type to download...";
341+
htmlString += "<body> <p> " + AndroidMode.getTextString("sys_image_downloader.dialog.select_image_body", EMULATOR_GUIDE_URL) + " </p> </body> </html>";
342+
String title = AndroidMode.getTextString("sys_image_downloader.dialog.select_image_title");
376343
JEditorPane pane = new JEditorPane("text/html", htmlString);
377344
pane.addHyperlinkListener(new HyperlinkListener() {
378345
@Override
@@ -387,7 +354,8 @@ public void hyperlinkUpdate(HyperlinkEvent e) {
387354
pane.setBackground(label.getBackground());
388355

389356
String[] options = new String[] {
390-
"Use x86 image", "Use ARM image"
357+
AndroidMode.getTextString("sys_image_downloader.option.x86_image"),
358+
AndroidMode.getTextString("sys_image_downloader.option.arm_image")
391359
};
392360
int result = JOptionPane.showOptionDialog(null, pane, title,
393361
JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE,
@@ -402,7 +370,7 @@ public void hyperlinkUpdate(HyperlinkEvent e) {
402370
}
403371

404372
public SysImageDownloader(Frame editor, boolean wear, boolean ask) {
405-
super(editor, "System image download", true);
373+
super(editor, AndroidMode.getTextString("sys_image_downloader.download_title"), true);
406374
this.editor = editor;
407375
this.wear = wear;
408376
this.askABI = ask;
@@ -463,9 +431,11 @@ public boolean getResult() {
463431
static public void installHAXM() {
464432
File haxmFolder = AndroidSDK.getHAXMInstallerFolder();
465433
if (Platform.isLinux()) {
466-
AndroidUtil.showMessage(HAXM_INSTALL_TITLE, KVM_INSTALL_MESSAGE);
434+
AndroidUtil.showMessage(AndroidMode.getTextString("sys_image_downloader.dialog.accel_images_title"),
435+
AndroidMode.getTextString("sys_image_downloader.dialog.kvm_config_body", KVM_LINUX_GUIDE_URL));
467436
} else if (haxmFolder.exists()) {
468-
AndroidUtil.showMessage(HAXM_INSTALL_TITLE, HAXM_INSTALL_MESSAGE);
437+
AndroidUtil.showMessage(AndroidMode.getTextString("sys_image_downloader.dialog.accel_images_title"),
438+
AndroidMode.getTextString("sys_image_downloader.dialog.haxm_install_body"));
469439

470440
ProcessBuilder pb;
471441
if (Platform.isWindows()) {
@@ -513,8 +483,8 @@ private void createLayout() {
513483
pain.setBorder(new EmptyBorder(13, 13, 13, 13));
514484
outer.add(pain);
515485

516-
String labelText = wear ? "Downloading watch system image..." :
517-
"Downloading phone system image...";
486+
String labelText = wear ? AndroidMode.getTextString("sys_image_downloader.download_watch_label") :
487+
AndroidMode.getTextString("sys_image_downloader.download_phone_label");
518488
JLabel textarea = new JLabel(labelText);
519489
textarea.setAlignmentX(LEFT_ALIGNMENT);
520490
pain.add(textarea);
@@ -547,7 +517,7 @@ private void createLayout() {
547517

548518
// Box buttons = Box.createHorizontalBox();
549519
buttons.setAlignmentX(LEFT_ALIGNMENT);
550-
JButton cancelButton = new JButton("Cancel download");
520+
JButton cancelButton = new JButton(AndroidMode.getTextString("download_prompt.cancel"));
551521
Dimension dim = new Dimension(Toolkit.getButtonWidth()*2,
552522
cancelButton.getPreferredSize().height);
553523

0 commit comments

Comments
 (0)