mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Change download directory for apk file
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -16678,8 +16678,8 @@ forge-gui/src/main/java/forge/gauntlet/GauntletWinLoseController.java -text
|
||||
forge-gui/src/main/java/forge/interfaces/IButton.java -text
|
||||
forge-gui/src/main/java/forge/interfaces/ICheckBox.java -text
|
||||
forge-gui/src/main/java/forge/interfaces/IComboBox.java -text
|
||||
forge-gui/src/main/java/forge/interfaces/IDeviceAdapter.java -text
|
||||
forge-gui/src/main/java/forge/interfaces/IGuiBase.java -text
|
||||
forge-gui/src/main/java/forge/interfaces/INetworkConnection.java -text
|
||||
forge-gui/src/main/java/forge/interfaces/IProgressBar.java -text
|
||||
forge-gui/src/main/java/forge/interfaces/ITextField.java -text
|
||||
forge-gui/src/main/java/forge/interfaces/IWinLoseView.java -text
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.interfaces.INetworkConnection;
|
||||
import forge.interfaces.IDeviceAdapter;
|
||||
import forge.util.Callback;
|
||||
import forge.util.FileUtil;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class Main extends AndroidApplication {
|
||||
return;
|
||||
}
|
||||
|
||||
initialize(Forge.getApp(new AndroidClipboard(), new AndroidNetworkConnection(),
|
||||
initialize(Forge.getApp(new AndroidClipboard(), new AndroidAdapter(),
|
||||
assetsDir, new Callback<String>() {
|
||||
@Override
|
||||
public void run(String runOnExit) {
|
||||
@@ -99,11 +99,11 @@ public class Main extends AndroidApplication {
|
||||
}
|
||||
}
|
||||
|
||||
private class AndroidNetworkConnection implements INetworkConnection {
|
||||
private class AndroidAdapter implements IDeviceAdapter {
|
||||
private final ConnectivityManager connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
public boolean isConnectedToInternet() {
|
||||
NetworkInfo activeNetworkInfo = connManager.getActiveNetworkInfo();
|
||||
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
||||
}
|
||||
@@ -113,5 +113,10 @@ public class Main extends AndroidApplication {
|
||||
NetworkInfo wifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||
return wifi.isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadsDir() {
|
||||
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.badlogic.gdx.backends.lwjgl.LwjglClipboard;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.assets.AssetsDownloader;
|
||||
import forge.interfaces.INetworkConnection;
|
||||
import forge.interfaces.IDeviceAdapter;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.Utils;
|
||||
|
||||
@@ -16,14 +16,14 @@ public class Main {
|
||||
FileUtil.ensureDirectoryExists(assetsDir);
|
||||
}
|
||||
|
||||
new LwjglApplication(Forge.getApp(new LwjglClipboard(), new DesktopNetworkConnection(),
|
||||
new LwjglApplication(Forge.getApp(new LwjglClipboard(), new DesktopAdapter(),
|
||||
assetsDir, null), "Forge", Utils.DEV_SCREEN_WIDTH, Utils.DEV_SCREEN_HEIGHT);
|
||||
}
|
||||
|
||||
private static class DesktopNetworkConnection implements INetworkConnection {
|
||||
private static class DesktopAdapter implements IDeviceAdapter {
|
||||
//just assume desktop always connected to wifi
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
public boolean isConnectedToInternet() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -31,5 +31,10 @@ public class Main {
|
||||
public boolean isConnectedToWifi() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadsDir() {
|
||||
return System.getProperty("user.home") + "/Downloads/";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import forge.assets.FSkinFont;
|
||||
import forge.assets.ImageCache;
|
||||
import forge.error.BugReporter;
|
||||
import forge.error.ExceptionHandler;
|
||||
import forge.interfaces.INetworkConnection;
|
||||
import forge.interfaces.IDeviceAdapter;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.properties.ForgePreferences;
|
||||
@@ -41,7 +41,7 @@ public class Forge implements ApplicationListener {
|
||||
|
||||
private static final ApplicationListener app = new Forge();
|
||||
private static Clipboard clipboard;
|
||||
private static INetworkConnection networkConnection;
|
||||
private static IDeviceAdapter deviceAdapter;
|
||||
private static Callback<String> onExit;
|
||||
private static int screenWidth;
|
||||
private static int screenHeight;
|
||||
@@ -54,10 +54,10 @@ public class Forge implements ApplicationListener {
|
||||
private static final SoundSystem soundSystem = new SoundSystem();
|
||||
private static final Stack<FScreen> screens = new Stack<FScreen>();
|
||||
|
||||
public static ApplicationListener getApp(Clipboard clipboard0, INetworkConnection networkConnection0, String assetDir0, Callback<String> onExit0) {
|
||||
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, Callback<String> onExit0) {
|
||||
if (GuiBase.getInterface() == null) {
|
||||
clipboard = clipboard0;
|
||||
networkConnection = networkConnection0;
|
||||
deviceAdapter = deviceAdapter0;
|
||||
onExit = onExit0;
|
||||
GuiBase.setInterface(new GuiMobile(assetDir0));
|
||||
}
|
||||
@@ -127,8 +127,8 @@ public class Forge implements ApplicationListener {
|
||||
return clipboard;
|
||||
}
|
||||
|
||||
public static INetworkConnection getNetworkConnection() {
|
||||
return networkConnection;
|
||||
public static IDeviceAdapter getDeviceAdapter() {
|
||||
return deviceAdapter;
|
||||
}
|
||||
|
||||
public static void showMenu() {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class AssetsDownloader {
|
||||
splashScreen.getProgressBar().setDescription("Checking for updates...");
|
||||
|
||||
String message;
|
||||
boolean connectedToInternet = Forge.getNetworkConnection().isConnected();
|
||||
boolean connectedToInternet = Forge.getDeviceAdapter().isConnectedToInternet();
|
||||
if (connectedToInternet) {
|
||||
try {
|
||||
URL versionUrl = new URL("http://cardforge.org/android/releases/forge/forge-gui-android/version.txt");
|
||||
@@ -48,13 +48,13 @@ public class AssetsDownloader {
|
||||
message = "A new version of Forge is available (" + version + ").\n" +
|
||||
"You are currently on an older version (" + Forge.CURRENT_VERSION + ").\n\n" +
|
||||
"Would you like to update to the new version now?";
|
||||
if (!Forge.getNetworkConnection().isConnectedToWifi()) {
|
||||
if (!Forge.getDeviceAdapter().isConnectedToWifi()) {
|
||||
message += " If so, you may want to connect to wifi first. The download is around 6.5MB.";
|
||||
}
|
||||
if (SOptionPane.showConfirmDialog(message, "New Version Available", "Update Now", "Update Later")) {
|
||||
String apkFile = downloadFile("update", "forge-android-" + version + "-signed-aligned.apk",
|
||||
"http://cardforge.org/android/releases/forge/forge-gui-android/" + version + "/",
|
||||
ForgeConstants.ASSETS_DIR, splashScreen.getProgressBar());
|
||||
Forge.getDeviceAdapter().getDownloadsDir(), splashScreen.getProgressBar());
|
||||
if (apkFile != null) {
|
||||
Forge.exit(true, apkFile);
|
||||
return;
|
||||
@@ -107,7 +107,7 @@ public class AssetsDownloader {
|
||||
//prompt user whether they wish to download the updated resource files
|
||||
message = "There are updated resource files to download. " +
|
||||
"This download is around 80MB, ";
|
||||
if (Forge.getNetworkConnection().isConnectedToWifi()) {
|
||||
if (Forge.getDeviceAdapter().isConnectedToWifi()) {
|
||||
message += "which shouldn't take long if your wifi connection is good.";
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package forge.interfaces;
|
||||
|
||||
public interface IDeviceAdapter {
|
||||
boolean isConnectedToInternet();
|
||||
boolean isConnectedToWifi();
|
||||
String getDownloadsDir();
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package forge.interfaces;
|
||||
|
||||
public interface INetworkConnection {
|
||||
boolean isConnected();
|
||||
boolean isConnectedToWifi();
|
||||
}
|
||||
Reference in New Issue
Block a user