[Android] Parse social pages links in POI editor #1545
Labels
No labels
Accessibility
Address
Android
Android Auto
Android Automotive (AAOS)
API
AppGallery
AppStore
Battery and Performance
Blocker
Bookmarks and Tracks
Borders
Bug
Build
CarPlay
Classificator
Community
Core
CrashReports
Cycling
Desktop
DevEx
DevOps
dev_sandbox
Directions
Documentation
Downloader
Drape
Driving
Duplicate
Editor
Elevation
Enhancement
Epic
External Map Datasets
F-Droid
Fonts
Frequently User Reported
Fund
Generator
Good first issue
Google Play
GPS
GSoC
iCloud
Icons
iOS
Legal
Linux Desktop
Linux packaging
Linux Phone
Mac OS
Map Data
Metro
Navigation
Need Feedback
Night Mode
NLnet 2024-06-281
No Feature Parity
Opening Hours
Outdoors
POI Info
Privacy
Public Transport
Raw Idea
Refactoring
Regional
Regression
Releases
RoboTest
Route Planning
Routing
Ruler
Search
Security
Styles
Tests
Track Recording
Translations
TTS
UI
UX
Walk Navigation
Watches
Web
Wikipedia
Windows
Won't fix
World Map
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: organicmaps/organicmaps#1545
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "github/fork/strump/issue-1397-android-editor-process-social-link"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Moved Facebook, Instagram, Twitter, VK cleanup functions from "generator" to "indexer".
Added call to
ValidateAndFormat_*
functions on social links edit.Fixed
contact:line
validation. Empty string is now correct value.Closes #1397
Closes #1546
Updated 15.11.2021
Renamed
contacts_processor
tovalidate_and_format_contacts
.Moved functions
ValidateFacebookPage
,ValidateInstagramPage
,ValidateTwitterPage
,ValidateVkPage
,ValidateLinePage
tovalidate_and_format_contacts.hpp/.cpp
Moved social network tests to separate file
validate_and_format_contacts_test.cpp
. Also addedcontact:line
tests there (no more issue #1546 😁 )Updated XCode project to fix iOS build.
mentioned in issue #1546
After I moved some functions from "generator" to "indexer" there could be uncertainty in
osm2meta.hpp
:Maybe we should rename
ValidateAndFormat_*
static functions for clarity?We sort includes by alphabet inside one include block.
validate_and_format_contacts would be a better name.
This else is redundant.
string const
.string const &
Redundant.
Redundant.
Redundant.
Redundant.
nit: easier to debug if the "if's" block (return here) is on the next line. And it is also in our style guide.
Redundant.
All these methods take
string const &
. Then you don't need to create a copy of the string in the function argument by usingstring facebookPage
(yes, in C++ this declaration creates a copy of the passed parameter). Usestring const & facebookPage
here and in other functions.approved this merge request
renamed to
validate_and_format_contacts.hpp
and sorted includes alphabetially.renamed to
validate_and_format_contacts
Fixed
Fixed
Done!
Done
Fixed
Fixed
Moved return to next line
Fixed
Changed argument type
approved this merge request
Moved regex's to static variables to reuse same regular expressions in validation and formatting functions. Now all regexes could be found at first lines of
validate_and_format_contacts.cpp
.Looks like I'm done with this PR 🕺🏻
nit: redundant else :)
nit: To make the code easier to read, and shift code below to the left by two spaces, and remove bracers, you can negate this if and immediately
return {};
nit: The same: Negating if removes the indentation below.
nit: & is redundant.
nit: & is redundant.
nit: & is redundant.
nit: & is redundant.
nit:
} // namespace osm
nit^2: . at the ends of sentences ;-)
nit^3: const position ;-)
nit: & is redundant.
nit: This part can be simpler and a bit faster by either adding an optional @ at the beginning of the regex, or using this approach:
nit: As you don't really need/use url object, the code can be shorter:
nit: Negate the if, return false, and make the code shorter without bracers.
nit^2: const :)
If webPath is empty, the code will crash below.
nit: Negate the if to simplify indentation and remove lines with bracers.
You can use this approach:
See how to properly fix this crash below.
See how to properly fix this crash below.
Review: Changes requested
Thank you very much! With every iteration your understanding of C++ beauty grows further and further ;-) I hope you enjoy it and don't hate me for the feedback :)
Нет предела совершенству!
Э, как-то сложно. Судя по логике, pop_back и pop_front будет просто и достаточно, ну и конечно надо проверить на empty предварительно.
Тогда на empty придётся проверять дважды. Это самый простой способ, он ещё кстати обработает @@@@
Simplified if() statement. But also added parentheses
(vkLogin.front() == '_' && vkLogin.back() == '_')
Get rid of
.back()
method using your adviceGet rid of
.back()
method using your adviceNegated if() statement
Get rid of
.back()
method using your adviceSimplified if() statement. But also added parentheses
(vkLogin.front() == '_' && vkLogin.back() == '_')
Simplified this block using negated
if (!EditableMapObject::ValidateWebsite(page))
Done
I personally don't like such one-liners because it's hard to read. Replaced with
if (regex_match(stripAtSymbol(page), s_lineRegex))
Done
Done
Done
Done
Done
Updated type declaration
Done (+ const)
Done (+ const)
Nedated if() statement
Done
Fixed
It appeared that
Url::FromString
method handles HTTP(S) protocol correctly. So I removed all checks for"http://"
and"https://"
invalidate_and_format_contacts.cpp
code and use onlyUrl::FromString(...)
. Also fixed comments and const variable definitions.Unit-tests didn't fail, so hope nothing broke 🤞
Current implementation of the Url class has some bugs now. For example, this works:
@biodranik
invalidate_and_format_contact.cpp
code I useUrl::FromString(page)
only after callingEditableMapObject::ValidateWebsite(page)
. We can add invalid urls to unit-testI don't mind to merge. Url::FromString is not changed in this PR and it's called after url validation. We don't break any constrains comparing to the master branch. If we want some refactoring, let's make separate PR, otherwise we will stuck here for a long time.
Thank you for your huge work and time! I hope you learned something new on the way :)