mirror of
https://github.com/material-components/material-components-android.git
synced 2026-02-20 08:39:55 +08:00
Catalog Demo for Material Radio Button
PiperOrigin-RevId: 209981850
This commit is contained in:
parent
2b8952d8e8
commit
3bb9a248a4
@ -31,6 +31,7 @@ def srcDirs = [
|
||||
'feature',
|
||||
'font',
|
||||
'main',
|
||||
'radiobutton',
|
||||
'switchmaterial',
|
||||
'tableofcontents',
|
||||
'tabs',
|
||||
|
||||
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2018 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.radiobutton;
|
||||
|
||||
import io.material.catalog.R;
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
import dagger.Provides;
|
||||
import dagger.android.ContributesAndroidInjector;
|
||||
import dagger.multibindings.IntoSet;
|
||||
import io.material.catalog.application.scope.ActivityScope;
|
||||
import io.material.catalog.application.scope.FragmentScope;
|
||||
import io.material.catalog.feature.Demo;
|
||||
import io.material.catalog.feature.DemoLandingFragment;
|
||||
import io.material.catalog.feature.FeatureDemo;
|
||||
|
||||
/** A fragment that displays radio button demos for the Catalog app. */
|
||||
public class RadioButtonFragment extends DemoLandingFragment {
|
||||
|
||||
@Override
|
||||
public int getTitleResId() {
|
||||
return R.string.cat_radiobutton_title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDescriptionResId() {
|
||||
return R.string.cat_radiobutton_description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Demo getMainDemo() {
|
||||
return new Demo() {
|
||||
@Override
|
||||
public Fragment createFragment() {
|
||||
return new RadioButtonMainDemoFragment();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** The Dagger module for {@link RadioButtonFragment} dependencies. */
|
||||
@dagger.Module
|
||||
public abstract static class Module {
|
||||
|
||||
@FragmentScope
|
||||
@ContributesAndroidInjector
|
||||
abstract RadioButtonFragment contributeInjector();
|
||||
|
||||
@IntoSet
|
||||
@Provides
|
||||
@ActivityScope
|
||||
static FeatureDemo provideFeatureDemo() {
|
||||
return new FeatureDemo(
|
||||
R.string.cat_radiobutton_title, R.drawable.ic_radio_button_checked_black_24dp) {
|
||||
@Override
|
||||
public Fragment createFragment() {
|
||||
return new RadioButtonFragment();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package io.material.catalog.radiobutton;
|
||||
|
||||
import io.material.catalog.R;
|
||||
|
||||
/*
|
||||
* Copyright 2018 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
|
||||
*
|
||||
* https://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.
|
||||
*/
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import io.material.catalog.feature.DemoFragment;
|
||||
|
||||
/** A fragment that displays the main RadioButton demo for the Catalog app. */
|
||||
public class RadioButtonMainDemoFragment extends DemoFragment {
|
||||
|
||||
@Override
|
||||
public View onCreateDemoView(
|
||||
LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
|
||||
View view =
|
||||
layoutInflater.inflate(R.layout.cat_radiobutton, viewGroup, false /* attachToRoot */);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2018 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
|
||||
|
||||
https://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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5 5,-2.24 5,-5 -2.24,-5 -5,-5zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/>
|
||||
</vector>
|
||||
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright 2018 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
|
||||
|
||||
https://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:id="@+id/main_viewGroup"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/cat_radiobutton_padding"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/cat_radiobutton_color_guide"
|
||||
android:textSize="@dimen/cat_radiobutton_header_size"/>
|
||||
<RadioGroup
|
||||
android:checkedButton="@+id/enabled_selected"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<RadioButton
|
||||
android:id="@+id/enabled_selected"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:enabled="true"
|
||||
android:text="@string/cat_radiobutton_enabled"/>
|
||||
<RadioButton
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:checked="false"
|
||||
android:enabled="true"
|
||||
android:text="@string/cat_radiobutton_enabled"/>
|
||||
<RadioButton
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:checked="false"
|
||||
android:enabled="true"
|
||||
android:text="@string/cat_radiobutton_enabled"/>
|
||||
</RadioGroup>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/cat_radiobutton_disabled_guide"
|
||||
android:textSize="@dimen/cat_radiobutton_header_size"/>
|
||||
<RadioGroup
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:checkedButton="@+id/selected_disabled"
|
||||
android:orientation="horizontal">
|
||||
<RadioButton
|
||||
android:id="@id/selected_disabled"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:enabled="false"
|
||||
android:text="@string/cat_radiobutton_disabled"/>
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false"
|
||||
android:enabled="false"
|
||||
android:text="@string/cat_radiobutton_disabled"/>
|
||||
</RadioGroup>
|
||||
</LinearLayout>
|
||||
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2018 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
|
||||
|
||||
https://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.
|
||||
-->
|
||||
<resources>
|
||||
<dimen name="cat_radiobutton_line_separator_margin">8dp</dimen>
|
||||
<dimen name="cat_radiobutton_padding">8dp</dimen>
|
||||
<dimen name="cat_radiobutton_indent">8dp</dimen>
|
||||
<dimen name="cat_radiobutton_header_size">12sp</dimen>
|
||||
</resources>
|
||||
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2018 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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<string name="cat_radiobutton_title">Radio Button</string>
|
||||
<string name="cat_radiobutton_description">
|
||||
The RadioButton provides a clickable element, usually part of a RadioButtonGroup. Within a single RadioGroup, only 1 RadioButton can be selected.</string>
|
||||
<string name="cat_radiobutton_color_guide">
|
||||
RadioButton elements respond to changes in colorSecondary.
|
||||
They cannot be deselected by a direct click.</string>
|
||||
<string name="cat_radiobutton_disabled_guide">RadioButton elements that are disabled cannot be interacted with and will appear faded.</string>
|
||||
<string name="cat_radiobutton_enabled">Enabled</string>
|
||||
<string name="cat_radiobutton_disabled">Disabled</string>
|
||||
|
||||
</resources>
|
||||
@ -27,6 +27,7 @@ import io.material.catalog.checkbox.CheckBoxFragment;
|
||||
import io.material.catalog.chip.ChipFragment;
|
||||
import io.material.catalog.fab.FabFragment;
|
||||
import io.material.catalog.font.FontFragment;
|
||||
import io.material.catalog.radiobutton.RadioButtonFragment;
|
||||
import io.material.catalog.switchmaterial.SwitchFragment;
|
||||
import io.material.catalog.tabs.TabsFragment;
|
||||
import io.material.catalog.textfield.TextFieldFragment;
|
||||
@ -49,6 +50,7 @@ import io.material.catalog.transformation.TransformationFragment;
|
||||
ChipFragment.Module.class,
|
||||
FabFragment.Module.class,
|
||||
FontFragment.Module.class,
|
||||
RadioButtonFragment.Module.class,
|
||||
SwitchFragment.Module.class,
|
||||
TabsFragment.Module.class,
|
||||
TextFieldFragment.Module.class,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user