3030import android .os .Build .VERSION_CODES ;
3131import android .os .Parcel ;
3232import android .os .Parcelable ;
33+ import androidx .annotation .FloatRange ;
3334import androidx .annotation .IntDef ;
3435import androidx .annotation .NonNull ;
3536import androidx .annotation .Nullable ;
@@ -136,17 +137,17 @@ public abstract static class BottomSheetCallback {
136137 /**
137138 * This flag will preserve the fitToContents boolean value on configuration change.
138139 */
139- public static final int SAVE_FIT_TO_CONTENTS = 0x2 ;
140+ public static final int SAVE_FIT_TO_CONTENTS = 1 << 1 ;
140141
141142 /**
142143 * This flag will preserve the hideable boolean value on configuration change.
143144 */
144- public static final int SAVE_HIDEABLE = 0x4 ;
145+ public static final int SAVE_HIDEABLE = 1 << 2 ;
145146
146147 /**
147148 * This flag will preserve the skipCollapsed boolean value on configuration change.
148149 */
149- public static final int SAVE_SKIP_COLLAPSED = 0x8 ;
150+ public static final int SAVE_SKIP_COLLAPSED = 1 << 3 ;
150151
151152 /**
152153 * This flag will preserve all aforementioned values on configuration change.
@@ -160,7 +161,22 @@ public abstract static class BottomSheetCallback {
160161 */
161162 public static final int SAVE_NONE = 0 ;
162163
163- private int saveFlags = SAVE_NONE ;
164+ /** @hide */
165+ @ RestrictTo (LIBRARY_GROUP )
166+ @ IntDef (
167+ flag = true ,
168+ value = {
169+ SAVE_PEEK_HEIGHT ,
170+ SAVE_FIT_TO_CONTENTS ,
171+ SAVE_HIDEABLE ,
172+ SAVE_SKIP_COLLAPSED ,
173+ SAVE_ALL ,
174+ SAVE_NONE ,
175+ })
176+ @ Retention (RetentionPolicy .SOURCE )
177+ public @interface SaveFlags {}
178+
179+ @ SaveFlags private int saveFlags = SAVE_NONE ;
164180
165181 private static final float HIDE_THRESHOLD = 0.5f ;
166182
@@ -728,7 +744,7 @@ public final int getPeekHeight() {
728744 * @param ratio a float between 0 and 1, representing the {@link #STATE_HALF_EXPANDED} ratio.
729745 * @attr com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_halfExpandedRatio
730746 */
731- public void setHalfExpandedRatio (float ratio ) {
747+ public void setHalfExpandedRatio (@ FloatRange ( from = 0.0f , to = 1.0f ) float ratio ) {
732748
733749 if ((ratio <= 0 ) || (ratio >= 1 )) {
734750 throw new IllegalArgumentException ("ratio must be a float value between 0 and 1" );
@@ -757,6 +773,7 @@ public void setExpandedOffset(int offset) {
757773 *
758774 * @attr com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_halfExpandedRatio
759775 */
776+ @ FloatRange (from = 0.0f , to = 1.0f )
760777 public float getHalfExpandedRatio () {
761778 return halfExpandedRatio ;
762779 }
@@ -818,7 +835,7 @@ public boolean getSkipCollapsed() {
818835 * @see #getSaveFlags()
819836 * @attr ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_saveFlags
820837 */
821- public void setSaveFlags (int flags ) {
838+ public void setSaveFlags (@ SaveFlags int flags ) {
822839 this .saveFlags = flags ;
823840 }
824841 /**
@@ -827,6 +844,7 @@ public void setSaveFlags(int flags) {
827844 * @see #setSaveFlags(int)
828845 * @attr ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_saveFlags
829846 */
847+ @ SaveFlags
830848 public int getSaveFlags () {
831849 return this .saveFlags ;
832850 }
@@ -1273,7 +1291,10 @@ int getPeekHeightMin() {
12731291 * Disables the shaped corner {@link ShapeAppearanceModel} interpolation transition animations.
12741292 * Will have no effect unless the sheet utilizes a {@link MaterialShapeDrawable} with set shape
12751293 * theming properties. Only For use in UI testing.
1294+ *
1295+ * @hide
12761296 */
1297+ @ RestrictTo (LIBRARY_GROUP )
12771298 @ VisibleForTesting
12781299 public void disableShapeAnimations () {
12791300 // Sets the shape value animator to null, prevents animations from occuring during testing.
0 commit comments