Skip to content

Commit

Permalink
[ProgressIndicator] Added a demo for using multiple indicator colors …
Browse files Browse the repository at this point in the history
…in Catalog.

PiperOrigin-RevId: 592009245
  • Loading branch information
pekingme authored and hunterstich committed Dec 19, 2023
1 parent 5d62e9e commit cd0d94e
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 0 deletions.
Expand Up @@ -72,6 +72,14 @@ public Fragment createFragment() {
@NonNull
public List<Demo> getAdditionalDemos() {
List<Demo> additionalDemos = getSharedAdditionalDemos();
additionalDemos.add(
new Demo(R.string.cat_progress_indicator_multi_color_demo_title) {
@Nullable
@Override
public Fragment createFragment() {
return new ProgressIndicatorMultiColorDemoFragment();
}
});
additionalDemos.add(
new Demo(R.string.cat_progress_indicator_demo_indeterminate_title) {
@Override
Expand Down
@@ -0,0 +1,46 @@
/*
* Copyright 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.material.catalog.progressindicator;

import io.material.catalog.R;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.progressindicator.CircularProgressIndicator;
import com.google.android.material.progressindicator.LinearProgressIndicator;
import io.material.catalog.feature.DemoFragment;

/**
* This is the fragment to demo using multiple indicator colors in {@link LinearProgressIndicator}
* and {@link CircularProgressIndicator}.
*/
public class ProgressIndicatorMultiColorDemoFragment extends DemoFragment {

@Override
@NonNull
public View onCreateDemoView(
@NonNull LayoutInflater layoutInflater,
@Nullable ViewGroup viewGroup,
@Nullable Bundle bundle) {

return layoutInflater.inflate(
R.layout.cat_progress_indicator_multi_color_fragment, viewGroup, false /* attachToRoot */);
}
}
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical"
android:padding="16dp"
android:showDividers="middle"
android:divider="@drawable/layout_divider">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cat_progress_indicator_linear_multicolor_disjoint"/>
<com.google.android.material.progressindicator.LinearProgressIndicator
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
app:indicatorColor="@array/cat_custom_progress_colors"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cat_progress_indicator_linear_multicolor_contiguous"/>
<com.google.android.material.progressindicator.LinearProgressIndicator
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
app:indicatorColor="@array/cat_custom_progress_colors"
app:indeterminateAnimationType="contiguous"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cat_progress_indicator_circular_multicolor"/>
<com.google.android.material.progressindicator.CircularProgressIndicator
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
app:indicatorColor="@array/cat_custom_progress_colors"/>

</LinearLayout>
Expand Up @@ -23,6 +23,10 @@
description="Title of demo for the progress indicators with different visibility change behaviors [CHAR LIMIT=NONE]">
Progress Indicator Visibility Demo
</string>
<string name="cat_progress_indicator_multi_color_demo_title" translatable="false"
description="Title of demo for the progress indicators with multi indicator colors [CHAR LIMIT=NONE]">
Progress Indicator Multicolored Demo
</string>
<string name="cat_progress_indicator_demo_indeterminate_title"
description="Title of demo for the progress indicators in indeterminate mode [CHAR LIMIT=NONE]">
Indeterminate Progress Indicator Demo
Expand Down Expand Up @@ -107,6 +111,18 @@
description="A circular progress progress indicator [CHAR LIMIT=NONE]">
Circular type
</string>
<string name="cat_progress_indicator_linear_multicolor_disjoint" translatable="false"
description="A linear progress indicator with multiple indicator colors and disjoint indeterminate animation [CHAR LIMIT=NONE]">
Linear type with multiple indicator colors and disjoint animations.
</string>
<string name="cat_progress_indicator_linear_multicolor_contiguous" translate="false"
description="A linear progress indicator with multiple indicator colors and contiguous indeterminate animation [CHAR LIMIT=NONE]">
Linear type with multiple indicator colors and contiguous animations.
</string>
<string name="cat_progress_indicator_circular_multicolor" translatable="false"
description="A circular progress indicator with multiple indicator colors [CHAR LIMIT=NONE]">
Circular type with multiple indicator colors.
</string>

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

0 comments on commit cd0d94e

Please sign in to comment.