Merge branch 'issue-995--installing-after-disabling-repo' into 'master'
Ensure apps are not kept in "Updates" when their repo is disabled. Closes #995 See merge request !568
This commit is contained in:
commit
2dbeb60666
@ -16,6 +16,7 @@ import android.support.v4.content.LocalBroadcastManager;
|
|||||||
import org.fdroid.fdroid.data.Apk;
|
import org.fdroid.fdroid.data.Apk;
|
||||||
import org.fdroid.fdroid.data.App;
|
import org.fdroid.fdroid.data.App;
|
||||||
import org.fdroid.fdroid.data.AppProvider;
|
import org.fdroid.fdroid.data.AppProvider;
|
||||||
|
import org.fdroid.fdroid.data.Repo;
|
||||||
import org.fdroid.fdroid.installer.ErrorDialogActivity;
|
import org.fdroid.fdroid.installer.ErrorDialogActivity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -76,6 +77,7 @@ public final class AppUpdateStatusManager {
|
|||||||
public static final String REASON_UPDATES_AVAILABLE = "updatesavailable";
|
public static final String REASON_UPDATES_AVAILABLE = "updatesavailable";
|
||||||
public static final String REASON_CLEAR_ALL_UPDATES = "clearallupdates";
|
public static final String REASON_CLEAR_ALL_UPDATES = "clearallupdates";
|
||||||
public static final String REASON_CLEAR_ALL_INSTALLED = "clearallinstalled";
|
public static final String REASON_CLEAR_ALL_INSTALLED = "clearallinstalled";
|
||||||
|
public static final String REASON_REPO_DISABLED = "repodisabled";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this is present and true, then the broadcast has been sent in response to the {@link AppUpdateStatus#status}
|
* If this is present and true, then the broadcast has been sent in response to the {@link AppUpdateStatus#status}
|
||||||
@ -203,6 +205,22 @@ public final class AppUpdateStatusManager {
|
|||||||
apksPendingInstall = context.getSharedPreferences("apks-pending-install", Context.MODE_PRIVATE);
|
apksPendingInstall = context.getSharedPreferences("apks-pending-install", Context.MODE_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeAllByRepo(Repo repo) {
|
||||||
|
boolean hasRemovedSome = false;
|
||||||
|
Iterator<AppUpdateStatus> it = getAll().iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
AppUpdateStatus status = it.next();
|
||||||
|
if (status.apk.repoId == repo.getId()) {
|
||||||
|
it.remove();
|
||||||
|
hasRemovedSome = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasRemovedSome) {
|
||||||
|
notifyChange(REASON_REPO_DISABLED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public AppUpdateStatus get(String key) {
|
public AppUpdateStatus get(String key) {
|
||||||
synchronized (appMapping) {
|
synchronized (appMapping) {
|
||||||
|
@ -10,6 +10,8 @@ import android.net.Uri;
|
|||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.fdroid.fdroid.AppUpdateStatusManager;
|
||||||
import org.fdroid.fdroid.Utils;
|
import org.fdroid.fdroid.Utils;
|
||||||
import org.fdroid.fdroid.data.Schema.RepoTable;
|
import org.fdroid.fdroid.data.Schema.RepoTable;
|
||||||
import org.fdroid.fdroid.data.Schema.RepoTable.Cols;
|
import org.fdroid.fdroid.data.Schema.RepoTable.Cols;
|
||||||
@ -242,6 +244,8 @@ public class RepoProvider extends FDroidProvider {
|
|||||||
int appCount = resolver.delete(appUri, null, null);
|
int appCount = resolver.delete(appUri, null, null);
|
||||||
Utils.debugLog(TAG, "Removed " + appCount + " apps from repo " + repo.address + ".");
|
Utils.debugLog(TAG, "Removed " + appCount + " apps from repo " + repo.address + ".");
|
||||||
|
|
||||||
|
AppUpdateStatusManager.getInstance(context).removeAllByRepo(repo);
|
||||||
|
|
||||||
AppProvider.Helper.recalculatePreferredMetadata(context);
|
AppProvider.Helper.recalculatePreferredMetadata(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,9 +362,10 @@ public class MainActivity extends AppCompatActivity implements BottomNavigationB
|
|||||||
|
|
||||||
AppUpdateStatusManager manager = AppUpdateStatusManager.getInstance(context);
|
AppUpdateStatusManager manager = AppUpdateStatusManager.getInstance(context);
|
||||||
|
|
||||||
|
String reason = intent.getStringExtra(AppUpdateStatusManager.EXTRA_REASON_FOR_CHANGE);
|
||||||
if (AppUpdateStatusManager.BROADCAST_APPSTATUS_LIST_CHANGED.equals(intent.getAction()) &&
|
if (AppUpdateStatusManager.BROADCAST_APPSTATUS_LIST_CHANGED.equals(intent.getAction()) &&
|
||||||
AppUpdateStatusManager.REASON_READY_TO_INSTALL.equals(
|
(AppUpdateStatusManager.REASON_READY_TO_INSTALL.equals(reason) ||
|
||||||
intent.getStringExtra(AppUpdateStatusManager.EXTRA_REASON_FOR_CHANGE))) {
|
AppUpdateStatusManager.REASON_REPO_DISABLED.equals(reason))) {
|
||||||
updateBadge = true;
|
updateBadge = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user