Some backlog

This commit is contained in:
shagr4th 2016-12-18 15:21:39 +01:00
parent a15aa70c32
commit a798ff264d
4 changed files with 61 additions and 12 deletions

View file

@ -12,7 +12,7 @@ import android.util.Log;
public class AssetUtil { public class AssetUtil {
public static void copyAsset(Context context, AssetManager am, boolean force) { public static boolean copyAsset(Context context, AssetManager am, boolean force) {
File newDir = getSDDir(context); File newDir = getSDDir(context);
File sd = Environment.getExternalStorageDirectory(); File sd = Environment.getExternalStorageDirectory();
if (sd != null && sd.exists() && sd.isDirectory() && newDir.exists() && newDir.isDirectory()) { if (sd != null && sd.exists() && sd.isDirectory() && newDir.exists() && newDir.isDirectory()) {
@ -31,7 +31,7 @@ public class AssetUtil {
hpDir.delete(); hpDir.delete();
} }
} }
copyAsset(am, newDir, force); return copyAsset(am, newDir, force);
} }
public static File getSDDir(Context context) { public static File getSDDir(Context context) {
@ -44,7 +44,8 @@ public class AssetUtil {
} }
} }
private static void copyAsset(AssetManager am, File rep, boolean force) { private static boolean copyAsset(AssetManager am, File rep, boolean force) {
boolean existingInstall = false;
try { try {
String assets[] = am.list( "" ); String assets[] = am.list( "" );
for( int i = 0 ; i < assets.length ; i++ ) { for( int i = 0 ; i < assets.length ; i++ ) {
@ -66,6 +67,7 @@ public class AssetUtil {
//boolean SKUNK = assets[i].equals("SKUNK"); //boolean SKUNK = assets[i].equals("SKUNK");
if (hp48 || rom || ram || hp48s || roms || rams) { if (hp48 || rom || ram || hp48s || roms || rams) {
File fout = new File(rep, assets[i]); File fout = new File(rep, assets[i]);
existingInstall |= fout.exists();
if (!fout.exists() || fout.length() == 0 || (required > 0 && fout.length() != required) || force) { if (!fout.exists() || fout.length() == 0 || (required > 0 && fout.length() != required) || force) {
Log.i("x48", "Overwriting " + assets[i]); Log.i("x48", "Overwriting " + assets[i]);
FileOutputStream out = new FileOutputStream(fout); FileOutputStream out = new FileOutputStream(fout);
@ -83,6 +85,7 @@ public class AssetUtil {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return existingInstall;
} }
public static boolean isFilesReady(Context context) { public static boolean isFilesReady(Context context) {

View file

@ -53,6 +53,12 @@ public class Settings extends PreferenceActivity {
savePref.setSummary(R.string.saveonexit_msgbox_value); savePref.setSummary(R.string.saveonexit_msgbox_value);
inlinePrefCat.addPreference(savePref); inlinePrefCat.addPreference(savePref);
/*CheckBoxPreference blockOrientation = new CheckBoxPreference(this);
blockOrientation.setKey("blockOrientation");
blockOrientation.setTitle(R.string.blockorientation_msgbox);
blockOrientation.setSummary(R.string.blockorientation_msgboxvalue);
inlinePrefCat.addPreference(blockOrientation);*/
CheckBoxPreference keybLitePref = new CheckBoxPreference(this); CheckBoxPreference keybLitePref = new CheckBoxPreference(this);
keybLitePref.setKey("keybLite"); keybLitePref.setKey("keybLite");
keybLitePref.setTitle(R.string.show_lite_keyb); keybLitePref.setTitle(R.string.show_lite_keyb);

View file

@ -36,17 +36,24 @@ public class X48 extends Activity {
private static EmulatorThread thread; private static EmulatorThread thread;
private static boolean errorLib;
// http://www.hpcalc.org/hp48/pc/emulators/gxrom-r.zip // http://www.hpcalc.org/hp48/pc/emulators/gxrom-r.zip
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Log.i("x48", "starting activity"); if (errorLib) {
AssetUtil.copyAsset(this, getResources().getAssets(), false); showDialog(DIALOG_LIB_KO);
return;
}
//Log.i("x48", "starting activity");
boolean firstLaunch = !AssetUtil.copyAsset(this, getResources().getAssets(), false);
readyToGo() ; readyToGo() ;
if (!AssetUtil.isFilesReady(this)) { if (!AssetUtil.isFilesReady(this)) {
showDialog(DIALOG_ROM_KO); showDialog(DIALOG_ROM_KO);
return;
} }
} }
@ -89,6 +96,10 @@ public class X48 extends Activity {
public void checkPrefs() { public void checkPrefs() {
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
/*if (mPrefs.getBoolean("blockOrientation", false))
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
else
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);*/
bitmapSkin = mPrefs.getBoolean("bitmapskin", false); bitmapSkin = mPrefs.getBoolean("bitmapskin", false);
mainView.backBuffer = null; mainView.backBuffer = null;
mainView.needFlip = true; mainView.needFlip = true;
@ -160,7 +171,11 @@ public class X48 extends Activity {
} }
static { static {
try {
System.loadLibrary("droid48"); System.loadLibrary("droid48");
} catch (java.lang.UnsatisfiedLinkError e) {
errorLib = true;
}
} }
@Override @Override
protected void onResume() { protected void onResume() {
@ -178,6 +193,9 @@ public class X48 extends Activity {
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);
if (mainView == null)
return true;
// We are going to create two menus. Note that we assign them // We are going to create two menus. Note that we assign them
// unique integer IDs, labels from our string resources, and // unique integer IDs, labels from our string resources, and
// given them shortcuts. // given them shortcuts.
@ -243,6 +261,7 @@ public class X48 extends Activity {
private static final int DIALOG_ROM_KO = 3; private static final int DIALOG_ROM_KO = 3;
private static final int DIALOG_RAM_KO = 4; private static final int DIALOG_RAM_KO = 4;
private static final int DIALOG_RAM_OK = 5; private static final int DIALOG_RAM_OK = 5;
private static final int DIALOG_LIB_KO = 6;
@Override @Override
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
@ -301,6 +320,17 @@ public class X48 extends Activity {
} }
}) })
.create(); .create();
case DIALOG_LIB_KO: return new AlertDialog.Builder(X48.this)
.setIcon(R.drawable.alert_dialog_icon)
.setTitle(R.string.help)
.setMessage(R.string.lib_ko)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
onDestroy();
}
})
.create();
} }
return null; return null;
} }

View file

@ -8,14 +8,14 @@
<string name="button_quit">Quit</string> <string name="button_quit">Quit</string>
<string name="reset_memory">Reset memory and quit</string> <string name="reset_memory">Reset memory and quit</string>
<string name="help">Help</string> <string name="help">Help</string>
<string name="ok">Ok</string> <string name="ok">OK</string>
<string name="prog_ok">The program/object has been put on the stack.\nNow, some HP knowledge is necessary:\n\n- if this is a library, push 0, then STO and shut down (right shift + on) / restart (on) the calculator: the program will be available in the Library (shift right + 2) menu.\n\n- If this is a regular object (dir, external, etc.), push a name between quotes on the stack (for example, \'prog\'), then push STO: the prog will be available in the VAR menu</string> <string name="prog_ok">The program/object has been put on the stack.\nNow, some HP knowledge is necessary:\n\n- if this is a library, push 0, then STO and shut down (right shift + on) / restart (on) the calculator: the program will be available in the Library (shift right + 2) menu.\n\n- If this is a regular object (dir, external, etc.), push a name between quotes on the stack (for example, \'prog\'), then push STO: the prog will be available in the VAR menu</string>
<string name="prog_ko">This program cannot be loaded.\nMake sure it\'s a valid one and you have enough memory to load it</string> <string name="prog_ko">This program cannot be loaded.\nMake sure it\'s a valid one and you have enough memory to load it</string>
<string name="rom_ko">Rom files not found! This shouldn\'t happen :\\. Quitting now...</string> <string name="rom_ko">Rom files not found! This shouldn\'t happen :\\. Quitting now&#8230;</string>
<string name="general_preferences">General settings</string> <string name="general_preferences">General settings</string>
<string name="display_preferences">Display settings</string> <string name="display_preferences">Display settings</string>
<string name="misc_preferences">Misc settings</string> <string name="misc_preferences">Misc settings</string>
<string name="lib_ko">Application cannot be started due to a native library error. Please try to redownload and reinstall the app</string>
<string name="choose_contrast">Contrast</string> <string name="choose_contrast">Contrast</string>
<string name="choose_contrast_value">Select the contrast</string> <string name="choose_contrast_value">Select the contrast</string>
<string name="choose_backkey">Back key behavior</string> <string name="choose_backkey">Back key behavior</string>
@ -54,10 +54,20 @@
<string name="disableLite">Disable minimal controls</string> <string name="disableLite">Disable minimal controls</string>
<string name="disableLite_summary">Prevents lite controls to show up when touching LCD</string> <string name="disableLite_summary">Prevents lite controls to show up when touching LCD</string>
<string name="sound">Enable sound</string> <string name="sound">Enable sound</string>
<string name="sound_summary">EXPERIMENTAL: system beeps ok, so far</string> <string name="sound_summary">EXPERIMENTAL: System beeps OK, so far</string>
<string name="hp48s">HP48 S</string> <string name="hp48s">HP48 S</string>
<string name="hp48s_summary">Emulate an HP48S (Need App Restart !)</string> <string name="hp48s_summary">Emulate an HP48S (Need App Restart !)</string>
<string name="bitmapSkin">HP48 Bitmap Skin</string> <string name="bitmapSkin">HP48 Bitmap Skin</string>
<string name="bitmapSkin_summary">Restore the previous bitmap skin (48G mode only !)</string> <string name="bitmapSkin_summary">Restore the previous bitmap skin (48G mode only !)</string>
<string name="show_menu">Touch the screen to show system options</string> <string name="show_menu">Touch the screen to show system options</string>
<string name="information">Information</string>
<string name="appreciation">Now you can show your appreciation for Droid48\nThank you !</string>
<string name="dismissforever">Dismiss forever</string>
<string name="donate">Donate</string>
<string name="donate_explain">If you like Droid48, you can show your appreciation here with a donation ! Thank you very much !</string>
<string name="thanks">Thanks for the donation !</string>
<string name="pleasewait">Connecting to billing system, please wait&#8230;</string>
<string name="blockorientation_msgbox">Lock portrait mode</string>
<string name="blockorientation_msgboxvalue">Prevent Droid48 to switch in landscape mode</string>
</resources> </resources>