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

PR for #149 location opens map #270

Closed
wants to merge 13 commits into from

Conversation

lemonboston
Copy link
Contributor

Linking to #149.

@dmfs please review.

I haven't tested with XmlModel, only with local tasks and DefaultModel. Should I test with XmlModel too, and if yes, could you please advise how can I do that, where to create account, etc?

private void init()
{
mMapOpener = new MapOpener(getContext());
mGestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener()
Copy link
Owner

@dmfs dmfs Sep 19, 2016

Choose a reason for hiding this comment

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

Can't you just make the text view or the LocationFieldView clickable?
Why the GestureDetector?

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 spent about 2 hours trying to make the clickable thing work and I couldn't. There is of course a chance that I missed something, so let me know if I should check again and spend like 1 hour more with it.
(I tried with clickable, focusable combinations on parent and child views and some other suggestion I found on StackOverflow.)

Copy link
Owner

Choose a reason for hiding this comment

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

The problem is that you inherit from TextFieldView. TextFieldView "linkifies" the TextView which consumes any clicks instead of passing them to the underlying LinearLayout.

I suggest to not subclass TextFieldView. Either create an AbstractTextView that both classes inherit from or just duplicate the methods in TextFieldView. Remember that subclassing non-abstract classes is evil ;-) (yeah, I know that we probably still do that in other places of this code base).

In this particular case I'd actually prefer the code duplication, because we're dealing with a lot of mutable dependencies (the UI) and I'd like to avoid any side effects like this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, thanks for the tip, the culprit was android:textIsSelectable="true" in the style of the TextViews.
Setting that to false allows clicking on the LinearLayout now.
LocationFieldView is no not the child of TextFieldView in the new PR.


public String getText()
{
return mText.getText().toString();
Copy link
Owner

Choose a reason for hiding this comment

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

Don't use UI components for business logic. UI is either output or input, you're using it like a variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I see, that felt a little bit wrong to me too, but on the other hand I thought user would probably want to search for location that is displayed, whatever that is.
But I changed TextFieldView now to save the actual text in a field and use that for the getter. Please check if it's good like that.

*
* @author Gabor Keszthelyi
*/
public class MapOpener
Copy link
Owner

Choose a reason for hiding this comment

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

This class doesn't feel right and probably shouldn't exist. I suggest to make this a private method of the LocationFieldView.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved it to private method.

@lemonboston
Copy link
Contributor Author

@dmfs please check comments above, otherwise it's ready for review again from my side

@dmfs
Copy link
Owner

dmfs commented Oct 3, 2016

This just crashed in my emulator:

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: org.dmfs.tasks, PID: 2159
                  android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=geo:0,0?q=New York }
                      at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1765)

@dmfs
Copy link
Owner

dmfs commented Oct 3, 2016

If there is no app to open the geo URI scheme, we should fall back to opening Google Maps in a browser.

@lemonboston
Copy link
Contributor Author

Yeah, that's a mistake, I should have checked if the intent could be resolved.. fixed it. And it falls back to opening http://maps.google.com/?q=<location> now.

@dmfs Ready for review again.

@dmfs
Copy link
Owner

dmfs commented Oct 9, 2016

Please remove the GestureDetector (as per my inline comment). Also, squash all commits into a single one and submit a new PR (you'll probably have to push into a new branch).

…Detector, make LinerLayout onClick work by setting textIsSelectable=false on child views (overriding style).
@lemonboston
Copy link
Contributor Author

Made the changes and squashed the commits, new PR is #285.
Closing this one.

@dmfs dmfs deleted the issues/149-location-opens-map branch March 29, 2017 22:41
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.

2 participants