Panagiotis Triantafyllou

map marker view part1

......@@ -5,7 +5,7 @@ android.buildFeatures.buildConfig = true
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.5.6deh5'
PUBLISH_VERSION = '4.5.5.6deh6'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -12,7 +12,6 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
......@@ -50,10 +49,7 @@ import ly.warp.sdk.io.callbacks.CallbackReceiver;
import ly.warp.sdk.io.models.Coupon;
import ly.warp.sdk.io.models.Merchant;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.constants.WarpConstants;
import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
import ly.warp.sdk.utils.managers.WarplyManager;
public class ShopsActivity extends FragmentActivity implements View.OnClickListener,
......@@ -168,8 +164,8 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
//// mMap.setOnMarkerClickListener(/*mClusterManager*/this);
// }
if (!TextUtils.isEmpty(mMerchantUuid)) {
WarplyManager.getStores("86eba6980cf746cbbcca5c6446700121", mStoresCallback);
if (!TextUtils.isEmpty(mMerchantUuid)) { // "86eba6980cf746cbbcca5c6446700121" test merchant for pins
WarplyManager.getStores(mMerchantUuid, mStoresCallback);
}
}
......@@ -188,59 +184,69 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
@Override
public boolean onMarkerClick(@NonNull Marker marker) {
// for (Merchant merch : mMerchantList) {
// if (merch.getUuid().equals(marker.getSnippet())) {
// final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this, R.style.BottomSheetDialog);
// bottomSheetDialog.setContentView(R.layout.dl_map_pin);
// ImageView dialogClose = (ImageView) bottomSheetDialog.findViewById(R.id.iv_map_pin_close);
// dialogClose.setOnClickListener(view -> bottomSheetDialog.dismiss());
// TextView pinTitle = (TextView) bottomSheetDialog.findViewById(R.id.tv_pin_title);
// WarpUtils.renderCustomFont(ShopsActivity.this, R.font.pf_square_sans_pro_bold, pinTitle);
// if (mMerchantParentList != null && mMerchantParentList.size() > 0) {
// for (Merchant parentMerch : mMerchantParentList) {
// if (parentMerch.getUuid().equals(merch.getParent())) {
// pinTitle.setText(parentMerch.getAdminName());
// break;
// }
// }
// }
// ImageView pinLogo = (ImageView) bottomSheetDialog.findViewById(R.id.iv_pin_logo);
// if (!TextUtils.isEmpty(merch.getImgPreview())) {
// Glide.with(this)
//// .setDefaultRequestOptions(
//// RequestOptions
//// .placeholderOf(R.drawable.ic_default_contact_photo)
//// .error(R.drawable.ic_default_contact_photo))
// .load(merch.getImgPreview())
// .diskCacheStrategy(DiskCacheStrategy.DATA)
// .into(pinLogo);
// }
// TextView pinName = (TextView) bottomSheetDialog.findViewById(R.id.tv_pin_name);
// WarpUtils.renderCustomFont(ShopsActivity.this, R.font.pf_square_sans_pro_medium, pinName);
// pinName.setText(merch.getName());
// TextView pinDays = (TextView) bottomSheetDialog.findViewById(R.id.tv_pin_days);
// WarpUtils.renderCustomFont(ShopsActivity.this, R.font.pf_square_sans_pro_regular, pinDays);
// pinDays.setText(merch.getSnippet()); //TODO: wrong getter
// TextView pinTel = (TextView) bottomSheetDialog.findViewById(R.id.tv_pin_tel);
// WarpUtils.renderCustomFont(ShopsActivity.this, R.font.pf_square_sans_pro_medium, pinTel);
// pinTel.setText(merch.getTelephone());
// TextView pinAddress = (TextView) bottomSheetDialog.findViewById(R.id.tv_pin_address);
// WarpUtils.renderCustomFont(ShopsActivity.this, R.font.pf_square_sans_pro_medium, pinAddress);
// pinAddress.setText(merch.getAddress());
// TextView pinDirectionsText = (TextView) bottomSheetDialog.findViewById(R.id.tv_directions);
// WarpUtils.renderCustomFont(ShopsActivity.this, R.font.pf_square_sans_pro_medium, pinDirectionsText);
// LinearLayout pinDirections = (LinearLayout) bottomSheetDialog.findViewById(R.id.ll_directions);
// pinDirections.setOnClickListener(view -> {
// Uri gmmIntentUri = Uri.parse("google.navigation:q=" + merch.getLatitude() + "," + merch.getLongitude()/* + "&mode=w"*/);
// Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
// mapIntent.setPackage("com.google.android.apps.maps");
// Merchant merch = (Merchant) marker.getTag();
// if (merch == null) return false;
//
// final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this, R.style.BottomSheetDialog);
// bottomSheetDialog.setContentView(R.layout.demo_marker_view);
//
// ImageView dialogClose = bottomSheetDialog.findViewById(R.id.iv_map_pin_close);
// if (dialogClose != null) dialogClose.setOnClickListener(view -> bottomSheetDialog.dismiss());
//
// ImageView pinLogo = bottomSheetDialog.findViewById(R.id.iv_pin_logo);
// if (pinLogo != null && !TextUtils.isEmpty(merch.getImgPreview())) {
// Glide.with(this)
// .load(merch.getImgPreview())
// .diskCacheStrategy(DiskCacheStrategy.DATA)
// .into(pinLogo);
// }
//
// TextView pinTitle = bottomSheetDialog.findViewById(R.id.tv_pin_title);
// if (pinTitle != null) {
// WarpUtils.renderCustomFont(this, R.font.ping_lcg_bold, pinTitle);
// pinTitle.setText(!TextUtils.isEmpty(merch.getAdminName()) ? merch.getAdminName() : merch.getName());
// }
//
// TextView pinName = bottomSheetDialog.findViewById(R.id.tv_pin_name);
// if (pinName != null) {
// WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, pinName);
// pinName.setText(!TextUtils.isEmpty(merch.getName()) ? merch.getName() : "");
// }
//
// TextView pinAddress = bottomSheetDialog.findViewById(R.id.tv_pin_address);
// if (pinAddress != null) {
// WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, pinAddress);
// pinAddress.setText(!TextUtils.isEmpty(merch.getAddress()) ? merch.getAddress() : "");
// }
//
// TextView pinTel = bottomSheetDialog.findViewById(R.id.tv_pin_tel);
// if (pinTel != null) {
// WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, pinTel);
// pinTel.setText(!TextUtils.isEmpty(merch.getTelephone()) ? merch.getTelephone() : "");
// }
//
// TextView pinDirectionsText = bottomSheetDialog.findViewById(R.id.tv_directions);
// if (pinDirectionsText != null) {
// WarpUtils.renderCustomFont(this, R.font.ping_lcg_bold, pinDirectionsText);
// }
//
// LinearLayout pinDirections = bottomSheetDialog.findViewById(R.id.ll_directions);
// if (pinDirections != null) {
// pinDirections.setOnClickListener(view -> {
// Uri gmmIntentUri = Uri.parse("google.navigation:q=" + merch.getLatitude() + "," + merch.getLongitude());
// Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
// mapIntent.setPackage("com.google.android.apps.maps");
// try {
// startActivity(mapIntent);
// });
// bottomSheetDialog.show();
// return false;
// }
// } catch (ActivityNotFoundException e) {
// Uri browserUri = Uri.parse("https://maps.google.com/?q=" + merch.getLatitude() + "," + merch.getLongitude());
// startActivity(new Intent(Intent.ACTION_VIEW, browserUri));
// }
// });
// }
return false;
//
// bottomSheetDialog.show();
return true;
}
// ===========================================================
......@@ -321,53 +327,57 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap staticImage, @Nullable Transition<? super Bitmap> transition) {
Bitmap scaledPin = Bitmap.createScaledBitmap(staticImage,
(int) (staticImage.getWidth() * 0.75f),
(int) (staticImage.getHeight() * 0.75f),
true);
if (!TextUtils.isEmpty(merch.getImgPreview())) {
Glide.with(ShopsActivity.this)
.asBitmap()
.load(merch.getImgPreview())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(new CustomTarget<Bitmap>() {
@Override
@Override
public void onResourceReady(@NonNull Bitmap poiImage, @Nullable Transition<? super Bitmap> transition) {
Bitmap combinedBitmap = overlayBitmaps(staticImage, poiImage, 48, 48, 0);
Bitmap combinedBitmap = overlayBitmaps(scaledPin, poiImage, 48, 48, 0);
if (mMap != null) {
mMap.addMarker(new MarkerOptions()
Marker m = mMap.addMarker(new MarkerOptions()
.position(new LatLng(merch.getLatitude(), merch.getLongitude()))
.icon(BitmapDescriptorFactory.fromBitmap(combinedBitmap))
.anchor(0.5f, 1.0f)
.snippet(merch.getUuid()));
.anchor(0.5f, 1.0f));
if (m != null) m.setTag(merch);
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
if (mMap != null) {
mMap.addMarker(new MarkerOptions()
Marker m = mMap.addMarker(new MarkerOptions()
.position(new LatLng(merch.getLatitude(), merch.getLongitude()))
.icon(BitmapDescriptorFactory.fromBitmap(staticImage))
.anchor(0.5f, 1.0f)
.snippet(merch.getUuid()));
.icon(BitmapDescriptorFactory.fromBitmap(scaledPin))
.anchor(0.5f, 1.0f));
if (m != null) m.setTag(merch);
}
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
if (mMap != null) {
mMap.addMarker(new MarkerOptions()
Marker m = mMap.addMarker(new MarkerOptions()
.position(new LatLng(merch.getLatitude(), merch.getLongitude()))
.icon(BitmapDescriptorFactory.fromBitmap(staticImage))
.anchor(0.5f, 1.0f)
.snippet(merch.getUuid()));
.icon(BitmapDescriptorFactory.fromBitmap(scaledPin))
.anchor(0.5f, 1.0f));
if (m != null) m.setTag(merch);
}
}
});
} else {
if (mMap != null) {
mMap.addMarker(new MarkerOptions()
Marker m = mMap.addMarker(new MarkerOptions()
.position(new LatLng(merch.getLatitude(), merch.getLongitude()))
.icon(BitmapDescriptorFactory.fromBitmap(staticImage))
.anchor(0.5f, 1.0f)
.snippet(merch.getUuid()));
.icon(BitmapDescriptorFactory.fromBitmap(scaledPin))
.anchor(0.5f, 1.0f));
if (m != null) m.setTag(merch);
}
}
}
......@@ -375,10 +385,10 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
if (mMap != null) {
mMap.addMarker(new MarkerOptions()
Marker m = mMap.addMarker(new MarkerOptions()
.position(new LatLng(merch.getLatitude(), merch.getLongitude()))
.anchor(0.5f, 1.0f)
.snippet(merch.getUuid()));
.anchor(0.5f, 1.0f));
if (m != null) m.setTag(merch);
}
}
});
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="2.5dp" />
<solid
android:width="0dp"
android:color="@color/custom_grey10" />
</shape>
\ No newline at end of file
<?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="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/white"
android:paddingHorizontal="24dp"
android:paddingVertical="8dp">
<View
android:id="@+id/sheet_view"
android:layout_width="48dp"
android:layout_height="5dp"
android:layout_centerHorizontal="true"
android:background="@drawable/shape_rectangle_rounded_corners_grey" />
<ImageView
android:id="@+id/iv_map_pin_close"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:background="@drawable/shape_rectangle_rounded_grey"
android:padding="12dp"
android:src="@drawable/demo_close" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_map_pin_close">
<ImageView
android:id="@+id/iv_pin_logo"
android:layout_width="102dp"
android:layout_height="102dp"
android:scaleType="centerCrop"
android:background="@drawable/shape_rectangle_rounded_grey"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content">-->
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_toEndOf="@id/iv_pin_logo"-->
<!-- android:layout_toStartOf="@id/iv_map_pin_close"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:orientation="vertical"-->
<!-- android:paddingStart="12dp"-->
<!-- android:paddingEnd="8dp">-->
<!-- <TextView-->
<!-- android:id="@+id/tv_pin_title"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:includeFontPadding="false"-->
<!-- android:textColor="@color/custom_black6"-->
<!-- android:textSize="16sp"-->
<!-- android:textStyle="bold" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_pin_name"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="2dp"-->
<!-- android:includeFontPadding="false"-->
<!-- android:textColor="@color/custom_grey3"-->
<!-- android:textSize="13sp" />-->
<!-- </LinearLayout>-->
<!-- </RelativeLayout>-->
<!-- <View-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="1dp"-->
<!-- android:layout_marginTop="16dp"-->
<!-- android:layout_marginBottom="16dp"-->
<!-- android:background="@color/custom_grey4" />-->
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:gravity="center_vertical"-->
<!-- android:orientation="horizontal">-->
<!-- <ImageView-->
<!-- android:layout_width="16dp"-->
<!-- android:layout_height="16dp"-->
<!-- android:src="@android:drawable/ic_dialog_map"-->
<!-- android:tint="@color/custom_grey3" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_pin_address"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginStart="8dp"-->
<!-- android:layout_weight="1"-->
<!-- android:includeFontPadding="false"-->
<!-- android:textColor="@color/custom_grey3"-->
<!-- android:textSize="13sp" />-->
<!-- </LinearLayout>-->
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="8dp"-->
<!-- android:gravity="center_vertical"-->
<!-- android:orientation="horizontal">-->
<!-- <ImageView-->
<!-- android:layout_width="16dp"-->
<!-- android:layout_height="16dp"-->
<!-- android:src="@android:drawable/ic_menu_call"-->
<!-- android:tint="@color/custom_grey3" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_pin_tel"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginStart="8dp"-->
<!-- android:layout_weight="1"-->
<!-- android:includeFontPadding="false"-->
<!-- android:textColor="@color/custom_grey3"-->
<!-- android:textSize="13sp" />-->
<!-- </LinearLayout>-->
<!-- <LinearLayout-->
<!-- android:id="@+id/ll_directions"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="48dp"-->
<!-- android:layout_marginTop="20dp"-->
<!-- android:background="@drawable/shape_rectangle_rounded_black2"-->
<!-- android:gravity="center"-->
<!-- android:orientation="horizontal">-->
<!-- <TextView-->
<!-- android:id="@+id/tv_directions"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:includeFontPadding="false"-->
<!-- android:text="@string/lbl_directions"-->
<!-- android:textColor="@color/white"-->
<!-- android:textSize="14sp" />-->
<!-- </LinearLayout>-->
</RelativeLayout>
......@@ -41,4 +41,5 @@
<color name="custom_yellow2">#FFEABA</color>
<color name="custom_gold">#573300</color>
<color name="custom_grey9">#ADB3B8</color>
<color name="custom_grey10">#ECEDEF</color>
</resources>
......
......@@ -41,4 +41,5 @@
<string name="demo_coupon_expired">Expired</string>
<string name="demo_partners_title">Partner businesses</string>
<string name="demo_search_title">Αναζήτηση</string>
<string name="lbl_directions">Οδηγίες</string>
</resources>
......
......@@ -30,4 +30,21 @@
<style name="progressBarBlue" parent="@style/Theme.AppCompat">
<item name="colorAccent">@color/custom_light_blue</item>
</style>
<style name="BottomSheetDialog" parent="Theme.MaterialComponents.Light.BottomSheetDialog">
<item name="android:windowIsFloating">false</item>
<item name="bottomSheetStyle">@style/BottomSheetStyle</item>
</style>
<style name="BottomSheetStyle" parent="Widget.MaterialComponents.BottomSheet.Modal">
<item name="shapeAppearanceOverlay">@style/BottomSheetShapeAppearance</item>
</style>
<style name="BottomSheetShapeAppearance" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSizeTopLeft">16dp</item>
<item name="cornerSizeTopRight">16dp</item>
<item name="cornerSizeBottomLeft">0dp</item>
<item name="cornerSizeBottomRight">0dp</item>
</style>
</resources>
......