diff --git a/projects/mtg/Android/src/net/wagic/utils/DeckImporter.java b/projects/mtg/Android/src/net/wagic/utils/DeckImporter.java index 55bfe3dd6..74aeaafe0 100644 --- a/projects/mtg/Android/src/net/wagic/utils/DeckImporter.java +++ b/projects/mtg/Android/src/net/wagic/utils/DeckImporter.java @@ -11,14 +11,13 @@ import android.util.Log; public class DeckImporter { - public static String importDeck( File f, String mypath, String activePath ) { String message = ""; String deck = ""; String deckname = ""; - String prefix = "#SB:"; - int cardcount = 0; + String prefix = "#SB:"; + int cardcount = 0; if(f.exists() && !f.isDirectory()) { deckname = f.getName(); @@ -36,91 +35,86 @@ public class DeckImporter while (scanner.hasNext()) { String line = scanner.nextLine(); - line = line.trim(); - if (!line.equals("") && cardcount < 61) // don't write out blank lines - { - String[] slines = line.split("\\s+"); - String arranged = ""; - for(int idx = 1; idx < slines.length; idx++) - { - arranged += slines[idx] + " "; - } - if ((isNumeric(slines[0])) && arranged != null) - { - if (slines[1] != null && slines[1].startsWith("[")) - { - arranged = arranged.substring(5); - slines[1] = slines[1].replaceAll("\\[", "").replaceAll("\\]",""); - deck += arranged + " (" + renameSet(slines[1]) + ") * " + slines[0] + "\n"; - } - else - { - deck += arranged + "(*) * " + slines[0] + "\n"; - } - cardcount += Integer.parseInt(slines[0]); - } - } - } - File profile = new File(activePath+"/Res/settings/options.txt"); - if(profile.exists() && !profile.isDirectory()) - { - String profileName = getActiveProfile(profile); - if(profileName != "Missing!") - { - File rootProfiles = new File(activePath+"/Res/profiles/"+profileName); - if(rootProfiles.exists() && rootProfiles.isDirectory()) - { - //save deck - int countdeck = 1; - File[] files = rootProfiles.listFiles(); - for (int i = 0; i < files.length; i++) - {//check if there is available deck... - if(files[i].getName().startsWith("deck")) - countdeck++; - } - File toSave = new File(rootProfiles+"/deck"+countdeck+".txt"); - try - { - FileOutputStream fop = new FileOutputStream(toSave); - - // if file doesn't exists, then create it - if (!toSave.exists()) { - toSave.createNewFile(); - } - // get the content in bytes - byte[] contentInBytes = deck.getBytes(); - fop.write(contentInBytes); - fop.flush(); - fop.close(); - message = "Import Deck Success!\n"+cardcount+" total cards in this deck\n\n"+deck; - } - catch (IOException e) - { - message = e.getMessage(); - } - } - else - { - message = "Missing Folder!"; - } - } - } - else - { - message = "Invalid Profile!"; - } - } - else - { - message = "No errors, and file EMPTY"; - } - } - catch(IOException e) - { - message = e.getMessage(); - } - } - return message; + line = line.trim(); + if (!line.equals("") && cardcount < 61) // don't write out blank lines + { + String[] slines = line.split("\\s+"); + String arranged = ""; + for (int idx = 1; idx < slines.length; idx++) + { + arranged += slines[idx] + " "; + } + if ((isNumeric(slines[0])) && arranged != null) + { + if (slines[1] != null && slines[1].startsWith("[")) + { + arranged = arranged.substring(5); + slines[1] = slines[1].replaceAll("\\[", "").replaceAll("\\]", ""); + deck += arranged + " (" + renameSet(slines[1]) + ") * " + slines[0] + "\n"; + } else + { + deck += arranged + "(*) * " + slines[0] + "\n"; + } + cardcount += Integer.parseInt(slines[0]); + } + } + } + File profile = new File(activePath + "/Res/settings/options.txt"); + if (profile.exists() && !profile.isDirectory()) + { + String profileName = getActiveProfile(profile); + if (profileName != "Missing!") + { + File rootProfiles = new File(activePath + "/Res/profiles/" + profileName); + if (rootProfiles.exists() && rootProfiles.isDirectory()) + { + //save deck + int countdeck = 1; + File[] files = rootProfiles.listFiles(); + for (int i = 0; i < files.length; i++) + {//check if there is available deck... + if (files[i].getName().startsWith("deck")) + countdeck++; + } + File toSave = new File(rootProfiles + "/deck" + countdeck + ".txt"); + try + { + FileOutputStream fop = new FileOutputStream(toSave); + + // if file doesn't exists, then create it + if (!toSave.exists()) + { + toSave.createNewFile(); + } + // get the content in bytes + byte[] contentInBytes = deck.getBytes(); + fop.write(contentInBytes); + fop.flush(); + fop.close(); + message = "Import Deck Success!\n" + cardcount + " total cards in this deck\n\n" + deck; + } catch (IOException e) + { + message = e.getMessage(); + } + } else + { + message = "Missing Folder!"; + } + } + } else + { + message = "Invalid Profile!"; + } + } else + { + message = "No errors, and file EMPTY"; + } + } catch (IOException e) + { + message = e.getMessage(); + } + } + return message; } private static boolean isNumeric(String input) @@ -135,7 +129,7 @@ public class DeckImporter } return true; } - + private static String getActiveProfile(File mypath) { String name = ""; @@ -158,7 +152,7 @@ public class DeckImporter } return name; } - + private static String renameSet(String set) { if (set == "") @@ -278,5 +272,4 @@ public class DeckImporter else return set; } - } diff --git a/projects/mtg/Android/src/net/wagic/utils/StorageOptions.java b/projects/mtg/Android/src/net/wagic/utils/StorageOptions.java index 622e89bad..ce2c37c7c 100644 --- a/projects/mtg/Android/src/net/wagic/utils/StorageOptions.java +++ b/projects/mtg/Android/src/net/wagic/utils/StorageOptions.java @@ -310,84 +310,95 @@ public class StorageOptions * * @return true if the device is rooted, false otherwise. */ - public static boolean isRooted() { - - // get from build info - String buildTags = android.os.Build.TAGS; - if (buildTags != null && buildTags.contains("test-keys")) { - return true; - } - - // check if /system/app/Superuser.apk is present - try { - File file = new File("/system/app/Superuser.apk"); - if (file.exists()) { - return true; - } - } - catch (Exception e1) { - // ignore - } - try { - File file = new File("/system/app/Superuser/Superuser.apk"); - if (file.exists()) { - return true; - } - } - catch (Exception e1) { - // ignore - } - //SuperSU - try { - File file = new File("/system/app/SuperSU.apk"); - if (file.exists()) { - return true; - } - } - catch (Exception e1) { - // ignore - } - try { - File file = new File("/system/app/SuperSU/SuperSU.apk"); - if (file.exists()) { - return true; - } - } - catch (Exception e1) { - // ignore - } - // try executing commands - return canExecuteCommand("/system/xbin/which su") - || canExecuteCommand("/system/bin/which su") || canExecuteCommand("which su"); - } - - // executes a command on the system - private static boolean canExecuteCommand(String command) { - boolean executedSuccesfully; - try { - Runtime.getRuntime().exec(command); - executedSuccesfully = true; - } - catch (Exception e) { - executedSuccesfully = false; - } - - return executedSuccesfully; - } - - private static boolean findForcemount(){ - try + public static boolean isRooted() { - File file = new File(System.getenv("EXTERNAL_STORAGE")+"/forcemount"); - if (file.exists()) + // get from build info + String buildTags = android.os.Build.TAGS; + if (buildTags != null && buildTags.contains("test-keys")) { return true; } - } - catch (Exception e1) + + // check if /system/app/Superuser.apk is present + try + { + File file = new File("/system/app/Superuser.apk"); + if (file.exists()) + { + return true; + } + } catch (Exception e1) + { + // ignore + } + try + { + File file = new File("/system/app/Superuser/Superuser.apk"); + if (file.exists()) + { + return true; + } + } catch (Exception e1) + { + // ignore + } + //SuperSU + try + { + File file = new File("/system/app/SuperSU.apk"); + if (file.exists()) + { + return true; + } + } catch (Exception e1) + { + // ignore + } + try + { + File file = new File("/system/app/SuperSU/SuperSU.apk"); + if (file.exists()) + { + return true; + } + } catch (Exception e1) + { + // ignore + } + // try executing commands + return canExecuteCommand("/system/xbin/which su") + || canExecuteCommand("/system/bin/which su") || canExecuteCommand("which su"); + } + + // executes a command on the system + private static boolean canExecuteCommand(String command) { + boolean executedSuccesfully; + try + { + Runtime.getRuntime().exec(command); + executedSuccesfully = true; + } catch (Exception e) + { + executedSuccesfully = false; + } + + return executedSuccesfully; + } + + private static boolean findForcemount() + { + try + { + File file = new File(System.getenv("EXTERNAL_STORAGE") + "/forcemount"); + if (file.exists()) + { + return true; + } + } catch (Exception e1) + { + return false; + } return false; } - return false; - } } diff --git a/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java b/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java index 0b8f093d8..64b2a95b4 100644 --- a/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java +++ b/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java @@ -14,8 +14,6 @@ import java.net.URLConnection; import java.util.ArrayList; import java.util.Scanner; - - import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLContext; @@ -1096,7 +1094,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK try { - EGL10 egl = (EGL10) EGLContext.getEGL(); EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); @@ -1162,7 +1159,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK EGL10 egl = (EGL10) EGLContext.getEGL(); if (mEGLSurface != null) { - /* * Unbind and destroy the old EGL surface, if there is one. */ @@ -1197,7 +1193,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK // EGL buffer flip public void flipEGL() { - if (!mSurfaceValid) { createSurface(this.getHolder()); @@ -1223,7 +1218,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK Log.e("SDL", s.toString()); } } - } // Key events @@ -1234,6 +1228,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) return false; + if (event.getAction() == KeyEvent.ACTION_DOWN) { // Log.d("SDL", "key down: " + keyCode); @@ -1252,7 +1247,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK // Touch events public boolean onTouch(View v, MotionEvent event) { - for (int index = 0; index < event.getPointerCount(); ++index) { int action = event.getActionMasked();