diff --git a/app/build.gradle b/app/build.gradle index 84a09c9..d716cb7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,6 +26,11 @@ android { lintOptions { abortOnError false } + + compileOptions { + sourceCompatibility 1.8 + targetCompatibility 1.8 + } } dependencies { diff --git a/app/release/app-release.apk b/app/release/app-release.apk index fd52bbb..d8d1e60 100644 Binary files a/app/release/app-release.apk and b/app/release/app-release.apk differ diff --git a/app/release/output.json b/app/release/output.json index 3d2892a..44a598a 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":11,"versionName":"1.0.2","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":13,"versionName":"1.1.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file diff --git a/bottomsheets-core/build.gradle b/bottomsheets-core/build.gradle index fb71e32..a96e4c4 100644 --- a/bottomsheets-core/build.gradle +++ b/bottomsheets-core/build.gradle @@ -38,6 +38,11 @@ android { lintOptions { abortOnError false } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } dependencies { diff --git a/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/BottomSheetContainer.java b/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/BottomSheetContainer.java index 15e57c4..8de78c3 100644 --- a/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/BottomSheetContainer.java +++ b/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/BottomSheetContainer.java @@ -176,6 +176,12 @@ private void initBottomSheet() { mBottomSheetView = new FrameLayout(getContext()); mBottomSheetView.setLayoutParams(generateDefaultLayoutParams()); mBottomSheetView.setBackground(createBottomSheetBackgroundDrawable()); + mBottomSheetView.setPadding( + mBottomSheetView.getPaddingLeft(), + ((int) mConfig.getExtraPaddingTop()), + mBottomSheetView.getPaddingRight(), + ((int) mConfig.getExtraPaddingBottom()) + ); // Creating the actual sheet content view final View createdSheetView = Preconditions.checkNonNull(onCreateSheetContentView(getContext())); @@ -347,38 +353,42 @@ public final void dismiss(boolean animate) { private void postViewShowingAction(final boolean animate) { - postPendingViewManagementAction(new Runnable() { - @Override - public void run() { - if(animate) { - if(!State.EXPANDED.equals(mState) && !State.EXPANDING.equals(mState)) { - setUiState(State.COLLAPSED); - animateStateTransition(State.EXPANDING); - } - } else { - setUiState(mState = State.EXPANDED); - } + postPendingViewManagementAction(() -> expandSheet(animate)); + } + + + + + private void expandSheet(final boolean animate) { + if(animate) { + if(!State.EXPANDED.equals(mState) && !State.EXPANDING.equals(mState)) { + setUiState(State.COLLAPSED); + animateStateTransition(State.EXPANDING); } - }); + } else { + setUiState(mState = State.EXPANDED); + } } private void postViewDismissingAction(final boolean animate) { - postPendingViewManagementAction(new Runnable() { - @Override - public void run() { - if(animate) { - if(!State.COLLAPSED.equals(mState) && !State.COLLAPSING.equals(mState)) { - animateStateTransition(State.COLLAPSING); - } - } else { - removeFromContainer(); - setUiState(mState = State.COLLAPSED); - } + postPendingViewManagementAction(() -> collapseSheet(animate)); + } + + + + + private void collapseSheet(final boolean animate) { + if(animate) { + if(!State.COLLAPSED.equals(mState) && !State.COLLAPSING.equals(mState)) { + animateStateTransition(State.COLLAPSING); } - }); + } else { + removeFromContainer(); + setUiState(mState = State.COLLAPSED); + } } @@ -430,15 +440,12 @@ private void animateStateTransition(final State state) { // creating and starting a brand-new one mAnimator = ValueAnimator.ofFloat(startValue, endValue); - mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - final float animatedValue = (Float) valueAnimator.getAnimatedValue(); - final float newY = (startY + (animatedValue * (endY - startY))); + mAnimator.addUpdateListener(valueAnimator -> { + final float animatedValue = (Float) valueAnimator.getAnimatedValue(); + final float newY = (startY + (animatedValue * (endY - startY))); - mBottomSheetView.setY(newY); - setBackgroundAlpha(animatedValue); - } + mBottomSheetView.setY(newY); + setBackgroundAlpha(animatedValue); }); mAnimator.addListener(new AnimatorListenerAdapter() { diff --git a/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/config/BaseConfig.java b/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/config/BaseConfig.java index dfbd19d..1b6f997 100644 --- a/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/config/BaseConfig.java +++ b/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/config/BaseConfig.java @@ -59,6 +59,20 @@ public interface BaseConfig { */ float getTopGapSize(); + /** + * Retrieves the extra padding top. + * + * @return the extra padding from the top. + */ + float getExtraPaddingTop(); + + /** + * Retrieves the extra padding bottom. + * + * @return the extra padding from the bottom. + */ + float getExtraPaddingBottom(); + /** * Retrieves the sheet's maximum width. * diff --git a/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/config/BaseConfigBuilder.java b/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/config/BaseConfigBuilder.java index 6ed75f5..9efafb5 100644 --- a/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/config/BaseConfigBuilder.java +++ b/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/config/BaseConfigBuilder.java @@ -75,6 +75,24 @@ public interface BaseConfigBuilder extends Bui @NonNull BT maxSheetWidth(float maxWidth); + /** + * Sets the top padding that will be added to the bottom sheet view container. + * + * @param extraPaddingTop the extra padding from the top + * @return the current instance of the configuration builder (for chaining purposes) + */ + @NonNull + BT extraPaddingTop(float extraPaddingTop); + + /** + * Sets the bottom padding that will be added to the bottom sheet view container. + * + * @param extraPaddingBottom the extra padding from the bottom + * @return the current instance of the configuration builder (for chaining purposes) + */ + @NonNull + BT extraPaddingBottom(float extraPaddingBottom); + /** * Sets the background dimming color. * diff --git a/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/config/Config.java b/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/config/Config.java index 3000f03..7b84de5 100644 --- a/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/config/Config.java +++ b/bottomsheets-core/src/main/java/com/arthurivanets/bottomsheets/config/Config.java @@ -40,6 +40,8 @@ public final class Config implements BaseConfig { private final float sheetCornerRadius; private final float maxSheetWidth; private final float topGapSize; + private final float extraPaddingTop; + private final float extraPaddingBottom; private final int dimColor; private final int sheetBackgroundColor; @@ -57,6 +59,8 @@ private Config(Builder builder) { this.sheetCornerRadius = builder.sheetCornerRadius; this.maxSheetWidth = builder.maxSheetWidth; this.topGapSize = builder.topGapSize; + this.extraPaddingTop = builder.extraPaddingTop; + this.extraPaddingBottom = builder.extraPaddingBottom; this.dimColor = builder.dimColor; this.sheetBackgroundColor = builder.sheetBackgroundColor; this.animationDuration = builder.animationDuration; @@ -91,6 +95,22 @@ public final float getTopGapSize() { + @Override + public final float getExtraPaddingTop() { + return this.extraPaddingTop; + } + + + + + @Override + public final float getExtraPaddingBottom() { + return this.extraPaddingBottom; + } + + + + @Override public final float getMaxSheetWidth() { return this.maxSheetWidth; @@ -146,6 +166,8 @@ public static final class Builder implements BaseConfigBuilder