Merge branch 'master' of https://github.com/kevlahnota/wagic
This commit is contained in:
@@ -157,6 +157,8 @@ public class DeckImporter
|
||||
|
||||
private static String renameSet(String set)
|
||||
{
|
||||
if (set == "")
|
||||
return "*";
|
||||
if (set == "AL")
|
||||
return "ALL";
|
||||
if (set == "AQ")
|
||||
|
||||
@@ -61,7 +61,7 @@ public class StorageOptions
|
||||
if (line.startsWith("/"))
|
||||
{
|
||||
String[] lineElements = line.split("\\s+");
|
||||
if ("vfat".equals(lineElements[2]) || "fuse".equals(lineElements[2]))
|
||||
if ("vfat".equals(lineElements[2]) || "fuse".equals(lineElements[2]) || "sdcardfs".equals(lineElements[2]))
|
||||
{
|
||||
File mountPoint = new File(lineElements[1]);
|
||||
if (!lineElements[1].equals(defaultMountPoint))
|
||||
@@ -201,13 +201,43 @@ public class StorageOptions
|
||||
mMounts.remove(i--);
|
||||
}
|
||||
|
||||
if (t == 0 && Build.VERSION.SDK_INT >= 19)
|
||||
{//If none is found and build version is kitkat or higher
|
||||
File root = new File("/storage/sdcard0");
|
||||
if (root.exists() && root.isDirectory() && root.canWrite())
|
||||
mMounts.add("/storage/sdcard0");
|
||||
if (isExternalStorageAvailable() && !isExternalStorageReadOnly())
|
||||
mMounts.add("/storage/sdcard1");
|
||||
if (t == 0 && Build.VERSION.SDK_INT >= 16)
|
||||
{//if none is found lets force it for Jellybean and above...
|
||||
if (System.getenv("EXTERNAL_STORAGE") != null)
|
||||
{
|
||||
File root = new File(System.getenv("EXTERNAL_STORAGE"));
|
||||
if (root.exists() && root.isDirectory() && root.canWrite())
|
||||
{
|
||||
if(!isRooted())
|
||||
{
|
||||
File folder = new File(System.getenv("EXTERNAL_STORAGE")+"/Android/data/net.wagic.app/files");
|
||||
folder.mkdirs();
|
||||
mMounts.add(folder.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
mMounts.add(System.getenv("EXTERNAL_STORAGE"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (System.getenv("SECONDARY_STORAGE") != null)
|
||||
{
|
||||
File root = new File(System.getenv("SECONDARY_STORAGE"));
|
||||
if (root.exists() && root.isDirectory() && root.canWrite())
|
||||
{
|
||||
if(!isRooted())
|
||||
{
|
||||
File folder = new File(System.getenv("SECONDARY_STORAGE")+"/Android/data/net.wagic.app/files");
|
||||
folder.mkdirs();
|
||||
mMounts.add(folder.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
mMounts.add(System.getenv("SECONDARY_STORAGE"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,6 +254,8 @@ public class StorageOptions
|
||||
{ // TODO: /mnt/sdcard is assumed to always mean internal storage. Use this comparison until there is a better way to do this
|
||||
if ("/mnt/sdcard".equalsIgnoreCase(path) || "/storage/sdcard0".equalsIgnoreCase(path))
|
||||
mLabels.add("Internal SD " + "[" + path + "]");
|
||||
else if (path.contains("emulated"))
|
||||
mLabels.add("Emulated SD " + " [" + path + "]");
|
||||
else
|
||||
mLabels.add("External SD " + " [" + path + "]");
|
||||
}
|
||||
@@ -256,4 +288,74 @@ public class StorageOptions
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the device is rooted.
|
||||
*
|
||||
* @return <code>true</code> if the device is rooted, <code>false</code> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,10 +215,9 @@ public class SDLActivity extends Activity implements OnKeyListener
|
||||
|
||||
private void importDeckOptions()
|
||||
{
|
||||
AlertDialog.Builder importDeck = new AlertDialog.Builder(this);
|
||||
int index=internalPath.lastIndexOf('/');
|
||||
AlertDialog.Builder importDeck = new AlertDialog.Builder(this);
|
||||
importDeck.setTitle("Choose Deck to Import:");
|
||||
File root = new File(internalPath.substring(0,index)+"/Download");
|
||||
File root = new File(System.getenv("EXTERNAL_STORAGE")+"/Download");
|
||||
File[] files = root.listFiles();
|
||||
for( File f : files)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user