Panagiotis Triantafyllou

more additions

......@@ -46,4 +46,4 @@ LoginType=msisdn
# The deeplink url scheme for react native campaigns:
# Example visit.greece.gr
#DL_URL_SCHEME=
\ No newline at end of file
DL_URL_SCHEME=demo
\ No newline at end of file
......
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4-cos2'
PUBLISH_VERSION = '4.5.4-cos3'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -66,6 +66,11 @@
<data
android:host="cosmoteapp.gr"
android:scheme="demo" />
<data
android:host="cosmoteapp.gr"
android:pathPrefix="/payment"
android:scheme="demo" />
</intent-filter>
</activity>
......
......@@ -126,6 +126,10 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
String parameter = String.valueOf(intent.getData().getQueryParameter("participations"));
showDialog(parameter);
}
if (data.getPath().equals("/payment")) {
Intent intentBill = new Intent(BaseFragmentActivity.this, BillPaymentActivity.class);
startActivity(intentBill);
}
}
}
......
......@@ -2,8 +2,20 @@ package ly.warp.sdk.activities;
import android.app.Activity;
import android.app.Dialog;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.BitmapFactory;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
......@@ -14,6 +26,8 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.app.NotificationCompat;
import ly.warp.sdk.R;
import ly.warp.sdk.db.WarplyDBHelper;
import ly.warp.sdk.utils.WarpUtils;
......@@ -54,14 +68,41 @@ public class BillPaymentActivity extends Activity implements View.OnClickListene
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent.hasExtra("channel")) {
String tempUrl = BaseFragmentActivity.getUniqueCampaignList().get("lucky_draw").get(0).getIndexUrl();
tempUrl = tempUrl
+ "?web_id=" + WarpUtils.getWebId(this)
+ "&app_uuid=" + WarplyProperty.getAppUuid(this)
+ "&api_key=" + WarpUtils.getApiKey(this)
+ "&session_uuid=" + BaseFragmentActivity.getUniqueCampaignList().get("lucky_draw").get(0).getSessionUUID()
+ "&access_token=" + WarplyDBHelper.getInstance(this).getAuthValue("access_token")
+ "&refresh_token=" + WarplyDBHelper.getInstance(this).getAuthValue("refresh_token")
+ "&client_id=" + WarplyDBHelper.getInstance(this).getClientValue("client_id")
+ "&client_secret=" + WarplyDBHelper.getInstance(this).getClientValue("client_secret");
if (BaseFragmentActivity.getConsumer() != null)
tempUrl = tempUrl + "&auth_token=" + (BaseFragmentActivity.getConsumer().getUuid());
else
tempUrl = tempUrl + "&auth_token=";
startActivity(WarpViewActivity.createIntentFromURL(this, tempUrl));
}
}
@Override
public void onClick(View view) {
if (view.getId() == R.id.iv_bill_payment_close) {
onBackPressed();
return;
}
if (view.getId() == R.id.button_pay) {
// open dialog
showDialog();
new Handler(Looper.getMainLooper()).postDelayed(
() -> createLocalNotification(BillPaymentActivity.this),
3000);
}
}
......@@ -69,6 +110,50 @@ public class BillPaymentActivity extends Activity implements View.OnClickListene
// Methods
// ===========================================================
private void createLocalNotification(Context context) {
PendingIntent pendingIntent;
Intent notifyIntent;
notifyIntent = new Intent(this, BillPaymentActivity.class).putExtra("channel", "paymentNotify");
notifyIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
pendingIntent = PendingIntent.getActivity(context, 1001, notifyIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE);
} else {
pendingIntent = PendingIntent.getActivity(context, 1001, notifyIntent, PendingIntent.FLAG_ONE_SHOT);
}
NotificationCompat.Builder b = new NotificationCompat.Builder(this, "paymentNotify")
.setSmallIcon(R.drawable.gift_icon)
.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.ic_launcher))
.setContentTitle("Συγχαρητήρια!")
.setContentText("Ξεκλείδωσες το My Lucky Draw με την πληρωμή του λογαριασμού σου! Πάρε μέρος στις κληρώσεις!")
.setStyle(new NotificationCompat.BigTextStyle()
.bigText("Ξεκλείδωσες το My Lucky Draw με την πληρωμή του λογαριασμού σου! Πάρε μέρος στις κληρώσεις!"))
.setAutoCancel(true)
.setVibrate(new long[0])
.setDefaults(Notification.DEFAULT_ALL)
.setChannelId("paymentNotify")
.setPriority(Notification.PRIORITY_HIGH)
.setContentIntent(pendingIntent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel("paymentNotify", "paymentNotify", NotificationManager.IMPORTANCE_HIGH);
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
notificationChannel.setDescription("Ξεκλείδωσες το My Lucky Draw με την πληρωμή του λογαριασμού σου! Πάρε μέρος στις κληρώσεις!");
notificationChannel.setShowBadge(true);
NotificationManager nm = getSystemService(NotificationManager.class);
nm.createNotificationChannel(notificationChannel);
Notification notification_build = b.setChannelId("paymentNotify").build();
notification_build.flags = Notification.FLAG_AUTO_CANCEL;
nm.notify(1001, notification_build);
} else {
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification_build = b.build();
notification_build.flags = Notification.FLAG_AUTO_CANCEL;
nm.notify(1001, notification_build);
}
}
private void initViews() {
mIvBack.setOnClickListener(this);
mPayBtn.setOnClickListener(this);
......