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.
This commit is contained in:
parent
2868e3c4f1
commit
1ea35f6977
@ -363,14 +363,6 @@
|
||||
android:value=".FDroid" />
|
||||
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".views.swap.SwapWorkflowActivity$SwapAppDetails"
|
||||
android:label="@string/app_details"
|
||||
android:parentActivityName=".views.swap.SwapWorkflowActivity" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".views.swap.SwapWorkflowActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:label="@string/menu_preferences"
|
||||
android:name=".PreferencesActivity"
|
||||
|
@ -277,7 +277,27 @@ public class SwapAppsView extends ListView implements
|
||||
TextView statusInstalled;
|
||||
TextView statusIncompatible;
|
||||
|
||||
private BroadcastReceiver downloadReceiver = new BroadcastReceiver() {
|
||||
private BroadcastReceiver downloadProgressReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Apk apk = getApkToInstall();
|
||||
String broadcastUrl = intent.getStringExtra(Downloader.EXTRA_ADDRESS);
|
||||
if (!TextUtils.equals(Utils.getApkUrl(apk.repoAddress, apk), broadcastUrl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int read = intent.getIntExtra(Downloader.EXTRA_BYTES_READ, 0);
|
||||
int total = intent.getIntExtra(Downloader.EXTRA_TOTAL_BYTES, 0);
|
||||
if (total > 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);
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user