Skip to content

Commit cd0d94e

Browse files
pekingmehunterstich
authored andcommitted
[ProgressIndicator] Added a demo for using multiple indicator colors in Catalog.
PiperOrigin-RevId: 592009245
1 parent 5d62e9e commit cd0d94e

File tree

4 files changed

+128
-0
lines changed

4 files changed

+128
-0
lines changed

catalog/java/io/material/catalog/progressindicator/ProgressIndicatorFragment.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ public Fragment createFragment() {
7272
@NonNull
7373
public List<Demo> getAdditionalDemos() {
7474
List<Demo> additionalDemos = getSharedAdditionalDemos();
75+
additionalDemos.add(
76+
new Demo(R.string.cat_progress_indicator_multi_color_demo_title) {
77+
@Nullable
78+
@Override
79+
public Fragment createFragment() {
80+
return new ProgressIndicatorMultiColorDemoFragment();
81+
}
82+
});
7583
additionalDemos.add(
7684
new Demo(R.string.cat_progress_indicator_demo_indeterminate_title) {
7785
@Override
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2023 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.material.catalog.progressindicator;
17+
18+
import io.material.catalog.R;
19+
20+
import android.os.Bundle;
21+
import android.view.LayoutInflater;
22+
import android.view.View;
23+
import android.view.ViewGroup;
24+
import androidx.annotation.NonNull;
25+
import androidx.annotation.Nullable;
26+
import com.google.android.material.progressindicator.CircularProgressIndicator;
27+
import com.google.android.material.progressindicator.LinearProgressIndicator;
28+
import io.material.catalog.feature.DemoFragment;
29+
30+
/**
31+
* This is the fragment to demo using multiple indicator colors in {@link LinearProgressIndicator}
32+
* and {@link CircularProgressIndicator}.
33+
*/
34+
public class ProgressIndicatorMultiColorDemoFragment extends DemoFragment {
35+
36+
@Override
37+
@NonNull
38+
public View onCreateDemoView(
39+
@NonNull LayoutInflater layoutInflater,
40+
@Nullable ViewGroup viewGroup,
41+
@Nullable Bundle bundle) {
42+
43+
return layoutInflater.inflate(
44+
R.layout.cat_progress_indicator_multi_color_fragment, viewGroup, false /* attachToRoot */);
45+
}
46+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2023 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
18+
xmlns:app="http://schemas.android.com/apk/res-auto"
19+
android:layout_width="match_parent"
20+
android:layout_height="match_parent"
21+
android:clipChildren="false"
22+
android:clipToPadding="false"
23+
android:orientation="vertical"
24+
android:padding="16dp"
25+
android:showDividers="middle"
26+
android:divider="@drawable/layout_divider">
27+
<TextView
28+
android:layout_width="wrap_content"
29+
android:layout_height="wrap_content"
30+
android:text="@string/cat_progress_indicator_linear_multicolor_disjoint"/>
31+
<com.google.android.material.progressindicator.LinearProgressIndicator
32+
android:layout_width="match_parent"
33+
android:layout_height="wrap_content"
34+
android:indeterminate="true"
35+
app:indicatorColor="@array/cat_custom_progress_colors"/>
36+
37+
<TextView
38+
android:layout_width="wrap_content"
39+
android:layout_height="wrap_content"
40+
android:text="@string/cat_progress_indicator_linear_multicolor_contiguous"/>
41+
<com.google.android.material.progressindicator.LinearProgressIndicator
42+
android:layout_width="match_parent"
43+
android:layout_height="wrap_content"
44+
android:indeterminate="true"
45+
app:indicatorColor="@array/cat_custom_progress_colors"
46+
app:indeterminateAnimationType="contiguous"/>
47+
48+
<TextView
49+
android:layout_width="wrap_content"
50+
android:layout_height="wrap_content"
51+
android:text="@string/cat_progress_indicator_circular_multicolor"/>
52+
<com.google.android.material.progressindicator.CircularProgressIndicator
53+
android:layout_width="wrap_content"
54+
android:layout_height="wrap_content"
55+
android:indeterminate="true"
56+
app:indicatorColor="@array/cat_custom_progress_colors"/>
57+
58+
</LinearLayout>

catalog/java/io/material/catalog/progressindicator/res/values/strings.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
description="Title of demo for the progress indicators with different visibility change behaviors [CHAR LIMIT=NONE]">
2424
Progress Indicator Visibility Demo
2525
</string>
26+
<string name="cat_progress_indicator_multi_color_demo_title" translatable="false"
27+
description="Title of demo for the progress indicators with multi indicator colors [CHAR LIMIT=NONE]">
28+
Progress Indicator Multicolored Demo
29+
</string>
2630
<string name="cat_progress_indicator_demo_indeterminate_title"
2731
description="Title of demo for the progress indicators in indeterminate mode [CHAR LIMIT=NONE]">
2832
Indeterminate Progress Indicator Demo
@@ -107,6 +111,18 @@
107111
description="A circular progress progress indicator [CHAR LIMIT=NONE]">
108112
Circular type
109113
</string>
114+
<string name="cat_progress_indicator_linear_multicolor_disjoint" translatable="false"
115+
description="A linear progress indicator with multiple indicator colors and disjoint indeterminate animation [CHAR LIMIT=NONE]">
116+
Linear type with multiple indicator colors and disjoint animations.
117+
</string>
118+
<string name="cat_progress_indicator_linear_multicolor_contiguous" translate="false"
119+
description="A linear progress indicator with multiple indicator colors and contiguous indeterminate animation [CHAR LIMIT=NONE]">
120+
Linear type with multiple indicator colors and contiguous animations.
121+
</string>
122+
<string name="cat_progress_indicator_circular_multicolor" translatable="false"
123+
description="A circular progress indicator with multiple indicator colors [CHAR LIMIT=NONE]">
124+
Circular type with multiple indicator colors.
125+
</string>
110126

111127
<string name="cat_progress_indicator_start_to_end_linear_single_color"
112128
description="A start-to-end linear progress indicator with a single color [CHAR LIMIT=NONE]">

0 commit comments

Comments
 (0)