Skip to content

Commit

Permalink
Add icons to redesigned CBD dialog.
Browse files Browse the repository at this point in the history
Dialog with icons:
https://screenshot.googleplex.com/GQ0LeamyMkN.png

Dialog for phones with low DP (< 360dp):
https://screenshot.googleplex.com/CwuaYHVgdiF.png
(truncated spinner text still needs to be fixed)

BUG=681523

Review-Url: https://codereview.chromium.org/2652983002
Cr-Commit-Position: refs/heads/master@{#455241}
  • Loading branch information
xchrdw authored and Commit bot committed Mar 7, 2017
1 parent d8f77d0 commit 50c18ca
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 10 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
Expand All @@ -33,6 +34,7 @@
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
import org.chromium.chrome.browser.tabmodel.document.TabDelegate;
import org.chromium.chrome.browser.widget.TintedDrawable;
import org.chromium.components.signin.ChromeSigninController;

import java.util.Arrays;
Expand All @@ -53,6 +55,7 @@ public class ClearBrowsingDataPreferences extends PreferenceFragment
*/
private static class Item implements BrowsingDataCounterCallback,
Preference.OnPreferenceClickListener {
private static final int MIN_DP_FOR_ICON = 360;
private final ClearBrowsingDataPreferences mParent;
private final DialogOption mOption;
private final ClearBrowsingDataCheckBoxPreference mCheckbox;
Expand All @@ -75,7 +78,18 @@ public Item(ClearBrowsingDataPreferences parent,
mCheckbox.setEnabled(enabled);
mCheckbox.setChecked(selected);

if (!ClearBrowsingDataTabsFragment.isFeatureEnabled()) {
if (ClearBrowsingDataTabsFragment.isFeatureEnabled()) {
int dp = mParent.getResources().getConfiguration().smallestScreenWidthDp;
if (dp >= MIN_DP_FOR_ICON) {
if (option.iconNeedsTinting()) {
Drawable icon = TintedDrawable.constructTintedDrawable(
mParent.getResources(), option.getIcon(), R.color.google_grey_600);
mCheckbox.setIcon(icon);
} else {
mCheckbox.setIcon(option.getIcon());
}
}
} else {
// No summary when unchecked. The redesigned basic and advanced
// CBD views will always show the checkbox summary.
mCheckbox.setSummaryOff("");
Expand Down Expand Up @@ -165,30 +179,56 @@ public void setShouldAnnounceCounterResult(boolean value) {
* The various data types that can be cleared via this screen.
*/
public enum DialogOption {
CLEAR_HISTORY(BrowsingDataType.HISTORY, PREF_HISTORY),
CLEAR_COOKIES_AND_SITE_DATA(BrowsingDataType.COOKIES, PREF_COOKIES),
CLEAR_CACHE(BrowsingDataType.CACHE, PREF_CACHE),
CLEAR_PASSWORDS(BrowsingDataType.PASSWORDS, PREF_PASSWORDS),
CLEAR_FORM_DATA(BrowsingDataType.FORM_DATA, PREF_FORM_DATA);
CLEAR_HISTORY(
BrowsingDataType.HISTORY, PREF_HISTORY, R.drawable.ic_history_grey600_24dp, false),
CLEAR_COOKIES_AND_SITE_DATA(
BrowsingDataType.COOKIES, PREF_COOKIES, R.drawable.permission_cookie, true),
CLEAR_CACHE(
BrowsingDataType.CACHE, PREF_CACHE, R.drawable.ic_collections_grey600_24dp, false),
CLEAR_PASSWORDS(BrowsingDataType.PASSWORDS, PREF_PASSWORDS,
R.drawable.ic_vpn_key_grey600_24dp, false),
CLEAR_FORM_DATA(
BrowsingDataType.FORM_DATA, PREF_FORM_DATA, R.drawable.bookmark_edit_normal, true);

private final int mDataType;
private final String mPreferenceKey;
private final int mIcon;
private final boolean mNeedsTinting;

private DialogOption(int dataType, String preferenceKey) {
private DialogOption(int dataType, String preferenceKey, int icon, boolean needsTinting) {
mDataType = dataType;
mPreferenceKey = preferenceKey;
mIcon = icon;
mNeedsTinting = needsTinting;
}

/**
* @return The {@link BrowsingDataType} this option represents.
*/
public int getDataType() {
return mDataType;
}

/**
* @return String The key of the corresponding preference.
* @return The key of the corresponding preference.
*/
public String getPreferenceKey() {
return mPreferenceKey;
}

/**
* @return The resource id for the icon that is used to display this option.
*/
public int getIcon() {
return mIcon;
}

/**
* @return Whether the icon has a different color than google_grey_600.
*/
public boolean iconNeedsTinting() {
return mNeedsTinting;
}
}

/**
Expand Down
9 changes: 7 additions & 2 deletions tools/resources/optimize-png-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ Options:
-r<revision> If this is specified, the script processes only png files
changed since this revision. The <dir> options will be used
to narrow down the files under specific directories.
-c<commit> Same as -r but referencing a git commit. Only files changed
between this commit and HEAD will be processed.
-v Shows optimization process for each file.
-h Print this help text."
exit 1
Expand Down Expand Up @@ -446,9 +448,12 @@ fi

OPTIMIZE_LEVEL=1
# Parse options
while getopts o:r:h:v opts
while getopts o:c:r:h:v opts
do
case $opts in
c)
COMMIT=$OPTARG
;;
r)
COMMIT=$(git svn find-rev r$OPTARG | tail -1) || exit
if [ -z "$COMMIT" ] ; then
Expand Down Expand Up @@ -541,7 +546,7 @@ if [ $PROCESSED_FILE != 0 ]; then
let diff=$TOTAL_OLD_BYTES-$TOTAL_NEW_BYTES
let percent=$diff*100/$TOTAL_OLD_BYTES
echo "Result: $TOTAL_OLD_BYTES => $TOTAL_NEW_BYTES bytes" \
"($diff bytes: $percent%)"
"($diff bytes: $percent\%)"
fi
if [ $CORRUPTED_FILE != 0 ]; then
echo "Warning: corrupted files found: $CORRUPTED_FILE"
Expand Down

0 comments on commit 50c18ca

Please sign in to comment.