forked from organicmaps/organicmaps
[android] Review fixes
This commit is contained in:
parent
08bd233dc4
commit
509b2d9bff
10 changed files with 85 additions and 86 deletions
|
@ -38,10 +38,9 @@ jobject CreateBanner(JNIEnv * env, bool hasBanner, string const & bannerTitleId,
|
|||
|
||||
jobject CreateMapObject(JNIEnv * env, int mapObjectType, string const & title,
|
||||
string const & subtitle, double lat, double lon, string const & address,
|
||||
Metadata const & metadata, string const & apiId,
|
||||
bool hasBanner, string const & bannerTitleId,
|
||||
string const & bannerMessageId, string const & bannerIconId,
|
||||
string const & bannerUrl)
|
||||
Metadata const & metadata, string const & apiId, bool hasBanner,
|
||||
string const & bannerTitleId, string const & bannerMessageId,
|
||||
string const & bannerIconId, string const & bannerUrl)
|
||||
{
|
||||
// public MapObject(@MapObjectType int mapObjectType, String title, String subtitle, double lat,
|
||||
// double lon, String address, String apiId, @NonNull Banner banner)
|
||||
|
@ -53,14 +52,10 @@ jobject CreateMapObject(JNIEnv * env, int mapObjectType, string const & title,
|
|||
jobject jbanner =
|
||||
CreateBanner(env, hasBanner, bannerTitleId, bannerMessageId, bannerIconId, bannerUrl);
|
||||
|
||||
jobject mapObject = env->NewObject(g_mapObjectClazz, ctorId,
|
||||
mapObjectType,
|
||||
jni::ToJavaString(env, title),
|
||||
jni::ToJavaString(env, subtitle),
|
||||
jni::ToJavaString(env, address),
|
||||
lat, lon,
|
||||
jni::ToJavaString(env, apiId),
|
||||
jbanner);
|
||||
jobject mapObject =
|
||||
env->NewObject(g_mapObjectClazz, ctorId, mapObjectType, jni::ToJavaString(env, title),
|
||||
jni::ToJavaString(env, subtitle), jni::ToJavaString(env, address), lat, lon,
|
||||
jni::ToJavaString(env, apiId), jbanner);
|
||||
|
||||
InjectMetadata(env, g_mapObjectClazz, mapObject, metadata);
|
||||
return mapObject;
|
||||
|
@ -70,7 +65,8 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
|||
{
|
||||
if (info.IsBookmark())
|
||||
{
|
||||
// public Bookmark(@IntRange(from = 0) int categoryId, @IntRange(from = 0) int bookmarkId, String name)
|
||||
// public Bookmark(@IntRange(from = 0) int categoryId, @IntRange(from = 0) int bookmarkId,
|
||||
// String name)
|
||||
static jmethodID const ctorId = jni::GetConstructorID(
|
||||
env, g_bookmarkClazz, "(IILjava/lang/String;Lcom/mapswithme/maps/bookmarks/data/Banner;)V");
|
||||
|
||||
|
@ -80,20 +76,21 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
|||
|
||||
auto const & bac = info.GetBookmarkAndCategory();
|
||||
BookmarkCategory * cat = g_framework->NativeFramework()->GetBmCategory(bac.m_categoryIndex);
|
||||
BookmarkData const & data = static_cast<Bookmark const *>(cat->GetUserMark(bac.m_bookmarkIndex))->GetData();
|
||||
BookmarkData const & data =
|
||||
static_cast<Bookmark const *>(cat->GetUserMark(bac.m_bookmarkIndex))->GetData();
|
||||
|
||||
jni::TScopedLocalRef jName(env, jni::ToJavaString(env, data.GetName()));
|
||||
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(), jbanner);
|
||||
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(), jbanner);
|
||||
if (info.IsFeature())
|
||||
InjectMetadata(env, g_mapObjectClazz, mapObject, info.GetMetadata());
|
||||
return mapObject;
|
||||
}
|
||||
|
||||
ms::LatLon const ll = info.GetLatLon();
|
||||
search::AddressInfo const address = g_framework->NativeFramework()->GetAddressInfoAtPoint(info.GetMercator());
|
||||
search::AddressInfo const address =
|
||||
g_framework->NativeFramework()->GetAddressInfoAtPoint(info.GetMercator());
|
||||
|
||||
// TODO(yunikkk): object can be POI + API + search result + bookmark simultaneously.
|
||||
// TODO(yunikkk): Should we pass localized strings here and in other methods as byte arrays?
|
||||
|
|
|
@ -56,9 +56,7 @@
|
|||
android:layout_toRightOf="@id/iv__banner_icon"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body4"
|
||||
android:visibility="gone"
|
||||
tools:text="Бесплатная курьерская доставка по России!
|
||||
|
||||
Коллекции женской, мужской и детской одежды, обуви,
|
||||
tools:text="Бесплатная курьерская доставка по России!\n\nКоллекции женской, мужской и детской одежды, обуви,
|
||||
а также товары для дома и спорта. Цены."
|
||||
tools:visibility="visible"/>
|
||||
|
||||
|
|
|
@ -1258,9 +1258,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, "", Banner.empty()),
|
||||
from.mLat, from.mLon, "", Banner.EMPTY),
|
||||
new MapObject(MapObject.API_POINT, to.mName, "", "",
|
||||
to.mLat, to.mLon, "", Banner.empty()));
|
||||
to.mLat, to.mLon, "", Banner.EMPTY));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,41 +7,7 @@ import android.support.annotation.Nullable;
|
|||
|
||||
public final class Banner implements Parcelable
|
||||
{
|
||||
private final boolean mIsActive;
|
||||
@Nullable
|
||||
private final String mTitle;
|
||||
@Nullable
|
||||
private final String mMessage;
|
||||
@Nullable
|
||||
private final String mIconUrl;
|
||||
@Nullable
|
||||
private final String mUrl;
|
||||
|
||||
@NonNull
|
||||
public static Banner empty()
|
||||
{
|
||||
return new Banner(false, "", "", "", "");
|
||||
}
|
||||
|
||||
public Banner(boolean isActive, @Nullable String title, @Nullable String message,
|
||||
@Nullable String iconUrl, @Nullable String url)
|
||||
{
|
||||
mIsActive = isActive;
|
||||
mTitle = title;
|
||||
mMessage = message;
|
||||
// mIconUrl = iconUrl;
|
||||
mIconUrl = "https://lh6.ggpht.com/bVwOOcO1jm_bfvqtkUDEyyOl2PZ-ZLaxqzylW5NtM2NHSlLQAnC1t45gf6d6JX07XQ=w300";
|
||||
mUrl = url;
|
||||
}
|
||||
|
||||
protected Banner(Parcel in)
|
||||
{
|
||||
mIsActive = in.readByte() != 0;
|
||||
mTitle = in.readString();
|
||||
mMessage = in.readString();
|
||||
mIconUrl = in.readString();
|
||||
mUrl = in.readString();
|
||||
}
|
||||
public static final Banner EMPTY = new Banner(false, "", "", "", "");
|
||||
|
||||
public static final Creator<Banner> CREATOR = new Creator<Banner>()
|
||||
{
|
||||
|
@ -58,6 +24,37 @@ public final class Banner implements Parcelable
|
|||
}
|
||||
};
|
||||
|
||||
private final boolean mIsActive;
|
||||
@Nullable
|
||||
private final String mTitle;
|
||||
@Nullable
|
||||
private final String mMessage;
|
||||
@Nullable
|
||||
private final String mIconUrl;
|
||||
@Nullable
|
||||
private final String mUrl;
|
||||
|
||||
public Banner(boolean isActive, @Nullable String title, @Nullable String message,
|
||||
@Nullable String iconUrl, @Nullable String url)
|
||||
{
|
||||
mIsActive = isActive;
|
||||
mTitle = title;
|
||||
mMessage = message;
|
||||
//TODO: uncomment this when cpp banner implementation will be done
|
||||
//mIconUrl = iconUrl;
|
||||
mIconUrl = "https://lh6.ggpht.com/bVwOOcO1jm_bfvqtkUDEyyOl2PZ-ZLaxqzylW5NtM2NHSlLQAnC1t45gf6d6JX07XQ=w300";
|
||||
mUrl = url;
|
||||
}
|
||||
|
||||
protected Banner(Parcel in)
|
||||
{
|
||||
mIsActive = in.readByte() != 0;
|
||||
mTitle = in.readString();
|
||||
mMessage = in.readString();
|
||||
mIconUrl = in.readString();
|
||||
mUrl = in.readString();
|
||||
}
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
return mIsActive;
|
||||
|
|
|
@ -305,7 +305,7 @@ public enum LocationHelper
|
|||
|
||||
if (mMyPosition == null)
|
||||
mMyPosition = new MapObject(MapObject.MY_POSITION, "", "", "", mSavedLocation.getLatitude(),
|
||||
mSavedLocation.getLongitude(), "", Banner.empty());
|
||||
mSavedLocation.getLongitude(), "", Banner.EMPTY);
|
||||
|
||||
return mMyPosition;
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ public class SearchFragment extends BaseMwmFragment
|
|||
{
|
||||
//noinspection ConstantConditions
|
||||
final MapObject point = new MapObject(MapObject.SEARCH, result.name,
|
||||
result.description.featureType, "", result.lat, result.lon, "", Banner.empty());
|
||||
result.description.featureType, "", result.lat, result.lon, "", Banner.EMPTY);
|
||||
RoutingController.get().onPoiSelected(point);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.mapswithme.maps.widget.placepage;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
@ -14,13 +13,13 @@ import com.bumptech.glide.Glide;
|
|||
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.bookmarks.data.Banner;
|
||||
import com.mapswithme.util.ConnectionState;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
||||
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
import static com.mapswithme.util.SharedPropertiesUtils.isShowcaseSwitchedOnLocal;
|
||||
|
||||
final class BannerController implements View.OnClickListener
|
||||
{
|
||||
|
@ -46,13 +45,7 @@ final class BannerController implements View.OnClickListener
|
|||
private final float mMarginBase;
|
||||
private final float mMarginHalfPlus;
|
||||
|
||||
private boolean mState = false;
|
||||
|
||||
private static boolean isShowcaseSwitchedOn()
|
||||
{
|
||||
return PreferenceManager.getDefaultSharedPreferences(MwmApplication.get())
|
||||
.getBoolean(MwmApplication.get().getString(R.string.pref_showcase_switched_on), false);
|
||||
}
|
||||
private boolean mIsOpened = false;
|
||||
|
||||
BannerController(@NonNull View bannerView, @Nullable OnBannerClickListener listener)
|
||||
{
|
||||
|
@ -79,7 +72,7 @@ final class BannerController implements View.OnClickListener
|
|||
if (mMessage != null)
|
||||
mMessage.setText(banner.getMessage());
|
||||
boolean showBanner = banner.isActive() && ConnectionState.isConnected()
|
||||
&& isShowcaseSwitchedOn();
|
||||
&& isShowcaseSwitchedOnLocal();
|
||||
UiUtils.showIf(showBanner, mFrame);
|
||||
if (UiUtils.isLandscape(mFrame.getContext()))
|
||||
open();
|
||||
|
@ -92,10 +85,10 @@ final class BannerController implements View.OnClickListener
|
|||
|
||||
void open()
|
||||
{
|
||||
if (!isShowing() || mBanner == null || mState)
|
||||
if (!isShowing() || mBanner == null || mIsOpened)
|
||||
return;
|
||||
|
||||
mState = true;
|
||||
mIsOpened = true;
|
||||
setFrameHeight(WRAP_CONTENT);
|
||||
setIconParams(mOpenIconSize, 0, mMarginBase);
|
||||
UiUtils.show(mMessage, mAdMarker);
|
||||
|
@ -107,10 +100,10 @@ final class BannerController implements View.OnClickListener
|
|||
|
||||
void close()
|
||||
{
|
||||
if (!isShowing() || mBanner == null || !mState)
|
||||
if (!isShowing() || mBanner == null || !mIsOpened)
|
||||
return;
|
||||
|
||||
mState = false;
|
||||
mIsOpened = false;
|
||||
setFrameHeight((int) mCloseFrameHeight);
|
||||
setIconParams(mCloseIconSize, mMarginBase, mMarginHalfPlus);
|
||||
UiUtils.hide(mMessage, mAdMarker);
|
||||
|
|
|
@ -163,7 +163,6 @@ public class PlacePageView extends RelativeLayout
|
|||
private TextView mHotelRatingBase;
|
||||
//TODO: remove this after booking_api.cpp will be done
|
||||
private View mHotelMore;
|
||||
// Banner
|
||||
@Nullable
|
||||
BannerController mBannerController;
|
||||
|
||||
|
@ -719,7 +718,7 @@ public class PlacePageView extends RelativeLayout
|
|||
@Override
|
||||
public void onBannerClick(@NonNull Banner banner)
|
||||
{
|
||||
// TODO: go to banner url
|
||||
// TODO (goblinr): go to banner url
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -746,7 +745,7 @@ public class PlacePageView extends RelativeLayout
|
|||
mAnimationController = isBottom ? new BottomPlacePageAnimationController(this)
|
||||
: new LeftPlacePageAnimationController(this);
|
||||
if (isBottom)
|
||||
((BottomPlacePageAnimationController)mAnimationController).setBannerOpenListener(this);
|
||||
((BottomPlacePageAnimationController) mAnimationController).setBannerOpenListener(this);
|
||||
}
|
||||
|
||||
public void restore()
|
||||
|
@ -949,9 +948,8 @@ public class PlacePageView extends RelativeLayout
|
|||
UiUtils.showIf(!isPriceEmpty, mTvSponsoredPrice);
|
||||
}
|
||||
|
||||
Banner banner = mMapObject.getBanner();
|
||||
if (mBannerController != null)
|
||||
mBannerController.updateData(banner);
|
||||
mBannerController.updateData(mMapObject.getBanner());
|
||||
}
|
||||
|
||||
private void refreshDetails()
|
||||
|
|
21
android/src/com/mapswithme/util/SharedPropertiesUtils.java
Normal file
21
android/src/com/mapswithme/util/SharedPropertiesUtils.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package com.mapswithme.util;
|
||||
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
import static com.mapswithme.maps.MwmApplication.prefs;
|
||||
|
||||
public final class SharedPropertiesUtils
|
||||
{
|
||||
public static boolean isShowcaseSwitchedOnLocal()
|
||||
{
|
||||
return prefs()
|
||||
.getBoolean(MwmApplication.get().getString(R.string.pref_showcase_switched_on), false);
|
||||
}
|
||||
|
||||
//Utils class
|
||||
private SharedPropertiesUtils()
|
||||
{
|
||||
throw new IllegalStateException("Try instantiate utility class SharedPropertiesUtils");
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ import java.net.URL;
|
|||
import java.util.List;
|
||||
|
||||
import static com.mapswithme.maps.MwmApplication.prefs;
|
||||
import static com.mapswithme.util.SharedPropertiesUtils.isShowcaseSwitchedOnLocal;
|
||||
|
||||
public final class MytargetHelper
|
||||
{
|
||||
|
@ -172,12 +173,6 @@ public final class MytargetHelper
|
|||
mShowcase.handleBannerClick(banner);
|
||||
}
|
||||
|
||||
private static boolean isShowcaseSwitchedOnLocal()
|
||||
{
|
||||
return PreferenceManager.getDefaultSharedPreferences(MwmApplication.get())
|
||||
.getBoolean(MwmApplication.get().getString(R.string.pref_showcase_switched_on), false);
|
||||
}
|
||||
|
||||
public static boolean isShowcaseSwitchedOnServer()
|
||||
{
|
||||
return prefs().getBoolean(PREF_CHECK, true);
|
||||
|
|
Loading…
Add table
Reference in a new issue