Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #86 from chrisbanes/cb/android-11
Browse files Browse the repository at this point in the history
Support for the Android 11 WindowInsets types
  • Loading branch information
chrisbanes authored Jan 12, 2021
2 parents 2cc452e + 3dcf8b4 commit 05310d4
Show file tree
Hide file tree
Showing 11 changed files with 613 additions and 290 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private const val TAG = "Insetter"

@BindingAdapter(
value = [
"consumeSystemWindowInsets",
"consumeWindowInsets",
"paddingLeftSystemWindowInsets",
"paddingTopSystemWindowInsets",
"paddingRightSystemWindowInsets",
Expand All @@ -48,7 +48,7 @@ private const val TAG = "Insetter"
)
fun applyInsetsFromBooleans(
v: View,
consumeSystemWindowInsets: Boolean,
consumeWindowInsets: Boolean,
padSystemWindowLeft: Boolean,
padSystemWindowTop: Boolean,
padSystemWindowRight: Boolean,
Expand All @@ -67,39 +67,43 @@ fun applyInsetsFromBooleans(
marginSystemGestureBottom: Boolean
) {
Insetter.builder()
.applySystemWindowInsetsToPadding(
.padding(
windowInsetTypesOf(ime = true, statusBars = true, navigationBars = true),
Side.create(
padSystemWindowLeft,
padSystemWindowTop,
padSystemWindowRight,
padSystemWindowBottom
)
)
.applySystemWindowInsetsToMargin(
.margin(
windowInsetTypesOf(ime = true, statusBars = true, navigationBars = true),
Side.create(
marginSystemWindowLeft,
marginSystemWindowTop,
marginSystemWindowRight,
marginSystemWindowBottom
)
)
.applySystemGestureInsetsToPadding(
.padding(
windowInsetTypesOf(systemGestures = true),
Side.create(
padSystemGestureLeft,
padSystemGestureTop,
padSystemGestureRight,
padSystemGestureBottom
)
)
.applySystemGestureInsetsToMargin(
.margin(
windowInsetTypesOf(systemGestures = true),
Side.create(
marginSystemGestureLeft,
marginSystemGestureTop,
marginSystemGestureRight,
marginSystemGestureBottom
)
)
.consumeSystemWindowInsets(consumeSystemWindowInsets)
.consume(if (consumeWindowInsets) Insetter.CONSUME_ALL else Insetter.CONSUME_NONE)
.applyToView(v)
}

Expand Down
20 changes: 20 additions & 0 deletions library/api/library.api
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,23 @@ public final class dev/chrisbanes/insetter/Insetter$Builder {
public final fun applySystemWindowInsetsToPadding (I)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun applyToView (Landroid/view/View;)Ldev/chrisbanes/insetter/Insetter;
public final fun build ()Ldev/chrisbanes/insetter/Insetter;
public final fun consume (I)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun consumeSystemWindowInsets (I)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun consumeSystemWindowInsets (Z)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun margin (I)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun margin (II)Ldev/chrisbanes/insetter/Insetter$Builder;
public static synthetic fun margin$default (Ldev/chrisbanes/insetter/Insetter$Builder;IIILjava/lang/Object;)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun marginBottom (I)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun marginLeft (I)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun marginRight (I)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun marginTop (I)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun padding (I)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun padding (II)Ldev/chrisbanes/insetter/Insetter$Builder;
public static synthetic fun padding$default (Ldev/chrisbanes/insetter/Insetter$Builder;IIILjava/lang/Object;)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun paddingBottom (I)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun paddingLeft (I)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun paddingRight (I)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun paddingTop (I)Ldev/chrisbanes/insetter/Insetter$Builder;
public final fun setOnApplyInsetsListener (Ldev/chrisbanes/insetter/OnApplyInsetsListener;)Ldev/chrisbanes/insetter/Insetter$Builder;
}

Expand Down Expand Up @@ -62,6 +77,11 @@ public final class dev/chrisbanes/insetter/Side {
public abstract interface annotation class dev/chrisbanes/insetter/Sides : java/lang/annotation/Annotation {
}

public final class dev/chrisbanes/insetter/TypesKt {
public static final fun windowInsetTypesOf (ZZZZZZZZ)I
public static synthetic fun windowInsetTypesOf$default (ZZZZZZZZILjava/lang/Object;)I
}

public final class dev/chrisbanes/insetter/ViewDimensions {
public static final field Companion Ldev/chrisbanes/insetter/ViewDimensions$Companion;
public static final field EMPTY Ldev/chrisbanes/insetter/ViewDimensions;
Expand Down
1 change: 1 addition & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ android {

dependencies {
api Libs.AndroidX.core
api Libs.AndroidX.coreKtx
implementation Libs.Kotlin.stdlib

androidTestImplementation project(':test-utils')
Expand Down
Loading

0 comments on commit 05310d4

Please sign in to comment.