Skip to content

Commit 8d57b44

Browse files
committed
add new preference to let the implementor decide if they want to draw under the status bar, or if they want to let the library manage the content padding
1 parent db153e1 commit 8d57b44

File tree

6 files changed

+32
-3
lines changed

6 files changed

+32
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
### v1.5.0
4+
5+
* Don't assume 24dp for the status bar size (Essential Ph-1)
6+
* Add DragDismissIntentBuilder preference for whether or not you want to draw under the status bar.
7+
* If not, the library will handle the content margin at the top, to take the status bar into account
8+
* This is off by default, so the library is handling the status bar size, for you
39

410
### v1.4.4
511

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ To include it in your project, add this to your module's `build.gradle` file:
1919
```groovy
2020
dependencies {
2121
...
22-
compile 'com.klinkerapps:drag-dismiss-activity:1.4.4'
22+
compile 'com.klinkerapps:drag-dismiss-activity:1.5.0'
2323
}
2424
```
2525

@@ -88,6 +88,7 @@ new DragDismissBundleBuilder(context)
8888
.setShouldScrollToolbar(true) // defaults to true
8989
.setFullscreenOnTablets(false) // defaults to false, tablets will have padding on each side
9090
.setDragElasticity(DragDismissIntentBuilder.DragElasticity.NORMAL) // Larger elasticities will make it easier to dismiss.
91+
.setDrawUnderStatusBar(false) // defaults to false. Change to true if you don't want me to handle the content margin for the Activity. Does not apply to the RecyclerView Activities
9192
.build(dragDismissActivity);
9293

9394
// do anything else that you want to set up the Intent

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ MIN_SDK=15
2323
TARGET_SDK=26
2424
COMPILE_SDK=26
2525

26-
VERSION_NAME=1.4.4
26+
VERSION_NAME=1.5.0
2727
VERSION_CODE=1
2828
GROUP=com.klinkerapps
2929

library/src/main/java/xyz/klinker/android/drag_dismiss/DragDismissIntentBuilder.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class DragDismissIntentBuilder {
3131
public static final String EXTRA_SHOULD_SHOW_TOOLBAR = "extra_show_toolbar";
3232
public static final String EXTRA_SHOULD_SCROLL_TOOLBAR = "extra_scroll_toolbar";
3333
public static final String EXTRA_FULLSCREEN_FOR_TABLETS = "extra_fullscreen_tablets";
34+
public static final String EXTRA_DRAW_UNDER_STATUS_BAR = "extra_draw_under_status_bar";
3435

3536
public static final int DEFAULT_TOOLBAR_RESOURCE = R.color.dragdismiss_toolbarBackground;
3637

@@ -49,6 +50,7 @@ public enum DragElasticity {
4950
private boolean shouldShowToolbar = true;
5051
private boolean shouldScrollToolbar = true;
5152
private boolean fullscreen = false;
53+
private boolean drawUnderStatusBar = false;
5254

5355
private Context context;
5456

@@ -73,6 +75,7 @@ public Intent build(Intent intentToBuildOn) {
7375
intentToBuildOn.putExtra(EXTRA_SHOULD_SHOW_TOOLBAR, shouldShowToolbar);
7476
intentToBuildOn.putExtra(EXTRA_SHOULD_SCROLL_TOOLBAR, shouldScrollToolbar);
7577
intentToBuildOn.putExtra(EXTRA_FULLSCREEN_FOR_TABLETS, fullscreen);
78+
intentToBuildOn.putExtra(EXTRA_DRAW_UNDER_STATUS_BAR, drawUnderStatusBar);
7679

7780
return intentToBuildOn;
7881
}
@@ -164,4 +167,19 @@ public DragDismissIntentBuilder setFullscreenOnTablets(boolean fullscreen) {
164167
this.fullscreen = fullscreen;
165168
return this;
166169
}
170+
171+
/**
172+
* Set whether or not you want to place content under the status bar manually, in your layout. If not,
173+
* this library will handle the content margins to account for the status bar. Remember that not all
174+
* phones have the same size status bar. This will only apply for the {@link xyz.klinker.android.drag_dismiss.delegate.DragDismissDelegate}, not
175+
* the {@link xyz.klinker.android.drag_dismiss.delegate.DragDismissRecyclerViewDelegate}.
176+
* You will need to always handle the RecyclerView yourself. A header View is a great way to do that.
177+
*
178+
* @param drawUnderStatusBar
179+
* @return the builder.
180+
*/
181+
public DragDismissIntentBuilder setDrawUnderStatusBar(boolean drawUnderStatusBar) {
182+
this.drawUnderStatusBar = drawUnderStatusBar;
183+
return this;
184+
}
167185
}

library/src/main/java/xyz/klinker/android/drag_dismiss/delegate/AbstractDragDismissDelegate.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public abstract class AbstractDragDismissDelegate {
5454
private int primaryColor;
5555
private boolean shouldShowToolbar;
5656
private boolean shouldScrollToolbar;
57+
protected boolean drawUnderStatusBar;
5758

5859
AbstractDragDismissDelegate(AppCompatActivity activity) {
5960
this.activity = activity;
@@ -101,6 +102,7 @@ private void getIntentExtras() {
101102
activity.getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);
102103
}
103104

105+
this.drawUnderStatusBar = activity.getIntent().getBooleanExtra(DragDismissIntentBuilder.EXTRA_DRAW_UNDER_STATUS_BAR, false);
104106
this.fullscreenForTablets = activity.getIntent().getBooleanExtra(DragDismissIntentBuilder.EXTRA_FULLSCREEN_FOR_TABLETS, false);
105107
this.shouldScrollToolbar = activity.getIntent().getBooleanExtra(DragDismissIntentBuilder.EXTRA_SHOULD_SCROLL_TOOLBAR, true);
106108
this.shouldShowToolbar = activity.getIntent().getBooleanExtra(DragDismissIntentBuilder.EXTRA_SHOULD_SHOW_TOOLBAR, true);

library/src/main/java/xyz/klinker/android/drag_dismiss/delegate/DragDismissDelegate.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ public void onDrag(float elasticOffset, float elasticOffsetPixels, float rawOffs
6969
FrameLayout elasticContent = (FrameLayout) activity.findViewById(R.id.dragdismiss_content);
7070
elasticContent.addView(callback.onCreateContent(activity.getLayoutInflater(), elasticContent, savedInstanceState));
7171

72-
((NestedScrollView.LayoutParams) elasticContent.getLayoutParams()).topMargin = StatusBarHelper.getStatusBarHeight(activity);
72+
if (!drawUnderStatusBar) {
73+
((NestedScrollView.LayoutParams) elasticContent.getLayoutParams()).topMargin = StatusBarHelper.getStatusBarHeight(activity);
74+
}
7375
}
7476

7577
@Override

0 commit comments

Comments
 (0)