Panagiotis Triantafyllou

huawei map

......@@ -116,6 +116,7 @@
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_more_for_you.xml" value="0.22" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_past_coupons.xml" value="0.358695652173913" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_shops.xml" value="0.36666666666666664" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_shops_huawei.xml" value="0.23157894736842105" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_steps.xml" value="0.358695652173913" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_telco.xml" value="0.36666666666666664" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_webview.xml" value="0.4282238442822384" />
......
apply plugin: 'com.android.application'
//apply plugin: 'com.google.gms.google-services'
//apply plugin: 'com.huawei.agconnect'
android {
compileSdkVersion 31
......@@ -23,16 +24,22 @@ android {
signingConfigs {
config {
// Set the parameters based on the actual signing information.
keyAlias 'warplydemo'
keyPassword 'warplydemo'
storeFile file('../keystore/warplydemo.jks')
storePassword 'warplydemo'
keyAlias 'democosmote'
keyPassword 'democosmote'
storeFile file('../keystore/democosmote.jks')
storePassword 'democosmote'
}
debug {
keyAlias 'androiddebugkey'
keyPassword 'android'
storeFile file('../keystore/debug.keystore')
storePassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.config
......
......@@ -10,7 +10,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.huawei.agconnect:agcp:1.6.2.300'
classpath 'com.huawei.agconnect:agcp:1.7.2.300'
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
......
No preview for this file type
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4.6rc41'
PUBLISH_VERSION = '4.5.4.6rc42'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......@@ -89,6 +89,8 @@ dependencies {
implementation 'com.huawei.hms:base:6.6.0.300'
implementation 'com.huawei.hms:push:6.7.0.300'
implementation 'com.huawei.hms:ads-identifier:3.4.56.300'
implementation 'com.huawei.hms:maps:6.9.0.300'
implementation 'com.huawei.hms:maps-basic:6.9.0.300'
//------------------------------ SQLCipher -----------------------------//
api "net.zetetic:android-database-sqlcipher:4.5.2"
......
......@@ -12,6 +12,8 @@
<uses-permission
android:name="android.permission.REQUEST_INSTALL_PACKAGES"
tools:node="remove" />
<uses-permission android:name="com.huawei.appmarket.service.commondata.permission.GET_COMMON_DATA"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<application android:largeHeap="true">
<!-- <meta-data-->
......@@ -88,6 +90,12 @@
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.ShopsHuaweiActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.CouponShareActivity"
android:exported="false"
android:screenOrientation="portrait"
......
......@@ -36,6 +36,7 @@ import ly.warp.sdk.io.models.Coupon;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.io.models.Merchant;
import ly.warp.sdk.services.EventCouponsService;
import ly.warp.sdk.utils.WarplyDeviceInfoCollector;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
......@@ -131,10 +132,17 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
if (view.getId() == R.id.ll_shops) {
WarplyAnalyticsManager.logTrackersEvent(this, "click", "SeeShops");
Intent intent = new Intent(CouponInfoActivity.this, ShopsActivity.class);
intent.putExtra("couponset", (Serializable) mCouponset);
startActivity(intent);
return;
if (WarplyDeviceInfoCollector.isPackageInstalled("com.android.vending", getPackageManager())) {
Intent intent = new Intent(CouponInfoActivity.this, ShopsActivity.class);
intent.putExtra("couponset", (Serializable) mCouponset);
startActivity(intent);
return;
} else {
Intent intent = new Intent(CouponInfoActivity.this, ShopsHuaweiActivity.class);
intent.putExtra("couponset", (Serializable) mCouponset);
startActivity(intent);
return;
}
}
if (view.getId() == R.id.ll_website) {
WarplyAnalyticsManager.logTrackersEvent(this, "click", "SeeShopWebsite");
......
......@@ -69,7 +69,7 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
private Couponset mCouponset;
private GoogleMap mMap;
private ClusterManager<Merchant> mClusterManager;
SupportMapFragment mMapView;
private SupportMapFragment mMapView;
private MerchantList mMerchantList = new MerchantList();
private AlertDialog mAlertDialogNoShopsAvailable;
private Merchant mMerchant;
......
package ly.warp.sdk.activities;
import android.Manifest;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.huawei.hms.maps.CameraUpdate;
import com.huawei.hms.maps.CameraUpdateFactory;
import com.huawei.hms.maps.HuaweiMap;
import com.huawei.hms.maps.MapsInitializer;
import com.huawei.hms.maps.OnMapReadyCallback;
import com.huawei.hms.maps.SupportMapFragment;
import com.huawei.hms.maps.model.LatLng;
import com.huawei.hms.maps.model.Marker;
import com.huawei.hms.maps.model.MarkerOptions;
import java.util.ArrayList;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;
import ly.warp.sdk.R;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.io.models.Merchant;
import ly.warp.sdk.io.models.MerchantList;
import ly.warp.sdk.io.request.WarplyMerchantsRequest;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.constants.WarpConstants;
import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
import ly.warp.sdk.utils.managers.WarplyManager;
public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClickListener, OnMapReadyCallback,
HuaweiMap.OnMapLoadedCallback, HuaweiMap.OnMarkerClickListener {
// ===========================================================
// Constants
// ===========================================================
public final static float DEFAULT_LOCATION_ZOOM = 6.2f;
// ===========================================================
// Fields
// ===========================================================
private ImageView mIvBack;
private Couponset mCouponset;
private HuaweiMap mMap;
// private ClusterManager<Merchant> mClusterManager;
private SupportMapFragment mSupportMapFragment;
private MerchantList mMerchantList = new MerchantList();
private AlertDialog mAlertDialogNoShopsAvailable;
private Merchant mMerchant;
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapsInitializer.initialize(this);
setContentView(R.layout.activity_shops_huawei);
mCouponset = (Couponset) getIntent().getSerializableExtra("couponset");
for (Merchant merchant : WarplyManagerHelper.getMerchantList()) {
if (merchant.getUuid().equals(mCouponset.getMerchantUuid())) {
mMerchant = merchant;
break;
}
}
mIvBack = findViewById(R.id.iv_shops_back);
mSupportMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mv_shops_huawei);
mSupportMapFragment.getMapAsync(this);
mIvBack.setOnClickListener(this);
}
@Override
public void onResume() {
super.onResume();
WarplyAnalyticsManager.logTrackersEvent(this, "screen", "ShopsScreen");
}
@Override
public void onClick(View view) {
if (view.getId() == R.id.iv_shops_back) {
onBackPressed();
}
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
}
// @Override
// public void onRequestPermissionsResult(
// int requestCode,
// String permissions[],
// int[] grantResults) {
// switch (requestCode) {
// case REQUEST_PERMISSION_PHONE_STATE:
// if (grantResults.length > 0
// && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// Toast.makeText(MainActivity.this, "Permission Granted!", Toast.LENGTH_SHORT).show();
// } else {
// Toast.makeText(MainActivity.this, "Permission Denied!", Toast.LENGTH_SHORT).show();
// }
// }
// }
@Override
public void onMapReady(HuaweiMap huaweiMap) {
mMap = huaweiMap;
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
mMap.setMyLocationEnabled(true);
}
} else {
mMap.setMyLocationEnabled(false);
// ActivityCompat.requestPermissions(this,
// new String[]{Manifest.permission.ACCESS_FINE_LOCATION,
// Manifest.permission.ACCESS_COARSE_LOCATION}, 501);
}
mMap.setMyLocationEnabled(false);
mMap.setMapType(HuaweiMap.MAP_TYPE_NORMAL);
mMap.setMinZoomPreference(DEFAULT_LOCATION_ZOOM);
mMap.setLatLngBoundsForCameraTarget(WarpConstants.GREECE_BOUNDS_HUAWEI);
mMap.getUiSettings().setZoomControlsEnabled(true);
mMap.getUiSettings().setZoomGesturesEnabled(true);
mMap.getUiSettings().setCompassEnabled(false);
mMap.getUiSettings().setMyLocationButtonEnabled(false);
mMap.getUiSettings().setMapToolbarEnabled(false);
mMap.getUiSettings().setTiltGesturesEnabled(false);
mMap.getUiSettings().setRotateGesturesEnabled(false);
mMap.setOnMapLoadedCallback(this);
mMap.setOnMarkerClickListener(/*mClusterManager*/this);
mMap.setMarkersClustering(true);
}
@Override
public void onMapLoaded() {
if (mMap != null) {
CameraUpdate camUpdate;
camUpdate = CameraUpdateFactory.newLatLngBounds(WarpConstants.GREECE_BOUNDS_HUAWEI, 48);
mMap.animateCamera(camUpdate);
}
//
// if (mClusterManager == null) {
// mClusterManager = new ClusterManager<>(this, mMap);
// mClusterManager.setOnClusterClickListener(this);
//// mMap.setOnMarkerClickListener(/*mClusterManager*/this);
// }
//
if (mCouponset != null) {
ArrayList<String> uuids = new ArrayList<>();
uuids.add(mCouponset.getMerchantUuid());
new Thread(() -> {
if (!Thread.currentThread().isInterrupted()) {
WarplyManager.getMerchantsMultilingual(new WarplyMerchantsRequest()
.setIsMultilingual(true)
.setParentUuids(uuids)
, mMerchantsCallback);
}
Thread.currentThread().interrupt();
}).start();
}
}
// @Override
// public boolean onClusterClick(Cluster<Merchant> cluster) {
// if (mMap != null) {
// mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(cluster.getPosition(),
// (float) Math.floor(mMap.getCameraPosition().zoom + 1)), 300, null);
//
//// mMap.clear();
//// mClusterManager.clearItems();
//// mClusterManager.addItems(cluster.getItems());
//// mClusterManager.cluster();
// }
// return true;
// }
@Override
public boolean onMarkerClick(@NonNull Marker marker) {
for (Merchant merch : mMerchantList) {
if (merch.getUuid().equals(marker.getSnippet())) {
WarplyAnalyticsManager.logTrackersEvent(this, "click", ("ShopsScreenMarker").concat(":").concat(marker.getSnippet()));
final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
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);
pinTitle.setText(merch.getAdminName());
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);
pinName.setText(merch.getName());
TextView pinDays = (TextView) bottomSheetDialog.findViewById(R.id.tv_pin_days);
pinDays.setText(merch.getSnippet()); //TODO: wrong getter
TextView pinTel = (TextView) bottomSheetDialog.findViewById(R.id.tv_pin_tel);
pinTel.setText(merch.getTelephone());
TextView pinAddress = (TextView) bottomSheetDialog.findViewById(R.id.tv_pin_address);
pinAddress.setText(merch.getAddress());
LinearLayout pinDirections = (LinearLayout) bottomSheetDialog.findViewById(R.id.ll_directions);
pinDirections.setOnClickListener(view -> {
Uri hmmIntentUri = Uri.parse("petalmaps://navigation?daddr=" + merch.getLatitude() + "," + merch.getLongitude());
Intent mapIntent = new Intent(Intent.ACTION_VIEW, hmmIntentUri);
if (mapIntent.resolveActivity(getPackageManager()) != null) {
startActivity(mapIntent);
} else {
noMapAvailableDialog();
}
});
bottomSheetDialog.show();
return false;
}
}
return false;
}
// ===========================================================
// Methods
// ===========================================================
private void showNoShopsAvailableDialog() {
if (!isFinishing()) {
mAlertDialogNoShopsAvailable = new AlertDialog.Builder(this)
.setTitle(R.string.cos_dlg_no_shops_title)
.setMessage(R.string.cos_dlg_no_shops)
.setCancelable(false)
.setPositiveButton(R.string.cos_dlg_no_shops_positive, (dialogPositive, whichPositive) -> {
dialogPositive.dismiss();
openWebsite();
})
.setNegativeButton(R.string.cos_dlg_negative_button2, (dialogNegative, whichNegative) -> {
dialogNegative.dismiss();
onBackPressed();
})
.show();
}
}
private void noMapAvailableDialog() {
if (!isFinishing()) {
mAlertDialogNoShopsAvailable = new AlertDialog.Builder(this)
.setTitle(R.string.cos_dlg_error_title)
.setMessage(R.string.cos_dlg_no_map)
.setCancelable(false)
.setPositiveButton("ΟΚ", (dialogPositive, whichPositive) -> {
dialogPositive.dismiss();
})
.show();
}
}
private void openWebsite() {
WarplyAnalyticsManager.logTrackersEvent(this, "click", "SeeShopWebsite");
if (!TextUtils.isEmpty(mMerchant.getWebsite())) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(mMerchant.getWebsite()));
startActivity(intent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
}
private final CallbackReceiver<MerchantList> mMerchantsCallback = new CallbackReceiver<MerchantList>() {
@Override
public void onSuccess(MerchantList result) {
mMerchantList.clear();
mMerchantList.addAll(result);
new Handler(Looper.getMainLooper()).post(() -> {
// if (mClusterManager != null) {
// mMap.clear();
// mClusterManager.clearItems();
// if (result != null) {
// mClusterManager.addItems(result);
// }
// mClusterManager.cluster();
// }
int nonNullCoords = 0;
for (Merchant merchCoords : result) {
if (merchCoords.getLatitude() != 0.0 && merchCoords.getLongitude() != 0.0) {
nonNullCoords++;
}
}
if (result.size() == 0 || nonNullCoords == 0) {
showNoShopsAvailableDialog();
return;
}
for (Merchant merch : result) {
mMap.addMarker(new MarkerOptions()
.position(new LatLng(merch.getLatitude(), merch.getLongitude()))
.anchor(0.5f, 0.5f)
.title(merch.getTitle())
.snippet(merch.getUuid())
.clusterable(true));
}
});
}
@Override
public void onFailure(int errorCode) {
Log.v("SHOPS_HUAWEI_ACTIVITY", String.valueOf(errorCode));
}
};
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}
......@@ -385,7 +385,7 @@ public class WarplyDeviceInfoCollector {
return json;
}
public boolean isPackageInstalled(String packageName, PackageManager packageManager) {
public static boolean isPackageInstalled(String packageName, PackageManager packageManager) {
try {
return packageManager.getApplicationInfo(packageName, 0).enabled;
} catch (PackageManager.NameNotFoundException e) {
......
......@@ -83,6 +83,11 @@ public class WarpConstants {
new LatLng(41.97761, 28.62522)
);
public static final com.huawei.hms.maps.model.LatLngBounds GREECE_BOUNDS_HUAWEI = new com.huawei.hms.maps.model.LatLngBounds(
new com.huawei.hms.maps.model.LatLng(34.75261, 19.33079),
new com.huawei.hms.maps.model.LatLng(41.97761, 28.62522)
);
/* Result codes */
public static final int RESULT_CODE_SUCCESS = 1;
......
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_loyalty_wallet_header"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@android:color/white">
<ImageView
android:id="@+id/iv_shops_back"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:scaleType="centerInside"
android:src="@drawable/ic_back"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
fontPath="fonts/pf_square_sans_pro_medium.ttf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cos_coupon_shops_title"
android:textColor="@color/grey"
android:textSize="17sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout
android:id="@+id/cl_loyalty_info_view_inner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/cl_loyalty_wallet_header">
<fragment
android:id="@+id/mv_shops_huawei"
class="com.huawei.hms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
</RelativeLayout>
......@@ -146,6 +146,7 @@
<string name="cos_dlg_coupon_depleted_title">Το κουπόνι εξαντλήθηκε</string>
<string name="cos_dlg_coupon_depleted_message">Μείνε συντονισμένος για νέες προσφορές και κουπόνια.</string>
<string name="cos_dlg_no_shops">Ο συνεργάτης διαθέτει μόνο ηλεκτρονικό κατάστημα για ηλεκτρονικές παραγγελίες.</string>
<string name="cos_dlg_no_map">Το πρόγραμμα Χάρτες Petal λείπει.</string>
<string name="cos_dlg_no_shops_title">Καταστήματα συνεργάτη</string>
<string name="cos_dlg_no_shops_positive">Δες το eshop</string>
......