-
Notifications
You must be signed in to change notification settings - Fork 319
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
Conversation
ce8fe34
to
81e80b8
Compare
0ee06db
to
858d8af
Compare
There was a problem hiding this 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.
This comment was marked as resolved.
Sorry, something went wrong.
@@ -586,29 +476,25 @@ private void addBottomSheetListener() { | |||
} | |||
|
|||
private void initializeClickListeners() { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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?
858d8af
to
8d1c28e
Compare
@danesfeder ready for re-review |
5d30c0d
to
2d256c2
Compare
There was a problem hiding this 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() { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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)
?
fcf2bdc
to
71837ba
Compare
@danesfeder ready for re-review |
Originally reported by @zeallat in #1301
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? |
@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. |
71837ba
to
8b88cc3
Compare
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 🚀 |
8b88cc3
to
0e2ab24
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here ☝️
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic numbers ☝️ 👇
0e2ab24
to
d49c154
Compare
There was a problem hiding this 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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
/** | ||
* Shows the widget |
There was a problem hiding this comment.
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; | ||
|
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
Line 480 in 2f5d53a
feedbackButton.addOnClickListener(new OnClickListener() { |
Line 490 in 2f5d53a
soundButton.addOnClickListener(new View.OnClickListener() { |
Line 562 in 2f5d53a
recenterBtn.addOnClickListener(new RecenterBtnClickListener(navigationPresenter)); |
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2f5d53a
to
190e8b2
Compare
190e8b2
to
d45f212
Compare
There was a problem hiding this 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
Closes #1217 and relates to #1216