Skip to content

Commit

Permalink
Hides the download pending message when the download is attached.
Browse files Browse the repository at this point in the history
This is done to prevent screen readers from reading the message after
the download has started.

(cherry picked from commit 90405c8)

Bug: 1324665
Change-Id: I00222acd1af5751e620541dd1efef0798751ca41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3641536
Reviewed-by: Shakti Sahu <shaktisahu@chromium.org>
Commit-Queue: Alex Mitra <alexmitra@chromium.org>
Auto-Submit: Alex Mitra <alexmitra@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1004906}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3655461
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Cr-Commit-Position: refs/branch-heads/5060@{#121}
Cr-Branched-From: b83393d-refs/heads/main@{#1002911}
  • Loading branch information
AlexMitraChromium authored and Chromium LUCI CQ committed May 19, 2022
1 parent c6cba25 commit 344583c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
import static org.chromium.chrome.browser.download.interstitial.DownloadInterstitialProperties.SECONDARY_BUTTON_CALLBACK;
import static org.chromium.chrome.browser.download.interstitial.DownloadInterstitialProperties.SECONDARY_BUTTON_IS_VISIBLE;
import static org.chromium.chrome.browser.download.interstitial.DownloadInterstitialProperties.SECONDARY_BUTTON_TEXT;
import static org.chromium.chrome.browser.download.interstitial.DownloadInterstitialProperties.SHOULD_REMOVE_PENDING_MESSAGE;
import static org.chromium.chrome.browser.download.interstitial.DownloadInterstitialProperties.STATE;
import static org.chromium.chrome.browser.download.interstitial.DownloadInterstitialProperties.TITLE_TEXT;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import androidx.core.util.Pair;

Expand Down Expand Up @@ -251,9 +253,10 @@ public void onItemRemoved(ContentId id) {}
@Override
public void onItemUpdated(OfflineItem item, UpdateDelta updateDelta) {
if (mModel.get(DOWNLOAD_ITEM) == null) {
if (!mDownloadUrl.equals(item.originalUrl)) {
return;
}
if (!TextUtils.equals(mDownloadUrl, item.originalUrl)) return;
// Run before download is first attached.
mModel.set(SHOULD_REMOVE_PENDING_MESSAGE, true);

} else if (!item.id.equals(mModel.get(DOWNLOAD_ITEM).id)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ interface DownloadInterstitialProperties extends ListProperties {
WritableObjectPropertyKey<Callback<OfflineItem>> SECONDARY_BUTTON_CALLBACK =
new WritableObjectPropertyKey<>();

WritableBooleanPropertyKey SHOULD_REMOVE_PENDING_MESSAGE = new WritableBooleanPropertyKey();

PropertyKey[] ALL_KEYS = new PropertyKey[] {ENABLE_ITEM_ANIMATIONS, CALLBACK_OPEN,
CALLBACK_PAUSE, CALLBACK_RESUME, CALLBACK_CANCEL, CALLBACK_SHARE, CALLBACK_REMOVE,
CALLBACK_RENAME, CALLBACK_CHANGE, PROVIDER_VISUALS, PROVIDER_FAVICON,
CALLBACK_SELECTION, SELECTION_MODE_ACTIVE, CALLBACK_PAGINATION_CLICK,
CALLBACK_GROUP_PAGINATION_CLICK, DOWNLOAD_ITEM, STATE, TITLE_TEXT,
PRIMARY_BUTTON_IS_VISIBLE, PRIMARY_BUTTON_TEXT, PRIMARY_BUTTON_CALLBACK,
SECONDARY_BUTTON_IS_VISIBLE, SECONDARY_BUTTON_TEXT, SECONDARY_BUTTON_CALLBACK};
SECONDARY_BUTTON_IS_VISIBLE, SECONDARY_BUTTON_TEXT, SECONDARY_BUTTON_CALLBACK,
SHOULD_REMOVE_PENDING_MESSAGE};
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,9 @@ void setSecondaryButtonText(String text) {
void setSecondaryButtonCallback(Runnable callback) {
mSecondaryButton.setOnClickListener(v -> callback.run());
}

/** Removes the message shown before a download initially begins. */
void removePendingMessage() {
mView.findViewById(R.id.loading_message).setVisibility(View.GONE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public static void bind(PropertyModel model, DownloadInterstitialView view, Prop
view.setSecondaryButtonCallback(
model.get(DownloadInterstitialProperties.SECONDARY_BUTTON_CALLBACK)
.bind(model.get(DownloadInterstitialProperties.DOWNLOAD_ITEM)));
} else if (key.equals(DownloadInterstitialProperties.SHOULD_REMOVE_PENDING_MESSAGE)) {
view.removePendingMessage();
}
}
}

0 comments on commit 344583c

Please sign in to comment.