[android] add: Show add/edit place in place page.

This commit is contained in:
Alexander Marchuk 2015-12-08 13:07:54 +03:00 committed by Sergey Yershov
parent c364f24b28
commit 9e72a7e8eb
8 changed files with 80 additions and 37 deletions

View file

@ -10,7 +10,6 @@
android:overScrollMode="never">
<RelativeLayout
android:id="@+id/rl__place_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false">
@ -40,11 +39,11 @@
android:layout_marginRight="@dimen/margin_base"/>
<LinearLayout
android:id="@+id/ll__details_left"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/anchor_center"
android:orientation="vertical">
<include layout="@layout/place_page_editor"/>
<include layout="@layout/place_page_placename"/>
@ -55,16 +54,13 @@
<include layout="@layout/place_page_website"/>
<include layout="@layout/place_page_wiki"/>
</LinearLayout>
<LinearLayout
android:id="@+id/ll__details_right"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/anchor_center"
android:orientation="vertical">
<include layout="@layout/place_page_email"/>
<include layout="@layout/place_page_schedule"/>
@ -76,9 +72,7 @@
<include layout="@layout/place_page_operator"/>
<include layout="@layout/place_page_cuisine"/>
</LinearLayout>
</RelativeLayout>
<include

View file

@ -7,7 +7,6 @@
android:tag="schedule"
tools:visibility="visible">
<ImageView
android:id="@+id/iv__place_cuisine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_base"

View file

@ -9,7 +9,6 @@
android:background="?ppBackground"
android:overScrollMode="never">
<LinearLayout
android:id="@+id/rl__place_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
@ -23,6 +22,8 @@
android:layout_marginBottom="@dimen/margin_half"
android:background="?attr/dividerHorizontal"/>
<include layout="@layout/place_page_editor"/>
<include layout="@layout/place_page_placename"/>
<include layout="@layout/place_page_entrance"/>

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/ll__place_editor"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/clickableBackground"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingBottom="@dimen/margin_half"
android:paddingTop="@dimen/margin_half"
xmlns:tools="http://schemas.android.com/tools">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_base"
android:src="@drawable/ic_edit"/>
<TextView
android:id="@+id/tv__editor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/text_place_page"
android:textSize="@dimen/text_size_body_1"
tools:text="@string/pp_place_add"/>
</LinearLayout>

View file

@ -7,7 +7,6 @@
tools:background="#40FF0000"
tools:visibility="visible">
<ImageView
android:id="@+id/iv__place_entrance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_base"

View file

@ -7,7 +7,6 @@
android:tag="schedule"
tools:visibility="visible">
<ImageView
android:id="@+id/iv__place_schedule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_base"

View file

@ -13,14 +13,31 @@ public abstract class MapObject implements Parcelable
protected double mLon;
protected String mTypeName;
protected Metadata mMetadata;
private final boolean mDroppedPin;
public MapObject(String name, double lat, double lon, String typeName)
{
this(name, lat, lon, typeName, new Metadata());
}
public MapObject(String name, double lat, double lon, String typeName, Metadata metadata)
{
mName = name;
mLat = lat;
mLon = lon;
mTypeName = typeName;
mMetadata = new Metadata();
mMetadata = metadata;
mDroppedPin = TextUtils.isEmpty(mName);
}
protected MapObject(Parcel source)
{
this(source.readString(), // Name
source.readDouble(), // Lat
source.readDouble(), // Lon
source.readString(), // Type
(Metadata)source.readParcelable(Metadata.class.getClassLoader()));
}
public void setDefaultIfEmpty()
@ -84,6 +101,11 @@ public abstract class MapObject implements Parcelable
public String getPoiTypeName() { return mTypeName; }
public boolean isDroppedPin()
{
return mDroppedPin;
}
public void addMetadata(int type, String value)
{
mMetadata.addMetadata(type, value);
@ -153,15 +175,6 @@ public abstract class MapObject implements Parcelable
return null;
}
protected MapObject(Parcel source)
{
mName = source.readString();
mLat = source.readDouble();
mLon = source.readDouble();
mTypeName = source.readString();
mMetadata = source.readParcelable(Metadata.class.getClassLoader());
}
public enum MapObjectType
{
POI,

View file

@ -84,20 +84,16 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
private TextView mTvTitle;
private Toolbar mToolbar;
private TextView mTvSubtitle;
private TextView mTvOpened;
private ArrowView mAvDirection;
private TextView mTvDistance;
private RatingBar mRbStars;
private TextView mTvElevation;
// Place page details
private ScrollView mPpDetails;
private RelativeLayout mAddress;
private TextView mTvAddress;
private LinearLayout mPhone;
private TextView mTvPhone;
private LinearLayout mWebsite;
private TextView mTvWebsite;
private LinearLayout mLatlon;
private TextView mTvLatlon;
private LinearLayout mSchedule;
private TextView mTvSchedule;
@ -112,10 +108,11 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
private TextView mTvWiki;
private LinearLayout mEntrance;
private TextView mTvEntrance;
private View mEditor;
private TextView mTvEditor;
// Bookmark
private ImageView mIvColor;
private EditText mEtBookmarkName;
private TextView mTvNotes;
private WebView mWvDescription;
private TextView mTvDescription;
private Button mBtnEditHtmlDescription;
@ -172,7 +169,6 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
mTvTitle = (TextView) ppPreview.findViewById(R.id.tv__title);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mTvSubtitle = (TextView) ppPreview.findViewById(R.id.tv__subtitle);
mTvOpened = (TextView) ppPreview.findViewById(R.id.tv__opened_till);
mTvDistance = (TextView) ppPreview.findViewById(R.id.tv__straight_distance);
mAvDirection = (ArrowView) ppPreview.findViewById(R.id.av__direction);
mAvDirection.setOnClickListener(this);
@ -181,16 +177,15 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
mTvElevation = (TextView) ppPreview.findViewById(R.id.tv__peak_elevation);
mPpDetails = (ScrollView) findViewById(R.id.pp__details);
mAddress = (RelativeLayout) mPpDetails.findViewById(R.id.ll__place_name);
mTvAddress = (TextView) mPpDetails.findViewById(R.id.tv__place_address);
RelativeLayout address = (RelativeLayout)mPpDetails.findViewById(R.id.ll__place_name);
mPhone = (LinearLayout) mPpDetails.findViewById(R.id.ll__place_phone);
mPhone.setOnClickListener(this);
mTvPhone = (TextView) mPpDetails.findViewById(R.id.tv__place_phone);
mWebsite = (LinearLayout) mPpDetails.findViewById(R.id.ll__place_website);
mWebsite.setOnClickListener(this);
mTvWebsite = (TextView) mPpDetails.findViewById(R.id.tv__place_website);
mLatlon = (LinearLayout) mPpDetails.findViewById(R.id.ll__place_latlon);
mLatlon.setOnClickListener(this);
LinearLayout latlon = (LinearLayout)mPpDetails.findViewById(R.id.ll__place_latlon);
latlon.setOnClickListener(this);
mTvLatlon = (TextView) mPpDetails.findViewById(R.id.tv__place_latlon);
mSchedule = (LinearLayout) mPpDetails.findViewById(R.id.ll__place_schedule);
mTvSchedule = (TextView) mPpDetails.findViewById(R.id.tv__place_schedule);
@ -209,8 +204,11 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
mWiki.setOnClickListener(this);
mEntrance = (LinearLayout) mPpDetails.findViewById(R.id.ll__place_entrance);
mTvEntrance = (TextView) mEntrance.findViewById(R.id.tv__place_entrance);
mLatlon.setOnLongClickListener(this);
mAddress.setOnLongClickListener(this);
mEditor = mPpDetails.findViewById(R.id.ll__place_editor);
mTvEditor = (TextView) mEditor.findViewById(R.id.tv__editor);
mEditor.setOnClickListener(this);
latlon.setOnLongClickListener(this);
address.setOnLongClickListener(this);
mPhone.setOnLongClickListener(this);
mWebsite.setOnLongClickListener(this);
mSchedule.setOnLongClickListener(this);
@ -234,8 +232,8 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
}
});
mTvNotes = (TextView) mPpDetails.findViewById(R.id.tv__bookmark_notes);
mTvNotes.setOnClickListener(this);
TextView tvNotes = (TextView)mPpDetails.findViewById(R.id.tv__bookmark_notes);
tvNotes.setOnClickListener(this);
mTvBookmarkGroup = (TextView) mPpDetails.findViewById(R.id.tv__bookmark_group);
mTvBookmarkGroup.setOnClickListener(this);
@ -503,13 +501,18 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
if (RoutingController.get().isPlanning())
{
UiUtils.show(mRouteButtonsFrame);
UiUtils.hide(mGeneralButtonsFrame);
UiUtils.hide(mGeneralButtonsFrame, mEditor);
}
else
{
UiUtils.show(mGeneralButtonsFrame);
UiUtils.showIf(!hasMapObject(null), mEditor);
UiUtils.hide(mRouteButtonsFrame);
if (!hasMapObject(null))
mTvEditor.setText(mMapObject.isDroppedPin() ? R.string.pp_place_add
: R.string.pp_place_edit);
UiUtils.showIf(showBackButton || ParsedMwmRequest.isPickPointMode(), mApiBack);
UiUtils.showIf(showRoutingButton, mRoutingButton);
}
@ -528,7 +531,7 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
private void refreshMyPosition(Location l)
{
mTvDistance.setVisibility(View.GONE);
UiUtils.hide(mTvDistance);
if (l == null)
return;
@ -713,11 +716,20 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
});
}
private void showEditor()
{
((MwmActivity)getContext()).showEditor(mMapObject);
}
@Override
public void onClick(View v)
{
switch (v.getId())
{
case R.id.ll__place_editor:
showEditor();
break;
case R.id.iv__bookmark_color:
saveBookmarkNameIfUpdated();
selectBookmarkColor();