diff --git a/project/java/DataDownloader.java b/project/java/DataDownloader.java
index d70834ccf..e5ddf398f 100644
--- a/project/java/DataDownloader.java
+++ b/project/java/DataDownloader.java
@@ -57,6 +57,8 @@ import android.content.Context;
import android.content.res.Resources;
import java.lang.String;
import android.text.SpannedString;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
class CountingInputStream extends BufferedInputStream
@@ -188,6 +190,7 @@ class DataDownloader extends Thread
@Override
public void run()
{
+ Parent.keyListener = new BackKeyListener(Parent);
String [] downloadFiles = Globals.DataDownloadUrl;
int total = 0;
int count = 0;
@@ -213,11 +216,13 @@ class DataDownloader extends Thread
}
}
DownloadComplete = true;
+ Parent.keyListener = null;
initParent();
}
public boolean DownloadDataFile(final String DataDownloadUrl, final String DownloadFlagFileName, int downloadCount, int downloadTotal, int downloadIndex)
{
+ DownloadCanBeResumed = false;
Resources res = Parent.getResources();
String [] downloadUrls = DataDownloadUrl.split("[|]");
@@ -298,6 +303,7 @@ class DataDownloader extends Thread
path = getOutFilePath(url.substring( 1, url.indexOf(":", 1) ));
url = url.substring( url.indexOf(":", 1) + 1 );
DoNotUnzip = true;
+ DownloadCanBeResumed = true;
File partialDownload = new File( path );
if( partialDownload.exists() && !partialDownload.isDirectory() && !forceOverwrite )
partialDownloadLen = partialDownload.length();
@@ -674,10 +680,56 @@ class DataDownloader extends Thread
return http;
*/
}
-
+
+
+ public class BackKeyListener implements Settings.KeyEventsListener
+ {
+ MainActivity p;
+ public BackKeyListener(MainActivity _p)
+ {
+ p = _p;
+ }
+
+ public void onKeyEvent(final int keyCode)
+ {
+ if( DownloadFailed )
+ System.exit(1);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(p);
+ builder.setTitle(p.getResources().getString(R.string.cancel_download));
+ builder.setMessage(p.getResources().getString(R.string.cancel_download) + (DownloadCanBeResumed ? " " + p.getResources().getString(R.string.cancel_download_resume) : ""));
+
+ builder.setPositiveButton(p.getResources().getString(R.string.yes), new DialogInterface.OnClickListener()
+ {
+ public void onClick(DialogInterface dialog, int item)
+ {
+ System.exit(1);
+ dialog.dismiss();
+ }
+ });
+ builder.setNegativeButton(p.getResources().getString(R.string.no), new DialogInterface.OnClickListener()
+ {
+ public void onClick(DialogInterface dialog, int item)
+ {
+ dialog.dismiss();
+ }
+ });
+ builder.setOnCancelListener(new DialogInterface.OnCancelListener()
+ {
+ public void onCancel(DialogInterface dialog)
+ {
+ }
+ });
+ AlertDialog alert = builder.create();
+ alert.setOwnerActivity(p);
+ alert.show();
+ }
+ }
+
public StatusWriter Status;
public boolean DownloadComplete = false;
public boolean DownloadFailed = false;
+ public boolean DownloadCanBeResumed = false;
private MainActivity Parent;
private String outFilesDir = null;
}
diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java
index 98944c18b..6f1820709 100644
--- a/project/java/MainActivity.java
+++ b/project/java/MainActivity.java
@@ -623,6 +623,7 @@ public class MainActivity extends Activity
if( mGLView.nativeKey( keyCode, 1 ) == 0 )
return super.onKeyDown(keyCode, event);
}
+ /*
else
if( keyCode == KeyEvent.KEYCODE_BACK && downloader != null )
{
@@ -631,6 +632,7 @@ public class MainActivity extends Activity
if( !downloader.DownloadComplete )
onStop();
}
+ */
else
if( keyListener != null )
{
diff --git a/project/java/translations/values-fr/strings.xml b/project/java/translations/values-fr/strings.xml
index 1df365962..3224cc78a 100644
--- a/project/java/translations/values-fr/strings.xml
+++ b/project/java/translations/values-fr/strings.xml
@@ -171,4 +171,8 @@
Cancel
Your device does not have gyroscope
Reset all options to default values?
+Cancel data downloading?
+You can resume it later, the data will not be downloaded twice.
+Yes
+No
diff --git a/project/java/translations/values-ru/strings.xml b/project/java/translations/values-ru/strings.xml
index 3f73b71cc..c10d240e4 100644
--- a/project/java/translations/values-ru/strings.xml
+++ b/project/java/translations/values-ru/strings.xml
@@ -143,4 +143,8 @@
Отменить
Гироскоп отсутствует
Сбросить все настройки в значения по умолчанию?
+Остановить загрузку?
+Загрузка может быть продолжена позднее.
+Да
+Нет
diff --git a/project/java/translations/values-uk/strings.xml b/project/java/translations/values-uk/strings.xml
index 9a549d1fe..11b168d89 100644
--- a/project/java/translations/values-uk/strings.xml
+++ b/project/java/translations/values-uk/strings.xml
@@ -142,4 +142,8 @@
Cancel
Your device does not have gyroscope
Reset all options to default values?
+Cancel data downloading?
+You can resume it later, the data will not be downloaded twice.
+Yes
+No
diff --git a/project/java/translations/values/strings.xml b/project/java/translations/values/strings.xml
index f15e9192d..c8bc65289 100644
--- a/project/java/translations/values/strings.xml
+++ b/project/java/translations/values/strings.xml
@@ -173,4 +173,9 @@
Reset config to defaults
Reset all options to default values?
+ Cancel data downloading?
+ You can resume it later, the data will not be downloaded twice.
+ Yes
+ No
+
diff --git a/todo.txt b/todo.txt
index a821162d9..6ee3b5c22 100644
--- a/todo.txt
+++ b/todo.txt
@@ -5,8 +5,6 @@ Requested features (see also bugs.txt)
- Redesign on-screen keyboard layout dialog.
-- Option to reset SDL config to default.
-
- Option for default on-screen key theme in AndroidAppSettings.cfg.
- Select between normal mouse input and magnifying glass/relative input automatically, based on screen size.