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

Added ability to hide buttons/alert views #1251

Merged
merged 1 commit into from
Sep 24, 2018

Conversation

devotaaabel
Copy link
Contributor

@devotaaabel devotaaabel commented Aug 31, 2018

Closes #1217 and relates to #1216

@devotaaabel devotaaabel added this to the 0.18.0 milestone Aug 31, 2018
@devotaaabel devotaaabel self-assigned this Aug 31, 2018
@devotaaabel devotaaabel force-pushed the devota-allow-hiding-of-components branch from ce8fe34 to 81e80b8 Compare August 31, 2018 16:19
@danesfeder danesfeder modified the milestones: 0.18.0, 0.19.0 Sep 4, 2018
@devotaaabel devotaaabel added ⚠️ DO NOT MERGE PR should not be merged! and removed ✓ ready for review labels Sep 4, 2018
@devotaaabel devotaaabel force-pushed the devota-allow-hiding-of-components branch 7 times, most recently from 0ee06db to 858d8af Compare September 7, 2018 18:58
@devotaaabel devotaaabel added ✓ ready for review and removed ⚠️ DO NOT MERGE PR should not be merged! labels Sep 7, 2018
Copy link
Contributor

@danesfeder danesfeder left a comment

Choose a reason for hiding this comment

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

@devotaaabel this is looking great - I love that we are able to remove some code from InstructionView.

Just some general comments and cleanup. Can you add javadoc for all public interfaces and methods? Also, can we update the method declaration to public > protected > private -- saw some out of order (SoundButton) and figured I'd call it out before @Guardiola31337 does 😉

public class FeedbackButton extends ConstraintLayout implements NavigationButton {
private FloatingActionButton feedbackFab;
private List<OnClickListener> onClickListeners;

This comment was marked as resolved.

@@ -586,29 +476,25 @@ private void addBottomSheetListener() {
}

private void initializeClickListeners() {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can update the naming here to better describe the button setup functions it's calling

@@ -809,7 +695,7 @@ private void hideThenStepLayout() {
}

@Nullable
private FragmentManager obtainSupportFragmentManger() {
private FragmentManager obtainSupportFragmentManager() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice typo catch here 😅

show(NavigationConstants.FEEDBACK_SUBMITTED, 3000, false);
}

public void showReportProblemFor3Seconds() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than hardcode this to 3Seconds can we update to showReportProblemFor(int seconds), passing in the constant at the call site?

@devotaaabel devotaaabel force-pushed the devota-allow-hiding-of-components branch from 858d8af to 8d1c28e Compare September 10, 2018 19:41
@devotaaabel
Copy link
Contributor Author

@danesfeder ready for re-review

@devotaaabel devotaaabel force-pushed the devota-allow-hiding-of-components branch 3 times, most recently from 5d30c0d to 2d256c2 Compare September 11, 2018 19:49
Copy link
Contributor

@danesfeder danesfeder left a comment

Choose a reason for hiding this comment

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

@devotaaabel thanks for the updates 🚀

Just a couple minor comments / questions

@@ -342,6 +327,14 @@ public void setDistanceFormatter(DistanceFormatter distanceFormatter) {
}
}

public NavigationButton retrieveSoundButton() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Still missing some javadoc here and retrieveFeedbackButton

*
* @param navigationViewModel to set
*/
public void setModel(NavigationViewModel navigationViewModel) {
Copy link
Contributor

Choose a reason for hiding this comment

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

To align method naming here, does it make sense to update this to subscribe like InstructionView#subscribe(NavigationViewModel)?

@devotaaabel devotaaabel force-pushed the devota-allow-hiding-of-components branch from fcf2bdc to 71837ba Compare September 18, 2018 14:21
@devotaaabel
Copy link
Contributor Author

@danesfeder ready for re-review

@Guardiola31337
Copy link
Contributor

Originally reported by @zeallat in #1301

I want to create custom SummaryBottomSheet and InstructionView, but it seems no features are provide for this. So I want to hide original SummaryBottomSheet and InstructionView and generate other.

How can I set visibility(especially View.GONE) of SummaryBottomSheet and InstructionView?
Many thanks for read this issue.


Is it possible to include this feature request as part of this PR @devotaaabel? Does that make sense at all? If not, feel free to re-open #1301 and we can fix in a different PR. What do you think @devotaaabel?

@devotaaabel
Copy link
Contributor Author

@Guardiola31337 I think we should communicate with the developer about creating their own custom view to allow for custom components before adding the ability to hide.

@devotaaabel devotaaabel force-pushed the devota-allow-hiding-of-components branch from 71837ba to 8b88cc3 Compare September 20, 2018 12:43
@Guardiola31337
Copy link
Contributor

@devotaaabel

I think we should communicate with the developer about creating their own custom view to allow for custom components before adding the ability to hide.

Followed up in 👉 #1301 (comment)

Let's hold off in adding this feature here and revisit later if finally needed (seems overkill anyways).

Will give a final round of 👀 and we can merge here 🚀

@devotaaabel devotaaabel force-pushed the devota-allow-hiding-of-components branch from 8b88cc3 to 0e2ab24 Compare September 20, 2018 13:24
Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

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

Overall this looks good @devotaaabel Great work 👏

Left some minor comments / questions and cleanup before merging here.

void addOnClickListener(View.OnClickListener onClickListener);

/**
* Hides the widget
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor thing - Should this be button (instead of widget) to better reflect what's state in the interface name? The other way around could also work i.e. naming the interface NavigationWidget but not sure if that would make sense though for all the cases in which it's implemented. It seems there are all "buttons" after all.

void hide();

/**
* Shows the widget
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here ☝️

}

/**
* Returns the feedback button for sending feedback about the maps
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor thing - about the *navigation (instead of maps) would better describe what the feedback button allows you to do.

return instructionView.retrieveFeedbackButton();
}

public NavigationButton retrieveRecenterButton() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Still missing some Javadoc here.

private void setupOnClickListeners() {
onClickListeners = new ArrayList<>();

setOnClickListener(new OnClickListener() {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about extracting the listener into a class property?

Same thing happens in FeedbackButton and SoundButton.

}

private void setupSoundButton() {
soundButton.addOnClickListener(new View.OnClickListener() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here ☝️

Copy link
Contributor

Choose a reason for hiding this comment

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

Minor thing - View. is not needed (OnClickListener is enough as in setupFeedbackButton ☝️)

* Shows this alert view for when feedback is submitted
*/
public void showFeedbackSubmitted() {
show(NavigationConstants.FEEDBACK_SUBMITTED, 3000, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT Magic number


private void showReportProblem() {
show(NavigationConstants.REPORT_PROBLEM,
NavigationConstants.ALERT_VIEW_PROBLEM_DURATION, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT unnecessary new line

@Override
protected void onFinishInflate() {
super.onFinishInflate();
setOnClickListener(new View.OnClickListener() {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about extracting the listener into a class property?

}

private void initializeAnimation() {
Animation fadeIn = new AlphaAnimation(0, 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Magic numbers ☝️ 👇

@devotaaabel devotaaabel force-pushed the devota-allow-hiding-of-components branch from 0e2ab24 to d49c154 Compare September 21, 2018 15:41
Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @devotaaabel 🚀

Just a couple minor comments / questions

import android.util.AttributeSet;

public class FeedbackButton extends ConstraintLayout implements NavigationButton {
private FloatingActionButton feedbackFab;
Copy link
Contributor

Choose a reason for hiding this comment

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

Private field 'feedbackFab' is assigned but never accessed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Guardiola31337 I meant to add the listener to the FAB and not the whole widget. It is corrected

}

/**
* Hides the widget
Copy link
Contributor

Choose a reason for hiding this comment

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

}

/**
* Shows the widget
Copy link
Contributor

Choose a reason for hiding this comment

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


class MultiOnClickListener implements View.OnClickListener {
private Set<View.OnClickListener> onClickListeners;

Copy link
Contributor

Choose a reason for hiding this comment

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

NIT unnecessary new line

onClickListeners.add(onClickListener);
}

void removeListener(View.OnClickListener onClickListener) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Saw that although we're adding listeners using the above API addListener

recenterBtn.addOnClickListener(new RecenterBtnClickListener(navigationPresenter));
we're not calling the removeListener counterpart at all 🤔

Shouldn't we add calls where appropriate to avoid potential memory leaks?

if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
Drawable soundChipBackground = DrawableCompat.wrap(soundChipText.getBackground()).mutate();
int navigationViewPrimaryColor = ThemeSwitcher.retrieveThemeColor(getContext(),
R.attr.navigationViewPrimary);
Copy link
Contributor

Choose a reason for hiding this comment

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

* Gets the sound button which is used for muting/unmuting, for uses such as adding listeners and
* hiding the button.
*
* @return Sound button with {@link NavigationButton} API
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor thing - sound should be lowercase

* Gets the feedback button which is used for sending feedback, for uses such as adding listeners
* and hiding the button.
*
* @return Feedback button with {@link NavigationButton} API
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor thing - feedback should be lowercase

}

private void setupSoundButton() {
soundButton.addOnClickListener(new View.OnClickListener() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor thing - View. is not needed (OnClickListener is enough as in setupFeedbackButton ☝️)

@Override
public void run() {
show(NavigationConstants.REPORT_PROBLEM,
NavigationConstants.ALERT_VIEW_PROBLEM_DURATION, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

@devotaaabel devotaaabel force-pushed the devota-allow-hiding-of-components branch from 2f5d53a to 190e8b2 Compare September 24, 2018 19:46
@devotaaabel devotaaabel force-pushed the devota-allow-hiding-of-components branch from 190e8b2 to d45f212 Compare September 24, 2018 19:57
Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

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

Thanks for addressing all the comments @devotaaabel :shipit:

@devotaaabel devotaaabel merged commit 2d92c9b into master Sep 24, 2018
@devotaaabel devotaaabel deleted the devota-allow-hiding-of-components branch September 24, 2018 20:26
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.

3 participants