Skip to content

Commit

Permalink
Updated flow to check for updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aanorbel committed Feb 14, 2024
1 parent 5830cf0 commit 7a2f1d8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/menu/add_descriptor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
android:id="@+id/add_descriptor"
app:showAsAction="ifRoom|withText"
tools:title="Add Link"
android:title="Update Descriptor" />
</menu>
android:title="Add Link" />
</menu>

0 comments on commit 7a2f1d8

Please sign in to comment.