Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Dialog to abort data downloading

  • Loading branch information...
commit afce1cbde2eb2e005b8187efbda6d4808b07657d 1 parent 7c1805a
@pelya authored
View
54 project/java/DataDownloader.java
@@ -57,6 +57,8 @@ Java source code (C) 2009-2012 Sergii Pylypenko
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 @@ public void setStatusField(TextView _Status)
@Override
public void run()
{
+ Parent.keyListener = new BackKeyListener(Parent);
String [] downloadFiles = Globals.DataDownloadUrl;
int total = 0;
int count = 0;
@@ -213,11 +216,13 @@ public void run()
}
}
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 @@ public boolean DownloadDataFile(final String DataDownloadUrl, final String Downl
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 @@ private static DefaultHttpClient HttpWithDisabledSslCertCheck()
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;
}
View
2  project/java/MainActivity.java
@@ -623,6 +623,7 @@ public boolean onKeyDown(int keyCode, final KeyEvent event)
if( mGLView.nativeKey( keyCode, 1 ) == 0 )
return super.onKeyDown(keyCode, event);
}
+ /*
else
if( keyCode == KeyEvent.KEYCODE_BACK && downloader != null )
{
@@ -631,6 +632,7 @@ public boolean onKeyDown(int keyCode, final KeyEvent event)
if( !downloader.DownloadComplete )
onStop();
}
+ */
else
if( keyListener != null )
{
View
4 project/java/translations/values-fr/strings.xml
@@ -171,4 +171,8 @@
<string name="cancel">Cancel</string>
<string name="calibrate_gyroscope_not_supported">Your device does not have gyroscope</string>
<string name="reset_config_ask">Reset all options to default values?</string>
+<string name="cancel_download">Cancel data downloading?</string>
+<string name="cancel_download_resume">You can resume it later, the data will not be downloaded twice.</string>
+<string name="yes">Yes</string>
+<string name="no">No</string>
</resources>
View
4 project/java/translations/values-ru/strings.xml
@@ -143,4 +143,8 @@
<string name="cancel">Отменить</string>
<string name="calibrate_gyroscope_not_supported">Гироскоп отсутствует</string>
<string name="reset_config_ask">Сбросить все настройки в значения по умолчанию?</string>
+<string name="cancel_download">Остановить загрузку?</string>
+<string name="cancel_download_resume">Загрузка может быть продолжена позднее.</string>
+<string name="yes">Да</string>
+<string name="no">Нет</string>
</resources>
View
4 project/java/translations/values-uk/strings.xml
@@ -142,4 +142,8 @@
<string name="cancel">Cancel</string>
<string name="calibrate_gyroscope_not_supported">Your device does not have gyroscope</string>
<string name="reset_config_ask">Reset all options to default values?</string>
+<string name="cancel_download">Cancel data downloading?</string>
+<string name="cancel_download_resume">You can resume it later, the data will not be downloaded twice.</string>
+<string name="yes">Yes</string>
+<string name="no">No</string>
</resources>
View
5 project/java/translations/values/strings.xml
@@ -173,4 +173,9 @@
<string name="reset_config">Reset config to defaults</string>
<string name="reset_config_ask">Reset all options to default values?</string>
+ <string name="cancel_download">Cancel data downloading?</string>
+ <string name="cancel_download_resume">You can resume it later, the data will not be downloaded twice.</string>
+ <string name="yes">Yes</string>
+ <string name="no">No</string>
+
</resources>
View
2  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.
Please sign in to comment.
Something went wrong with that request. Please try again.