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:
parent
8f8aa44f43
commit
109a927a68
@ -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
|
||||
public void enableAndroidBeam() {
|
||||
NfcHelper.setAndroidBeam(this, app.packageName);
|
||||
|
@ -51,6 +51,8 @@ import java.io.IOException;
|
||||
* {@code {@link #stopSelf(int)}}, so {@code Intent}s are sometimes redelivered even
|
||||
* 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}.
|
||||
* {@link #isPendingInstall(String)} and other checks are used to check whether to
|
||||
* process the redelivered {@code Intent} or not.
|
||||
* <p>
|
||||
* 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
|
||||
@ -471,25 +473,12 @@ public class InstallManagerService extends Service {
|
||||
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
|
||||
* the {@code urlString} of the download used as the unique ID,
|
||||
* and the file hash used to verify that things are the same.
|
||||
*
|
||||
* @see #isPendingInstall(String)
|
||||
* @see #isPendingInstall(Context, String)
|
||||
*/
|
||||
public static void putPendingInstall(Context context, String urlString, String packageName) {
|
||||
if (pendingInstalls == null) {
|
||||
|
@ -43,7 +43,6 @@ import org.fdroid.fdroid.data.ApkProvider;
|
||||
import org.fdroid.fdroid.data.App;
|
||||
import org.fdroid.fdroid.data.InstalledAppProvider;
|
||||
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.AppSecurityPermissions;
|
||||
import org.fdroid.fdroid.views.main.MainActivity;
|
||||
@ -58,6 +57,8 @@ public class AppDetailsRecyclerViewAdapter
|
||||
|
||||
public interface AppDetailsRecyclerViewAdapterCallbacks {
|
||||
|
||||
boolean isAppDownloading();
|
||||
|
||||
void enableAndroidBeam();
|
||||
|
||||
void disableAndroidBeam();
|
||||
@ -487,7 +488,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
buttonSecondaryView.setOnClickListener(onUnInstallClickListener);
|
||||
buttonPrimaryView.setText(R.string.menu_install);
|
||||
buttonPrimaryView.setVisibility(versions.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
if (InstallManagerService.isPendingInstall(context, app.packageName)) {
|
||||
if (callbacks.isAppDownloading()) {
|
||||
buttonPrimaryView.setText(R.string.downloading);
|
||||
buttonPrimaryView.setEnabled(false);
|
||||
buttonLayout.setVisibility(View.GONE);
|
||||
|
@ -101,6 +101,10 @@ public class AppDetailsAdapterTest extends FDroidProviderTest {
|
||||
}
|
||||
|
||||
private final AppDetailsRecyclerViewAdapter.AppDetailsRecyclerViewAdapterCallbacks dummyCallbacks = new AppDetailsRecyclerViewAdapter.AppDetailsRecyclerViewAdapterCallbacks() { // NOCHECKSTYLE LineLength
|
||||
@Override
|
||||
public boolean isAppDownloading() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableAndroidBeam() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user