diff --git a/app/src/main/java/org/openobservatory/ooniprobe/activity/MainActivity.java b/app/src/main/java/org/openobservatory/ooniprobe/activity/MainActivity.java index a139150cc..787850719 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/activity/MainActivity.java +++ b/app/src/main/java/org/openobservatory/ooniprobe/activity/MainActivity.java @@ -219,30 +219,37 @@ private void onManualUpdatesFetchComplete(WorkInfo workInfo) { if (workInfo != null) { binding.reviewUpdateNotificationFragment.setVisibility(View.VISIBLE); switch (workInfo.getState()) { - case SUCCEEDED -> getSupportFragmentManager() + case SUCCEEDED -> { + String descriptor = workInfo.getOutputData().getString(ManualUpdateDescriptorsWorker.KEY_UPDATED_DESCRIPTORS); + if (descriptor == null) { + removeProgressFragment(R.id.review_update_notification_fragment); + return; + } + getSupportFragmentManager() .beginTransaction() .add( - R.id.review_update_notification_fragment, - OONIRunDynamicProgressBar.newInstance(ProgressType.REVIEW_LINK, new OnActionListener() { - @Override - public void onActionButtonCLicked() { - - getReviewUpdatesLauncher().launch( - ReviewDescriptorUpdatesActivity.newIntent( - MainActivity.this, - workInfo.getOutputData().getString(ManualUpdateDescriptorsWorker.KEY_UPDATED_DESCRIPTORS) - ) - ); - removeProgressFragment(R.id.review_update_notification_fragment); - } - - @Override - public void onCloseButtonClicked() { - removeProgressFragment(R.id.review_update_notification_fragment); - } - }), - OONIRunDynamicProgressBar.getTAG() + "_review_update_success_notification" + R.id.review_update_notification_fragment, + OONIRunDynamicProgressBar.newInstance(ProgressType.REVIEW_LINK, new OnActionListener() { + @Override + public void onActionButtonCLicked() { + + getReviewUpdatesLauncher().launch( + ReviewDescriptorUpdatesActivity.newIntent( + MainActivity.this, + descriptor + ) + ); + removeProgressFragment(R.id.review_update_notification_fragment); + } + + @Override + public void onCloseButtonClicked() { + removeProgressFragment(R.id.review_update_notification_fragment); + } + }), + OONIRunDynamicProgressBar.getTAG() + "_review_update_success_notification" ).commit(); + } case ENQUEUED -> getSupportFragmentManager() .beginTransaction() diff --git a/app/src/main/java/org/openobservatory/ooniprobe/common/worker/UpdateDescriptorsWorker.kt b/app/src/main/java/org/openobservatory/ooniprobe/common/worker/UpdateDescriptorsWorker.kt index 589f51ea7..4db8f6fd6 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/common/worker/UpdateDescriptorsWorker.kt +++ b/app/src/main/java/org/openobservatory/ooniprobe/common/worker/UpdateDescriptorsWorker.kt @@ -106,6 +106,11 @@ class ManualUpdateDescriptorsWorker( d.testDescriptorManager.getDescriptorWithAutoUpdateDisabled() } + if(descriptors.isEmpty()) { + Log.e(TAG, "No descriptors to update") + return Result.success() + } + for (descriptor in descriptors) { Log.d(TAG, "Fetching updates for ${descriptor.runId}") diff --git a/app/src/main/res/menu/add_descriptor.xml b/app/src/main/res/menu/add_descriptor.xml index 06ff07db9..632cc4035 100644 --- a/app/src/main/res/menu/add_descriptor.xml +++ b/app/src/main/res/menu/add_descriptor.xml @@ -6,5 +6,5 @@ android:id="@+id/add_descriptor" app:showAsAction="ifRoom|withText" tools:title="Add Link" - android:title="Update Descriptor" /> - \ No newline at end of file + android:title="Add Link" /> +