Skip to content

Commit

Permalink
put android toolbar titles in the strings file
Browse files Browse the repository at this point in the history
  • Loading branch information
codeanticode committed Jun 16, 2022
1 parent 12c1a57 commit 475224e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 33 deletions.
12 changes: 12 additions & 0 deletions mode/languages/mode.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@
# | File | Edit | Sketch | Android | Tools | Help |
# | File |

menu.sketch.stop = Stop
menu.file.new = New
menu.file.open = Open
menu.file.save = Save

menu.file.export_signed_package = Export Signed Package
menu.file.export_signed_bundle = Export Signed Bundle
menu.file.export_android_project = Export Android Project


# | File | Edit | Sketch | Android | Tools | Help |
# | Sketch |

menu.sketch.run_on_device = Run on Device
menu.sketch.run_in_emulator = Run in Emulator

# | File | Edit | Sketch | Android | Tools | Help |
# | Android |

Expand Down
14 changes: 7 additions & 7 deletions mode/src/processing/mode/android/AndroidEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@ public boolean handleSaveAs() {


public JMenu buildFileMenu() {
String exportPackageTitle = AndroidToolbar.getTitle(AndroidToolbar.EXPORT_PACKAGE, true);
JMenuItem exportPackage = Toolkit.newJMenuItem(exportPackageTitle, 'K');
String exportPackageTitle = AndroidToolbar.getTitle(AndroidToolbar.EXPORT_PACKAGE);
JMenuItem exportPackage = Toolkit.newJMenuItemExt(exportPackageTitle);
exportPackage.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleExportPackage();
}
});


String exportBundleTitle = AndroidToolbar.getTitle(AndroidToolbar.EXPORT_BUNDLE, false);
String exportBundleTitle = AndroidToolbar.getTitle(AndroidToolbar.EXPORT_BUNDLE);
JMenuItem exportBundle = Toolkit.newJMenuItem(exportBundleTitle, 'B');
exportBundle.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Expand All @@ -141,7 +141,7 @@ public void actionPerformed(ActionEvent e) {
});


String exportProjectTitle = AndroidToolbar.getTitle(AndroidToolbar.EXPORT_PROJECT, true);
String exportProjectTitle = AndroidToolbar.getTitle(AndroidToolbar.EXPORT_PROJECT);
JMenuItem exportProject = Toolkit.newJMenuItemShift(exportProjectTitle, 'X');
exportProject.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Expand All @@ -154,21 +154,21 @@ public void actionPerformed(ActionEvent e) {


public JMenu buildSketchMenu() {
JMenuItem runItem = Toolkit.newJMenuItem(AndroidToolbar.getTitle(AndroidToolbar.RUN, false), 'D');
JMenuItem runItem = Toolkit.newJMenuItem(AndroidToolbar.getTitle(AndroidToolbar.RUN_ON_DEVICE), 'D');
runItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleRunDevice();
}
});

JMenuItem presentItem = Toolkit.newJMenuItemShift(AndroidToolbar.getTitle(AndroidToolbar.RUN, true), 'E');
JMenuItem presentItem = Toolkit.newJMenuItemShift(AndroidToolbar.getTitle(AndroidToolbar.RUN_IN_EMULATOR), 'E');
presentItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleRunEmulator();
}
});

JMenuItem stopItem = new JMenuItem(AndroidToolbar.getTitle(AndroidToolbar.STOP, false));
JMenuItem stopItem = new JMenuItem(AndroidToolbar.getTitle(AndroidToolbar.STOP));
stopItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleStop();
Expand Down
43 changes: 17 additions & 26 deletions mode/src/processing/mode/android/AndroidToolbar.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@

@SuppressWarnings("serial")
public class AndroidToolbar extends EditorToolbar {
static protected final int RUN = 0;
static protected final int STOP = 1;
static protected final int RUN_ON_DEVICE = 0;
static protected final int RUN_IN_EMULATOR = 1;
static protected final int STOP = 2;

static protected final int NEW = 2;
static protected final int OPEN = 3;
static protected final int SAVE = 4;
static protected final int EXPORT_PACKAGE = 5;
static protected final int EXPORT_BUNDLE = 6;
static protected final int EXPORT_PROJECT = 7;
static protected final int NEW = 3;
static protected final int OPEN = 4;
static protected final int SAVE = 5;

static protected final int EXPORT_PACKAGE = 6;
static protected final int EXPORT_BUNDLE = 7;
static protected final int EXPORT_PROJECT = 8;


private AndroidEditor aEditor;
Expand All @@ -61,25 +63,14 @@ public AndroidToolbar(Editor editor, Base base) {
}


// TODO:
// Buttons are initialized in createButtons, see code of EditorToolbar.rebuild()
// public void init() {
// Image[][] images = loadImages();
// for (int i = 0; i < 6; i++) {
// addButton(getTitle(i, false), getTitle(i, true), images[i], i == NEW);
// }
// }


static public String getTitle(int index, boolean shift) {
static public String getTitle(int index) {
switch (index) {
case RUN: return !shift ? "Run on Device" : "Run in Emulator";
case STOP: return "Stop";
case NEW: return "New";
case OPEN: return "Open";
case SAVE: return "Save";


case RUN_ON_DEVICE: return AndroidMode.getTextString("menu.sketch.run_on_device");
case RUN_IN_EMULATOR: return AndroidMode.getTextString("menu.sketch.run_in_emulator");
case STOP: return AndroidMode.getTextString("menu.sketch.stop");
case NEW: return AndroidMode.getTextString("menu.file.new");
case OPEN: return AndroidMode.getTextString("menu.file.open");
case SAVE: return AndroidMode.getTextString("menu.file.save");
case EXPORT_PACKAGE: return AndroidMode.getTextString("menu.file.export_signed_package");
case EXPORT_BUNDLE: return AndroidMode.getTextString("menu.file.export_signed_bundle");
case EXPORT_PROJECT: return AndroidMode.getTextString("menu.file.export_android_project");
Expand Down

0 comments on commit 475224e

Please sign in to comment.