Added option to download latest core file from Android app (both at startup and from settings menu).
This commit is contained in:
@@ -110,6 +110,7 @@ public class SDLActivity extends Activity implements OnKeyListener {
|
|||||||
public static final String kSaveDataPathPreference = "StorageDataLocation";
|
public static final String kSaveDataPathPreference = "StorageDataLocation";
|
||||||
public static final String kWagicDataStorageOptionsKey = "dataStorageOptions";
|
public static final String kWagicDataStorageOptionsKey = "dataStorageOptions";
|
||||||
public static final int kStorageDataOptionsMenuId = 2000;
|
public static final int kStorageDataOptionsMenuId = 2000;
|
||||||
|
public static final int kdownloadResOptionsMenuId = 4000;
|
||||||
public static final int kOtherOptionsMenuId = 3000;
|
public static final int kOtherOptionsMenuId = 3000;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -170,6 +171,7 @@ public class SDLActivity extends Activity implements OnKeyListener {
|
|||||||
MenuItem downloader;
|
MenuItem downloader;
|
||||||
MenuItem about;
|
MenuItem about;
|
||||||
MenuItem storage;
|
MenuItem storage;
|
||||||
|
MenuItem resource;
|
||||||
|
|
||||||
// Handler for the messages
|
// Handler for the messages
|
||||||
Handler commandHandler = new Handler() {
|
Handler commandHandler = new Handler() {
|
||||||
@@ -951,6 +953,9 @@ public class SDLActivity extends Activity implements OnKeyListener {
|
|||||||
about = menu.add(Menu.NONE, 4, 4, "About");
|
about = menu.add(Menu.NONE, 4, 4, "About");
|
||||||
storage = settingsMenu.add(kStorageDataOptionsMenuId,
|
storage = settingsMenu.add(kStorageDataOptionsMenuId,
|
||||||
kStorageDataOptionsMenuId, Menu.NONE, "Storage Data Options");
|
kStorageDataOptionsMenuId, Menu.NONE, "Storage Data Options");
|
||||||
|
resource = settingsMenu.add(kdownloadResOptionsMenuId,
|
||||||
|
kdownloadResOptionsMenuId, Menu.NONE, "Download Core & Quit");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -966,6 +971,10 @@ public class SDLActivity extends Activity implements OnKeyListener {
|
|||||||
|
|
||||||
if (itemId == kStorageDataOptionsMenuId) {
|
if (itemId == kStorageDataOptionsMenuId) {
|
||||||
displayStorageOptions();
|
displayStorageOptions();
|
||||||
|
} else if (itemId == kdownloadResOptionsMenuId) {
|
||||||
|
File oldRes = new File(getSystemStorageLocation() + RES_FILENAME);
|
||||||
|
oldRes.delete();
|
||||||
|
startDownload();
|
||||||
} else if (itemId == 2) {
|
} else if (itemId == 2) {
|
||||||
importDeckOptions();
|
importDeckOptions();
|
||||||
} else if (itemId == 3) {
|
} else if (itemId == 3) {
|
||||||
@@ -1000,7 +1009,7 @@ public class SDLActivity extends Activity implements OnKeyListener {
|
|||||||
public void showSettingsSubMenu() {
|
public void showSettingsSubMenu() {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle("Settings Menu");
|
builder.setTitle("Settings Menu");
|
||||||
String[] choices = { "Storage Data Options" };
|
String[] choices = { "Storage Data Options", "Download Core & Quit" };
|
||||||
builder.setItems(choices,
|
builder.setItems(choices,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -1009,6 +1018,9 @@ public class SDLActivity extends Activity implements OnKeyListener {
|
|||||||
case 0:
|
case 0:
|
||||||
onOptionsItemSelected(storage);
|
onOptionsItemSelected(storage);
|
||||||
break;
|
break;
|
||||||
|
case 1:
|
||||||
|
onOptionsItemSelected(resource);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1122,13 +1134,41 @@ public class SDLActivity extends Activity implements OnKeyListener {
|
|||||||
prepareOptionMenu(null);
|
prepareOptionMenu(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void forceResDownload(final File oldRes) {
|
||||||
|
AlertDialog.Builder resChooser = new AlertDialog.Builder(this);
|
||||||
|
final SDLActivity parent = this;
|
||||||
|
|
||||||
|
resChooser.setTitle("Do you want to download latest core file?");
|
||||||
|
|
||||||
|
resChooser.setPositiveButton("Yes",
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
FrameLayout _videoLayout = new FrameLayout(parent);
|
||||||
|
setContentView(_videoLayout,
|
||||||
|
new LayoutParams(LayoutParams.FILL_PARENT,
|
||||||
|
LayoutParams.FILL_PARENT));
|
||||||
|
oldRes.delete();
|
||||||
|
startDownload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
resChooser.setNegativeButton("No",
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
mainDisplay();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
resChooser.create().show();
|
||||||
|
}
|
||||||
|
|
||||||
public void initializeGame() {
|
public void initializeGame() {
|
||||||
String coreFileLocation = getSystemStorageLocation() + RES_FILENAME;
|
String coreFileLocation = getSystemStorageLocation() + RES_FILENAME;
|
||||||
|
|
||||||
File file = new File(coreFileLocation);
|
File file = new File(coreFileLocation);
|
||||||
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
mainDisplay();
|
forceResDownload(file);
|
||||||
} else {
|
} else {
|
||||||
FrameLayout _videoLayout = new FrameLayout(this);
|
FrameLayout _videoLayout = new FrameLayout(this);
|
||||||
setContentView(_videoLayout,
|
setContentView(_videoLayout,
|
||||||
|
|||||||
Reference in New Issue
Block a user