|
21 | 21 | import static android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP; |
22 | 22 |
|
23 | 23 | import android.content.Context; |
24 | | -import android.content.res.ColorStateList; |
25 | 24 | import android.content.res.TypedArray; |
26 | 25 | import android.os.Build; |
27 | 26 | import android.os.Parcel; |
28 | 27 | import android.os.Parcelable; |
29 | 28 | import android.support.annotation.IntDef; |
30 | 29 | import android.support.annotation.NonNull; |
31 | | -import android.support.annotation.Nullable; |
32 | 30 | import android.support.annotation.RestrictTo; |
33 | 31 | import android.support.annotation.VisibleForTesting; |
34 | | -import com.google.android.material.resources.MaterialResources; |
35 | | -import com.google.android.material.shape.MaterialShapeDrawable; |
36 | | -import com.google.android.material.shape.ShapeAppearanceModel; |
37 | 32 | import android.support.design.widget.CoordinatorLayout; |
38 | 33 | import android.support.v4.math.MathUtils; |
39 | 34 | import android.support.v4.view.AbsSavedState; |
@@ -143,14 +138,6 @@ public abstract static class BottomSheetCallback { |
143 | 138 | /** The last peek height calculated in onLayoutChild. */ |
144 | 139 | private int lastPeekHeight; |
145 | 140 |
|
146 | | - /** True if Behavior has a non-null value for the shapeAppearance attribute */ |
147 | | - private boolean shapeThemingEnabled; |
148 | | - |
149 | | - private MaterialShapeDrawable materialShapeDrawable; |
150 | | - |
151 | | - /** Default Shape Appearance to be used in bottomsheet */ |
152 | | - private ShapeAppearanceModel shapeAppearanceModelDefault; |
153 | | - |
154 | 141 | int fitToContentsOffset; |
155 | 142 |
|
156 | 143 | int halfExpandedOffset; |
@@ -194,16 +181,6 @@ public BottomSheetBehavior() {} |
194 | 181 | public BottomSheetBehavior(Context context, AttributeSet attrs) { |
195 | 182 | super(context, attrs); |
196 | 183 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BottomSheetBehavior_Layout); |
197 | | - this.shapeThemingEnabled = a.hasValue(R.styleable.BottomSheetBehavior_Layout_shapeAppearance); |
198 | | - boolean hasBackgroundTint = a.hasValue(R.styleable.BottomSheetBehavior_Layout_backgroundTint); |
199 | | - if (hasBackgroundTint) { |
200 | | - ColorStateList bottomSheetColor = |
201 | | - MaterialResources.getColorStateList( |
202 | | - context, a, R.styleable.BottomSheetBehavior_Layout_backgroundTint); |
203 | | - createMaterialShapeDrawable(context, attrs, hasBackgroundTint, bottomSheetColor); |
204 | | - } else { |
205 | | - createMaterialShapeDrawable(context, attrs, hasBackgroundTint, null); |
206 | | - } |
207 | 184 | TypedValue value = a.peekValue(R.styleable.BottomSheetBehavior_Layout_behavior_peekHeight); |
208 | 185 | if (value != null && value.data == PEEK_HEIGHT_AUTO) { |
209 | 186 | setPeekHeight(value.data); |
@@ -244,12 +221,6 @@ public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirect |
244 | 221 | if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { |
245 | 222 | child.setFitsSystemWindows(true); |
246 | 223 | } |
247 | | - // Only set MaterialShapeDrawable as background if shapeTheming is enabled, otherwise will |
248 | | - // default to android:background declared in styles or layout. |
249 | | - if (shapeThemingEnabled && materialShapeDrawable != null) { |
250 | | - ViewCompat.setBackground(child, materialShapeDrawable); |
251 | | - } |
252 | | - |
253 | 224 | int savedTop = child.getTop(); |
254 | 225 | // First let the parent lay it out |
255 | 226 | parent.onLayoutChild(child, layoutDirection); |
@@ -737,27 +708,11 @@ void setStateInternal(@State int state) { |
737 | 708 | bottomSheet, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); |
738 | 709 | bottomSheet.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); |
739 | 710 |
|
740 | | - updateDrawableOnStateChange(state); |
741 | 711 | if (callback != null) { |
742 | 712 | callback.onStateChanged(bottomSheet, state); |
743 | 713 | } |
744 | 714 | } |
745 | 715 |
|
746 | | - private void updateDrawableOnStateChange(@State int state) { |
747 | | - if (materialShapeDrawable != null) { |
748 | | - if (state == STATE_EXPANDED && (parentHeight <= viewRef.get().getHeight())) { |
749 | | - // If the bottomsheet is fully expanded, change ShapeAppearance to sharp corners to |
750 | | - // indicate the bottomsheet has no more content to scroll. |
751 | | - // Overriding of this style may be performed in the bottomsheet callback. |
752 | | - materialShapeDrawable.getShapeAppearanceModel().setCornerRadius(0); |
753 | | - materialShapeDrawable.invalidateSelf(); |
754 | | - } |
755 | | - if (state == STATE_COLLAPSED || state == STATE_DRAGGING) { |
756 | | - materialShapeDrawable.setShapeAppearanceModel(shapeAppearanceModelDefault); |
757 | | - } |
758 | | - } |
759 | | - } |
760 | | - |
761 | 716 | private void calculateCollapsedOffset() { |
762 | 717 | if (fitToContents) { |
763 | 718 | collapsedOffset = Math.max(parentHeight - lastPeekHeight, fitToContentsOffset); |
@@ -803,32 +758,6 @@ View findScrollingChild(View view) { |
803 | 758 | return null; |
804 | 759 | } |
805 | 760 |
|
806 | | - private void createMaterialShapeDrawable( |
807 | | - Context context, |
808 | | - AttributeSet attrs, |
809 | | - boolean hasBackgroundTint, |
810 | | - @Nullable ColorStateList bottomSheetColor) { |
811 | | - if (this.shapeThemingEnabled) { |
812 | | - this.shapeAppearanceModelDefault = new ShapeAppearanceModel( |
813 | | - context, |
814 | | - attrs, |
815 | | - R.styleable.BottomSheetBehavior_Layout_shapeAppearance, |
816 | | - R.styleable.BottomSheetBehavior_Layout_shapeAppearanceOverlay); |
817 | | - |
818 | | - this.materialShapeDrawable = |
819 | | - new MaterialShapeDrawable(shapeAppearanceModelDefault); |
820 | | - |
821 | | - if (hasBackgroundTint && bottomSheetColor != null) { |
822 | | - materialShapeDrawable.setFillColor(bottomSheetColor); |
823 | | - } else { |
824 | | - // If the tint isn't set, use the theme default background color. |
825 | | - TypedValue defaultColor = new TypedValue(); |
826 | | - context.getTheme().resolveAttribute(android.R.attr.colorBackground, defaultColor, true); |
827 | | - materialShapeDrawable.setTint(defaultColor.data); |
828 | | - } |
829 | | - } |
830 | | - } |
831 | | - |
832 | 761 | private float getYVelocity() { |
833 | 762 | if (velocityTracker == null) { |
834 | 763 | return 0; |
|
0 commit comments