diff --git a/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java b/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java index c8d9920ec..d5bcc0c08 100644 --- a/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java +++ b/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java @@ -237,6 +237,13 @@ public final class LocalRepoManager { } } + /** + * Get the {@code index.jar} file that represents the local swap repo. + */ + public File getIndexJar() { + return xmlIndexJar; + } + public void deleteRepo() { deleteContents(repoDir); } @@ -277,10 +284,6 @@ public final class LocalRepoManager { apps.put(packageName, app); } - public List getApps() { - return new ArrayList<>(apps.keySet()); - } - public void copyIconsToRepo() { ApplicationInfo appInfo; for (final App app : apps.values()) { diff --git a/app/src/main/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java b/app/src/main/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java index 6062d643e..d789ac7d0 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java +++ b/app/src/main/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java @@ -376,7 +376,10 @@ public class SwapWorkflowActivity extends AppCompatActivity { getService().swapWith(null); if (!getService().isEnabled()) { - prepareInitialRepo(); + if (!LocalRepoManager.get(this).getIndexJar().exists()) { + Utils.debugLog(TAG, "Preparing initial repo with only F-Droid, until we have allowed the user to configure their own repo."); + new PrepareInitialSwapRepo().execute(); + } } inflateInnerView(R.layout.swap_blank); @@ -452,16 +455,6 @@ public class SwapWorkflowActivity extends AppCompatActivity { } } - private void prepareInitialRepo() { - // TODO: Make it so that this and updateSwappableAppsTask (the _real_ swap repo task) - // don't stomp on eachothers toes. The other one should wait for this to finish, or cancel - // this, but this should never take precedence over the other. - // TODO: Also don't allow this to run multiple times (e.g. if a user keeps navigating back - // to the main screen. - Utils.debugLog(TAG, "Preparing initial repo with only F-Droid, until we have allowed the user to configure their own repo."); - new PrepareInitialSwapRepo().execute(); - } - /** * Once the UpdateAsyncTask has finished preparing our repository index, we can * show the next screen to the user. This will be one of two things: