show downloading header on Downloading/PendingInstall status

PendingInstall means that the user considers the install still in process,
like when F-Droid gets killed in the background.  There is unfortunately no
reliable way currently to ensure that removePendingInstall() is called when
the app is finally installed so we can't use it here.

This reverts a small part of 1c50e2891054b629e2af6b2d0b1fc89e0b1cf18b

closes fdroid/fdroidclient#1527
fdroid/fdroidclient#1532
This commit is contained in:
Hans-Christoph Steiner 2018-07-30 14:20:21 +02:00
parent 8f8aa44f43
commit 109a927a68
4 changed files with 16 additions and 15 deletions

View File

@ -698,6 +698,13 @@ public class AppDetails2 extends AppCompatActivity
}); });
} }
@Override
public boolean isAppDownloading() {
return currentStatus != null &&
(currentStatus.status == AppUpdateStatusManager.Status.PendingInstall
|| currentStatus.status == AppUpdateStatusManager.Status.Downloading);
}
@Override @Override
public void enableAndroidBeam() { public void enableAndroidBeam() {
NfcHelper.setAndroidBeam(this, app.packageName); NfcHelper.setAndroidBeam(this, app.packageName);

View File

@ -51,6 +51,8 @@ import java.io.IOException;
* {@code {@link #stopSelf(int)}}, so {@code Intent}s are sometimes redelivered even * {@code {@link #stopSelf(int)}}, so {@code Intent}s are sometimes redelivered even
* though they are no longer valid. {@link #onStartCommand(Intent, int, int)} checks * though they are no longer valid. {@link #onStartCommand(Intent, int, int)} checks
* first that the incoming {@code Intent} is not an invalid, redelivered {@code Intent}. * first that the incoming {@code Intent} is not an invalid, redelivered {@code Intent}.
* {@link #isPendingInstall(String)} and other checks are used to check whether to
* process the redelivered {@code Intent} or not.
* <p> * <p>
* The canonical URL for the APK file to download is also used as the unique ID to * The canonical URL for the APK file to download is also used as the unique ID to
* represent the download itself throughout F-Droid. This follows the model * represent the download itself throughout F-Droid. This follows the model
@ -471,25 +473,12 @@ public class InstallManagerService extends Service {
return pendingInstalls.contains(urlString); return pendingInstalls.contains(urlString);
} }
/**
* Look up by {@code packageName} whether it is a Pending Install.
*
* @see #isPendingInstall(String)
*/
public static boolean isPendingInstall(Context context, String packageName) {
if (pendingInstalls == null) {
pendingInstalls = getPendingInstalls(context);
}
return pendingInstalls.getAll().values().contains(packageName);
}
/** /**
* Mark a given APK as in the process of being installed, with * Mark a given APK as in the process of being installed, with
* the {@code urlString} of the download used as the unique ID, * the {@code urlString} of the download used as the unique ID,
* and the file hash used to verify that things are the same. * and the file hash used to verify that things are the same.
* *
* @see #isPendingInstall(String) * @see #isPendingInstall(String)
* @see #isPendingInstall(Context, String)
*/ */
public static void putPendingInstall(Context context, String urlString, String packageName) { public static void putPendingInstall(Context context, String urlString, String packageName) {
if (pendingInstalls == null) { if (pendingInstalls == null) {

View File

@ -43,7 +43,6 @@ import org.fdroid.fdroid.data.ApkProvider;
import org.fdroid.fdroid.data.App; import org.fdroid.fdroid.data.App;
import org.fdroid.fdroid.data.InstalledAppProvider; import org.fdroid.fdroid.data.InstalledAppProvider;
import org.fdroid.fdroid.data.RepoProvider; import org.fdroid.fdroid.data.RepoProvider;
import org.fdroid.fdroid.installer.InstallManagerService;
import org.fdroid.fdroid.privileged.views.AppDiff; import org.fdroid.fdroid.privileged.views.AppDiff;
import org.fdroid.fdroid.privileged.views.AppSecurityPermissions; import org.fdroid.fdroid.privileged.views.AppSecurityPermissions;
import org.fdroid.fdroid.views.main.MainActivity; import org.fdroid.fdroid.views.main.MainActivity;
@ -58,6 +57,8 @@ public class AppDetailsRecyclerViewAdapter
public interface AppDetailsRecyclerViewAdapterCallbacks { public interface AppDetailsRecyclerViewAdapterCallbacks {
boolean isAppDownloading();
void enableAndroidBeam(); void enableAndroidBeam();
void disableAndroidBeam(); void disableAndroidBeam();
@ -487,7 +488,7 @@ public class AppDetailsRecyclerViewAdapter
buttonSecondaryView.setOnClickListener(onUnInstallClickListener); buttonSecondaryView.setOnClickListener(onUnInstallClickListener);
buttonPrimaryView.setText(R.string.menu_install); buttonPrimaryView.setText(R.string.menu_install);
buttonPrimaryView.setVisibility(versions.size() > 0 ? View.VISIBLE : View.GONE); buttonPrimaryView.setVisibility(versions.size() > 0 ? View.VISIBLE : View.GONE);
if (InstallManagerService.isPendingInstall(context, app.packageName)) { if (callbacks.isAppDownloading()) {
buttonPrimaryView.setText(R.string.downloading); buttonPrimaryView.setText(R.string.downloading);
buttonPrimaryView.setEnabled(false); buttonPrimaryView.setEnabled(false);
buttonLayout.setVisibility(View.GONE); buttonLayout.setVisibility(View.GONE);

View File

@ -101,6 +101,10 @@ public class AppDetailsAdapterTest extends FDroidProviderTest {
} }
private final AppDetailsRecyclerViewAdapter.AppDetailsRecyclerViewAdapterCallbacks dummyCallbacks = new AppDetailsRecyclerViewAdapter.AppDetailsRecyclerViewAdapterCallbacks() { // NOCHECKSTYLE LineLength private final AppDetailsRecyclerViewAdapter.AppDetailsRecyclerViewAdapterCallbacks dummyCallbacks = new AppDetailsRecyclerViewAdapter.AppDetailsRecyclerViewAdapterCallbacks() { // NOCHECKSTYLE LineLength
@Override
public boolean isAppDownloading() {
return false;
}
@Override @Override
public void enableAndroidBeam() { public void enableAndroidBeam() {