- only minor whitespace formatting Android

This commit is contained in:
Rolzad73
2016-08-04 08:32:17 -04:00
parent 62a6ddf3ca
commit dd5635d9cd
3 changed files with 169 additions and 171 deletions

View File

@@ -11,14 +11,13 @@ import android.util.Log;
public class DeckImporter public class DeckImporter
{ {
public static String importDeck( File f, String mypath, String activePath ) public static String importDeck( File f, String mypath, String activePath )
{ {
String message = ""; String message = "";
String deck = ""; String deck = "";
String deckname = ""; String deckname = "";
String prefix = "#SB:"; String prefix = "#SB:";
int cardcount = 0; int cardcount = 0;
if(f.exists() && !f.isDirectory()) if(f.exists() && !f.isDirectory())
{ {
deckname = f.getName(); deckname = f.getName();
@@ -36,91 +35,86 @@ public class DeckImporter
while (scanner.hasNext()) while (scanner.hasNext())
{ {
String line = scanner.nextLine(); String line = scanner.nextLine();
line = line.trim(); line = line.trim();
if (!line.equals("") && cardcount < 61) // don't write out blank lines if (!line.equals("") && cardcount < 61) // don't write out blank lines
{ {
String[] slines = line.split("\\s+"); String[] slines = line.split("\\s+");
String arranged = ""; String arranged = "";
for(int idx = 1; idx < slines.length; idx++) for (int idx = 1; idx < slines.length; idx++)
{ {
arranged += slines[idx] + " "; arranged += slines[idx] + " ";
} }
if ((isNumeric(slines[0])) && arranged != null) if ((isNumeric(slines[0])) && arranged != null)
{ {
if (slines[1] != null && slines[1].startsWith("[")) if (slines[1] != null && slines[1].startsWith("["))
{ {
arranged = arranged.substring(5); arranged = arranged.substring(5);
slines[1] = slines[1].replaceAll("\\[", "").replaceAll("\\]",""); slines[1] = slines[1].replaceAll("\\[", "").replaceAll("\\]", "");
deck += arranged + " (" + renameSet(slines[1]) + ") * " + slines[0] + "\n"; deck += arranged + " (" + renameSet(slines[1]) + ") * " + slines[0] + "\n";
} } else
else {
{ deck += arranged + "(*) * " + slines[0] + "\n";
deck += arranged + "(*) * " + slines[0] + "\n"; }
} cardcount += Integer.parseInt(slines[0]);
cardcount += Integer.parseInt(slines[0]); }
} }
} }
} File profile = new File(activePath + "/Res/settings/options.txt");
File profile = new File(activePath+"/Res/settings/options.txt"); if (profile.exists() && !profile.isDirectory())
if(profile.exists() && !profile.isDirectory()) {
{ String profileName = getActiveProfile(profile);
String profileName = getActiveProfile(profile); if (profileName != "Missing!")
if(profileName != "Missing!") {
{ File rootProfiles = new File(activePath + "/Res/profiles/" + profileName);
File rootProfiles = new File(activePath+"/Res/profiles/"+profileName); if (rootProfiles.exists() && rootProfiles.isDirectory())
if(rootProfiles.exists() && rootProfiles.isDirectory()) {
{ //save deck
//save deck int countdeck = 1;
int countdeck = 1; File[] files = rootProfiles.listFiles();
File[] files = rootProfiles.listFiles(); for (int i = 0; i < files.length; i++)
for (int i = 0; i < files.length; i++) {//check if there is available deck...
{//check if there is available deck... if (files[i].getName().startsWith("deck"))
if(files[i].getName().startsWith("deck")) countdeck++;
countdeck++; }
} File toSave = new File(rootProfiles + "/deck" + countdeck + ".txt");
File toSave = new File(rootProfiles+"/deck"+countdeck+".txt"); try
try {
{ FileOutputStream fop = new FileOutputStream(toSave);
FileOutputStream fop = new FileOutputStream(toSave);
// if file doesn't exists, then create it
// if file doesn't exists, then create it if (!toSave.exists())
if (!toSave.exists()) { {
toSave.createNewFile(); toSave.createNewFile();
} }
// get the content in bytes // get the content in bytes
byte[] contentInBytes = deck.getBytes(); byte[] contentInBytes = deck.getBytes();
fop.write(contentInBytes); fop.write(contentInBytes);
fop.flush(); fop.flush();
fop.close(); fop.close();
message = "Import Deck Success!\n"+cardcount+" total cards in this deck\n\n"+deck; message = "Import Deck Success!\n" + cardcount + " total cards in this deck\n\n" + deck;
} } catch (IOException e)
catch (IOException e) {
{ message = e.getMessage();
message = e.getMessage(); }
} } else
} {
else message = "Missing Folder!";
{ }
message = "Missing Folder!"; }
} } else
} {
} message = "Invalid Profile!";
else }
{ } else
message = "Invalid Profile!"; {
} message = "No errors, and file EMPTY";
} }
else } catch (IOException e)
{ {
message = "No errors, and file EMPTY"; message = e.getMessage();
} }
} }
catch(IOException e) return message;
{
message = e.getMessage();
}
}
return message;
} }
private static boolean isNumeric(String input) private static boolean isNumeric(String input)
@@ -135,7 +129,7 @@ public class DeckImporter
} }
return true; return true;
} }
private static String getActiveProfile(File mypath) private static String getActiveProfile(File mypath)
{ {
String name = ""; String name = "";
@@ -158,7 +152,7 @@ public class DeckImporter
} }
return name; return name;
} }
private static String renameSet(String set) private static String renameSet(String set)
{ {
if (set == "") if (set == "")
@@ -278,5 +272,4 @@ public class DeckImporter
else else
return set; return set;
} }
} }

View File

@@ -310,84 +310,95 @@ public class StorageOptions
* *
* @return <code>true</code> if the device is rooted, <code>false</code> otherwise. * @return <code>true</code> if the device is rooted, <code>false</code> otherwise.
*/ */
public static boolean isRooted() { 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
{ {
File file = new File(System.getenv("EXTERNAL_STORAGE")+"/forcemount"); // get from build info
if (file.exists()) String buildTags = android.os.Build.TAGS;
if (buildTags != null && buildTags.contains("test-keys"))
{ {
return true; 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;
} }
return false;
}
} }

View File

@@ -14,8 +14,6 @@ import java.net.URLConnection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Scanner; import java.util.Scanner;
import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext; import javax.microedition.khronos.egl.EGLContext;
@@ -1096,7 +1094,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
try try
{ {
EGL10 egl = (EGL10) EGLContext.getEGL(); EGL10 egl = (EGL10) EGLContext.getEGL();
EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); 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(); EGL10 egl = (EGL10) EGLContext.getEGL();
if (mEGLSurface != null) if (mEGLSurface != null)
{ {
/* /*
* Unbind and destroy the old EGL surface, if there is one. * 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 // EGL buffer flip
public void flipEGL() public void flipEGL()
{ {
if (!mSurfaceValid) if (!mSurfaceValid)
{ {
createSurface(this.getHolder()); createSurface(this.getHolder());
@@ -1223,7 +1218,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
Log.e("SDL", s.toString()); Log.e("SDL", s.toString());
} }
} }
} }
// Key events // 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) if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
return false; return false;
if (event.getAction() == KeyEvent.ACTION_DOWN) if (event.getAction() == KeyEvent.ACTION_DOWN)
{ {
// Log.d("SDL", "key down: " + keyCode); // Log.d("SDL", "key down: " + keyCode);
@@ -1252,7 +1247,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
// Touch events // Touch events
public boolean onTouch(View v, MotionEvent event) public boolean onTouch(View v, MotionEvent event)
{ {
for (int index = 0; index < event.getPointerCount(); ++index) for (int index = 0; index < event.getPointerCount(); ++index)
{ {
int action = event.getActionMasked(); int action = event.getActionMasked();