From 1ea35f69774e9ce8b274e96f21d85a6f524783b1 Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Sun, 16 Aug 2015 17:29:52 +1000 Subject: [PATCH] Remove unused AppDetails subclass. Show download progress for swap. The AppDetails subclass used to be used when you couldn't install apps directly from the swap workflow. Now we don't send people to app details, so the activity is unneeded. The swap progress also now listens for progress broadcasts, rather than showing an indeterminant progress bar. --- F-Droid/AndroidManifest.xml | 8 ----- .../fdroid/views/swap/SwapAppsView.java | 32 ++++++++++++++++--- .../views/swap/SwapWorkflowActivity.java | 26 --------------- 3 files changed, 28 insertions(+), 38 deletions(-) diff --git a/F-Droid/AndroidManifest.xml b/F-Droid/AndroidManifest.xml index 9344576ad..25d3aa94e 100644 --- a/F-Droid/AndroidManifest.xml +++ b/F-Droid/AndroidManifest.xml @@ -363,14 +363,6 @@ android:value=".FDroid" /> - - - 0) { + int progress = (int) ((double) read / total * 100); + progressView.setIndeterminate(false); + progressView.setMax(100); + progressView.setProgress(progress); + } + } + }; + + private BroadcastReceiver apkDownloadReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Apk apk = getApkToInstall(); @@ -315,9 +335,12 @@ public class SwapAppsView extends ListView implements }; public ViewHolder() { - // TODO: Unregister receiver correctly... - IntentFilter filter = new IntentFilter(ApkDownloader.ACTION_STATUS); - LocalBroadcastManager.getInstance(getActivity()).registerReceiver(downloadReceiver, filter); + // TODO: Unregister receivers correctly... + IntentFilter apkFilter = new IntentFilter(ApkDownloader.ACTION_STATUS); + LocalBroadcastManager.getInstance(getActivity()).registerReceiver(apkDownloadReceiver, apkFilter); + + IntentFilter progressFilter = new IntentFilter(Downloader.LOCAL_ACTION_PROGRESS); + LocalBroadcastManager.getInstance(getActivity()).registerReceiver(downloadProgressReceiver, progressFilter); } public void setApp(@NonNull App app) { @@ -351,6 +374,7 @@ public class SwapAppsView extends ListView implements private void resetView() { progressView.setVisibility(View.GONE); + progressView.setIndeterminate(true); nameView.setText(app.name); ImageLoader.getInstance().displayImage(app.iconUrl, iconView, displayImageOptions); diff --git a/F-Droid/src/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java b/F-Droid/src/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java index 5c939423e..dd37ea9ac 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java +++ b/F-Droid/src/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java @@ -634,32 +634,6 @@ public class SwapWorkflowActivity extends AppCompatActivity { } } - /** - * Only difference from base class is that it navigates up to a different task. - * It will go to the {@link org.fdroid.fdroid.views.swap.SwapWorkflowActivity} - * whereas the base-class will go back to the main list of apps. Need to juggle - * the repoId in order to be able to return to an appropriately configured swap - * list. - */ - public static class SwapAppDetails extends AppDetails { - - private long repoId; - - @Override - protected void onResume() { - super.onResume(); - repoId = getIntent().getLongExtra(EXTRA_REPO_ID, -1); - } - - @Override - protected void navigateUp() { - Intent parentIntent = NavUtils.getParentActivityIntent(this); - parentIntent.putExtra(EXTRA_REPO_ID, repoId); - NavUtils.navigateUpTo(this, parentIntent); - } - - } - /** * Helper class to try and make sense of what the swap workflow is currently doing. * The more technologies are involved in the process (e.g. Bluetooth/Wifi/NFC/etc)