forked from organicmaps/organicmaps
Merge pull request #5890 from alexzatsepin/MAPSME-4311-create-ad-local-button
[android] Mapsme 4311 create ad local button
This commit is contained in:
commit
94be18a325
18 changed files with 232 additions and 69 deletions
|
@ -39,15 +39,17 @@ jobject CreateMapObject(JNIEnv * env, int mapObjectType, string const & title,
|
|||
string const & secondaryTitle, string const & subtitle, double lat,
|
||||
double lon, string const & address, Metadata const & metadata,
|
||||
string const & apiId, jobjectArray jbanners, bool isReachableByTaxi,
|
||||
string const & bookingSearchUrl)
|
||||
string const & bookingSearchUrl, jobject const & localAdInfo)
|
||||
{
|
||||
// public MapObject(@MapObjectType int mapObjectType, String title, String subtitle, double lat,
|
||||
// double lon, String address, String apiId, @NonNull Banner banner, boolean reachableByTaxi,
|
||||
// @Nullable String bookingSearchUrl)
|
||||
// public MapObject(@MapObjectType int mapObjectType, String title, String secondaryTitle,
|
||||
// String subtitle, double lat, double lon, String address, String apiId,
|
||||
// @NonNull Banner banner, boolean reachableByTaxi,
|
||||
// @Nullable String bookingSearchUrl, @Nullable LocalAdInfo localAdInfo)
|
||||
static jmethodID const ctorId =
|
||||
jni::GetConstructorID(env, g_mapObjectClazz,
|
||||
"(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;DDLjava/lang/"
|
||||
"String;[Lcom/mapswithme/maps/ads/Banner;ZLjava/lang/String;)V");
|
||||
"String;[Lcom/mapswithme/maps/ads/Banner;ZLjava/lang/String;"
|
||||
"Lcom/mapswithme/maps/ads/LocalAdInfo;)V");
|
||||
|
||||
jni::TScopedLocalRef jTitle(env, jni::ToJavaString(env, title));
|
||||
jni::TScopedLocalRef jSecondaryTitle(env, jni::ToJavaString(env, secondaryTitle));
|
||||
|
@ -58,7 +60,7 @@ jobject CreateMapObject(JNIEnv * env, int mapObjectType, string const & title,
|
|||
jobject mapObject = env->NewObject(g_mapObjectClazz, ctorId, mapObjectType, jTitle.get(),
|
||||
jSecondaryTitle.get(), jSubtitle.get(), jAddress.get(), lat,
|
||||
lon, jApiId.get(), jbanners, isReachableByTaxi,
|
||||
jBookingSearchUrl.get());
|
||||
jBookingSearchUrl.get(), localAdInfo);
|
||||
|
||||
InjectMetadata(env, g_mapObjectClazz, mapObject, metadata);
|
||||
return mapObject;
|
||||
|
@ -66,9 +68,11 @@ jobject CreateMapObject(JNIEnv * env, int mapObjectType, string const & title,
|
|||
|
||||
jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
||||
{
|
||||
jobjectArray jbanners = nullptr;
|
||||
jni::TScopedLocalObjectArrayRef jbanners(env, nullptr);
|
||||
if (info.HasBanner())
|
||||
jbanners = ToBannersArray(env, info.GetBanners());
|
||||
jbanners.reset(ToBannersArray(env, info.GetBanners()));
|
||||
|
||||
jni::TScopedLocalRef localAdInfo(env, CreateLocalAdInfo(env, info));
|
||||
|
||||
if (info.IsBookmark())
|
||||
{
|
||||
|
@ -77,7 +81,8 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
|||
static jmethodID const ctorId =
|
||||
jni::GetConstructorID(env, g_bookmarkClazz,
|
||||
"(IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;"
|
||||
"[Lcom/mapswithme/maps/ads/Banner;ZLjava/lang/String;)V");
|
||||
"[Lcom/mapswithme/maps/ads/Banner;ZLjava/lang/String;"
|
||||
"Lcom/mapswithme/maps/ads/LocalAdInfo;)V");
|
||||
|
||||
auto const & bac = info.GetBookmarkAndCategory();
|
||||
BookmarkCategory * cat = g_framework->NativeFramework()->GetBmCategory(bac.m_categoryIndex);
|
||||
|
@ -91,7 +96,8 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
|||
jobject mapObject =
|
||||
env->NewObject(g_bookmarkClazz, ctorId, static_cast<jint>(info.m_bac.m_categoryIndex),
|
||||
static_cast<jint>(info.m_bac.m_bookmarkIndex), jName.get(), jTitle.get(),
|
||||
jSecondaryTitle.get(), jbanners, info.IsReachableByTaxi(), jBookingSearchUrl.get());
|
||||
jSecondaryTitle.get(), jbanners.get(), info.IsReachableByTaxi(),
|
||||
jBookingSearchUrl.get(), localAdInfo.get());
|
||||
if (info.IsFeature())
|
||||
InjectMetadata(env, g_mapObjectClazz, mapObject, info.GetMetadata());
|
||||
return mapObject;
|
||||
|
@ -106,17 +112,19 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
|||
if (info.IsMyPosition())
|
||||
return CreateMapObject(env, kMyPosition, info.GetTitle(), info.GetSecondaryTitle(),
|
||||
info.GetSubtitle(), ll.lat, ll.lon, address.FormatAddress(), {}, "",
|
||||
jbanners, info.IsReachableByTaxi(), info.GetBookingSearchUrl());
|
||||
jbanners.get(), info.IsReachableByTaxi(), info.GetBookingSearchUrl(),
|
||||
localAdInfo.get());
|
||||
|
||||
if (info.HasApiUrl())
|
||||
return CreateMapObject(env, kApiPoint, info.GetTitle(), info.GetSecondaryTitle(), info.GetSubtitle(),
|
||||
ll.lat, ll.lon, address.FormatAddress(), info.GetMetadata(),
|
||||
info.GetApiUrl(), jbanners, info.IsReachableByTaxi(), info.GetBookingSearchUrl());
|
||||
info.GetApiUrl(), jbanners.get(), info.IsReachableByTaxi(),
|
||||
info.GetBookingSearchUrl(), localAdInfo.get());
|
||||
|
||||
return CreateMapObject(env, kPoi, info.GetTitle(), info.GetSecondaryTitle(), info.GetSubtitle(),
|
||||
ll.lat, ll.lon, address.FormatAddress(),
|
||||
info.IsFeature() ? info.GetMetadata() : Metadata(), "", jbanners,
|
||||
info.IsReachableByTaxi(), info.GetBookingSearchUrl());
|
||||
info.IsFeature() ? info.GetMetadata() : Metadata(), "", jbanners.get(),
|
||||
info.IsReachableByTaxi(), info.GetBookingSearchUrl(), localAdInfo.get());
|
||||
}
|
||||
|
||||
jobjectArray ToBannersArray(JNIEnv * env, vector<ads::Banner> const & banners)
|
||||
|
@ -126,4 +134,15 @@ jobjectArray ToBannersArray(JNIEnv * env, vector<ads::Banner> const & banners)
|
|||
return CreateBanner(env, item.m_bannerId, static_cast<jint>(item.m_type));
|
||||
});
|
||||
}
|
||||
|
||||
jobject CreateLocalAdInfo(JNIEnv * env, place_page::Info const & info)
|
||||
{
|
||||
static jclass const localAdInfoClazz = jni::GetGlobalClassRef(env, "com/mapswithme/maps/ads/LocalAdInfo");
|
||||
static jmethodID const ctorId = jni::GetConstructorID(env, localAdInfoClazz,
|
||||
"(ILjava/lang/String;)V");
|
||||
|
||||
jni::TScopedLocalRef jLocalAdUrl(env, jni::ToJavaString(env, info.GetLocalAdsUrl()));
|
||||
|
||||
return env->NewObject(localAdInfoClazz, ctorId, info.GetLocalAdsStatus(), jLocalAdUrl.get());
|
||||
}
|
||||
} // namespace usermark_helper
|
||||
|
|
|
@ -34,4 +34,6 @@ jobject CreateMapObject(JNIEnv * env, int mapObjectType, string const & title, s
|
|||
jobject CreateMapObject(JNIEnv * env, place_page::Info const & info);
|
||||
|
||||
jobjectArray ToBannersArray(JNIEnv * env, vector<ads::Banner> const & banners);
|
||||
|
||||
jobject CreateLocalAdInfo(JNIEnv * env, place_page::Info const & info);
|
||||
} // namespace usermark_helper
|
||||
|
|
|
@ -71,11 +71,11 @@
|
|||
|
||||
<include layout="@layout/place_page_taxi"/>
|
||||
|
||||
<include layout="@layout/divider_horizontal"/>
|
||||
|
||||
<include layout="@layout/place_page_more"/>
|
||||
|
||||
<include layout="@layout/divider_horizontal"/>
|
||||
<include layout="@layout/divider_horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/margin_half"/>
|
||||
|
||||
<include layout="@layout/place_page_editor"/>
|
||||
|
||||
|
@ -83,6 +83,12 @@
|
|||
|
||||
<include layout="@layout/place_page_add"/>
|
||||
|
||||
<include layout="@layout/place_page_local_ad"/>
|
||||
|
||||
<include layout="@layout/divider_horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/margin_half"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.mapswithme.maps.widget.ObservableScrollView>
|
||||
|
|
|
@ -6,13 +6,9 @@
|
|||
style="@style/PlacePageItemFrame"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
style="@style/PlacePageMetadataIcon"
|
||||
android:src="@drawable/ic_add_place"
|
||||
android:tint="?colorAccent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv__editor"
|
||||
style="@style/PlacePageMetadataText.Button"
|
||||
android:text="@string/placepage_add_place_button"/>
|
||||
</LinearLayout>
|
||||
android:text="@string/placepage_add_place_button"
|
||||
android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -7,14 +7,10 @@
|
|||
android:visibility="visible"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
style="@style/PlacePageMetadataIcon"
|
||||
android:src="@drawable/ic_add_place"
|
||||
android:tint="?colorAccent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv__editor"
|
||||
style="@style/PlacePageMetadataText.Button"
|
||||
android:gravity="center"
|
||||
android:text="@string/placepage_add_business_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -57,11 +57,11 @@
|
|||
|
||||
<include layout="@layout/place_page_taxi"/>
|
||||
|
||||
<include layout="@layout/divider_horizontal"/>
|
||||
|
||||
<include layout="@layout/place_page_more"/>
|
||||
|
||||
<include layout="@layout/divider_horizontal"/>
|
||||
<include layout="@layout/divider_horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/margin_half"/>
|
||||
|
||||
<include layout="@layout/place_page_editor"/>
|
||||
|
||||
|
@ -69,6 +69,12 @@
|
|||
|
||||
<include layout="@layout/place_page_add"/>
|
||||
|
||||
<include layout="@layout/place_page_local_ad"/>
|
||||
|
||||
<include layout="@layout/divider_horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/margin_half"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/shadow_top"/>
|
||||
|
|
|
@ -5,14 +5,9 @@
|
|||
android:id="@+id/ll__place_editor"
|
||||
style="@style/PlacePageItemFrame"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
style="@style/PlacePageMetadataIcon"
|
||||
android:src="@drawable/ic_edit"
|
||||
android:tint="?colorAccent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv__editor"
|
||||
style="@style/PlacePageMetadataText.Button"
|
||||
android:gravity="center"
|
||||
android:text="@string/edit_place"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
13
android/res/layout/place_page_local_ad.xml
Normal file
13
android/res/layout/place_page_local_ad.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/ll__local_ad"
|
||||
style="@style/PlacePageItemFrame"
|
||||
tools:showIn="@layout/place_page_details"
|
||||
tools:visibility="visible">
|
||||
<TextView
|
||||
android:id="@+id/tv__local_ad"
|
||||
style="@style/PlacePageMetadataText.Button"
|
||||
android:gravity="center"
|
||||
android:text="@string/placepage_add_place_button"/>
|
||||
</LinearLayout>
|
|
@ -1105,4 +1105,6 @@
|
|||
<string name="search_hotel_filter_hostel">Hostel</string>
|
||||
<string name="search_hotel_filter_resort">Resort</string>
|
||||
<string name="search_hotel_filter_motel">Motel</string>
|
||||
<string name="create_campaign_button">Create ad campaign</string>
|
||||
<string name="view_campaign_button">View ad campaign</string>
|
||||
</resources>
|
||||
|
|
|
@ -1420,9 +1420,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
final RoutePoint from = data.mPoints[0];
|
||||
final RoutePoint to = data.mPoints[1];
|
||||
RoutingController.get().prepare(new MapObject(MapObject.API_POINT, from.mName, "", "", "",
|
||||
from.mLat, from.mLon, "", null, false, ""),
|
||||
from.mLat, from.mLon, "", null, false, "", null),
|
||||
new MapObject(MapObject.API_POINT, to.mName, "", "", "",
|
||||
to.mLat, to.mLon, "", null, false, ""));
|
||||
to.mLat, to.mLon, "", null, false, "", null));
|
||||
return true;
|
||||
case ParsedUrlMwmRequest.RESULT_SEARCH:
|
||||
final ParsedSearchRequest request = Framework.nativeGetParsedSearchRequest();
|
||||
|
|
82
android/src/com/mapswithme/maps/ads/LocalAdInfo.java
Normal file
82
android/src/com/mapswithme/maps/ads/LocalAdInfo.java
Normal file
|
@ -0,0 +1,82 @@
|
|||
package com.mapswithme.maps.ads;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
public class LocalAdInfo implements Parcelable
|
||||
{
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({ STATUS_NOT_AVAILABLE, STATUS_CANDIDATE, STATUS_CUSTOMER})
|
||||
|
||||
public @interface Status {}
|
||||
|
||||
private static final int STATUS_NOT_AVAILABLE = 0;
|
||||
private static final int STATUS_CANDIDATE = 1;
|
||||
private static final int STATUS_CUSTOMER = 2;
|
||||
|
||||
@Status
|
||||
private final int mStatus;
|
||||
@Nullable
|
||||
private final String mUrl;
|
||||
|
||||
private LocalAdInfo(@Status int status, @Nullable String url)
|
||||
{
|
||||
mUrl = url;
|
||||
mStatus = status;
|
||||
}
|
||||
|
||||
public boolean isAvailable()
|
||||
{
|
||||
return mStatus != STATUS_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
public boolean isCustomer()
|
||||
{
|
||||
return mStatus == STATUS_CUSTOMER;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getUrl()
|
||||
{
|
||||
return mUrl;
|
||||
}
|
||||
|
||||
private LocalAdInfo(Parcel in)
|
||||
{
|
||||
//noinspection WrongConstant
|
||||
this(in.readInt() /* mStatus */, in.readString() /* mUrl */);
|
||||
}
|
||||
|
||||
public static final Creator<LocalAdInfo> CREATOR = new Creator<LocalAdInfo>()
|
||||
{
|
||||
@Override
|
||||
public LocalAdInfo createFromParcel(Parcel in)
|
||||
{
|
||||
return new LocalAdInfo(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalAdInfo[] newArray(int size)
|
||||
{
|
||||
return new LocalAdInfo[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int describeContents()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags)
|
||||
{
|
||||
dest.writeInt(mStatus);
|
||||
dest.writeString(mUrl);
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import android.text.TextUtils;
|
|||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.ads.Banner;
|
||||
import com.mapswithme.maps.ads.LocalAdInfo;
|
||||
import com.mapswithme.util.Constants;
|
||||
|
||||
// TODO consider refactoring to remove hack with MapObject unmarshalling itself and Bookmark at the same time.
|
||||
|
@ -25,10 +26,10 @@ public class Bookmark extends MapObject
|
|||
|
||||
Bookmark(@IntRange(from = 0) int categoryId, @IntRange(from = 0) int bookmarkId, String title,
|
||||
@Nullable String secondaryTitle, @Nullable String objectTitle, @Nullable Banner[] banners,
|
||||
boolean reachableByTaxi, @Nullable String bookingSearchUrl)
|
||||
boolean reachableByTaxi, @Nullable String bookingSearchUrl, @Nullable LocalAdInfo localAdInfo)
|
||||
{
|
||||
super(BOOKMARK, title, secondaryTitle, "", "", 0, 0, "", banners, reachableByTaxi,
|
||||
bookingSearchUrl);
|
||||
bookingSearchUrl, localAdInfo);
|
||||
|
||||
mCategoryId = categoryId;
|
||||
mBookmarkId = bookmarkId;
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.support.annotation.Nullable;
|
|||
import android.text.TextUtils;
|
||||
|
||||
import com.mapswithme.maps.ads.Banner;
|
||||
import com.mapswithme.maps.ads.LocalAdInfo;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
@ -46,20 +47,22 @@ public class MapObject implements Parcelable
|
|||
private boolean mReachableByTaxi;
|
||||
@Nullable
|
||||
private String mBookingSearchUrl;
|
||||
@Nullable
|
||||
private LocalAdInfo mLocalAdInfo;
|
||||
|
||||
public MapObject(@MapObjectType int mapObjectType, String title, @Nullable String secondaryTitle,
|
||||
String subtitle, String address, double lat, double lon, String apiId,
|
||||
@Nullable Banner[] banners, boolean reachableByTaxi,
|
||||
@Nullable String bookingSearchUrl)
|
||||
@Nullable String bookingSearchUrl, @Nullable LocalAdInfo localAdInfo)
|
||||
{
|
||||
this(mapObjectType, title, secondaryTitle, subtitle, address, lat, lon, new Metadata(),
|
||||
apiId, banners, reachableByTaxi, bookingSearchUrl);
|
||||
apiId, banners, reachableByTaxi, bookingSearchUrl, localAdInfo);
|
||||
}
|
||||
|
||||
public MapObject(@MapObjectType int mapObjectType, String title, @Nullable String secondaryTitle,
|
||||
String subtitle, String address, double lat, double lon, Metadata metadata,
|
||||
String apiId, @Nullable Banner[] banners, boolean reachableByTaxi,
|
||||
@Nullable String bookingSearchUrl)
|
||||
@Nullable String bookingSearchUrl, @Nullable LocalAdInfo localAdInfo)
|
||||
{
|
||||
mMapObjectType = mapObjectType;
|
||||
mTitle = title;
|
||||
|
@ -72,6 +75,7 @@ public class MapObject implements Parcelable
|
|||
mApiId = apiId;
|
||||
mReachableByTaxi = reachableByTaxi;
|
||||
mBookingSearchUrl = bookingSearchUrl;
|
||||
mLocalAdInfo = localAdInfo;
|
||||
if (banners != null)
|
||||
mBanners = new ArrayList<>(Arrays.asList(banners));
|
||||
}
|
||||
|
@ -90,7 +94,8 @@ public class MapObject implements Parcelable
|
|||
source.readString(), // ApiId;
|
||||
null, // mBanners
|
||||
source.readByte() != 0, // ReachableByTaxi
|
||||
source.readString()); // BookingSearchUrl
|
||||
source.readString(), // BookingSearchUrl
|
||||
(LocalAdInfo) source.readParcelable(LocalAdInfo.class.getClassLoader())); // LocalAdInfo
|
||||
mBanners = readBanners(source);
|
||||
}
|
||||
|
||||
|
@ -225,6 +230,12 @@ public class MapObject implements Parcelable
|
|||
return mBookingSearchUrl;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public LocalAdInfo getLocalAdInfo()
|
||||
{
|
||||
return mLocalAdInfo;
|
||||
}
|
||||
|
||||
private static MapObject readFromParcel(Parcel source)
|
||||
{
|
||||
@MapObjectType int type = source.readInt();
|
||||
|
@ -255,6 +266,7 @@ public class MapObject implements Parcelable
|
|||
dest.writeString(mApiId);
|
||||
dest.writeByte((byte) (mReachableByTaxi ? 1 : 0));
|
||||
dest.writeString(mBookingSearchUrl);
|
||||
dest.writeParcelable(mLocalAdInfo, 0);
|
||||
dest.writeTypedList(mBanners);
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ public enum LocationHelper
|
|||
|
||||
if (mMyPosition == null)
|
||||
mMyPosition = new MapObject(MapObject.MY_POSITION, "", "", "", "", mSavedLocation.getLatitude(),
|
||||
mSavedLocation.getLongitude(), "", null, false, "");
|
||||
mSavedLocation.getLongitude(), "", null, false, "", null);
|
||||
|
||||
return mMyPosition;
|
||||
}
|
||||
|
|
|
@ -467,7 +467,7 @@ public class SearchFragment extends BaseMwmFragment
|
|||
{
|
||||
//noinspection ConstantConditions
|
||||
final MapObject point = new MapObject(MapObject.SEARCH, result.name, "",
|
||||
result.description.featureType, "", result.lat, result.lon, "", null, false, "");
|
||||
result.description.featureType, "", result.lat, result.lon, "", null, false, "", null);
|
||||
RoutingController.get().onPoiSelected(point);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,10 @@ package com.mapswithme.maps.widget.placepage;
|
|||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.location.Location;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
|
@ -46,6 +44,7 @@ import com.mapswithme.maps.R;
|
|||
import com.mapswithme.maps.ads.CompoundNativeAdLoader;
|
||||
import com.mapswithme.maps.ads.DefaultAdTracker;
|
||||
import com.mapswithme.maps.ads.Factory;
|
||||
import com.mapswithme.maps.ads.LocalAdInfo;
|
||||
import com.mapswithme.maps.api.ParsedMwmRequest;
|
||||
import com.mapswithme.maps.bookmarks.data.Bookmark;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
|
@ -157,6 +156,8 @@ public class PlacePageView extends RelativeLayout
|
|||
private View mEditPlace;
|
||||
private View mAddOrganisation;
|
||||
private View mAddPlace;
|
||||
private View mLocalAd;
|
||||
private TextView mTvLocalAd;
|
||||
// Bookmark
|
||||
private View mBookmarkFrame;
|
||||
private WebView mWvBookmarkNote;
|
||||
|
@ -354,6 +355,9 @@ public class PlacePageView extends RelativeLayout
|
|||
mAddOrganisation.setOnClickListener(this);
|
||||
mAddPlace = mDetails.findViewById(R.id.ll__place_add);
|
||||
mAddPlace.setOnClickListener(this);
|
||||
mLocalAd = mDetails.findViewById(R.id.ll__local_ad);
|
||||
mLocalAd.setOnClickListener(this);
|
||||
mTvLocalAd = (TextView) mLocalAd.findViewById(R.id.tv__local_ad);
|
||||
latlon.setOnLongClickListener(this);
|
||||
address.setOnLongClickListener(this);
|
||||
mPhone.setOnLongClickListener(this);
|
||||
|
@ -508,10 +512,10 @@ public class PlacePageView extends RelativeLayout
|
|||
break;
|
||||
|
||||
case BOOKING_SEARCH:
|
||||
if (mMapObject != null)
|
||||
if (mMapObject != null && !TextUtils.isEmpty(mMapObject.getBookingSearchUrl()))
|
||||
{
|
||||
Statistics.INSTANCE.trackBookingSearchEvent(mMapObject);
|
||||
followUrl(mMapObject.getBookingSearchUrl());
|
||||
Utils.openUrl(getContext(), mMapObject.getBookingSearchUrl());
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -843,7 +847,7 @@ public class PlacePageView extends RelativeLayout
|
|||
|
||||
try
|
||||
{
|
||||
followUrl(book ? info.getUrl() : info.getDescriptionUrl());
|
||||
Utils.openUrl(getContext(), book ? info.getUrl() : info.getDescriptionUrl());
|
||||
}
|
||||
catch (ActivityNotFoundException e)
|
||||
{
|
||||
|
@ -1226,13 +1230,30 @@ public class PlacePageView extends RelativeLayout
|
|||
|
||||
if (inRouting || MapManager.nativeIsLegacyMode())
|
||||
{
|
||||
UiUtils.hide(mEditPlace, mAddOrganisation, mAddPlace);
|
||||
UiUtils.hide(mEditPlace, mAddOrganisation, mAddPlace, mLocalAd);
|
||||
}
|
||||
else
|
||||
{
|
||||
UiUtils.showIf(Editor.nativeShouldShowEditPlace(), mEditPlace);
|
||||
UiUtils.showIf(Editor.nativeShouldShowAddBusiness(), mAddOrganisation);
|
||||
UiUtils.showIf(Editor.nativeShouldShowAddPlace(), mAddPlace);
|
||||
refreshLocalAdInfo(mapObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshLocalAdInfo(@NonNull MapObject mapObject)
|
||||
{
|
||||
LocalAdInfo localAdInfo = mapObject.getLocalAdInfo();
|
||||
boolean isLocalAdAvailable = localAdInfo != null && localAdInfo.isAvailable();
|
||||
if (isLocalAdAvailable && !TextUtils.isEmpty(localAdInfo.getUrl()))
|
||||
{
|
||||
mTvLocalAd.setText(localAdInfo.isCustomer() ? R.string.view_campaign_button
|
||||
: R.string.create_campaign_button);
|
||||
UiUtils.show(mLocalAd);
|
||||
}
|
||||
else
|
||||
{
|
||||
UiUtils.hide(mLocalAd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1505,6 +1526,17 @@ public class PlacePageView extends RelativeLayout
|
|||
case R.id.ll__place_add:
|
||||
addPlace();
|
||||
break;
|
||||
case R.id.ll__local_ad:
|
||||
if (mMapObject != null)
|
||||
{
|
||||
LocalAdInfo localAdInfo = mMapObject.getLocalAdInfo();
|
||||
if (localAdInfo == null)
|
||||
throw new AssertionError("A local ad must be non-null if button is shown!");
|
||||
|
||||
if (!TextUtils.isEmpty(localAdInfo.getUrl()))
|
||||
Utils.openUrl(getContext(), localAdInfo.getUrl());
|
||||
}
|
||||
break;
|
||||
case R.id.ll__more:
|
||||
onSponsoredClick(false /* book */, true /* isMoreDetails */);
|
||||
break;
|
||||
|
@ -1525,7 +1557,7 @@ public class PlacePageView extends RelativeLayout
|
|||
Utils.callPhone(getContext(), mTvPhone.getText().toString());
|
||||
break;
|
||||
case R.id.ll__place_website:
|
||||
followUrl(mTvWebsite.getText().toString());
|
||||
Utils.openUrl(getContext(), mTvWebsite.getText().toString());
|
||||
break;
|
||||
case R.id.ll__place_wiki:
|
||||
// TODO: Refactor and use separate getters for Wiki and all other PP meta info too.
|
||||
|
@ -1534,7 +1566,7 @@ public class PlacePageView extends RelativeLayout
|
|||
LOGGER.e(TAG, "Cannot follow url, mMapObject is null!", new Throwable());
|
||||
break;
|
||||
}
|
||||
followUrl(mMapObject.getMetadata(Metadata.MetadataType.FMD_WIKIPEDIA));
|
||||
Utils.openUrl(getContext(), mMapObject.getMetadata(Metadata.MetadataType.FMD_WIKIPEDIA));
|
||||
break;
|
||||
case R.id.direction_frame:
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.PP_DIRECTION_ARROW);
|
||||
|
@ -1572,7 +1604,7 @@ public class PlacePageView extends RelativeLayout
|
|||
{
|
||||
//null checking is done in 'isSponsored' method
|
||||
//noinspection ConstantConditions
|
||||
followUrl(mSponsored.getReviewUrl());
|
||||
Utils.openUrl(getContext(), mSponsored.getReviewUrl());
|
||||
if (mMapObject != null)
|
||||
Statistics.INSTANCE.trackHotelEvent(PP_HOTEL_REVIEWS_LAND, mSponsored, mMapObject);
|
||||
}
|
||||
|
@ -1586,15 +1618,6 @@ public class PlacePageView extends RelativeLayout
|
|||
}
|
||||
}
|
||||
|
||||
private void followUrl(String url)
|
||||
{
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
if (!url.startsWith("http://") && !url.startsWith("https://"))
|
||||
url = "http://" + url;
|
||||
intent.setData(Uri.parse(url));
|
||||
getContext().startActivity(intent);
|
||||
}
|
||||
|
||||
private void toggleIsBookmark(@NonNull MapObject mapObject)
|
||||
{
|
||||
if (MapObject.isOfType(MapObject.BOOKMARK, mapObject))
|
||||
|
|
|
@ -204,7 +204,11 @@ public class Utils
|
|||
|
||||
public static void openUrl(@NonNull Context activity, @NonNull String url)
|
||||
{
|
||||
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
if (!url.startsWith("http://") && !url.startsWith("https://"))
|
||||
url = "http://" + url;
|
||||
intent.setData(Uri.parse(url));
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void sendSupportMail(@NonNull Activity activity, @NonNull String subject)
|
||||
|
|
|
@ -23355,3 +23355,9 @@
|
|||
[search_hotel_filter_motel]
|
||||
en = Motel
|
||||
ru = Мотель
|
||||
|
||||
[create_campaign_button]
|
||||
en = Create ad campaign
|
||||
|
||||
[view_campaign_button]
|
||||
en = View ad campagain
|
||||
|
|
Loading…
Add table
Reference in a new issue