Skip to content

Commit fa39e39

Browse files
committed
fix adjustResize issues
The top level views should fit the system window. Applying that alone would make it so the view was not drawn under the status bar. Applying the TransparentStatusBarInsetLayout makes it so the activity can still use the transparent status bar effect
1 parent e0bb5fa commit fa39e39

File tree

6 files changed

+63
-10
lines changed

6 files changed

+63
-10
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515
#
1616

17-
GRADLE_PLUGIN_VERSION=3.0.0-alpha5
17+
GRADLE_PLUGIN_VERSION=3.0.0-beta5
1818
BUILD_TOOLS_VERSION=26.0.1
1919

2020
ANDROID_SUPPORT_VERSION=26.0.1

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

library/src/main/java/xyz/klinker/android/drag_dismiss/activity/DragDismissRecyclerViewActivity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package xyz.klinker.android.drag_dismiss.activity;
1818

19-
import android.support.v7.widget.RecyclerView;
20-
2119
import xyz.klinker.android.drag_dismiss.delegate.AbstractDragDismissDelegate;
2220
import xyz.klinker.android.drag_dismiss.delegate.DragDismissRecyclerViewDelegate;
2321

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (C) 2017 Luke Klinker
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 xyz.klinker.android.drag_dismiss.view;
18+
19+
import android.content.Context;
20+
import android.os.Build;
21+
import android.support.annotation.Nullable;
22+
import android.util.AttributeSet;
23+
import android.view.WindowInsets;
24+
import android.widget.LinearLayout;
25+
26+
public class TransparentStatusBarInsetLayout extends LinearLayout {
27+
private int[] mInsets = new int[4];
28+
29+
public TransparentStatusBarInsetLayout(Context context) {
30+
super(context);
31+
}
32+
33+
public TransparentStatusBarInsetLayout(Context context, @Nullable AttributeSet attrs) {
34+
super(context, attrs);
35+
}
36+
37+
public TransparentStatusBarInsetLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
38+
super(context, attrs, defStyleAttr);
39+
}
40+
41+
@Override
42+
public final WindowInsets onApplyWindowInsets(WindowInsets insets) {
43+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
44+
mInsets[0] = insets.getSystemWindowInsetLeft();
45+
mInsets[1] = insets.getSystemWindowInsetTop();
46+
mInsets[2] = insets.getSystemWindowInsetRight();
47+
return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(0, 0, 0,
48+
insets.getSystemWindowInsetBottom()));
49+
} else {
50+
return insets;
51+
}
52+
}
53+
}

library/src/main/res/layout/dragdismiss_activity.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
~ limitations under the License.
1616
-->
1717

18-
<LinearLayout
18+
<xyz.klinker.android.drag_dismiss.view.TransparentStatusBarInsetLayout
1919
xmlns:android="http://schemas.android.com/apk/res/android"
2020
android:layout_width="match_parent"
2121
android:layout_height="match_parent"
22-
android:orientation="horizontal">
22+
android:orientation="horizontal"
23+
android:fitsSystemWindows="true">
2324

2425
<View
2526
android:layout_width="0dp"
@@ -89,4 +90,4 @@
8990
android:background="@color/dragdismiss_transparentSideBackground"
9091
android:id="@+id/dragdismiss_transparent_side_2"/>
9192

92-
</LinearLayout>
93+
</xyz.klinker.android.drag_dismiss.view.TransparentStatusBarInsetLayout>

library/src/main/res/layout/dragdismiss_activity_recycler.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
~ limitations under the License.
1616
-->
1717

18-
<LinearLayout
18+
<xyz.klinker.android.drag_dismiss.view.TransparentStatusBarInsetLayout
1919
xmlns:android="http://schemas.android.com/apk/res/android"
2020
android:layout_width="match_parent"
2121
android:layout_height="match_parent"
22-
android:orientation="horizontal">
22+
android:orientation="horizontal"
23+
android:fitsSystemWindows="true">
2324

2425
<View
2526
android:layout_width="0dp"
@@ -89,4 +90,4 @@
8990
android:background="@color/dragdismiss_transparentSideBackground"
9091
android:id="@+id/dragdismiss_transparent_side_2"/>
9192

92-
</LinearLayout>
93+
</xyz.klinker.android.drag_dismiss.view.TransparentStatusBarInsetLayout>

0 commit comments

Comments
 (0)