some bug fixed regarding the downloader
authorXeli
Sun, 15 Jan 2012 21:04:31 +0100
changeset 6566 bc1214f66ee4
parent 6565 e24855695aca
child 6567 54e19cefcdac
some bug fixed regarding the downloader
project_files/Android-build/SDL-android-project/AndroidManifest.xml
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadDialogFragment.java
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadFragment.java
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadService.java
--- a/project_files/Android-build/SDL-android-project/AndroidManifest.xml	Sun Jan 15 21:00:10 2012 +0100
+++ b/project_files/Android-build/SDL-android-project/AndroidManifest.xml	Sun Jan 15 21:04:31 2012 +0100
@@ -30,8 +30,8 @@
         <activity android:name=".Downloader.DownloadListActivity"
                   android:label="@string/app_name"
 				  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
-				  android:screenOrientation='landscape'>
-        </activity>
+				  android:screenOrientation='landscape'
+				  android:launchMode="singleTop"/>
         
         <service android:name=".Downloader.DownloadService"/>
         
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadDialogFragment.java	Sun Jan 15 21:00:10 2012 +0100
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadDialogFragment.java	Sun Jan 15 21:04:31 2012 +0100
@@ -60,7 +60,7 @@
 
 		public void onClick(DialogInterface dialog, int which) {
 			if(which == Dialog.BUTTON_POSITIVE){
-				Intent i = new Intent(getActivity(), DownloadFragment.class);
+				Intent i = new Intent(getActivity(), DownloadListActivity.class);
 				i.putExtra(DownloadFragment.EXTRA_TASK, task);
 				getActivity().startActivity(i);
 			}
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadFragment.java	Sun Jan 15 21:00:10 2012 +0100
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadFragment.java	Sun Jan 15 21:04:31 2012 +0100
@@ -32,7 +32,6 @@
 import android.os.Messenger;
 import android.os.RemoteException;
 import android.support.v4.app.Fragment;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -199,10 +198,14 @@
 				break;
 			case MSG_FAILED:
 				progress.setProgress(progress.getMax());
-				progress_sub.setText(R.string.download_failed);
-				//	positive.setText(R.string.download_back);
-				//	positive.setOnClickListener(doneClicker);
-
+				
+				String errorMsg = getString(R.string.download_failed);
+				switch(msg.arg1){
+				case DownloadAsyncTask.EXIT_CONNERROR: progress_sub.setText(errorMsg + " " + "Connection error"); break;
+				case DownloadAsyncTask.EXIT_FNF: progress_sub.setText(errorMsg + " " + "File not found"); break;
+				case DownloadAsyncTask.EXIT_MD5: progress_sub.setText(errorMsg + " " + "MD5 check failed"); break;
+				case DownloadAsyncTask.EXIT_URLFAIL: progress_sub.setText(errorMsg + " " + "Invalid url"); break;
+				}
 				negative.setText(R.string.download_tryagain);
 				negative.setOnClickListener(tryAgainClicker);
 				break;
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadService.java	Sun Jan 15 21:00:10 2012 +0100
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadService.java	Sun Jan 15 21:04:31 2012 +0100
@@ -175,7 +175,7 @@
 			contentView.setProgressBar(R.id.notification_progress, 100, 34, false);
 			progressNotification.contentView = contentView;
 
-			PendingIntent contentIntent = PendingIntent.getActivity(DownloadService.this, 0, new Intent(DownloadService.this, DownloadFragment.class), Intent.FLAG_ACTIVITY_NEW_TASK);
+			PendingIntent contentIntent = PendingIntent.getActivity(DownloadService.this, 0, new Intent(DownloadService.this, DownloadListActivity.class), Intent.FLAG_ACTIVITY_NEW_TASK);
 			progressNotification.contentIntent = contentIntent;
 
 			startForeground(NOTIFICATION_PROCESSING, progressNotification);
@@ -199,10 +199,10 @@
 		public void done(int result){
 			switch(result){
 			case DownloadAsyncTask.EXIT_SUCCESS: 	sendMessageToClients(Message.obtain(handler, DownloadFragment.MSG_DONE)); break;
-			case DownloadAsyncTask.EXIT_CONNERROR:  sendMessageToClients(Message.obtain(handler, DownloadFragment.MSG_FAILED)); break;
-			case DownloadAsyncTask.EXIT_FNF:		sendMessageToClients(Message.obtain(handler, DownloadFragment.MSG_FAILED)); break;
-			case DownloadAsyncTask.EXIT_MD5:		sendMessageToClients(Message.obtain(handler, DownloadFragment.MSG_FAILED)); break;
-			case DownloadAsyncTask.EXIT_URLFAIL:	sendMessageToClients(Message.obtain(handler, DownloadFragment.MSG_FAILED)); break;
+			case DownloadAsyncTask.EXIT_CONNERROR:  sendMessageToClients(Message.obtain(handler, DownloadFragment.MSG_FAILED, DownloadAsyncTask.EXIT_CONNERROR, 0)); break;
+			case DownloadAsyncTask.EXIT_FNF:		sendMessageToClients(Message.obtain(handler, DownloadFragment.MSG_FAILED, DownloadAsyncTask.EXIT_FNF, 0)); break;
+			case DownloadAsyncTask.EXIT_MD5:		sendMessageToClients(Message.obtain(handler, DownloadFragment.MSG_FAILED, DownloadAsyncTask.EXIT_MD5, 0)); break;
+			case DownloadAsyncTask.EXIT_URLFAIL:	sendMessageToClients(Message.obtain(handler, DownloadFragment.MSG_FAILED, DownloadAsyncTask.EXIT_URLFAIL, 0)); break;
 			case DownloadAsyncTask.EXIT_CANCELLED:	sendMessageToClients(Message.obtain(handler, DownloadFragment.MSG_DONE)); break;
 			}