Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
353628a7
Commit
353628a7
authored
9 months ago
by
YK Hung
Committed by
Android (Google) Code Review
9 months ago
Browse files
Options
Downloads
Plain Diff
Merge "Allow the bottom summary to have its own content description" into main
parents
5b6a560c
a6477319
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/SettingsLib/UsageProgressBarPreference/src/com/android/settingslib/widget/UsageProgressBarPreference.java
+32
-18
32 additions, 18 deletions
...ndroid/settingslib/widget/UsageProgressBarPreference.java
with
32 additions
and
18 deletions
packages/SettingsLib/UsageProgressBarPreference/src/com/android/settingslib/widget/UsageProgressBarPreference.java
+
32
−
18
View file @
353628a7
...
...
@@ -38,8 +38,9 @@ import java.util.regex.Matcher;
import
java.util.regex.Pattern
;
/**
* Progres bar preference with a usage summary and a total summary.
* This preference shows number in usage summary with enlarged font size.
* Progress bar preference with a usage summary and a total summary.
*
* <p>This preference shows number in usage summary with enlarged font size.
*/
public
class
UsageProgressBarPreference
extends
Preference
{
...
...
@@ -48,18 +49,18 @@ public class UsageProgressBarPreference extends Preference {
private
CharSequence
mUsageSummary
;
private
CharSequence
mTotalSummary
;
private
CharSequence
mBottomSummary
;
private
CharSequence
mBottomSummaryContentDescription
;
private
ImageView
mCustomImageView
;
private
int
mPercent
=
-
1
;
/**
* Perform inflation from XML and apply a class-specific base style.
*
* @param context
The {@link Context} this is associated with, through which it can
*
access the
current theme, resources, {@link SharedPreferences}, etc.
* @param attrs
The attributes of the XML tag that is inflating the preference
* @param context The {@link Context} this is associated with, through which it can
access the
* current theme, resources, {@link SharedPreferences}, etc.
* @param attrs The attributes of the XML tag that is inflating the preference
* @param defStyle An attribute in the current theme that contains a reference to a style
* resource that supplies default values for the view. Can be 0 to not
* look for defaults.
* resource that supplies default values for the view. Can be 0 to not look for defaults.
*/
public
UsageProgressBarPreference
(
Context
context
,
AttributeSet
attrs
,
int
defStyle
)
{
super
(
context
,
attrs
,
defStyle
);
...
...
@@ -69,9 +70,9 @@ public class UsageProgressBarPreference extends Preference {
/**
* Perform inflation from XML and apply a class-specific base style.
*
* @param context The {@link Context} this is associated with, through which it can
*
access the
current theme, resources, {@link SharedPreferences}, etc.
* @param attrs
The attributes of the XML tag that is inflating the preference
* @param context The {@link Context} this is associated with, through which it can
access the
* current theme, resources, {@link SharedPreferences}, etc.
* @param attrs The attributes of the XML tag that is inflating the preference
*/
public
UsageProgressBarPreference
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
...
...
@@ -114,9 +115,17 @@ public class UsageProgressBarPreference extends Preference {
notifyChanged
();
}
/** Set content description for the bottom summary. */
public
void
setBottomSummaryContentDescription
(
CharSequence
contentDescription
)
{
if
(!
TextUtils
.
equals
(
mBottomSummaryContentDescription
,
contentDescription
))
{
mBottomSummaryContentDescription
=
contentDescription
;
notifyChanged
();
}
}
/** Set percentage of the progress bar. */
public
void
setPercent
(
long
usage
,
long
total
)
{
if
(
usage
>
total
)
{
if
(
usage
>
total
)
{
return
;
}
if
(
total
==
0L
)
{
...
...
@@ -146,14 +155,13 @@ public class UsageProgressBarPreference extends Preference {
/**
* Binds the created View to the data for this preference.
*
* <p>This is a good place to grab references to custom Views in the layout and set
*
properties
on them.
* <p>This is a good place to grab references to custom Views in the layout and set
properties
* on them.
*
* <p>Make sure to call through to the superclass's implementation.
*
* @param holder The ViewHolder that provides references to the views to fill in. These views
* will be recycled, so you should not hold a reference to them after this method
* returns.
* will be recycled, so you should not hold a reference to them after this method returns.
*/
@Override
public
void
onBindViewHolder
(
PreferenceViewHolder
holder
)
{
...
...
@@ -177,6 +185,9 @@ public class UsageProgressBarPreference extends Preference {
bottomSummary
.
setVisibility
(
View
.
VISIBLE
);
bottomSummary
.
setMovementMethod
(
LinkMovementMethod
.
getInstance
());
bottomSummary
.
setText
(
mBottomSummary
);
if
(!
TextUtils
.
isEmpty
(
mBottomSummaryContentDescription
))
{
bottomSummary
.
setContentDescription
(
mBottomSummaryContentDescription
);
}
}
final
ProgressBar
progressBar
=
(
ProgressBar
)
holder
.
findViewById
(
android
.
R
.
id
.
progress
);
...
...
@@ -205,9 +216,12 @@ public class UsageProgressBarPreference extends Preference {
final
Matcher
matcher
=
mNumberPattern
.
matcher
(
summary
);
if
(
matcher
.
find
())
{
final
SpannableString
spannableSummary
=
new
SpannableString
(
summary
);
spannableSummary
.
setSpan
(
new
AbsoluteSizeSpan
(
64
,
true
/* dip */
),
matcher
.
start
(),
matcher
.
end
(),
Spanned
.
SPAN_EXCLUSIVE_EXCLUSIVE
);
final
SpannableString
spannableSummary
=
new
SpannableString
(
summary
);
spannableSummary
.
setSpan
(
new
AbsoluteSizeSpan
(
64
,
true
/* dip */
),
matcher
.
start
(),
matcher
.
end
(),
Spanned
.
SPAN_EXCLUSIVE_EXCLUSIVE
);
return
spannableSummary
;
}
return
summary
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment