[Android] Multiple place phones (#845)

* Added parsing of semicolon separated phones. Added multiple phones on place details UI.
Call button on place page now shows popup if case of multiple phone numbers.
Edit UI changes. Replace phone input field with text view and new PhoneFragment.
Added phones validation on save.

Signed-off-by: S. Kozyr <s.trump@gmail.com>

* Reformatter code. Removed commented code.

Signed-off-by: S. Kozyr <s.trump@gmail.com>

* Reformatted code

Signed-off-by: S. Kozyr <s.trump@gmail.com>

* Added RecyclerView to show multiple phones on a place details fragment.

Signed-off-by: S. Kozyr <s.trump@gmail.com>

* Changed layout to support RTL languages and removed redundant attributes.
Extracted new string "editor_add_phone" = "Add phone".

Signed-off-by: S. Kozyr <s.trump@gmail.com>

* Added "phone_number" string value.

Signed-off-by: S. Kozyr <s.trump@gmail.com>

* Removed unused code. Fixed formatting

Signed-off-by: S. Kozyr <s.trump@gmail.com>

* Reverted "phone_number" string

Signed-off-by: S. Kozyr <s.trump@gmail.com>

* Formatter strings.xml using `clean_strings_txt.py`

Signed-off-by: S. Kozyr <s.trump@gmail.com>

Co-authored-by: Roman Tsisyk <roman@tsisyk.com>
This commit is contained in:
Sergiy Kozyr 2021-07-25 01:27:48 +03:00 committed by GitHub
parent 9922c9d63c
commit 6dc57fd452
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 603 additions and 37 deletions

View file

@ -144,9 +144,35 @@
<include
android:id="@+id/block_opening_hours"
layout="@layout/item_opening_hours"/>
<include
android:id="@+id/block_phone"
layout="@layout/item_editor_input"/>
<RelativeLayout
android:id="@+id/block_phone"
style="@style/MwmWidget.Editor.MetadataBlock.Clickable">
<ImageView
style="@style/MwmWidget.Editor.MetadataIcon"
android:src="@drawable/ic_phone"
tools:ignore="ContentDescription"/>
<TextView
android:id="@+id/phone"
style="@style/MwmWidget.Editor.FieldLayout.EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/editor_margin_left"
android:layout_toStartOf="@+id/edit_phone"/>
<TextView
android:id="@+id/edit_phone"
android:layout_marginStart="@dimen/margin_half_plus"
android:background="?clickableBackground"
android:gravity="center_vertical"
android:text="@string/edit"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:textAppearance="@style/MwmTextAppearance.Body1"
android:textColor="?colorAccent"/>
</RelativeLayout>
<include
android:id="@+id/block_website"
layout="@layout/item_editor_input"/>

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<FrameLayout
style="@style/MwmWidget.FrameLayout.Elevation"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?windowBackgroundForced"
android:layout_above="@+id/tv__mode_switch"
android:layout_below="@id/toolbar">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/phones_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?cardBackground"
android:scrollbars="vertical" />
</FrameLayout>
<TextView
android:id="@+id/tv__append_phone"
android:layout_width="match_parent"
android:layout_height="@dimen/height_block_base"
android:layout_alignParentBottom="true"
android:background="?clickableBackground"
android:gravity="center_vertical"
android:padding="@dimen/margin_base"
android:text="@string/editor_add_phone"
android:textAllCaps="true"
android:textAppearance="@style/MwmTextAppearance.Body3"
android:textColor="?colorAccent"/>
<include
layout="@layout/shadow_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/tv__mode_switch"/>
</RelativeLayout>

View file

@ -0,0 +1,44 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/height_item_oneline"
android:background="?clickableBackground"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="@dimen/margin_half_plus"
android:paddingEnd="@dimen/margin_half">
<ImageView
android:id="@+id/phone_icon"
style="@style/MwmWidget.Editor.MetadataIcon"
tools:ignore="ContentDescription"
tools:src="@drawable/ic_phone"
android:layout_alignParentLeft="true"/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/phone_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/margin_half"
android:layout_toEndOf="@id/phone_icon"
android:layout_toStartOf="@id/delete_icon"
android:textColorHint="?android:textColorSecondary">
<EditText
android:id="@+id/input"
style="@style/MwmWidget.Editor.FieldLayout.EditText"
tools:hint="Hint"
tools:text="Input"
android:inputType="phone"/>
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="@+id/delete_icon"
style="@style/MwmWidget.Editor.MetadataIcon"
tools:ignore="ContentDescription"
tools:src="@drawable/ic_delete"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout>

View file

@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?windowBackgroundForced"
android:orientation="vertical">
@ -42,7 +43,12 @@
<include layout="@layout/place_page_entrance"/>
<include layout="@layout/place_page_phone"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rw__phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?cardBackground"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
<include layout="@layout/place_page_website"/>

View file

@ -4,9 +4,10 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ll__place_phone"
style="@style/PlacePageItemFrame"
android:tag="phone"
tools:background="#2000FF00"
tools:visibility="visible">
android:orientation="horizontal"
android:visibility="visible"
android:tag="phone">
<ImageView
android:id="@+id/iv__place_phone"

View file

@ -603,6 +603,7 @@
<string name="bookmarks_error_title_list_name_already_taken">هذا الاسم أخذ سابقا</string>
<string name="bookmarks_error_message_list_name_already_taken">يرجى اختيار اسم آخر</string>
<string name="please_wait">أرجو الإنتظار…</string>
<string name="phone_number">رقم الهاتف</string>
<string name="profile">الملف الشخصي OpenStreetMap</string>
<string name="place_page_search_similar_hotel">ابحث عن فنادق مماثلة</string>
<string name="bookmarks_detect_title">تم اكتشاف ملفات جديدة</string>

View file

@ -601,6 +601,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Toto jméno již bylo provedeno</string>
<string name="bookmarks_error_message_list_name_already_taken">Zvolte jiný název</string>
<string name="please_wait">Prosím, čekejte…</string>
<string name="phone_number">Telefonní číslo</string>
<string name="profile">Profil OpenStreetMap</string>
<string name="place_page_search_similar_hotel">Hledat podobné hotely</string>
<string name="bookmarks_detect_title">Byly zjištěny nové soubory</string>

View file

@ -603,6 +603,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Dette navn er allerede taget</string>
<string name="bookmarks_error_message_list_name_already_taken">Vælg venligst et andet navn</string>
<string name="please_wait">Vent venligst…</string>
<string name="phone_number">Telefonnummer</string>
<string name="profile">OpenStreetMap profil</string>
<string name="place_page_search_similar_hotel">Søg lignende hoteller</string>
<string name="bookmarks_detect_title">Nye filer registreret</string>

View file

@ -605,6 +605,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Dieser Name ist bereits vergeben</string>
<string name="bookmarks_error_message_list_name_already_taken">Bitte wähle einen anderen Namen</string>
<string name="please_wait">Warten Sie mal…</string>
<string name="phone_number">Telefonnummer</string>
<string name="profile">OpenStreetMap-Profil</string>
<string name="place_page_search_similar_hotel">Nach ähnlichen Hotels suchen</string>
<string name="bookmarks_detect_title">Neue Dateien erkannt</string>

View file

@ -599,6 +599,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Αυτό το όνομα έχει ήδη ληφθεί</string>
<string name="bookmarks_error_message_list_name_already_taken">Επιλέξτε άλλο όνομα</string>
<string name="please_wait">Παρακαλώ περιμένετε…</string>
<string name="phone_number">Τηλεφωνικό νούμερο</string>
<string name="profile">Προφίλ OpenStreetMap</string>
<string name="place_page_search_similar_hotel">Αναζήτηση παρόμοιων ξενοδοχείων</string>
<string name="bookmarks_detect_title">Εντοπίστηκαν νέα αρχεία</string>

View file

@ -599,6 +599,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Este nombre ya ha sido tomado</string>
<string name="bookmarks_error_message_list_name_already_taken">Por favor elige otro nombre</string>
<string name="please_wait">Por favor espera…</string>
<string name="phone_number">Número de teléfono</string>
<string name="profile">Perfil de OpenStreetMap</string>
<string name="place_page_search_similar_hotel">Buscar hoteles similares</string>
<string name="bookmarks_detect_title">Nuevos archivos detectados</string>

View file

@ -593,6 +593,7 @@
<string name="bookmarks_error_title_list_name_already_taken">این اسم قبلا انتخاب شده است</string>
<string name="bookmarks_error_message_list_name_already_taken">لطفا نام دیگری را انتخاب کنید</string>
<string name="please_wait">لطفا صبر کنید…</string>
<string name="phone_number">شماره تلفن</string>
<string name="profile">OpenStreetMap نمایه</string>
<string name="place_page_search_similar_hotel">جست‌وجوی هتل‌های مشابه</string>
<string name="bookmarks_detect_title">فایل‌های جدید پیدا شد</string>

View file

@ -603,6 +603,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Tämä nimi on jo otettu</string>
<string name="bookmarks_error_message_list_name_already_taken">Valitse toinen nimi</string>
<string name="please_wait">Odota…</string>
<string name="phone_number">Puhelinnumero</string>
<string name="profile">OpenStreetMap-profiili</string>
<string name="place_page_search_similar_hotel">Etsi samanlaisia hotelleja</string>
<string name="bookmarks_detect_title">Uusia tiedostoja havaittiin</string>

View file

@ -609,6 +609,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Ce nom est déjà pris</string>
<string name="bookmarks_error_message_list_name_already_taken">Merci de choisir un autre nom</string>
<string name="please_wait">S\'il vous plaît, attendez…</string>
<string name="phone_number">Numéro de téléphone</string>
<string name="profile">Profil OpenStreetMap</string>
<string name="place_page_search_similar_hotel">Rechercher des hôtels similaires</string>
<string name="bookmarks_detect_title">Nouveaux fichiers détectés</string>

View file

@ -600,6 +600,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Ez a név már foglalt</string>
<string name="bookmarks_error_message_list_name_already_taken">Kérjük, válasszon másik nevet</string>
<string name="please_wait">Kérlek várj…</string>
<string name="phone_number">Telefonszám</string>
<string name="profile">OpenStreetMap profil</string>
<string name="place_page_search_similar_hotel">Hasonló szálláshelyek keresése</string>
<string name="bookmarks_detect_title">Új fájlokat észleltek</string>

View file

@ -602,6 +602,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Nama ini sudah dipakai</string>
<string name="bookmarks_error_message_list_name_already_taken">Silakan pilih nama lain</string>
<string name="please_wait">Mohon tunggu…</string>
<string name="phone_number">Nomor telepon</string>
<string name="profile">Profil OpenStreetMap</string>
<string name="place_page_search_similar_hotel">Cari hotel serupa</string>
<string name="bookmarks_detect_title">File baru terdeteksi</string>

View file

@ -599,6 +599,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Questo nome è già stato scelto</string>
<string name="bookmarks_error_message_list_name_already_taken">Si prega di scegliere un altro nome</string>
<string name="please_wait">Attendere prego…</string>
<string name="phone_number">Numero di telefono</string>
<string name="profile">Profilo OpenStreetMap</string>
<string name="place_page_search_similar_hotel">Cerca hotel simili</string>
<string name="bookmarks_detect_title">Nuovi file rilevati</string>

View file

@ -599,6 +599,7 @@
<string name="bookmarks_error_title_list_name_already_taken">この名前はすでに使用されています</string>
<string name="bookmarks_error_message_list_name_already_taken">別の名前を選んでください</string>
<string name="please_wait">お待ちください…</string>
<string name="phone_number">電話番号</string>
<string name="profile">OpenStreetMap プロフィール</string>
<string name="place_page_search_similar_hotel">類似のホテルを検索</string>
<string name="bookmarks_detect_title">新しいファイルが検出されました</string>

View file

@ -601,6 +601,7 @@
<string name="bookmarks_error_title_list_name_already_taken">이 이름은 이미 사용 중입니다.</string>
<string name="bookmarks_error_message_list_name_already_taken">다른 이름을 선택하십시오.</string>
<string name="please_wait">잠시만 기다려주십시오…</string>
<string name="phone_number">전화 번호</string>
<string name="profile">OpenStreetMap 프로필</string>
<string name="place_page_search_similar_hotel">비슷한 호텔 검색</string>
<string name="bookmarks_detect_title">새 파일이 감지되었습니다.</string>

View file

@ -601,6 +601,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Dette navnet er allerede tatt</string>
<string name="bookmarks_error_message_list_name_already_taken">Vennligst velg et annet navn</string>
<string name="please_wait">Vennligst vent…</string>
<string name="phone_number">Telefonnummer</string>
<string name="profile">OpenStreetMap profil</string>
<string name="place_page_search_similar_hotel">Søk lignende hoteller</string>
<string name="bookmarks_detect_title">Nye filer oppdaget</string>

View file

@ -598,6 +598,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Deze naam is al in gebruik</string>
<string name="bookmarks_error_message_list_name_already_taken">Kies alstublieft een andere naam</string>
<string name="please_wait">Even geduld aub…</string>
<string name="phone_number">Telefoonnummer</string>
<string name="profile">OpenStreetMap-profiel</string>
<string name="place_page_search_similar_hotel">Zoek vergelijkbare hotels</string>
<string name="bookmarks_detect_title">Nieuwe bestanden gedetecteerd</string>

View file

@ -607,6 +607,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Ta nazwa jest już zajęta</string>
<string name="bookmarks_error_message_list_name_already_taken">Wybierz inną nazwę</string>
<string name="please_wait">Proszę czekać…</string>
<string name="phone_number">Numer telefonu</string>
<string name="profile">Profil OpenStreetMap</string>
<string name="place_page_search_similar_hotel">Wyszukaj podobne hotele</string>
<string name="bookmarks_detect_title">Wykryto nowe pliki</string>

View file

@ -603,6 +603,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Esse nome já foi levado</string>
<string name="bookmarks_error_message_list_name_already_taken">Por favor, escolha outro nome</string>
<string name="please_wait">Por favor, espere…</string>
<string name="phone_number">Número de telefone</string>
<string name="profile">Perfil do OpenStreetMap</string>
<string name="place_page_search_similar_hotel">Pesquisar hotéis semelhantes</string>
<string name="bookmarks_detect_title">Novos arquivos detectados</string>

View file

@ -602,6 +602,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Acest nume este deja luat</string>
<string name="bookmarks_error_message_list_name_already_taken">Alegeți un alt nume</string>
<string name="please_wait">Te rog asteapta…</string>
<string name="phone_number">Numar de telefon</string>
<string name="profile">Profil OpenStreetMap</string>
<string name="place_page_search_similar_hotel">Căutați hoteluri similare</string>
<string name="bookmarks_detect_title">Au fost detectate fișiere noi</string>

View file

@ -613,6 +613,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Такое имя уже занято</string>
<string name="bookmarks_error_message_list_name_already_taken">Выберите, пожалуйста, другое имя</string>
<string name="please_wait">Пожалуйста, подождите…</string>
<string name="phone_number">Номер телефона</string>
<string name="profile">Профиль OpenStreetMap</string>
<string name="place_page_search_similar_hotel">Найти похожие отели</string>
<string name="bookmarks_detect_title">Обнаружены новые файлы</string>

View file

@ -599,6 +599,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Tento názov už bol prijatý</string>
<string name="bookmarks_error_message_list_name_already_taken">Vyberte iné meno</string>
<string name="please_wait">Prosím čakajte…</string>
<string name="phone_number">Telefónne číslo</string>
<string name="profile">Profil OpenStreetMap</string>
<string name="place_page_search_similar_hotel">Vyhľadať podobné hotely</string>
<string name="bookmarks_detect_title">Zistené nové súbory</string>

View file

@ -599,6 +599,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Det här namnet är redan taget</string>
<string name="bookmarks_error_message_list_name_already_taken">Vänligen välj ett annat namn</string>
<string name="please_wait">Vänligen vänta…</string>
<string name="phone_number">Telefonnummer</string>
<string name="profile">OpenStreetMap profil</string>
<string name="place_page_search_similar_hotel">Sök liknande hotell</string>
<string name="bookmarks_detect_title">Nya filer upptäcktes</string>

View file

@ -603,6 +603,7 @@
<string name="bookmarks_error_title_list_name_already_taken">ชื่อนี้ถูกนำมาใช้แล้ว</string>
<string name="bookmarks_error_message_list_name_already_taken">โปรดเลือกชื่ออื่น</string>
<string name="please_wait">โปรดรอสักครู่ …</string>
<string name="phone_number">หมายเลขโทรศัพท์</string>
<string name="profile">โปรไฟล์ OpenStreetMap</string>
<string name="place_page_search_similar_hotel">ค้นหาโรงแรมที่คล้ายกัน</string>
<string name="bookmarks_detect_title">พบไฟล์ใหม่แล้ว</string>

View file

@ -603,6 +603,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Bu isim zaten alınmış</string>
<string name="bookmarks_error_message_list_name_already_taken">Lütfen başka bir isim seçiniz</string>
<string name="please_wait">Lütfen bekle…</string>
<string name="phone_number">Telefon numarası</string>
<string name="profile">OpenStreetMap profil</string>
<string name="place_page_search_similar_hotel">Benzer otellerde ara</string>
<string name="bookmarks_detect_title">Yeni dosyalar algılandı</string>

View file

@ -604,6 +604,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Це ім\'я вже зайнято</string>
<string name="bookmarks_error_message_list_name_already_taken">Виберіть інше ім\'я</string>
<string name="please_wait">Будь ласка, зачекайте…</string>
<string name="phone_number">Номер телефону</string>
<string name="profile">Профіль OpenStreetMap</string>
<string name="place_page_search_similar_hotel">Шукати схожі готелі</string>
<string name="bookmarks_detect_title">Виявлено нові файли</string>

View file

@ -603,6 +603,7 @@
<string name="bookmarks_error_title_list_name_already_taken">Tên này đã được sử dụng</string>
<string name="bookmarks_error_message_list_name_already_taken">Vui lòng chọn một tên khác</string>
<string name="please_wait">Vui lòng chờ…</string>
<string name="phone_number">Số điện thoại</string>
<string name="profile">Hồ sơ OpenStreetMap</string>
<string name="place_page_search_similar_hotel">Tìm kiếm khách sạn</string>
<string name="bookmarks_detect_title">Đã phát hiện tệp mới</string>

View file

@ -605,6 +605,7 @@
<string name="bookmarks_error_title_list_name_already_taken">這個名字已經被使用了</string>
<string name="bookmarks_error_message_list_name_already_taken">請選擇其他名稱</string>
<string name="please_wait">請稍候…</string>
<string name="phone_number">電話號碼</string>
<string name="profile">OpenStreetMap 資料</string>
<string name="place_page_search_similar_hotel">搜索類似的酒店</string>
<string name="bookmarks_detect_title">檢測到新文件</string>

View file

@ -601,6 +601,7 @@
<string name="bookmarks_error_title_list_name_already_taken">这个名字已经被使用了</string>
<string name="bookmarks_error_message_list_name_already_taken">请选择其他名称</string>
<string name="please_wait">请稍候…</string>
<string name="phone_number">电话号码</string>
<string name="profile">OpenStreetMap 资料</string>
<string name="place_page_search_similar_hotel">搜索类似的酒店</string>
<string name="bookmarks_detect_title">检测到新文件</string>

View file

@ -404,6 +404,7 @@
<string name="editor_correct_mistake">Correct mistake</string>
<string name="editor_add_select_location">Location</string>
<string name="editor_done_dialog_1">Youve changed the world map. Do not keep it to yourself! Tell your friends, and edit it together.</string>
<string name="editor_add_phone">Add phone</string>
<string name="share_with_friends">Share with friends</string>
<string name="editor_report_problem_desription_1">Please describe the problem in detail so that the OpenStreeMap community can fix the error.</string>
<string name="editor_report_problem_desription_2">Or do it yourself at https://www.openstreetmap.org/</string>
@ -627,6 +628,7 @@
<string name="bookmarks_error_title_list_name_already_taken">This name is already taken</string>
<string name="bookmarks_error_message_list_name_already_taken">Please choose another name</string>
<string name="please_wait">Please wait…</string>
<string name="phone_number">Phone number</string>
<string name="profile">OpenStreetMap profile</string>
<string name="place_page_search_similar_hotel">Search similar hotels</string>
<string name="bookmarks_detect_title">New files detected</string>

View file

@ -97,7 +97,8 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
private EditText mZipcode;
private View mBlockLevels;
private EditText mBuildingLevels;
private EditText mPhone;
private TextView mPhone;
private TextView mEditPhoneLink;
private EditText mWebsite;
private EditText mEmail;
private TextView mCuisine;
@ -107,7 +108,6 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
private TextInputLayout mInputHouseNumber;
private TextInputLayout mInputBuildingLevels;
private TextInputLayout mInputZipcode;
private TextInputLayout mInputPhone;
private TextInputLayout mInputWebsite;
private TextInputLayout mInputEmail;
@ -170,14 +170,6 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
});
mPhone.setText(Editor.nativeGetPhone());
mPhone.addTextChangedListener(new StringUtils.SimpleTextWatcher()
{
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
UiUtils.setInputError(mInputPhone, Editor.nativeIsPhoneValid(s.toString()) ? 0 : R.string.error_enter_correct_phone);
}
});
mWebsite.setText(Editor.nativeGetWebsite());
mWebsite.addTextChangedListener(new StringUtils.SimpleTextWatcher()
@ -222,7 +214,6 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
Editor.nativeSetHouseNumber(mHouseNumber.getText().toString());
Editor.nativeSetZipCode(mZipcode.getText().toString());
Editor.nativeSetBuildingLevels(mBuildingLevels.getText().toString());
Editor.nativeSetPhone(mPhone.getText().toString());
Editor.nativeSetWebsite(mWebsite.getText().toString());
Editor.nativeSetEmail(mEmail.getText().toString());
Editor.nativeSetHasWifi(mWifi.isChecked());
@ -433,9 +424,10 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
mBuildingLevels.setInputType(InputType.TYPE_CLASS_NUMBER);
mInputBuildingLevels = mBlockLevels.findViewById(R.id.custom_input);
View blockPhone = view.findViewById(R.id.block_phone);
mPhone = findInputAndInitBlock(blockPhone, R.drawable.ic_phone, R.string.phone);
mPhone.setInputType(InputType.TYPE_CLASS_PHONE);
mInputPhone = blockPhone.findViewById(R.id.custom_input);
mPhone = blockPhone.findViewById(R.id.phone);
mEditPhoneLink = blockPhone.findViewById(R.id.edit_phone);
mEditPhoneLink.setOnClickListener(this);
mPhone.setOnClickListener(this);
View blockWeb = view.findViewById(R.id.block_website);
mWebsite = findInputAndInitBlock(blockWeb, R.drawable.ic_website, R.string.website);
mWebsite.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
@ -502,6 +494,9 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
case R.id.opening_hours:
mParent.editTimetable();
break;
case R.id.phone:
case R.id.edit_phone:
mParent.editPhone();
case R.id.block_wifi:
mWifi.toggle();
break;

View file

@ -27,6 +27,7 @@ import com.mapswithme.maps.editor.data.Language;
import com.mapswithme.maps.editor.data.LocalizedName;
import com.mapswithme.maps.editor.data.LocalizedStreet;
import com.mapswithme.maps.editor.data.NamesDataSource;
import com.mapswithme.maps.editor.data.PhoneFragment;
import com.mapswithme.maps.intent.Factory;
import com.mapswithme.maps.widget.SearchToolbarController;
import com.mapswithme.maps.widget.ToolbarController;
@ -48,7 +49,8 @@ public class EditorHostFragment extends BaseMwmToolbarFragment
OPENING_HOURS,
STREET,
CUISINE,
LANGUAGE
LANGUAGE,
PHONE
}
private Mode mMode;
@ -171,6 +173,7 @@ public class EditorHostFragment extends BaseMwmToolbarFragment
case STREET:
case CUISINE:
case LANGUAGE:
case PHONE:
editMapObject();
break;
default:
@ -206,6 +209,13 @@ public class EditorHostFragment extends BaseMwmToolbarFragment
editWithFragment(Mode.OPENING_HOURS, R.string.editor_time_title, args, TimetableContainerFragment.class, false);
}
protected void editPhone()
{
final Bundle args = new Bundle();
args.putString(PhoneFragment.EXTRA_PHONE_LIST, Editor.nativeGetPhone());
editWithFragment(Mode.PHONE, R.string.phone_number, args, PhoneFragment.class, false);
}
protected void editStreet()
{
editWithFragment(Mode.STREET, R.string.choose_street, null, StreetFragment.class, false);
@ -301,6 +311,14 @@ public class EditorHostFragment extends BaseMwmToolbarFragment
saveMapObjectEdits();
}
break;
case PHONE:
final String phone = ((PhoneFragment) getChildFragmentManager().findFragmentByTag(PhoneFragment.class.getName())).getPhone();
if (Editor.nativeIsPhoneValid(phone))
{
Editor.nativeSetPhone(phone);
editMapObject();
}
break;
}
}
}

View file

@ -0,0 +1,157 @@
package com.mapswithme.maps.editor;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.textfield.TextInputLayout;
import com.mapswithme.maps.R;
import com.mapswithme.util.StringUtils;
import com.mapswithme.util.UiUtils;
import java.util.ArrayList;
import java.util.List;
public class PhoneListAdapter extends RecyclerView.Adapter<PhoneListAdapter.ViewHolder>
{
private List<String> phonesData = new ArrayList<>();
public PhoneListAdapter()
{
phonesData.add("");
}
public PhoneListAdapter(String phoneList)
{
if (TextUtils.isEmpty(phoneList))
{
phonesData.add("");
return;
}
phonesData = new ArrayList<>();
for (String p : phoneList.split(";"))
{
p = p.trim();
if (TextUtils.isEmpty(p)) continue;
phonesData.add(p);
}
if (phonesData.size() == 0) phonesData.add("");
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
{
return new ViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_phone, parent, false));
}
@Override
public void onBindViewHolder(@NonNull PhoneListAdapter.ViewHolder holder, int position)
{
holder.setPosition(position);
holder.setPhone(phonesData.get(position));
}
@Override
public int getItemCount()
{
return phonesData.size();
}
@Override
public long getItemId(int position)
{
return position;
}
public void appendPhone()
{
phonesData.add("");
notifyDataSetChanged();
}
public String getPhoneList()
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < phonesData.size(); i++)
{
final String p = phonesData.get(i).trim();
if (!TextUtils.isEmpty(p))
{
if (sb.length() > 0)
sb.append(';');
sb.append(p);
}
}
return sb.toString();
}
protected class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener
{
private int mPosition = -1;
private final EditText mInput;
private final ImageView deleteButton;
public ViewHolder(@NonNull View itemView)
{
super(itemView);
mInput = itemView.findViewById(R.id.input);
final TextInputLayout phoneInput = itemView.findViewById(R.id.phone_input);
mInput.addTextChangedListener(new StringUtils.SimpleTextWatcher()
{
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
UiUtils.setInputError(phoneInput, Editor.nativeIsPhoneValid(s.toString()) ? 0 : R.string.error_enter_correct_phone);
PhoneListAdapter.this.updatePhoneItem(mPosition, mInput.getText().toString());
}
});
deleteButton = itemView.findViewById(R.id.delete_icon);
deleteButton.setOnClickListener(this);
// TODO: setting icons from code because icons defined in layout XML are white.
deleteButton.setImageResource(R.drawable.ic_delete);
((ImageView) itemView.findViewById(R.id.phone_icon)).setImageResource(R.drawable.ic_phone);
}
public void setPosition(int position)
{
mPosition = position;
}
public void setPhone(String phone)
{
if (!mInput.getText().toString().equals(phone))
mInput.setText(phone);
}
@Override
public void onClick(View view)
{
if (view.getId() == R.id.delete_icon)
PhoneListAdapter.this.deleteItem(mPosition);
}
}
private void updatePhoneItem(int position, String text)
{
if (position == -1) return;
phonesData.set(position, text);
}
void deleteItem(int position)
{
phonesData.remove(position);
notifyDataSetChanged();
}
}

View file

@ -0,0 +1,62 @@
package com.mapswithme.maps.editor.data;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmFragment;
import com.mapswithme.maps.editor.PhoneListAdapter;
public class PhoneFragment extends BaseMwmFragment implements View.OnClickListener
{
public static final String EXTRA_PHONE_LIST = "Phone";
private PhoneListAdapter mAdapter;
private RecyclerView mPhonesRecycler;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return inflater.inflate(R.layout.fragment_phone, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
final Bundle args = getArguments();
String phoneList = null;
if (args != null)
phoneList = args.getString(EXTRA_PHONE_LIST);
mAdapter = new PhoneListAdapter(phoneList);
mAdapter.setHasStableIds(true);
view.findViewById(R.id.tv__append_phone).setOnClickListener(this);
mPhonesRecycler = view.findViewById(R.id.phones_recycler);
LinearLayoutManager manager = new LinearLayoutManager(view.getContext());
manager.setSmoothScrollbarEnabled(true);
mPhonesRecycler.setLayoutManager(manager);
mPhonesRecycler.setAdapter(mAdapter);
}
public String getPhone()
{
return mAdapter != null ? mAdapter.getPhoneList() : null;
}
@Override
public void onClick(View view)
{
if (view.getId() == R.id.tv__append_phone)
{
if (mAdapter != null) mAdapter.appendPhone();
}
}
}

View file

@ -33,6 +33,7 @@ import androidx.appcompat.widget.Toolbar;
import androidx.core.widget.NestedScrollViewClickFixed;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.MwmActivity;
import com.mapswithme.maps.MwmApplication;
@ -95,8 +96,8 @@ public class PlacePageView extends NestedScrollViewClickFixed
private ArrowView mAvDirection;
private TextView mTvDistance;
private TextView mTvAddress;
private View mPhone;
private TextView mTvPhone;
private RecyclerView mPhoneRecycler;
private PlacePhoneAdapter mPhoneAdapter;
private View mWebsite;
private TextView mTvWebsite;
private TextView mTvLatlon;
@ -291,9 +292,9 @@ public class PlacePageView extends NestedScrollViewClickFixed
mTvAddress = mPreview.findViewById(R.id.tv__address);
RelativeLayout address = findViewById(R.id.ll__place_name);
mPhone = findViewById(R.id.ll__place_phone);
mPhone.setOnClickListener(this);
mTvPhone = findViewById(R.id.tv__place_phone);
mPhoneRecycler = findViewById(R.id.rw__phone);
mPhoneAdapter = new PlacePhoneAdapter();
mPhoneRecycler.setAdapter(mPhoneAdapter);
mWebsite = findViewById(R.id.ll__place_website);
mWebsite.setOnClickListener(this);
mTvWebsite = findViewById(R.id.tv__place_website);
@ -326,7 +327,6 @@ public class PlacePageView extends NestedScrollViewClickFixed
mEditTopSpace = findViewById(R.id.edit_top_space);
latlon.setOnLongClickListener(this);
address.setOnLongClickListener(this);
mPhone.setOnLongClickListener(this);
mWebsite.setOnLongClickListener(this);
mOpeningHours.setOnLongClickListener(this);
mEmail.setOnLongClickListener(this);
@ -450,7 +450,7 @@ public class PlacePageView extends NestedScrollViewClickFixed
break;
case CALL:
onCallBtnClicked();
onCallBtnClicked(buttons);
break;
}
}
@ -537,9 +537,36 @@ public class PlacePageView extends NestedScrollViewClickFixed
RoutingController.get().removeStop(mMapObject);
}
private void onCallBtnClicked()
private List<String> getAllPhones()
{
Utils.callPhone(getContext(), mTvPhone.getText().toString());
return mPhoneAdapter.getPhonesList();
}
private void onCallBtnClicked(View parentView)
{
final List<String> phones = getAllPhones();
if (phones.size() == 1)
{
Utils.callPhone(getContext(), phones.get(0));
}
else
{
// Show popup menu with all phones
final PopupMenu popup = new PopupMenu(getContext(), parentView);
final Menu menu = popup.getMenu();
for (int i = 0; i < phones.size(); i++)
menu.add(Menu.NONE, i, i, phones.get(i));
popup.setOnMenuItemClickListener(item -> {
final int id = item.getItemId();
final Context ctx = getContext();
Utils.callPhone(ctx, phones.get(id));
return true;
});
popup.show();
}
}
public void setRoutingModeListener(@Nullable RoutingModeListener routingModeListener)
@ -771,7 +798,7 @@ public class PlacePageView extends NestedScrollViewClickFixed
String website = mapObject.getMetadata(Metadata.MetadataType.FMD_WEBSITE);
String url = mapObject.getMetadata(Metadata.MetadataType.FMD_URL);
refreshMetadataOrHide(TextUtils.isEmpty(website) ? url : website, mWebsite, mTvWebsite);
refreshMetadataOrHide(mapObject.getMetadata(Metadata.MetadataType.FMD_PHONE_NUMBER), mPhone, mTvPhone);
refreshPhoneNumberList(mapObject.getMetadata(Metadata.MetadataType.FMD_PHONE_NUMBER));
refreshMetadataOrHide(mapObject.getMetadata(Metadata.MetadataType.FMD_EMAIL), mEmail, mTvEmail);
refreshMetadataOrHide(mapObject.getMetadata(Metadata.MetadataType.FMD_OPERATOR), mOperator, mTvOperator);
refreshMetadataOrHide(Framework.nativeGetActiveObjectFormattedCuisine(), mCuisine, mTvCuisine);
@ -870,6 +897,11 @@ public class PlacePageView extends NestedScrollViewClickFixed
mTodayOpeningHours.setTextColor(color);
}
private void refreshPhoneNumberList(String phones)
{
mPhoneAdapter.refreshPhones(phones);
}
private void updateBookmarkButton()
{
if (mBookmarkButtonIcon == null || mBookmarkButtonFrame == null)
@ -961,7 +993,12 @@ public class PlacePageView extends NestedScrollViewClickFixed
final boolean hasNumber = mapObject.hasPhoneNumber();
if (hasNumber)
{
buttons.add(PlacePageButtons.Item.CALL);
mPhoneRecycler.setVisibility(VISIBLE);
}
else
mPhoneRecycler.setVisibility(GONE);
boolean needToShowRoutingButtons = RoutingController.get().isPlanning() || showRoutingButton;
@ -1118,9 +1155,6 @@ public class PlacePageView extends NestedScrollViewClickFixed
}
refreshLatLon(mMapObject);
break;
case R.id.ll__place_phone:
Utils.callPhone(getContext(), mTvPhone.getText().toString());
break;
case R.id.ll__place_website:
Utils.openUrl(getContext(), mTvWebsite.getText().toString());
break;
@ -1186,9 +1220,6 @@ public class PlacePageView extends NestedScrollViewClickFixed
case R.id.ll__place_email:
items.add(mTvEmail.getText().toString());
break;
case R.id.ll__place_phone:
items.add(mTvPhone.getText().toString());
break;
case R.id.ll__place_schedule:
String text = UiUtils.isVisible(mFullOpeningHours)
? mFullOpeningHours.getText().toString()

View file

@ -0,0 +1,117 @@
package com.mapswithme.maps.widget.placepage;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupMenu;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.mapswithme.maps.R;
import com.mapswithme.util.Utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class PlacePhoneAdapter extends RecyclerView.Adapter<PlacePhoneAdapter.ViewHolder>
{
private List<String> mPhoneData = Collections.emptyList();
public PlacePhoneAdapter() {}
public PlacePhoneAdapter(String phones) {
refreshPhones(phones);
}
public void refreshPhones(String phones) {
if (TextUtils.isEmpty(phones))
return;
mPhoneData = new ArrayList<>();
for (String p : phones.split(";"))
{
p = p.trim();
if (TextUtils.isEmpty(p)) continue;
mPhoneData.add(p);
}
notifyDataSetChanged();
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
{
return new ViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.place_page_phone_item, parent, false));
}
@Override
public void onBindViewHolder(@NonNull PlacePhoneAdapter.ViewHolder holder, int position)
{
holder.setPhone(mPhoneData.get(position));
}
@Override
public int getItemCount()
{
return mPhoneData.size();
}
public List<String> getPhonesList()
{
return new ArrayList<>(mPhoneData);
}
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener
{
private TextView mPhone;
public ViewHolder(@NonNull View itemView)
{
super(itemView);
mPhone = itemView.findViewById(R.id.tv__place_phone);
itemView.setVisibility(View.VISIBLE);
itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);
}
public void setPhone(String phoneNumber)
{
mPhone.setText(phoneNumber);
}
@Override
public void onClick(View view)
{
Utils.callPhone(view.getContext(), mPhone.getText().toString());
}
@Override
public boolean onLongClick(View view)
{
final PopupMenu popup = new PopupMenu(view.getContext(), view);
final Menu menu = popup.getMenu();
final String copyText = view.getResources().getString(android.R.string.copy);
final String phoneNumber = mPhone.getText().toString();
menu.add(Menu.NONE, 0, 0, String.format("%s %s", copyText, phoneNumber));
popup.setOnMenuItemClickListener(item -> {
final Context ctx = view.getContext();
Utils.copyTextToClipboard(ctx, phoneNumber);
Utils.showSnackbarAbove(view, view.getRootView().findViewById(R.id.menu_frame),
ctx.getString(R.string.copied_to_clipboard, phoneNumber));
return true;
});
popup.show();
return true;
}
}
}

View file

@ -15455,6 +15455,41 @@
sk = Prosím čakajte…
sw = Tafadhali subiri…
[phone_number]
tags = android
en = Phone number
ru = Номер телефона
ar = رقم الهاتف
cs = Telefonní číslo
da = Telefonnummer
nl = Telefoonnummer
fi = Puhelinnumero
fr = Numéro de téléphone
de = Telefonnummer
hu = Telefonszám
id = Nomor telepon
it = Numero di telefono
ja = 電話番号
ko = 전화 번호
nb = Telefonnummer
pl = Numer telefonu
pt = Número de telefone
pt-BR = Número de telefone
ro = Numar de telefon
es = Número de teléfono
sv = Telefonnummer
th = หมายเลขโทรศัพท์
tr = Telefon numarası
uk = Номер телефону
vi = Số điện thoại
zh-Hans = 电话号码
zh-Hant = 電話號碼
el = Τηλεφωνικό νούμερο
es_MX = Número de teléfono
fa = شماره تلفن
sk = Telefónne číslo
sw = Nambari ya simu
[profile]
tags = android, ios
en = OpenStreetMap profile