| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.preferences; | 5 package org.chromium.chrome.browser.preferences; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.graphics.drawable.Drawable; | 8 import android.graphics.drawable.Drawable; |
| 9 import android.os.Build; | 9 import android.os.Build; |
| 10 import android.preference.PreferenceGroup; | 10 import android.preference.PreferenceGroup; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 0, | 53 0, |
| 54 spannable.length() - prefCount.length(), | 54 spannable.length() - prefCount.length(), |
| 55 Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); | 55 Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
| 56 } else { | 56 } else { |
| 57 spannable.setSpan(new TypefaceSpan("sans-serif-medium"), | 57 spannable.setSpan(new TypefaceSpan("sans-serif-medium"), |
| 58 0, | 58 0, |
| 59 spannable.length() - prefCount.length(), | 59 spannable.length() - prefCount.length(), |
| 60 Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); | 60 Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // Color the first part of the title blue. | |
| 64 ForegroundColorSpan blueSpan = new ForegroundColorSpan( | |
| 65 ApiCompatibilityUtils.getColor(getContext().getResources(), | |
| 66 R.color.pref_accent_color)); | |
| 67 spannable.setSpan(blueSpan, 0, spannable.length() - prefCount.length(), | |
| 68 Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); | |
| 69 | |
| 70 // Gray out the total count of items. | |
| 71 int gray = ApiCompatibilityUtils.getColor(getContext().getResources(), | 63 int gray = ApiCompatibilityUtils.getColor(getContext().getResources(), |
| 72 R.color.expandable_group_dark_gray); | 64 R.color.expandable_group_dark_gray); |
| 73 spannable.setSpan(new ForegroundColorSpan(gray), | 65 spannable.setSpan(new ForegroundColorSpan(gray), |
| 74 spannable.length() - prefCount.length(), | 66 spannable.length() - prefCount.length(), |
| 75 spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); | 67 spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
| 76 setTitle(spannable); | 68 setTitle(spannable); |
| 77 } | 69 } |
| 78 | 70 |
| 79 public void setExpanded(boolean expanded) { | 71 public void setExpanded(boolean expanded) { |
| 80 mExpanded = expanded; | 72 mExpanded = expanded; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 92 mImageView = (ImageView) view.findViewById(R.id.expando); | 84 mImageView = (ImageView) view.findViewById(R.id.expando); |
| 93 if (mDrawable != null) mImageView.setImageDrawable(mDrawable); | 85 if (mDrawable != null) mImageView.setImageDrawable(mDrawable); |
| 94 | 86 |
| 95 // For accessibility, read out the whole title and whether the group is
collapsed/expanded. | 87 // For accessibility, read out the whole title and whether the group is
collapsed/expanded. |
| 96 String description = getTitle() + getContext().getResources().getString(
mExpanded | 88 String description = getTitle() + getContext().getResources().getString(
mExpanded |
| 97 ? R.string.accessibility_expanded_group | 89 ? R.string.accessibility_expanded_group |
| 98 : R.string.accessibility_collapsed_group); | 90 : R.string.accessibility_collapsed_group); |
| 99 view.setContentDescription(description); | 91 view.setContentDescription(description); |
| 100 } | 92 } |
| 101 } | 93 } |
| OLD | NEW |