Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listen for back button press #14

Merged
merged 5 commits into from
Jul 23, 2015
Merged

Listen for back button press #14

merged 5 commits into from
Jul 23, 2015

Conversation

iPaulPro
Copy link
Contributor

@iPaulPro iPaulPro commented Jul 1, 2015

Removes the need to listen for onBackPressed in the Activity. Sample updated to reflect this. Fixes #10.

if (event.isTracking() && !event.isCanceled()) {
if (isSheetShowing()) {
if (getState() == BottomSheetLayout.State.EXPANDED) {
peekSheet();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do want to bring this up again. In my case I'm using the bottom sheet for sharing. If you press back you want to completely cancel the share (what the default share sheet on lollipop does). If this is hard-coded to peek instead of dismiss, it will be vary hard to change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that there should be more flexibility here. I didn't want to make any assumptions, but only supply a solution to your issue posted. I will leave it to Flipboard to decide the best way to integrate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair, just wanted to make sure this is documented as an issue on the pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the purpose of discussion, what do you believe the best solution would be? A boolean field that toggles full dismiss vs peek dismiss? Can you identify other types of dismiss that could be desired? I struggled to find good naming, which was the main deterrent. setAlwaysPeekDismiss(boolean), setAlwaysFullDismiss(boolean), setPeekOnDismiss(boolean)? Those aren't great. Also, what do you believe should be the default?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that fully dismissing should be the default, I'm not sure I can think of any use cases where you'd want that not to happen, as you start with it off screen. I guess it would make sense to go back to peeking if it was somehow locked to peek on the screen, but that isn't a feature this lib implements. I'd go with passing the existing state enum instead of a boolean setBackDismissMode(State.PEEKED) or setBackDismissMode(State.HIDDEN).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see many use cases for wanting peek on dismiss. E.g. Tapping an item in peek mode expands to full.

Avoid enums in Android, but perhaps using IntDef makes the most sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree about avoiding enums, but the State enum is already there.

Conflicts:
	bottomsheet-sample/src/main/java/com/flipboard/bottomsheet/sample/MainActivity.java
Instead of assuming that a back press should change the state from EXPANDED to PEEKED, this can now be controlled through BottomSheetLayout.setDismissMode(State). The default is HIDDEN, which completely dismisses the Bottom Sheet when back is pressed in EXPANDED state.

Updates MenuActivity sample to demonstrate BottomSheetLayout.setDismissMode(State).
@ZacSweers
Copy link
Contributor

Sorry for the late response. There's been some good discussion, and we're going to mull over it tonight and tomorrow. In the meantime, @iPaulPro would you mind rebasing on the current master? We just merged a fairly significant change to the sample structure.

Also please fill out the Individual Contributor License Agreement if you haven't already.

@iPaulPro
Copy link
Contributor Author

iPaulPro commented Jul 2, 2015

@hzsweers No worries. I already merged the latest master, so you should see the big green button. :-)

I also submitted the CLA yesterday morning (before the PR).

}
return true;
} else if (event.getAction() == KeyEvent.ACTION_UP) {
KeyEvent.DispatcherState dispatcherState = getKeyDispatcherState();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the above block the variable is just referenced as state. Could the names be consistent? Either name is fine for me.

@emilsjolander
Copy link
Contributor

Just a couple small comments otherwise it looks good. Sorry for the extended delay.

ZacSweers added a commit that referenced this pull request Jul 23, 2015
Listen for back button press
@ZacSweers ZacSweers merged commit 2281d96 into Flipboard:master Jul 23, 2015
@ZacSweers
Copy link
Contributor

Merged and updated the API after

@iPaulPro
Copy link
Contributor Author

Sorry about that! Been super busy. Thanks :-)

@ZacSweers
Copy link
Contributor

No worries, thanks for the PR! This is released now in v1.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants