Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3789)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java

Issue 2258553003: [Downloads] Handle externally deleted items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dfalcantara@ review Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java
index 2caa75be46f9ae3b357145feaee2d5232f48188f..fb264595acc6ec8342179279664371f2f9b3d9ab 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java
@@ -6,6 +6,8 @@ package org.chromium.chrome.browser.download.ui;
import android.content.ComponentName;
import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Paint;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.text.TextUtils;
@@ -16,6 +18,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
+import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.DownloadItem;
@@ -69,6 +72,7 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo
private int mFilter = DownloadFilter.FILTER_ALL;
private DownloadManagerUi mManager;
private OfflinePageDownloadBridge mOfflinePageBridge;
+ private int mFilenameViewTextColor;
DownloadHistoryAdapter(boolean showOffTheRecord, ComponentName parentComponent) {
mShowOffTheRecord = showOffTheRecord;
@@ -143,6 +147,7 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo
final DownloadHistoryItemWrapper item = (DownloadHistoryItemWrapper) timedItem;
ItemViewHolder holder = (ItemViewHolder) current;
+ DownloadHistoryItemWrapper previousItem = holder.mItemView.mItem;
Context context = holder.mFilesizeView.getContext();
holder.mFilenameView.setText(item.getDisplayFileName());
holder.mHostnameView.setText(
@@ -174,6 +179,12 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo
}
holder.mIconView.setImageResource(iconResource);
+
+ // Externally removed items have a different style. Update the item's style if necessary.
+ if (previousItem == null
+ || previousItem.hasBeenExternallyRemoved() != item.hasBeenExternallyRemoved()) {
+ setItemViewStyle(holder, item);
+ }
}
/**
@@ -326,4 +337,34 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo
ContextUtils.getApplicationContext());
}
+ private void setItemViewStyle(ItemViewHolder holder, DownloadHistoryItemWrapper item) {
+ if (mFilenameViewTextColor == 0) {
+ // The color is not explicitly set in the XML. Programmatically retrieve the original
+ // color so that the color can be reset if it's changed due to the contained item
+ // being externally removed.
+ mFilenameViewTextColor = holder.mFilenameView.getTextColors().getDefaultColor();
+ }
+
+ Context context = holder.itemView.getContext();
+ Resources res = context.getResources();
+ if (item.hasBeenExternallyRemoved()) {
+ int disabledColor = ApiCompatibilityUtils.getColor(res, R.color.google_grey_300);
+
+ holder.mHostnameView.setTextColor(disabledColor);
+ holder.mIconView.setBackgroundColor(disabledColor);
+ holder.mFilenameView.setTextColor(disabledColor);
+ holder.mFilenameView.setPaintFlags(holder.mFilenameView.getPaintFlags()
+ | Paint.STRIKE_THRU_TEXT_FLAG);
+ holder.mFilesizeView.setText(context.getString(R.string.download_manager_ui_deleted));
+ } else {
+ holder.mHostnameView.setTextColor(mFilenameViewTextColor);
+ holder.mIconView.setBackgroundColor(ApiCompatibilityUtils.getColor(res,
+ R.color.light_active_color));
+ holder.mFilenameView.setTextColor(ApiCompatibilityUtils.getColor(res,
+ R.color.default_text_color));
+ holder.mFilenameView.setPaintFlags(holder.mFilenameView.getPaintFlags()
+ & ~Paint.STRIKE_THRU_TEXT_FLAG);
+ }
+ }
+
}

Powered by Google App Engine
This is Rietveld 408576698