move ApkDownloader.EXTRA_URL to Intent.setDataString()

This is part of the move to standardizing all internal broadcasts to use
the Intent's Uri field as the standard place for a download URL, and then
using that in IntentFilters to do matching.
This commit is contained in:
Hans-Christoph Steiner 2016-03-29 11:52:17 +02:00
parent 0473ac72da
commit d38058497e
2 changed files with 3 additions and 3 deletions

View File

@ -22,6 +22,7 @@ package org.fdroid.fdroid.net;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
@ -54,7 +55,6 @@ public class ApkDownloader implements AsyncDownloader.Listener {
public static final String EVENT_ERROR = "apkDownloadError"; public static final String EVENT_ERROR = "apkDownloadError";
public static final String ACTION_STATUS = "apkDownloadStatus"; public static final String ACTION_STATUS = "apkDownloadStatus";
public static final String EXTRA_URL = "apkDownloadUrl";
public static final int ERROR_HASH_MISMATCH = 101; public static final int ERROR_HASH_MISMATCH = 101;
@ -224,8 +224,8 @@ public class ApkDownloader implements AsyncDownloader.Listener {
} }
Intent intent = new Intent(ACTION_STATUS); Intent intent = new Intent(ACTION_STATUS);
intent.setData(Uri.parse(Utils.getApkUrl(repoAddress, curApk)));
intent.putExtras(event.getData()); intent.putExtras(event.getData());
intent.putExtra(EXTRA_URL, Utils.getApkUrl(repoAddress, curApk));
LocalBroadcastManager.getInstance(context).sendBroadcast(intent); LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
} }

View File

@ -278,7 +278,7 @@ public class SwapAppsView extends ListView implements
// once for each ViewHolder in order to get the repository address for the // once for each ViewHolder in order to get the repository address for the
// apkToInstall. This way, we can wait until we receive an incoming intent (if // apkToInstall. This way, we can wait until we receive an incoming intent (if
// at all) and then lazily load the apk to install. // at all) and then lazily load the apk to install.
String broadcastUrl = intent.getStringExtra(ApkDownloader.EXTRA_URL); String broadcastUrl = intent.getDataString();
if (TextUtils.equals(Utils.getApkUrl(apk.repoAddress, apk), broadcastUrl)) { if (TextUtils.equals(Utils.getApkUrl(apk.repoAddress, apk), broadcastUrl)) {
resetView(); resetView();
} }