remove EVENT_DATA_ERROR_TYPE for DownloaderService reorg
As part of the process of moving the APK downloading to an IntentService, I'm removing and incrementally reorganizing the existing events so that the code continues to be functional as it is reorganized. We might want to include more detail in a download error to expose to the user, but I think instead what will be more fruitful is to hide details on errors where there is nothing the user can do except retry. Then if there are errors where the user can do something about it, then F-Droid should instead offer them the option of doing that, and not just show an error message and walk away.
This commit is contained in:
parent
d38058497e
commit
91edad0c31
@ -985,14 +985,8 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
boolean finished = false;
|
||||
switch (event.type) {
|
||||
case ApkDownloader.EVENT_ERROR:
|
||||
final int res;
|
||||
if (event.getData().getInt(ApkDownloader.EVENT_DATA_ERROR_TYPE) == ApkDownloader.ERROR_HASH_MISMATCH) {
|
||||
res = R.string.corrupt_download;
|
||||
} else {
|
||||
res = R.string.details_notinstalled;
|
||||
}
|
||||
// this must be on the main UI thread
|
||||
Toast.makeText(this, res, Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(this, R.string.details_notinstalled, Toast.LENGTH_LONG).show();
|
||||
cleanUpFinishedDownload();
|
||||
finished = true;
|
||||
break;
|
||||
|
@ -29,10 +29,6 @@ public interface ProgressListener {
|
||||
this(type, NO_VALUE, NO_VALUE, null);
|
||||
}
|
||||
|
||||
public Event(String type, Bundle data) {
|
||||
this(type, NO_VALUE, NO_VALUE, data);
|
||||
}
|
||||
|
||||
public Event(String type, int progress, int total, Bundle data) {
|
||||
this.type = type;
|
||||
this.progress = progress;
|
||||
|
@ -27,10 +27,12 @@ import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.fdroid.fdroid.Hasher;
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.ProgressListener;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
import org.fdroid.fdroid.compat.FileCompat;
|
||||
import org.fdroid.fdroid.data.Apk;
|
||||
@ -56,16 +58,9 @@ public class ApkDownloader implements AsyncDownloader.Listener {
|
||||
|
||||
public static final String ACTION_STATUS = "apkDownloadStatus";
|
||||
|
||||
public static final int ERROR_HASH_MISMATCH = 101;
|
||||
|
||||
private static final String EVENT_SOURCE_ID = "sourceId";
|
||||
private static long downloadIdCounter;
|
||||
|
||||
/**
|
||||
* Used as a key to pass data through with an error event, explaining the type of event.
|
||||
*/
|
||||
public static final String EVENT_DATA_ERROR_TYPE = "apkDownloadErrorType";
|
||||
|
||||
@NonNull private final App app;
|
||||
@NonNull private final Apk curApk;
|
||||
@NonNull private final Context context;
|
||||
@ -208,12 +203,6 @@ public class ApkDownloader implements AsyncDownloader.Listener {
|
||||
sendProgressEvent(new ProgressListener.Event(type));
|
||||
}
|
||||
|
||||
private void sendError(int errorType) {
|
||||
Bundle data = new Bundle(1);
|
||||
data.putInt(EVENT_DATA_ERROR_TYPE, errorType);
|
||||
sendProgressEvent(new Event(EVENT_ERROR, data));
|
||||
}
|
||||
|
||||
// TODO: Completely remove progress listener, only use broadcasts...
|
||||
private void sendProgressEvent(Event event) {
|
||||
|
||||
@ -246,7 +235,8 @@ public class ApkDownloader implements AsyncDownloader.Listener {
|
||||
public void onDownloadComplete() {
|
||||
|
||||
if (!verifyOrDelete(localFile)) {
|
||||
sendError(ERROR_HASH_MISMATCH);
|
||||
sendProgressEvent(new Event(EVENT_ERROR));
|
||||
Toast.makeText(context, R.string.corrupt_download, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user