Dialog to abort data downloading
This commit is contained in:
@@ -57,6 +57,8 @@ import android.content.Context;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import java.lang.String;
|
import java.lang.String;
|
||||||
import android.text.SpannedString;
|
import android.text.SpannedString;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
|
||||||
|
|
||||||
class CountingInputStream extends BufferedInputStream
|
class CountingInputStream extends BufferedInputStream
|
||||||
@@ -188,6 +190,7 @@ class DataDownloader extends Thread
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
Parent.keyListener = new BackKeyListener(Parent);
|
||||||
String [] downloadFiles = Globals.DataDownloadUrl;
|
String [] downloadFiles = Globals.DataDownloadUrl;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -213,11 +216,13 @@ class DataDownloader extends Thread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
DownloadComplete = true;
|
DownloadComplete = true;
|
||||||
|
Parent.keyListener = null;
|
||||||
initParent();
|
initParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean DownloadDataFile(final String DataDownloadUrl, final String DownloadFlagFileName, int downloadCount, int downloadTotal, int downloadIndex)
|
public boolean DownloadDataFile(final String DataDownloadUrl, final String DownloadFlagFileName, int downloadCount, int downloadTotal, int downloadIndex)
|
||||||
{
|
{
|
||||||
|
DownloadCanBeResumed = false;
|
||||||
Resources res = Parent.getResources();
|
Resources res = Parent.getResources();
|
||||||
|
|
||||||
String [] downloadUrls = DataDownloadUrl.split("[|]");
|
String [] downloadUrls = DataDownloadUrl.split("[|]");
|
||||||
@@ -298,6 +303,7 @@ class DataDownloader extends Thread
|
|||||||
path = getOutFilePath(url.substring( 1, url.indexOf(":", 1) ));
|
path = getOutFilePath(url.substring( 1, url.indexOf(":", 1) ));
|
||||||
url = url.substring( url.indexOf(":", 1) + 1 );
|
url = url.substring( url.indexOf(":", 1) + 1 );
|
||||||
DoNotUnzip = true;
|
DoNotUnzip = true;
|
||||||
|
DownloadCanBeResumed = true;
|
||||||
File partialDownload = new File( path );
|
File partialDownload = new File( path );
|
||||||
if( partialDownload.exists() && !partialDownload.isDirectory() && !forceOverwrite )
|
if( partialDownload.exists() && !partialDownload.isDirectory() && !forceOverwrite )
|
||||||
partialDownloadLen = partialDownload.length();
|
partialDownloadLen = partialDownload.length();
|
||||||
@@ -674,10 +680,56 @@ class DataDownloader extends Thread
|
|||||||
return http;
|
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 StatusWriter Status;
|
||||||
public boolean DownloadComplete = false;
|
public boolean DownloadComplete = false;
|
||||||
public boolean DownloadFailed = false;
|
public boolean DownloadFailed = false;
|
||||||
|
public boolean DownloadCanBeResumed = false;
|
||||||
private MainActivity Parent;
|
private MainActivity Parent;
|
||||||
private String outFilesDir = null;
|
private String outFilesDir = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -623,6 +623,7 @@ public class MainActivity extends Activity
|
|||||||
if( mGLView.nativeKey( keyCode, 1 ) == 0 )
|
if( mGLView.nativeKey( keyCode, 1 ) == 0 )
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
else
|
else
|
||||||
if( keyCode == KeyEvent.KEYCODE_BACK && downloader != null )
|
if( keyCode == KeyEvent.KEYCODE_BACK && downloader != null )
|
||||||
{
|
{
|
||||||
@@ -631,6 +632,7 @@ public class MainActivity extends Activity
|
|||||||
if( !downloader.DownloadComplete )
|
if( !downloader.DownloadComplete )
|
||||||
onStop();
|
onStop();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
else
|
else
|
||||||
if( keyListener != null )
|
if( keyListener != null )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -171,4 +171,8 @@
|
|||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
<string name="calibrate_gyroscope_not_supported">Your device does not have gyroscope</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="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>
|
</resources>
|
||||||
|
|||||||
@@ -143,4 +143,8 @@
|
|||||||
<string name="cancel">Отменить</string>
|
<string name="cancel">Отменить</string>
|
||||||
<string name="calibrate_gyroscope_not_supported">Гироскоп отсутствует</string>
|
<string name="calibrate_gyroscope_not_supported">Гироскоп отсутствует</string>
|
||||||
<string name="reset_config_ask">Сбросить все настройки в значения по умолчанию?</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>
|
</resources>
|
||||||
|
|||||||
@@ -142,4 +142,8 @@
|
|||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
<string name="calibrate_gyroscope_not_supported">Your device does not have gyroscope</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="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>
|
</resources>
|
||||||
|
|||||||
@@ -173,4 +173,9 @@
|
|||||||
<string name="reset_config">Reset config to defaults</string>
|
<string name="reset_config">Reset config to defaults</string>
|
||||||
<string name="reset_config_ask">Reset all options to default values?</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>
|
</resources>
|
||||||
|
|||||||
2
todo.txt
2
todo.txt
@@ -5,8 +5,6 @@ Requested features (see also bugs.txt)
|
|||||||
|
|
||||||
- Redesign on-screen keyboard layout dialog.
|
- Redesign on-screen keyboard layout dialog.
|
||||||
|
|
||||||
- Option to reset SDL config to default.
|
|
||||||
|
|
||||||
- Option for default on-screen key theme in AndroidAppSettings.cfg.
|
- 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.
|
- Select between normal mouse input and magnifying glass/relative input automatically, based on screen size.
|
||||||
|
|||||||
Reference in New Issue
Block a user