mirror of
https://github.com/dgis/emu48android
synced 2024-12-26 09:58:49 +01:00
Improve code.
This commit is contained in:
parent
2e19448358
commit
d2c75a0699
4 changed files with 27 additions and 23 deletions
|
@ -56,7 +56,7 @@ CHANGES
|
||||||
|
|
||||||
Version 1.5 (2019-06-xx)
|
Version 1.5 (2019-06-xx)
|
||||||
|
|
||||||
- Add the printer simulator (set delay to 0 to speed up!).
|
- Add the Ir printer simulator (set delay to 0 to speed up!).
|
||||||
- Add the macro support.
|
- Add the macro support.
|
||||||
- Refactor the code for easier code sharing between Emu48, Emu42 and Emu71.
|
- Refactor the code for easier code sharing between Emu48, Emu42 and Emu71.
|
||||||
- Fix: Bad text characters when copy/paste the stack.
|
- Fix: Bad text characters when copy/paste the stack.
|
||||||
|
|
|
@ -236,7 +236,7 @@ public class MainScreenView extends PanAndScaleView {
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) == 0) {
|
if((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) == 0) {
|
||||||
char pressedKey = (char) event.getUnicodeChar();
|
char pressedKey = (char) event.getUnicodeChar();
|
||||||
Log.d(TAG, "onKeyDown is: " + pressedKey);
|
//Log.d(TAG, "onKeyDown is: " + pressedKey);
|
||||||
Integer windowsKeycode = charmap.get(pressedKey);
|
Integer windowsKeycode = charmap.get(pressedKey);
|
||||||
if(windowsKeycode == null)
|
if(windowsKeycode == null)
|
||||||
windowsKeycode = vkmap.get(keyCode);
|
windowsKeycode = vkmap.get(keyCode);
|
||||||
|
@ -254,7 +254,7 @@ public class MainScreenView extends PanAndScaleView {
|
||||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
if((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) == 0) {
|
if((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) == 0) {
|
||||||
char pressedKey = (char) event.getUnicodeChar();
|
char pressedKey = (char) event.getUnicodeChar();
|
||||||
Log.d(TAG, "onKeyUp is: " + pressedKey);
|
//Log.d(TAG, "onKeyUp is: " + pressedKey);
|
||||||
Integer windowsKeycode = charmap.get(pressedKey);
|
Integer windowsKeycode = charmap.get(pressedKey);
|
||||||
if(windowsKeycode == null)
|
if(windowsKeycode == null)
|
||||||
windowsKeycode = vkmap.get(keyCode);
|
windowsKeycode = vkmap.get(keyCode);
|
||||||
|
|
|
@ -414,16 +414,18 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
int nMacroState = NativeLib.getMacroState();
|
int nMacroState = NativeLib.getMacroState();
|
||||||
|
|
||||||
boolean uRun = NativeLib.isDocumentAvailable();
|
boolean uRun = NativeLib.isDocumentAvailable();
|
||||||
boolean bStackEnable = cCurrentRomType!='6' && cCurrentRomType!='A' && cCurrentRomType!='E' && cCurrentRomType!='P'; // CdB for HP: add apples
|
boolean bObjectEnable = cCurrentRomType!='6' && cCurrentRomType!='A' && cCurrentRomType!='E' && cCurrentRomType!='P'; // CdB for HP: add apples
|
||||||
|
boolean bStackCEnable = bObjectEnable;
|
||||||
|
boolean bStackPEnable = bObjectEnable;
|
||||||
|
|
||||||
menu.findItem(R.id.nav_save).setEnabled(uRun);
|
menu.findItem(R.id.nav_save).setEnabled(uRun);
|
||||||
menu.findItem(R.id.nav_save_as).setEnabled(uRun);
|
menu.findItem(R.id.nav_save_as).setEnabled(uRun);
|
||||||
menu.findItem(R.id.nav_close).setEnabled(uRun);
|
menu.findItem(R.id.nav_close).setEnabled(uRun);
|
||||||
menu.findItem(R.id.nav_load_object).setEnabled(uRun && bStackEnable);
|
menu.findItem(R.id.nav_load_object).setEnabled(uRun && bObjectEnable);
|
||||||
menu.findItem(R.id.nav_save_object).setEnabled(uRun && bStackEnable);
|
menu.findItem(R.id.nav_save_object).setEnabled(uRun && bObjectEnable);
|
||||||
menu.findItem(R.id.nav_copy_screen).setEnabled(uRun);
|
menu.findItem(R.id.nav_copy_screen).setEnabled(uRun);
|
||||||
menu.findItem(R.id.nav_copy_stack).setEnabled(uRun && bStackEnable);
|
menu.findItem(R.id.nav_copy_stack).setEnabled(uRun && bStackCEnable);
|
||||||
menu.findItem(R.id.nav_paste_stack).setEnabled(uRun && bStackEnable);
|
menu.findItem(R.id.nav_paste_stack).setEnabled(uRun && bStackPEnable);
|
||||||
menu.findItem(R.id.nav_reset_calculator).setEnabled(uRun);
|
menu.findItem(R.id.nav_reset_calculator).setEnabled(uRun);
|
||||||
menu.findItem(R.id.nav_backup_save).setEnabled(uRun);
|
menu.findItem(R.id.nav_backup_save).setEnabled(uRun);
|
||||||
menu.findItem(R.id.nav_backup_restore).setEnabled(uRun && isBackup);
|
menu.findItem(R.id.nav_backup_restore).setEnabled(uRun && isBackup);
|
||||||
|
@ -671,7 +673,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
intent.setType("*/*");
|
intent.setType("*/*");
|
||||||
intent.putExtra(Intent.EXTRA_TITLE, "emu48-state.e48");
|
intent.putExtra(Intent.EXTRA_TITLE, getString(R.string.filename) + "-state.e48");
|
||||||
startActivityForResult(intent, INTENT_GETOPENFILENAME);
|
startActivityForResult(intent, INTENT_GETOPENFILENAME);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -684,32 +686,33 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
intent.setType("*/*");
|
intent.setType("*/*");
|
||||||
int model = NativeLib.getCurrentModel();
|
int model = NativeLib.getCurrentModel();
|
||||||
String filename = "emu48-state.e48";
|
String emuXX = getString(R.string.filename);
|
||||||
|
String filename = emuXX + "-state.e48";
|
||||||
switch (model) {
|
switch (model) {
|
||||||
case 'S': //HP48SX
|
case 'S': //HP48SX
|
||||||
filename = "emu48-state-48sx.e48";
|
filename = emuXX + "-state-48sx.e48";
|
||||||
break;
|
break;
|
||||||
case 'G': //HP48GX
|
case 'G': //HP48GX
|
||||||
filename = "emu48-state-48gx.e48";
|
filename = emuXX + "-state-48gx.e48";
|
||||||
break;
|
break;
|
||||||
case '6': //HP38G 64K RAM
|
case '6': //HP38G 64K RAM
|
||||||
case 'A': //HP38G 32K RAM
|
case 'A': //HP38G 32K RAM
|
||||||
filename = "emu48-state.e38";
|
filename = emuXX + "-state.e38";
|
||||||
break;
|
break;
|
||||||
case 'E': // HP39G/(HP39G+/HP39GS)/HP40G/HP40GS
|
case 'E': // HP39G/(HP39G+/HP39GS)/HP40G/HP40GS
|
||||||
filename = "emu48-state.e39";
|
filename = emuXX + "-state.e39";
|
||||||
break;
|
break;
|
||||||
case 'P': // HP39G+/HP39GS
|
case 'P': // HP39G+/HP39GS
|
||||||
filename = "emu48-state.e39";
|
filename = emuXX + "-state.e39";
|
||||||
break;
|
break;
|
||||||
case '2': // HP48GII
|
case '2': // HP48GII
|
||||||
filename = "emu48-state-48gii.e49";
|
filename = emuXX + "-state-48gii.e49";
|
||||||
break;
|
break;
|
||||||
case 'Q': // HP49G+/HP50G
|
case 'Q': // HP49G+/HP50G
|
||||||
filename = "emu48-state-50g.e49";
|
filename = emuXX + "-state-50g.e49";
|
||||||
break;
|
break;
|
||||||
case 'X': // HP49G
|
case 'X': // HP49G
|
||||||
filename = "emu48-state-49g.e49";
|
filename = emuXX + "-state-49g.e49";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
intent.putExtra(Intent.EXTRA_TITLE, filename);
|
intent.putExtra(Intent.EXTRA_TITLE, filename);
|
||||||
|
@ -743,7 +746,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
intent.setType("*/*");
|
intent.setType("*/*");
|
||||||
intent.putExtra(Intent.EXTRA_TITLE, "emu48-object.hp");
|
intent.putExtra(Intent.EXTRA_TITLE, getString(R.string.filename) + "-object.hp");
|
||||||
startActivityForResult(intent, INTENT_OBJECT_LOAD);
|
startActivityForResult(intent, INTENT_OBJECT_LOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -768,7 +771,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
intent.setType("*/*");
|
intent.setType("*/*");
|
||||||
intent.putExtra(Intent.EXTRA_TITLE, "emu48-object.hp");
|
intent.putExtra(Intent.EXTRA_TITLE, getString(R.string.filename) + "-object.hp");
|
||||||
startActivityForResult(intent, INTENT_OBJECT_SAVE);
|
startActivityForResult(intent, INTENT_OBJECT_SAVE);
|
||||||
}
|
}
|
||||||
private void OnViewCopy() {
|
private void OnViewCopy() {
|
||||||
|
@ -779,7 +782,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
|
|
||||||
NativeLib.onViewCopy(bitmapScreen);
|
NativeLib.onViewCopy(bitmapScreen);
|
||||||
|
|
||||||
String imageFilename = "Emu48-" + new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.US).format(new Date());
|
String imageFilename = getString(R.string.filename) + "-" + new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.US).format(new Date());
|
||||||
try {
|
try {
|
||||||
File storagePath = new File(this.getExternalCacheDir(), "");
|
File storagePath = new File(this.getExternalCacheDir(), "");
|
||||||
File imageFile = File.createTempFile(imageFilename, ".png", storagePath);
|
File imageFile = File.createTempFile(imageFilename, ".png", storagePath);
|
||||||
|
@ -964,7 +967,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
intent.setType("*/*");
|
intent.setType("*/*");
|
||||||
intent.putExtra(Intent.EXTRA_TITLE, "emu48-macro.mac");
|
intent.putExtra(Intent.EXTRA_TITLE, getString(R.string.filename) + "-macro.mac");
|
||||||
startActivityForResult(intent, INTENT_MACRO_SAVE);
|
startActivityForResult(intent, INTENT_MACRO_SAVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -972,7 +975,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
intent.setType("*/*");
|
intent.setType("*/*");
|
||||||
intent.putExtra(Intent.EXTRA_TITLE, "emu48-macro.mac");
|
intent.putExtra(Intent.EXTRA_TITLE, getString(R.string.filename) + "-macro.mac");
|
||||||
startActivityForResult(intent, INTENT_MACRO_LOAD);
|
startActivityForResult(intent, INTENT_MACRO_LOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
<!-- MainActivity -->
|
<!-- MainActivity -->
|
||||||
|
|
||||||
<string name="app_name">Emu48</string>
|
<string name="app_name">Emu48</string>
|
||||||
|
<string name="filename">emu48</string>
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
<string name="navigation_drawer_open">Open navigation drawer</string>
|
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||||
|
|
Loading…
Reference in a new issue