[android] Display and edit category in editor.

This commit is contained in:
Dmitry Yunitsky 2016-04-18 15:58:18 +03:00
parent 2b3e7eb1cb
commit 7fca41d763
7 changed files with 146 additions and 60 deletions

View file

@ -373,4 +373,11 @@ Java_com_mapswithme_maps_editor_Editor_nativeIsHouseValid(JNIEnv * env, jclass c
{
return osm::EditableMapObject::ValidateHouseNumber(jni::ToNativeString(env, houseNumber));
}
// static boolean nativeGetCategory();
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetCategory(JNIEnv * env, jclass clazz)
{
return jni::ToJavaString(env, g_editableMapObject.GetLocalizedType());
}
} // extern "C"

View file

@ -4,18 +4,73 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/margin_half"
tools:context=".editor.EditorActivity"
tools:ignore="DuplicateIds">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/cv__category"
style="@style/MwmWidget.Editor.CardView">
<RelativeLayout
android:id="@+id/category"
style="@style/MwmWidget.Editor.MetadataBlock.Clickable"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_marginBottom="0dp"
android:padding="@dimen/margin_half_plus">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/margin_half_plus"
android:layout_marginLeft="@dimen/margin_quarter"
android:layout_marginRight="@dimen/margin_half_plus"
android:layout_marginStart="@dimen/margin_quarter"
tools:src="@drawable/ic_category_atm"/>
<Space
android:id="@+id/anchor_center"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerVertical="true"/>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/anchor_center"
android:layout_marginLeft="@dimen/margin_quarter"
android:layout_marginStart="@dimen/margin_quarter"
android:layout_toEndOf="@id/icon"
android:layout_toRightOf="@id/icon"
android:textAppearance="@style/MwmTextAppearance.Body4"
android:text="@string/editor_edit_place_category_title"/>
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/title"
android:layout_alignStart="@id/title"
android:layout_below="@id/title"
android:textAppearance="@style/MwmTextAppearance.Body1"
tools:text="Ololo"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/cv__name"
style="@style/MwmWidget.Editor.CardView">
<LinearLayout
android:id="@+id/name"
android:layout_width="match_parent"
@ -28,19 +83,19 @@
android:paddingLeft="@dimen/margin_base"
android:paddingRight="@dimen/margin_base"
android:paddingStart="@dimen/margin_base">
<com.mapswithme.maps.widget.CustomTextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/input"
style="@style/MwmWidget.Editor.FieldLayout.EditText"
android:hint="@string/editor_edit_place_name_hint"
android:singleLine="true"/>
</com.mapswithme.maps.widget.CustomTextInputLayout>
<TextView
android:id="@+id/name_multilang"
android:layout_width="match_parent"
@ -51,15 +106,15 @@
android:gravity="center_vertical"
android:text="@string/add_language"
android:textAppearance="@style/MwmTextAppearance.Body3"/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/cv__address"
style="@style/MwmWidget.Editor.CardView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -68,7 +123,7 @@
android:paddingLeft="@dimen/margin_base"
android:paddingRight="@dimen/margin_base"
android:paddingStart="@dimen/margin_base">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -77,17 +132,17 @@
android:text="@string/address"
android:textAppearance="@style/MwmTextAppearance.Body3"
tools:ignore="UnusedAttribute"/>
<RelativeLayout
android:id="@+id/block_street"
style="@style/MwmWidget.Editor.MetadataBlock.Clickable"
android:paddingBottom="@dimen/margin_half"
android:paddingTop="@dimen/margin_half">
<ImageView
style="@style/MwmWidget.Editor.MetadataIcon"
android:src="@drawable/ic_coordinates"/>
<TextView
android:id="@+id/street_title"
android:layout_width="match_parent"
@ -96,7 +151,7 @@
android:layout_marginStart="@dimen/editor_margin_left"
android:text="@string/street"
android:textAppearance="@style/MwmTextAppearance.Body4"/>
<TextView
android:id="@+id/street"
style="@style/MwmWidget.Editor.FieldLayout"
@ -107,7 +162,7 @@
android:gravity="center_vertical"
android:textAppearance="@style/MwmTextAppearance.Body1"
tools:text="Red str."/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
@ -116,13 +171,13 @@
android:layout_below="@id/street"
android:layout_marginTop="@dimen/margin_quarter_plus"
android:background="?dividerHorizontal"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/building"
style="@style/MwmWidget.Editor.MetadataBlock">
<com.mapswithme.maps.widget.CustomTextInputLayout
android:id="@+id/custom_input"
android:layout_width="match_parent"
@ -131,25 +186,25 @@
android:layout_centerVertical="true"
android:layout_marginLeft="54dp"
android:layout_marginStart="54dp">
<EditText
android:id="@+id/input"
style="@style/MwmWidget.Editor.FieldLayout.EditText"
android:hint="@string/house_number"
tools:text="79-59"/>
</com.mapswithme.maps.widget.CustomTextInputLayout>
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/cv__metadata"
style="@style/MwmWidget.Editor.CardView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -158,7 +213,7 @@
android:paddingLeft="@dimen/margin_base"
android:paddingRight="@dimen/margin_base"
android:paddingStart="@dimen/margin_base">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -167,88 +222,88 @@
android:text="@string/details"
android:textAppearance="@style/MwmTextAppearance.Body3"
tools:ignore="UnusedAttribute"/>
<include
android:id="@+id/block_opening_hours"
layout="@layout/item_opening_hours"/>
<RelativeLayout
android:id="@+id/block_phone"
style="@style/MwmWidget.Editor.MetadataBlock">
<ImageView
style="@style/MwmWidget.Editor.MetadataIcon"
android:src="@drawable/ic_phone"/>
<com.mapswithme.maps.widget.CustomTextInputLayout
style="@style/MwmWidget.Editor.FieldLayout"
android:layout_centerVertical="true">
<EditText
android:id="@+id/input"
style="@style/MwmWidget.Editor.FieldLayout.EditText"
android:hint="@string/phone"
android:inputType="phone"
tools:text="+937 99 92"/>
</com.mapswithme.maps.widget.CustomTextInputLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/block_website"
style="@style/MwmWidget.Editor.MetadataBlock">
<ImageView
style="@style/MwmWidget.Editor.MetadataIcon"
android:src="@drawable/ic_website"/>
<com.mapswithme.maps.widget.CustomTextInputLayout
style="@style/MwmWidget.Editor.FieldLayout"
android:layout_centerVertical="true">
<EditText
android:id="@+id/input"
style="@style/MwmWidget.Editor.FieldLayout.EditText"
android:hint="@string/website"
tools:text="maps.me"/>
</com.mapswithme.maps.widget.CustomTextInputLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/block_email"
style="@style/MwmWidget.Editor.MetadataBlock">
<ImageView
style="@style/MwmWidget.Editor.MetadataIcon"
android:src="@drawable/ic_email"/>
<com.mapswithme.maps.widget.CustomTextInputLayout
style="@style/MwmWidget.Editor.FieldLayout"
android:layout_centerVertical="true">
<EditText
android:id="@+id/input"
style="@style/MwmWidget.Editor.FieldLayout.EditText"
android:hint="@string/email"
tools:text="bugs@maps.me"/>
</com.mapswithme.maps.widget.CustomTextInputLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/block_cuisine"
style="@style/MwmWidget.Editor.MetadataBlock.Clickable"
android:paddingBottom="@dimen/margin_half"
android:paddingTop="@dimen/margin_half">
<ImageView
style="@style/MwmWidget.Editor.MetadataIcon"
android:src="@drawable/ic_cuisine"/>
<TextView
android:id="@+id/title_cuisine"
android:layout_width="match_parent"
@ -257,7 +312,7 @@
android:layout_marginStart="@dimen/editor_margin_left"
android:text="@string/cuisine"
android:textAppearance="@style/MwmTextAppearance.Body4"/>
<TextView
android:id="@+id/cuisine"
style="@style/MwmWidget.Editor.FieldLayout"
@ -268,7 +323,7 @@
android:gravity="center_vertical"
android:textAppearance="@style/MwmTextAppearance.Body1"
tools:text="Italian, russian, russian, russian, russian, russian, russian, russian, russian"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
@ -277,17 +332,17 @@
android:layout_below="@id/cuisine"
android:layout_marginTop="@dimen/margin_quarter_plus"
android:background="?dividerHorizontal"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/block_wifi"
style="@style/MwmWidget.Editor.MetadataBlock.Clickable">
<ImageView
style="@style/MwmWidget.Editor.MetadataIcon"
android:src="@drawable/ic_wifi"/>
<TextView
style="@style/MwmWidget.Editor.FieldLayout.EditText"
android:layout_width="match_parent"
@ -298,7 +353,7 @@
android:layout_toLeftOf="@+id/sw__wifi"
android:layout_toStartOf="@+id/sw__wifi"
android:text="@string/wifi"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/sw__wifi"
android:layout_width="wrap_content"
@ -307,11 +362,11 @@
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>

View file

@ -27,6 +27,7 @@
<style name="MwmWidget.Editor.MetadataBlock.Clickable">
<item name="android:background">?clickableBackground</item>
<item name="android:clickable">true</item>
</style>
<style name="MwmWidget.Editor.MetadataIcon">

View file

@ -1,5 +1,6 @@
package com.mapswithme.maps;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
@ -323,6 +324,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
return super.getThemeResourceId(theme);
}
@SuppressLint("InlinedApi")
@Override
public void onCreate(@Nullable Bundle savedInstanceState)
{

View file

@ -144,4 +144,6 @@ public final class Editor
public static native void nativePlaceDoesNotExist(double lat, double lon);
public static native boolean nativeIsHouseValid(String houseNumber);
public static native String nativeGetCategory();
}

View file

@ -21,6 +21,7 @@ import com.mapswithme.util.UiUtils;
public class EditorFragment extends BaseMwmFragment implements View.OnClickListener
{
private TextView mCategory;
private View mNameBlock;
private View mAddressBlock;
private View mMetadataBlock;
@ -62,6 +63,7 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
initViews(view);
mCategory.setText(Editor.nativeGetCategory());
// TODO(yunikkk): Add multilanguages support.
UiUtils.hide(mTvLocalizedNames);
mEtName.setText(Editor.nativeGetDefaultName());
@ -235,10 +237,15 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
private void initViews(View view)
{
final View categoryBlock = view.findViewById(R.id.category);
categoryBlock.setOnClickListener(this);
// TODO show icon and fill it when core will implement that
UiUtils.hide(categoryBlock.findViewById(R.id.icon));
mCategory = (TextView) categoryBlock.findViewById(R.id.name);
mNameBlock = view.findViewById(R.id.cv__name);
mAddressBlock = view.findViewById(R.id.cv__address);
mMetadataBlock = view.findViewById(R.id.cv__metadata);
mEtName = findInput(view.findViewById(R.id.name));
mEtName = findInput(mNameBlock);
mTvLocalizedNames = (TextView) view.findViewById(R.id.name_multilang);
view.findViewById(R.id.block_street).setOnClickListener(this);
mTvStreet = (TextView) view.findViewById(R.id.street);
@ -289,6 +296,8 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
case R.id.block_cuisine:
mParent.editCuisine();
break;
case R.id.category:
mParent.editCategory();
}
}
}

View file

@ -155,6 +155,16 @@ public class EditorHostFragment extends BaseMwmToolbarFragment
.commit();
}
protected void editCategory()
{
if (!mIsNewObject)
return;
final EditorActivity host = (EditorActivity) getActivity();
host.finish();
startActivity(new Intent(host, FeatureCategoryActivity.class));
}
private boolean setEdits()
{
return ((EditorFragment) getChildFragmentManager().findFragmentByTag(EditorFragment.class.getName())).setEdits();