Skip to content

Commit 55cfdb0

Browse files
ymariandsn5ft
authored andcommitted
Invalidate BorderDrawable when changing shapeAppearance
PiperOrigin-RevId: 224826056
1 parent 73f7681 commit 55cfdb0

File tree

12 files changed

+605
-0
lines changed

12 files changed

+605
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2018 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+
17+
package io.material.catalog.shapetheming;
18+
19+
import io.material.catalog.R;
20+
21+
import android.support.annotation.StyleRes;
22+
23+
/** A fragment that displays a Shape Theming demo using the Crane theme. */
24+
public class ShapeThemingCraneDemoFragment extends ShapeThemingDemoFragment {
25+
26+
@Override
27+
@StyleRes
28+
protected int getShapeTheme() {
29+
return R.style.ThemeOverlay_Crane;
30+
}
31+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2018 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+
17+
package io.material.catalog.shapetheming;
18+
19+
import io.material.catalog.R;
20+
21+
import android.os.Bundle;
22+
import android.support.annotation.Nullable;
23+
import android.support.annotation.StyleRes;
24+
import android.support.v7.view.ContextThemeWrapper;
25+
import android.view.LayoutInflater;
26+
import android.view.View;
27+
import android.view.ViewGroup;
28+
import io.material.catalog.feature.DemoFragment;
29+
30+
/** A base class for Shape Theming demos in the Catalog app. */
31+
public abstract class ShapeThemingDemoFragment extends DemoFragment {
32+
33+
@Nullable
34+
@Override
35+
public View onCreateDemoView(
36+
LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
37+
View view =
38+
layoutInflater.inflate(
39+
R.layout.cat_shape_theming_container, viewGroup, false /* attachToRoot */);
40+
ViewGroup container = view.findViewById(R.id.container);
41+
ContextThemeWrapper wrappedContext = new ContextThemeWrapper(getContext(), getShapeTheme());
42+
View.inflate(wrappedContext, R.layout.cat_shape_theming_content, container);
43+
return view;
44+
}
45+
46+
@StyleRes
47+
protected abstract int getShapeTheme();
48+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2018 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+
17+
package io.material.catalog.shapetheming;
18+
19+
import io.material.catalog.R;
20+
21+
import android.support.annotation.StyleRes;
22+
23+
/** A fragment that displays a Shape Theming demo using the Fortnightly theme. */
24+
public class ShapeThemingFortnightlyDemoFragment extends ShapeThemingDemoFragment {
25+
26+
@Override
27+
@StyleRes
28+
protected int getShapeTheme() {
29+
return R.style.ThemeOverlay_Fortnightly;
30+
}
31+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Copyright 2018 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+
17+
package io.material.catalog.shapetheming;
18+
19+
import io.material.catalog.R;
20+
21+
import static io.material.catalog.feature.FeatureDemo.STATUS_WIP;
22+
23+
import android.support.v4.app.Fragment;
24+
import dagger.Provides;
25+
import dagger.android.ContributesAndroidInjector;
26+
import dagger.multibindings.IntoSet;
27+
import io.material.catalog.application.scope.ActivityScope;
28+
import io.material.catalog.application.scope.FragmentScope;
29+
import io.material.catalog.feature.Demo;
30+
import io.material.catalog.feature.DemoLandingFragment;
31+
import io.material.catalog.feature.FeatureDemo;
32+
import java.util.ArrayList;
33+
import java.util.List;
34+
35+
/** A landing fragment that links to Shape Theming demos for the Catalog app. */
36+
public class ShapeThemingFragment extends DemoLandingFragment {
37+
38+
@Override
39+
public int getTitleResId() {
40+
return R.string.cat_shape_theming_title;
41+
}
42+
43+
@Override
44+
public int getDescriptionResId() {
45+
return R.string.cat_shape_theming_description;
46+
}
47+
48+
@Override
49+
public Demo getMainDemo() {
50+
return new Demo() {
51+
@Override
52+
public Fragment createFragment() {
53+
return new ShapeThemingMainDemoFragment();
54+
}
55+
};
56+
}
57+
58+
@Override
59+
public List<Demo> getAdditionalDemos() {
60+
List<Demo> additionalDemos = new ArrayList<>();
61+
additionalDemos.add(
62+
new Demo(R.string.cat_shape_theming_crane_demo_title) {
63+
@Override
64+
public Fragment createFragment() {
65+
return new ShapeThemingCraneDemoFragment();
66+
}
67+
});
68+
additionalDemos.add(
69+
new Demo(R.string.cat_shape_theming_fortnightly_demo_title) {
70+
@Override
71+
public Fragment createFragment() {
72+
return new ShapeThemingFortnightlyDemoFragment();
73+
}
74+
});
75+
additionalDemos.add(
76+
new Demo(R.string.cat_shape_theming_shrine_demo_title) {
77+
@Override
78+
public Fragment createFragment() {
79+
return new ShapeThemingShrineDemoFragment();
80+
}
81+
});
82+
return additionalDemos;
83+
}
84+
85+
/** The Dagger module for {@link ShapeThemingFragment} dependencies. */
86+
@dagger.Module
87+
public abstract static class Module {
88+
89+
@FragmentScope
90+
@ContributesAndroidInjector
91+
abstract ShapeThemingFragment contributeInjector();
92+
93+
@IntoSet
94+
@Provides
95+
@ActivityScope
96+
static FeatureDemo provideFeatureDemo() {
97+
return new FeatureDemo(R.string.cat_shape_theming_title, R.drawable.ic_shape, STATUS_WIP) {
98+
@Override
99+
public Fragment createFragment() {
100+
return new ShapeThemingFragment();
101+
}
102+
};
103+
}
104+
}
105+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2018 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+
17+
package io.material.catalog.shapetheming;
18+
19+
import io.material.catalog.R;
20+
21+
import android.support.annotation.StyleRes;
22+
23+
/** A fragment that displays a Shape Theming demo using the baseline theme. */
24+
public class ShapeThemingMainDemoFragment extends ShapeThemingDemoFragment {
25+
26+
@Override
27+
@StyleRes
28+
protected int getShapeTheme() {
29+
return R.style.ThemeOverlay_Baseline;
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2018 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+
17+
package io.material.catalog.shapetheming;
18+
19+
import io.material.catalog.R;
20+
21+
import android.support.annotation.StyleRes;
22+
23+
/** A fragment that displays a Shape Theming demo using the Shrine theme. */
24+
public class ShapeThemingShrineDemoFragment extends ShapeThemingDemoFragment {
25+
26+
@Override
27+
@StyleRes
28+
protected int getShapeTheme() {
29+
return R.style.ThemeOverlay_Shrine;
30+
}
31+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2018 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+
18+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
19+
android:layout_width="match_parent"
20+
android:layout_height="match_parent"
21+
android:id="@+id/container"/>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2018 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
18+
xmlns:android="http://schemas.android.com/apk/res/android"
19+
xmlns:app="http://schemas.android.com/apk/res-auto"
20+
android:layout_width="match_parent"
21+
android:layout_height="wrap_content"
22+
android:padding="8dp"
23+
android:background="?android:attr/colorBackground"
24+
android:orientation="vertical">
25+
26+
<!-- Components that support shape theming should be added here. -->
27+
28+
<!-- Chips -->
29+
30+
<com.google.android.material.chip.Chip
31+
android:id="@+id/cat_chip_entry_chip"
32+
android:layout_width="wrap_content"
33+
android:layout_height="wrap_content"
34+
android:layout_margin="8dp"
35+
android:layout_gravity="center_vertical|start"
36+
android:ellipsize="end"
37+
android:text="@string/cat_shape_theming_chip_text"
38+
app:chipIcon="@drawable/ic_placeholder_circle_24"/>
39+
40+
<!-- FABs -->
41+
42+
<com.google.android.material.widget.FloatingActionButton
43+
android:layout_width="wrap_content"
44+
android:layout_height="wrap_content"
45+
android:layout_margin="16dp"
46+
android:layout_gravity="center"
47+
app:srcCompat="@drawable/ic_add_24px"/>
48+
49+
<com.google.android.material.widget.FloatingActionButton
50+
android:layout_width="wrap_content"
51+
android:layout_height="wrap_content"
52+
android:layout_margin="16dp"
53+
android:layout_gravity="center"
54+
app:fabSize="mini"
55+
app:srcCompat="@drawable/ic_add_24px"/>
56+
57+
<!-- Cards -->
58+
59+
<com.google.android.material.card.MaterialCardView
60+
android:layout_width="match_parent"
61+
android:layout_height="wrap_content"
62+
android:layout_margin="16dp"
63+
android:layout_gravity="center"
64+
android:minHeight="@dimen/cat_shape_theming_card_min_height">
65+
<TextView
66+
android:layout_width="wrap_content"
67+
android:layout_height="wrap_content"
68+
android:text="@string/cat_shape_theming_card_text"/>
69+
</com.google.android.material.card.MaterialCardView>
70+
71+
<!-- Text fields -->
72+
73+
<com.google.android.material.textfield.TextInputLayout
74+
android:layout_width="match_parent"
75+
android:layout_height="wrap_content"
76+
android:layout_margin="8dp"
77+
android:hint="@string/cat_shape_theming_textfield_hint_outlined">
78+
<com.google.android.material.textfield.TextInputEditText
79+
android:layout_width="match_parent"
80+
android:layout_height="wrap_content"/>
81+
</com.google.android.material.textfield.TextInputLayout>
82+
83+
</LinearLayout>

0 commit comments

Comments
 (0)