├── euromsg
├── .gitignore
├── gradle.properties
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── colors.xml
│ │ │ └── style.xml
│ │ ├── values-night
│ │ │ └── strings.xml
│ │ ├── drawable
│ │ │ ├── ic_launcher.png
│ │ │ ├── ic_carousel_icon.png
│ │ │ ├── ic_carousel_left_arrow.png
│ │ │ ├── ic_carousel_right_icon.png
│ │ │ └── notification_button.xml
│ │ ├── drawable-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-xxhdpi
│ │ │ └── ic_launcher.png
│ │ └── layout
│ │ │ └── carousel_notification_item.xml
│ │ ├── java
│ │ └── euromsg
│ │ │ └── com
│ │ │ └── euromobileandroid
│ │ │ ├── enums
│ │ │ ├── RDNotificationPriority.java
│ │ │ ├── GsmPermit.java
│ │ │ ├── PushPermit.java
│ │ │ ├── EmailPermit.java
│ │ │ ├── MessageStatus.java
│ │ │ └── PushType.java
│ │ │ ├── utils
│ │ │ ├── NotificationPermissionCallback.java
│ │ │ ├── EuroLogger.java
│ │ │ ├── LogConfigApiClient.java
│ │ │ ├── NotificationPermissionActivity.java
│ │ │ ├── LogConfig.java
│ │ │ ├── SharedPreference.java
│ │ │ ├── RetryCounterManager.java
│ │ │ ├── ImageUtils.java
│ │ │ ├── LogUtils.java
│ │ │ └── PayloadUtils.java
│ │ │ ├── model
│ │ │ ├── EuromessageCallback.java
│ │ │ ├── BaseRequest.java
│ │ │ ├── SerializableMap.java
│ │ │ ├── Location.java
│ │ │ ├── Actions.java
│ │ │ ├── Element.java
│ │ │ ├── Retention.java
│ │ │ ├── CarouselItem.java
│ │ │ ├── Carousel.java
│ │ │ ├── GraylogModel.java
│ │ │ ├── Message.java
│ │ │ └── Subscription.java
│ │ │ ├── notification
│ │ │ ├── NotificationActionListener.java
│ │ │ ├── NotificationActionBroadcastReceiver.java
│ │ │ └── carousel
│ │ │ │ └── CarouselEventReceiver.java
│ │ │ ├── callback
│ │ │ ├── PushNotificationPermissionInterface.java
│ │ │ └── PushMessageInterface.java
│ │ │ ├── connection
│ │ │ ├── EuroApiService.java
│ │ │ ├── RetentionApiClient.java
│ │ │ ├── SubscriptionApiClient.java
│ │ │ ├── GraylogApiClient.java
│ │ │ └── CarouselImageDownloaderManager.java
│ │ │ ├── Constants.java
│ │ │ └── service
│ │ │ ├── EuroFirebaseMessagingService.java
│ │ │ └── EuroMsgFCMHelper.java
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
└── build.gradle
├── app
├── .gitignore
├── euromessage.png
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── raw
│ │ │ │ ├── money.wav
│ │ │ │ ├── sound.mp3
│ │ │ │ ├── stilshoe.wav
│ │ │ │ └── moneyprize.mp3
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── logo.png
│ │ │ ├── drawable
│ │ │ │ ├── euromessage.png
│ │ │ │ ├── related_digital_dark_mode.jpg
│ │ │ │ ├── delete_icon_dark_mode.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ └── layout
│ │ │ │ └── activity_second.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── relateddigital
│ │ │ │ └── euromessage
│ │ │ │ ├── Constants.java
│ │ │ │ ├── SP.java
│ │ │ │ ├── TestPush.java
│ │ │ │ ├── RouterFCMService.java
│ │ │ │ └── MainApplication.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── relateddigital
│ │ │ └── euromessage
│ │ │ ├── ExampleUnitTest.java
│ │ │ ├── AppUtilsTest.java
│ │ │ └── RetryCounterManagerTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── relateddigital
│ │ └── euromessage
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── jitpack.yml
├── screenhelp.png
├── notification.gif
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
└── libs.versions.toml
├── .idea
├── compiler.xml
├── vcs.xml
├── AndroidProjectSystem.xml
├── migrations.xml
├── deploymentTargetSelector.xml
├── gradle.xml
├── runConfigurations.xml
├── appInsightsSettings.xml
├── jarRepositories.xml
└── codeStyles
│ └── Project.xml
├── .gitignore
├── settings.gradle
├── .github
└── workflows
│ └── gradle.yml
├── gradle.properties
├── .travis.yml
├── scripts
└── publish-module.gradle
├── gradlew.bat
├── README.md
└── gradlew
/euromsg/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | google-services.json
3 | agconnect-services.json
4 | keystore.jks
--------------------------------------------------------------------------------
/jitpack.yml:
--------------------------------------------------------------------------------
1 | jdk:
2 | - openjdk17
3 | install:
4 | - ./gradlew :euromsg:publishToMavenLocal
5 |
--------------------------------------------------------------------------------
/screenhelp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/screenhelp.png
--------------------------------------------------------------------------------
/notification.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/notification.gif
--------------------------------------------------------------------------------
/app/euromessage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/app/euromessage.png
--------------------------------------------------------------------------------
/euromsg/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=euromessage
2 | POM_ARTIFACT_ID=euromessage-android
3 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/euromsg/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Day
3 |
4 |
--------------------------------------------------------------------------------
/euromsg/src/main/res/values-night/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Night
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/raw/money.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/app/src/main/res/raw/money.wav
--------------------------------------------------------------------------------
/app/src/main/res/raw/sound.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/app/src/main/res/raw/sound.mp3
--------------------------------------------------------------------------------
/app/src/main/res/raw/stilshoe.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/app/src/main/res/raw/stilshoe.wav
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/raw/moneyprize.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/app/src/main/res/raw/moneyprize.mp3
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/app/src/main/res/mipmap-hdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/euromessage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/app/src/main/res/drawable/euromessage.png
--------------------------------------------------------------------------------
/euromsg/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/euromsg/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/euromsg/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/euromsg/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/euromsg/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/euromsg/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/euromsg/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/euromsg/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/euromsg/src/main/res/drawable/ic_carousel_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/euromsg/src/main/res/drawable/ic_carousel_icon.png
--------------------------------------------------------------------------------
/euromsg/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/euromsg/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/related_digital_dark_mode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/app/src/main/res/drawable/related_digital_dark_mode.jpg
--------------------------------------------------------------------------------
/euromsg/src/main/res/drawable/ic_carousel_left_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/euromsg/src/main/res/drawable/ic_carousel_left_arrow.png
--------------------------------------------------------------------------------
/euromsg/src/main/res/drawable/ic_carousel_right_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/relateddigital/euromessage-android/HEAD/euromsg/src/main/res/drawable/ic_carousel_right_icon.png
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/enums/RDNotificationPriority.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.enums;
2 |
3 | public enum RDNotificationPriority {
4 | HIGH,
5 | NORMAL,
6 | LOW
7 | }
8 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/utils/NotificationPermissionCallback.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.utils;
2 |
3 | public interface NotificationPermissionCallback {
4 | void onPermissionResult(boolean granted);
5 | }
6 |
--------------------------------------------------------------------------------
/.idea/AndroidProjectSystem.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/model/EuromessageCallback.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.model;
2 |
3 | public interface EuromessageCallback {
4 |
5 | void success();
6 |
7 | void fail(String errorMessage);
8 | }
9 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/notification/NotificationActionListener.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.notification;
2 |
3 | public interface NotificationActionListener {
4 | void onNotificationActionClicked(String link);
5 | }
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Nov 02 21:33:53 EET 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
7 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/callback/PushNotificationPermissionInterface.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.callback;
2 |
3 | public interface PushNotificationPermissionInterface {
4 |
5 | void success(boolean granted);
6 |
7 | void fail(String errorMessage);
8 | }
9 |
--------------------------------------------------------------------------------
/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/callback/PushMessageInterface.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.callback;
2 |
3 | import java.util.List;
4 |
5 | import euromsg.com.euromobileandroid.model.Message;
6 |
7 | public interface PushMessageInterface {
8 | void success(List pushMessages);
9 |
10 | void fail(String errorMessage);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/delete_icon_dark_mode.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3E606F
4 | #D1DBBD
5 | #91AA9D
6 | #193441
7 | #3E606F
8 | #FCFFF5
9 |
10 |
11 |
--------------------------------------------------------------------------------
/euromsg/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #efefef
4 | #FFFFFF
5 | #000000
6 | #FF0000
7 | #008000
8 | #0000FF
9 | #800080
10 |
--------------------------------------------------------------------------------
/euromsg/src/main/res/drawable/notification_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/model/BaseRequest.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | public abstract class BaseRequest {
6 |
7 | @SerializedName("token")
8 | private String token;
9 |
10 | public String getToken() {
11 | return token;
12 | }
13 |
14 | public void setToken(String token) {
15 | this.token = token;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/enums/GsmPermit.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.enums;
2 |
3 | public enum GsmPermit {
4 | ACTIVE("Y"), PASSIVE("X");
5 |
6 | public final String name;
7 |
8 | GsmPermit(String s) {
9 | name = s;
10 | }
11 |
12 | public boolean equalsName(String otherName) {
13 | return name.equals(otherName);
14 | }
15 |
16 | public String toString() {
17 | return name;
18 | }
19 | }
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/enums/PushPermit.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.enums;
2 |
3 | public enum PushPermit {
4 | ACTIVE("Y"), PASSIVE("N");
5 |
6 | public final String name;
7 |
8 | PushPermit(String s) {
9 | name = s;
10 | }
11 |
12 | public boolean equalsName(String otherName) {
13 | return name.equals(otherName);
14 | }
15 |
16 | public String toString() {
17 | return name;
18 | }
19 | }
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/enums/EmailPermit.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.enums;
2 |
3 | public enum EmailPermit {
4 | ACTIVE("Y"), PASSIVE("X");
5 |
6 | public final String name;
7 |
8 | EmailPermit(String s) {
9 | name = s;
10 | }
11 |
12 | public boolean equalsName(String otherName) {
13 | return name.equals(otherName);
14 | }
15 |
16 | public String toString() {
17 | return name;
18 | }
19 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | /.idea/gradle.xml
11 | /.idea/misc.xml
12 | /.idea/deploymentTargetDropDown.xml
13 | .DS_Store
14 | /build
15 | /captures
16 | .externalNativeBuild
17 | local.properties
18 | .cxx
19 | /.idea/.name
20 | /app/google-services.json
21 | /app/agconnect-services.json
22 | /app/keystore.jks
23 | /scripts/publish-root.gradle
24 |
--------------------------------------------------------------------------------
/app/src/test/java/com/relateddigital/euromessage/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.relateddigital.euromessage;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/utils/EuroLogger.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.utils;
2 |
3 | import android.util.Log;
4 |
5 | import androidx.annotation.NonNull;
6 |
7 | import euromsg.com.euromobileandroid.BuildConfig;
8 | import euromsg.com.euromobileandroid.Constants;
9 |
10 |
11 | public class EuroLogger {
12 |
13 | public static void debugLog(@NonNull String message) {
14 | if (BuildConfig.DEBUG) {
15 | Log.d(Constants.LOG_TAG, message);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/enums/MessageStatus.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.enums;
2 |
3 | public enum MessageStatus {
4 | Read("O"), Received("D"), Silent("S");
5 |
6 | private final String name;
7 |
8 | private MessageStatus(String s) {
9 | name = s;
10 | }
11 |
12 | public boolean equalsName(String otherName) {
13 | return (otherName != null) && name.equals(otherName);
14 | }
15 |
16 | public String toString() {
17 | return name;
18 | }
19 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
13 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/enums/PushType.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.enums;
2 |
3 | import java.io.Serializable;
4 |
5 | public enum PushType implements Serializable {
6 | Text("Text"), Image("Image"), Carousel("Carousel"), Video("Video");
7 |
8 | private final String name;
9 |
10 | PushType(String s) {
11 | name = s;
12 | }
13 |
14 | public boolean equalsName(String otherName) {
15 | return name.equals(otherName);
16 | }
17 |
18 | public String toString() {
19 | return name;
20 | }
21 | }
--------------------------------------------------------------------------------
/euromsg/src/main/res/values/style.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | // settings.gradle
2 |
3 | pluginManagement {
4 | repositories {
5 | google()
6 | mavenCentral()
7 | gradlePluginPortal()
8 | maven { url 'https://developer.huawei.com/repo/' }
9 | }
10 | }
11 |
12 | dependencyResolutionManagement {
13 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
14 | repositories {
15 | google()
16 | mavenCentral()
17 | maven { url 'https://jitpack.io' }
18 | maven { url 'https://developer.huawei.com/repo/' }
19 | }
20 | }
21 |
22 | rootProject.name = "euromessage-android"
23 | include ':app'
24 | include ':euromsg'
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/model/SerializableMap.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.model;
2 |
3 | import java.io.Serializable;
4 | import java.util.HashMap;
5 | import java.util.Map;
6 |
7 | public class SerializableMap implements Serializable {
8 | private static final long serialVersionUID = 1L;
9 | private Map map;
10 |
11 | public SerializableMap() {
12 | map = new HashMap<>();
13 | }
14 |
15 | public void put(String key, Object value) {
16 | map.put(key, value);
17 | }
18 |
19 | public Map getMap() {
20 | return map;
21 | }
22 | }
--------------------------------------------------------------------------------
/.idea/deploymentTargetSelector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/euromsg/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/ozanuysal/Android IDE Bundle/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/model/Location.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | public class Location {
6 |
7 | @SerializedName("latitude")
8 | private double latitude;
9 | @SerializedName("longitude")
10 | private double longitude;
11 |
12 | public Location(double latitude, double longitude) {
13 | this.latitude = latitude;
14 | this.longitude = longitude;
15 | }
16 |
17 | public double getLatitude() {
18 | return latitude;
19 | }
20 |
21 | public void setLatitude(double latitude) {
22 | this.latitude = latitude;
23 | }
24 |
25 | public double getLongitude() {
26 | return longitude;
27 | }
28 |
29 | public void setLongitude(double longitude) {
30 | this.longitude = longitude;
31 | }
32 | }
--------------------------------------------------------------------------------
/euromsg/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
14 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/notification/NotificationActionBroadcastReceiver.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.notification;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 |
7 | public class NotificationActionBroadcastReceiver extends BroadcastReceiver {
8 | private final NotificationActionListener callback;
9 |
10 | public NotificationActionBroadcastReceiver(NotificationActionListener callback) {
11 | this.callback = callback;
12 | }
13 | @Override
14 | public void onReceive(Context context, Intent intent) {
15 | String linkUri = "";
16 | if (intent != null && "ACTION_CLICK".equals(intent.getAction())) {
17 | linkUri = intent.getStringExtra("KEY_ACTION_ITEM");
18 | }
19 |
20 | callback.onNotificationActionClicked(linkUri);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/relateddigital/euromessage/Constants.java:
--------------------------------------------------------------------------------
1 | package com.relateddigital.euromessage;
2 |
3 | class Constants {
4 |
5 | static final String GOOGLE_APP_ALIAS = "euromessage-android";
6 | static final String HUAWEI_APP_ALIAS = "euromsg-huawei";
7 |
8 | //Visilabs configurations for advertisement
9 | static final String ORGANIZATION_ID = "676D325830564761676D453D";
10 | static final String SITE_ID = "356467332F6533766975593D";
11 | static final String DATASOURCE = "visistore";
12 | static final String EURO_RECIPIENT_TYPE_BIREYSEL = "BIREYSEL";
13 | static final String EURO_RECIPIENT_TYPE_TACIR = "TACIR";
14 |
15 | static final String EMAIL_PERMIT_ACTIVE = "EMAIL_PERMIT_ACTIVE";
16 | static final String EMAIL_PERMIT_PASSIVE = "EMAIL_PERMIT_PASSIVE";
17 |
18 | static final String LAST_PUSH_TIME = "LAST_PUSH_TIME";
19 | static final String LAST_PUSH_PARAMS = "LAST_PUSH_PARAMS";
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/relateddigital/euromessage/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.relateddigital.euromessage;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 |
25 | assertEquals("com.relateddigital.euromessage", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/.github/workflows/gradle.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Gradle
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3 |
4 | name: Java CI with Gradle
5 |
6 | on:
7 | push:
8 | branches: [ master ]
9 | pull_request:
10 | branches: [ master ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v2
19 | - name: Set up JDK 17
20 | uses: actions/setup-java@v2
21 | with:
22 | java-version: '17'
23 | distribution: 'adopt'
24 |
25 | - name: Create google-services.json
26 | env:
27 | GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
28 | run: echo "$GOOGLE_SERVICES_JSON" > app/google-services.json
29 |
30 | - name: Grant execute permission for gradlew
31 | run: chmod +x gradlew
32 | - name: Build with Gradle
33 | run: ./gradlew build
34 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/model/Actions.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.model;
2 |
3 | import java.io.Serializable;
4 |
5 | public class Actions implements Serializable {
6 | private String Title = null;
7 | private String Action = null;
8 | private String Icon = null;
9 | private String Url = null;
10 |
11 | public String getTitle() {
12 | return Title;
13 | }
14 |
15 | public void setTitle(String title) {
16 | Title = title;
17 | }
18 |
19 | public String getAction() {
20 | return Action;
21 | }
22 |
23 | public void setAction(String action) {
24 | Action = action;
25 | }
26 |
27 | public String getIcon() {
28 | return Icon;
29 | }
30 |
31 | public void setIcon(String icon) {
32 | Icon = icon;
33 | }
34 |
35 | public String getUrl() {
36 | return Url;
37 | }
38 |
39 | public void setUrl(String url) {
40 | Url = url;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 |
6 | -ignorewarnings
7 | -keepattributes *Annotation*
8 | -keepattributes Exceptions
9 | -keepattributes InnerClasses
10 | -keepattributes Signature
11 | -keepattributes SourceFile,LineNumberTable
12 |
13 | # For more details, see
14 | # http://developer.android.com/guide/developing/tools/proguard.html
15 |
16 | # If your project uses WebView with JS, uncomment the following
17 | # and specify the fully qualified class name to the JavaScript interface
18 | # class:
19 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
20 | # public *;
21 | #}
22 |
23 | # Uncomment this to preserve the line number information for
24 | # debugging stack traces.
25 | #-keepattributes SourceFile,LineNumberTable
26 |
27 | # If you keep the line number information, uncomment this to
28 | # hide the original source file name.
29 | #-renamesourcefileattribute SourceFile
30 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/connection/EuroApiService.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.connection;
2 |
3 | import euromsg.com.euromobileandroid.model.GraylogModel;
4 | import euromsg.com.euromobileandroid.model.Retention;
5 | import euromsg.com.euromobileandroid.model.Subscription;
6 | import retrofit2.Call;
7 | import retrofit2.http.Body;
8 | import retrofit2.http.Header;
9 | import retrofit2.http.Headers;
10 | import retrofit2.http.POST;
11 |
12 | public interface EuroApiService {
13 |
14 | @Headers({ "Content-Type: application/json;charset=utf-8"})
15 | @POST("/subscription")
16 | Call saveSubscription(@Header("User-Agent") String userAgent, @Body Subscription subscription);
17 |
18 | @Headers({ "Content-Type: application/json;charset=utf-8"})
19 | @POST("/retention")
20 | Call report(@Header("User-Agent") String userAgent, @Body Retention retention);
21 |
22 | @Headers({ "Content-Type: application/json;charset=utf-8"})
23 | @POST("/log/mobileSdk")
24 | Call sendLogToGraylog(@Body GraylogModel graylogModel);
25 | }
26 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
--------------------------------------------------------------------------------
/.idea/appInsightsSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/model/Element.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.model;
2 |
3 | import java.io.Serializable;
4 |
5 | public class Element implements Serializable {
6 |
7 | private String id;
8 | private String url;
9 | private String picture;
10 | private String content;
11 | private String title;
12 |
13 | public String getId() {
14 | return id;
15 | }
16 |
17 | public void setId(String id) {
18 | this.id = id;
19 | }
20 |
21 | public String getUrl() {
22 | return url;
23 | }
24 |
25 | public void setUrl(String url) {
26 | this.url = url;
27 | }
28 |
29 | public String getPicture() {
30 | return picture;
31 | }
32 |
33 | public void setPicture(String picture) {
34 | this.picture = picture;
35 | }
36 |
37 | public String getContent() {
38 | return content;
39 | }
40 |
41 | public void setContent(String content) {
42 | this.content = content;
43 | }
44 |
45 | public String getTitle() {
46 | return title;
47 | }
48 |
49 | public void setTitle(String title) {
50 | this.title = title;
51 | }
52 | }
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 | dist: trusty
3 | sudo: required
4 | jdk: oraclejdk8
5 |
6 | env:
7 | global:
8 | - ANDROID_API_LEVEL=30
9 | - EMULATOR_API_LEVEL=24
10 | - ANDROID_BUILD_TOOLS_VERSION=30.0.2
11 | - ANDROID_ABI=armeabi-v7a # x86 requires HAXM and it's not supported by travis (https://github.com/travis-ci/travis-ci/issues/1419)
12 | - ADB_INSTALL_TIMEOUT=8 # in minutes (2 minutes by default)
13 |
14 | android:
15 | components:
16 | - tools
17 | - platform-tools
18 | - tools
19 | - extra-google-google_play_services
20 | - extra-android-m2repository
21 | licenses:
22 | - 'android-sdk-preview-license-.+'
23 | - 'android-sdk-license-.+'
24 | - 'google-gdk-license-.+'
25 |
26 | before_install:
27 | - chmod +x gradlew
28 | - touch $HOME/.android/repositories.cfg
29 | - yes | sdkmanager "platforms;android-30"
30 | - yes | sdkmanager "build-tools;30.0.2"
31 |
32 |
33 | before_cache:
34 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
35 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
36 |
37 | cache:
38 | directories:
39 | - $HOME/.gradle/caches/
40 | - $HOME/.gradle/wrapper/
41 | - $HOME/.android/build-cache
42 |
43 | before_script:
44 | - chmod +x gradlew
45 |
46 | script:
47 | - ./gradlew clean build
48 | - ./gradlew test
49 |
50 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/connection/RetentionApiClient.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.connection;
2 |
3 | import android.os.Build;
4 | import android.util.Log;
5 |
6 | import java.util.concurrent.TimeUnit;
7 |
8 | import euromsg.com.euromobileandroid.Constants;
9 | import okhttp3.OkHttpClient;
10 | import okhttp3.logging.HttpLoggingInterceptor;
11 | import retrofit2.Retrofit;
12 | import retrofit2.converter.gson.GsonConverterFactory;
13 |
14 | public class RetentionApiClient {
15 |
16 | private static Retrofit retrofit = null;
17 |
18 | public static Retrofit getClient() {
19 | if (Build.VERSION.SDK_INT < Constants.UI_FEATURES_MIN_API) {
20 | Log.e("Euromessage", "Euromessage SDK requires min API level 21!");
21 | return null;
22 | }
23 |
24 | if (retrofit == null) {
25 | HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
26 | interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
27 |
28 | OkHttpClient okHttpClient = new OkHttpClient.Builder()
29 | .addInterceptor(interceptor)
30 | .connectTimeout(30, TimeUnit.SECONDS)
31 | .readTimeout(30, TimeUnit.SECONDS)
32 | .writeTimeout(30, TimeUnit.SECONDS)
33 | .build();
34 | retrofit = new Retrofit.Builder()
35 | .baseUrl("https://pushr.euromsg.com/")
36 | .addConverterFactory(GsonConverterFactory.create())
37 | .client(okHttpClient)
38 | .build();
39 | }
40 |
41 | return retrofit;
42 | }
43 | }
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/connection/SubscriptionApiClient.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.connection;
2 |
3 | import android.os.Build;
4 | import android.util.Log;
5 |
6 | import java.util.concurrent.TimeUnit;
7 |
8 | import euromsg.com.euromobileandroid.Constants;
9 | import okhttp3.OkHttpClient;
10 | import okhttp3.logging.HttpLoggingInterceptor;
11 | import retrofit2.Retrofit;
12 | import retrofit2.converter.gson.GsonConverterFactory;
13 |
14 | public class SubscriptionApiClient {
15 |
16 | private static Retrofit retrofit = null;
17 |
18 | public static Retrofit getClient() {
19 | if (Build.VERSION.SDK_INT < Constants.UI_FEATURES_MIN_API) {
20 | Log.e("Euromessage", "Euromessage SDK requires min API level 21!");
21 | return null;
22 | }
23 |
24 | if (retrofit == null) {
25 | HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
26 | interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
27 |
28 | OkHttpClient okHttpClient = new OkHttpClient.Builder()
29 | .addInterceptor(interceptor)
30 | .connectTimeout(30, TimeUnit.SECONDS)
31 | .readTimeout(30, TimeUnit.SECONDS)
32 | .writeTimeout(30, TimeUnit.SECONDS)
33 | .build();
34 | retrofit = new Retrofit.Builder()
35 | .baseUrl("https://pushs.euromsg.com/")
36 | .addConverterFactory(GsonConverterFactory.create())
37 | .client(okHttpClient)
38 | .build();
39 | }
40 |
41 | return retrofit;
42 | }
43 | }
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/connection/GraylogApiClient.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.connection;
2 |
3 | import android.os.Build;
4 | import android.util.Log;
5 |
6 | import java.util.concurrent.TimeUnit;
7 |
8 | import euromsg.com.euromobileandroid.Constants;
9 | import okhttp3.OkHttpClient;
10 | import okhttp3.logging.HttpLoggingInterceptor;
11 | import retrofit2.Retrofit;
12 | import retrofit2.converter.gson.GsonConverterFactory;
13 |
14 | public class GraylogApiClient {
15 |
16 | private static Retrofit retrofit = null;
17 |
18 | public static Retrofit getClient() {
19 | if (Build.VERSION.SDK_INT < Constants.UI_FEATURES_MIN_API) {
20 | Log.e("Euromessage", "Euromessage SDK requires min API level 21!");
21 | return null;
22 | }
23 |
24 | if (retrofit == null) {
25 | HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
26 | interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
27 |
28 | OkHttpClient okHttpClient = new OkHttpClient.Builder()
29 | .addInterceptor(interceptor)
30 | .connectTimeout(30, TimeUnit.SECONDS)
31 | .readTimeout(30, TimeUnit.SECONDS)
32 | .writeTimeout(30, TimeUnit.SECONDS)
33 | .build();
34 | retrofit = new Retrofit.Builder()
35 | .baseUrl("https://rd-gateway-log.relateddigital.com/")
36 | .addConverterFactory(GsonConverterFactory.create())
37 | .client(okHttpClient)
38 | .build();
39 | }
40 |
41 | return retrofit;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.android.application)
3 | alias(libs.plugins.google.services)
4 | }
5 |
6 | apply plugin: 'com.huawei.agconnect'
7 |
8 | android {
9 | compileSdkVersion 35
10 | namespace "com.relateddigital.euromessage" // targetSdk > 32 için zorunlu
11 | defaultConfig {
12 | applicationId "com.relateddigital.euromessage"
13 | minSdkVersion 23
14 | targetSdkVersion 35
15 | versionCode 1
16 | versionName "5.3.7"
17 | multiDexEnabled true
18 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19 | buildConfigField 'String', 'VERSION_NAME', "\"5.3.7\""
20 | }
21 | buildTypes {
22 | release {
23 | minifyEnabled false
24 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
25 | }
26 | }
27 | compileOptions {
28 | sourceCompatibility JavaVersion.VERSION_17
29 | targetCompatibility JavaVersion.VERSION_17
30 | }
31 | buildFeatures {
32 | viewBinding true
33 | buildConfig true
34 | }
35 | lint {
36 | abortOnError false
37 | }
38 | }
39 |
40 | dependencies {
41 | implementation fileTree(dir: 'libs', include: ['*.jar'])
42 | implementation project(':euromsg')
43 |
44 | implementation libs.androidx.appcompat
45 | implementation libs.androidx.constraintlayout
46 | implementation libs.visilabs.android
47 | implementation libs.androidx.multidex
48 |
49 | implementation libs.huawei.agconnect.core
50 | implementation libs.huawei.hms.push
51 |
52 | testImplementation libs.junit
53 | androidTestImplementation libs.androidx.test.junit
54 | androidTestImplementation libs.androidx.test.espresso
55 | }
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/utils/LogConfigApiClient.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.utils;
2 |
3 | import euromsg.com.euromobileandroid.Constants;
4 | import okhttp3.OkHttpClient;
5 | import retrofit2.Retrofit;
6 | import retrofit2.converter.gson.GsonConverterFactory;
7 | import java.util.concurrent.TimeUnit;
8 |
9 | /**
10 | * Provides a Retrofit client instance for LogConfig API.
11 | * Equivalent to the Kotlin object LogConfigApiClient.
12 | */
13 | public final class LogConfigApiClient {
14 |
15 | private static volatile Retrofit retrofit = null;
16 |
17 | // Private constructor to prevent instantiation
18 | private LogConfigApiClient() {}
19 |
20 | /**
21 | * Gets the Retrofit client instance.
22 | * Uses double-checked locking for thread-safe lazy initialization.
23 | * @return The Retrofit client instance.
24 | */
25 | public static Retrofit getClient() {
26 | if (retrofit == null) {
27 | synchronized (LogConfigApiClient.class) {
28 | if (retrofit == null) {
29 | OkHttpClient okHttpClient = new OkHttpClient.Builder()
30 | .connectTimeout(5, TimeUnit.SECONDS)
31 | .readTimeout(5, TimeUnit.SECONDS)
32 | .writeTimeout(5, TimeUnit.SECONDS)
33 | .build();
34 |
35 | retrofit = new Retrofit.Builder()
36 | .baseUrl("https://mbls.visilabs.net/")
37 | .addConverterFactory(GsonConverterFactory.create())
38 | .client(okHttpClient)
39 | .build();
40 | }
41 | }
42 | }
43 | return retrofit;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/test/java/com/relateddigital/euromessage/AppUtilsTest.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.junit.runners.JUnit4;
6 |
7 | import java.text.SimpleDateFormat;
8 | import java.util.Date;
9 | import java.util.TimeZone;
10 |
11 | import euromsg.com.euromobileandroid.utils.AppUtils;
12 |
13 | @RunWith(JUnit4.class)
14 | public class AppUtilsTest {
15 |
16 | @Test
17 | public void testGetCurrentDateString() {
18 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
19 | String result1 = dateFormat.format(new Date());
20 | String result2 = AppUtils.getCurrentDateString();
21 | assert(result1.equals(result2));
22 | }
23 |
24 | @Test
25 | public void testIsDateDifferenceGreaterThan() {
26 | boolean result;
27 | String date1_1 = "2021-11-30 11:21:26";
28 | String date1_2 = "2021-11-24 11:21:26";
29 | int thresholdDay1 = 4;
30 |
31 | String date2_1 = "2021-11-30 11:21:26";
32 | String date2_2 = "2021-11-27 11:21:26";
33 | int thresholdDay2 = 4;
34 |
35 | String date3_1 = "2021-11-29 11:21:26";
36 | String date3_2 = "2021-11-30 11:21:26";
37 | int thresholdDay3 = 4;
38 |
39 | String date4_1 = "2021-11-30 11:21:26";
40 | String date4_2 = "2021.11.22 11:21:26";
41 | int thresholdDay4 = 4;
42 |
43 | result = AppUtils.isDateDifferenceGreaterThan(date1_1, date1_2, thresholdDay1) &&
44 | !AppUtils.isDateDifferenceGreaterThan(date2_1, date2_2, thresholdDay2) &&
45 | !AppUtils.isDateDifferenceGreaterThan(date3_1, date3_2, thresholdDay3) &&
46 | AppUtils.isDateDifferenceGreaterThan(date4_1, date4_2, thresholdDay4);
47 | assert(result);
48 | }
49 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Euromessage Demo
3 | SYNC :
4 | Token Failed
5 | Token Success
6 | TOKEN :
7 | Note: Please create a campaign from RMC to send a real push notification
8 | SEND A TEMPLATE CAROUSEL PUSH
9 | SEND A TEMPLATE IMAGE PUSH
10 | SEND A TEMPLATE TEXT PUSH
11 | REQUEST PERMISSION
12 | GET PAYLOADS
13 | DELETE PUSH WITH ID
14 | DELETE All PUSH
15 | Please Enter Email Address
16 | Add
17 | Other Related Digital Products:
18 | Visilabs In App Test
19 | Learn more about visilabs
20 | Firebase Token
21 | Huawei Token
22 | REGISTER EMAIL (İYS) :
23 | Register
24 | PUSH NOTIFICATION PARAMETERS :
25 | Key
26 | Value
27 | Last Push Time
28 | Huawei TEST
29 |
30 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/utils/NotificationPermissionActivity.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.utils;
2 |
3 | import androidx.activity.ComponentActivity;
4 | import androidx.activity.result.contract.ActivityResultContracts;
5 | import androidx.activity.result.ActivityResultLauncher;
6 | import androidx.core.app.NotificationManagerCompat;
7 |
8 | import android.os.Bundle;
9 |
10 | public class NotificationPermissionActivity extends ComponentActivity {
11 | public static NotificationPermissionCallback callback;
12 |
13 | private final ActivityResultLauncher requestPermissionLauncher = registerForActivityResult(
14 | new ActivityResultContracts.RequestPermission(),
15 | isGranted -> {
16 |
17 | if (callback != null) {
18 | callback.onPermissionResult(isGranted);
19 | }
20 | finish();
21 | }
22 | );
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | if (callback == null) {
28 | finish();
29 | return;
30 | }
31 | requestNotificationPermission();
32 | }
33 |
34 | private void requestNotificationPermission() {
35 | String permission = "android.permission.POST_NOTIFICATIONS";
36 | boolean granted = NotificationManagerCompat.from(this).areNotificationsEnabled();
37 | if (!granted) {
38 | requestPermissionLauncher.launch(permission);
39 | } else {
40 |
41 | if (callback != null) {
42 | callback.onPermissionResult(granted);
43 | }
44 | finish();
45 | }
46 | }
47 |
48 | public interface NotificationPermissionCallback {
49 | void onPermissionResult(boolean isGranted);
50 | }
51 | }
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/model/Retention.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | public class Retention extends BaseRequest {
6 |
7 | @SerializedName("key")
8 | private String key;
9 |
10 | @SerializedName("pushId")
11 | private String pushId;
12 |
13 | @SerializedName("status")
14 | private String status;
15 |
16 | @SerializedName("deliver")
17 | private int deliver;
18 |
19 | @SerializedName("isMobile")
20 | private int isMobile = 1;
21 |
22 | @SerializedName("actionBtn")
23 | private int actionBtn = 0;
24 |
25 | @SerializedName("emPushSp")
26 | private String emPushSp;
27 |
28 | public String getKey() {
29 | return key;
30 | }
31 |
32 | public void setKey(String key) {
33 | this.key = key;
34 | }
35 |
36 | public String getPushId() {
37 | return pushId;
38 | }
39 |
40 | public void setPushId(String pushId) {
41 | this.pushId = pushId;
42 | }
43 |
44 | public String getStatus() {
45 | return status;
46 | }
47 |
48 | public void setStatus(String status) {
49 | this.status = status;
50 | }
51 |
52 | public int getDeliver() {
53 | return deliver;
54 | }
55 |
56 | public void setDeliver(int deliver) {
57 | this.deliver = deliver;
58 | }
59 |
60 | public int getIsMobile() {
61 | return isMobile;
62 | }
63 |
64 | public void setIsMobile(int isMobile) {
65 | this.isMobile = isMobile;
66 | }
67 |
68 | public int getActionBtn() {
69 | return actionBtn;
70 | }
71 |
72 | public void setActionBtn(int actionBtn) {
73 | this.actionBtn = actionBtn;
74 | }
75 |
76 | public String getEmPushSp() {
77 | return emPushSp;
78 | }
79 |
80 | public void setEmPushSp(String emPushSp) {
81 | this.emPushSp = emPushSp;
82 | }
83 | }
--------------------------------------------------------------------------------
/app/src/test/java/com/relateddigital/euromessage/RetryCounterManagerTest.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.junit.runners.JUnit4;
6 |
7 | import euromsg.com.euromobileandroid.utils.RetryCounterManager;
8 |
9 | @RunWith(JUnit4.class)
10 | public class RetryCounterManagerTest {
11 |
12 | @Test
13 | public void testGetCounterId() {
14 | int res1 = RetryCounterManager.getCounterId();
15 | int res2 = RetryCounterManager.getCounterId();
16 | int res3 = RetryCounterManager.getCounterId();
17 | int res4 = RetryCounterManager.getCounterId();
18 | int res5 = RetryCounterManager.getCounterId();
19 |
20 | boolean result;
21 |
22 | result = (res1 == 1) && (res2 == 2) && (res3 == 3) && (res4 == 4) && (res5 == 5);
23 |
24 | assert(result);
25 | }
26 |
27 | @Test
28 | public void testCounter() {
29 | boolean result;
30 | RetryCounterManager.clearCounter(1);
31 | RetryCounterManager.clearCounter(2);
32 | RetryCounterManager.clearCounter(3);
33 | RetryCounterManager.clearCounter(4);
34 | RetryCounterManager.clearCounter(5);
35 | RetryCounterManager.increaseCounter(1);
36 | RetryCounterManager.increaseCounter(1);
37 | RetryCounterManager.increaseCounter(3);
38 | RetryCounterManager.increaseCounter(5);
39 | RetryCounterManager.increaseCounter(5);
40 | RetryCounterManager.increaseCounter(5);
41 | RetryCounterManager.increaseCounter(4);
42 | RetryCounterManager.increaseCounter(4);
43 | RetryCounterManager.increaseCounter(4);
44 | RetryCounterManager.clearCounter(4);
45 |
46 | result = (RetryCounterManager.getCounterValue(1) == 1) &&
47 | (RetryCounterManager.getCounterValue(2) == -1) &&
48 | (RetryCounterManager.getCounterValue(3) == 0) &&
49 | (RetryCounterManager.getCounterValue(4) == -1) &&
50 | (RetryCounterManager.getCounterValue(5) == 2);
51 |
52 | assert(result);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/euromsg/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.android.library)
3 | id 'maven-publish' // Bu plugin'i doğrudan uyguluyoruz
4 | }
5 |
6 | group = 'com.github.relateddigital'
7 | version = "5.3.7"
8 |
9 | ext {
10 | PUBLISH_GROUP_ID = 'com.github.relateddigital'
11 | PUBLISH_VERSION = "5.3.7"
12 | PUBLISH_VERSION_CODE = "50"
13 | PUBLISH_ARTIFACT_ID = 'euromessage-android'
14 | }
15 |
16 | android {
17 | compileSdkVersion 35
18 | namespace "euromsg.com.euromobileandroid" // Kütüphaneler için zorunlu
19 | defaultConfig {
20 | minSdkVersion 23
21 | targetSdkVersion 35
22 | consumerProguardFiles "consumer-rules.pro"
23 | buildConfigField 'String', 'VERSION_NAME', "\"5.3.7\""
24 | }
25 | buildTypes {
26 | release {
27 | minifyEnabled false
28 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
29 | }
30 | }
31 | buildFeatures {
32 | buildConfig true // <-- DOĞRU YER BURASI
33 | }
34 | lint {
35 | abortOnError false
36 | }
37 |
38 | publishing {
39 | singleVariant("release") {
40 | withSourcesJar()
41 | withJavadocJar()
42 | }
43 | }
44 | }
45 |
46 | dependencies {
47 | implementation fileTree(dir: 'libs', include: ['*.jar'])
48 |
49 | implementation libs.androidx.activity
50 | api libs.google.gson
51 | api libs.firebase.messaging
52 | api libs.google.play.services.base
53 | api libs.retrofit.core
54 | api libs.retrofit.adapter.rxjava2
55 | api libs.retrofit.converter.gson
56 | api libs.okhttp.core
57 | api libs.okhttp.logging.interceptor
58 | api libs.huawei.agconnect.core
59 | api libs.huawei.hms.push
60 |
61 | testImplementation libs.junit
62 | }
63 |
64 | // maven-publish ayarları
65 | publishing {
66 | publications {
67 | release(MavenPublication) {
68 | groupId = group
69 | artifactId = 'euromessage-android'
70 | version = version
71 |
72 | afterEvaluate {
73 | from components.release
74 | }
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/utils/LogConfig.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.utils;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 | import java.util.List;
5 | import java.util.Objects;
6 |
7 | /**
8 | * Represents the logging configuration.
9 | * Equivalent to the Kotlin data class LogConfig nested within LogUtils.
10 | */
11 | public class LogConfig {
12 |
13 | @SerializedName("isLoggingEnabled")
14 | private final boolean isLoggingEnabled;
15 |
16 | @SerializedName("excludedCustomerIds")
17 | private final List excludedCustomerIds;
18 |
19 | /**
20 | * Constructor for LogConfig.
21 | * @param isLoggingEnabled Whether logging is globally enabled.
22 | * @param excludedCustomerIds A list of customer IDs for whom logging should be disabled.
23 | */
24 | public LogConfig(boolean isLoggingEnabled, List excludedCustomerIds) {
25 | this.isLoggingEnabled = isLoggingEnabled;
26 | this.excludedCustomerIds = excludedCustomerIds;
27 | }
28 |
29 | /**
30 | * Checks if logging is enabled.
31 | * @return true if logging is enabled, false otherwise.
32 | */
33 | public boolean isLoggingEnabled() {
34 | return isLoggingEnabled;
35 | }
36 |
37 | /**
38 | * Gets the list of excluded customer IDs.
39 | * @return A list of customer IDs.
40 | */
41 | public List getExcludedCustomerIds() {
42 | return excludedCustomerIds;
43 | }
44 |
45 | @Override
46 | public boolean equals(Object o) {
47 | if (this == o) return true;
48 | if (o == null || getClass() != o.getClass()) return false;
49 | LogConfig logConfig = (LogConfig) o;
50 | return isLoggingEnabled == logConfig.isLoggingEnabled &&
51 | Objects.equals(excludedCustomerIds, logConfig.excludedCustomerIds);
52 | }
53 |
54 | @Override
55 | public int hashCode() {
56 | return Objects.hash(isLoggingEnabled, excludedCustomerIds);
57 | }
58 |
59 | @Override
60 | public String toString() {
61 | return "LogConfig{" +
62 | "isLoggingEnabled=" + isLoggingEnabled +
63 | ", excludedCustomerIds=" + excludedCustomerIds +
64 | '}';
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
39 |
40 |
41 |
42 |
43 |
44 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/notification/carousel/CarouselEventReceiver.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.notification.carousel;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.util.Log;
8 |
9 |
10 | import euromsg.com.euromobileandroid.Constants;
11 | import euromsg.com.euromobileandroid.EuroMobileManager;
12 | import euromsg.com.euromobileandroid.model.Carousel;
13 | import euromsg.com.euromobileandroid.model.Message;
14 | import euromsg.com.euromobileandroid.utils.AppUtils;
15 | import euromsg.com.euromobileandroid.utils.SharedPreference;
16 |
17 | public class CarouselEventReceiver extends BroadcastReceiver {
18 | private static final String LOG_TAG = "CarouselEventReceiver";
19 |
20 | @Override
21 | public void onReceive(Context context, Intent intent) {
22 | Bundle bundle = intent.getExtras();
23 | if (bundle != null) {
24 | Message message = (Message) bundle.getSerializable("message");
25 | int notificationId = bundle.getInt(Constants.NOTIFICATION_ID);
26 | int carouselEvent = bundle.getInt(Constants.EVENT_CAROUSAL_ITEM_CLICKED_KEY);
27 | Carousel carousel = bundle.getParcelable(Constants.CAROUSAL_SET_UP_KEY);
28 |
29 | if (carouselEvent > Constants.EVENT_RIGHT_ARROW_CLICKED) {
30 | if(message != null) {
31 | sendOpenReport(message, context);
32 | } else {
33 | Log.e(LOG_TAG, "Could not send the open report since the payload is empty!!");
34 | }
35 | }
36 |
37 | if (carouselEvent > 0 && carousel != null)
38 | CarouselBuilder.with(context, notificationId).handleClickEvent(carouselEvent, carousel);
39 | }
40 | }
41 |
42 | private void sendOpenReport(Message message, Context context) {
43 | if(EuroMobileManager.getInstance() == null) {
44 | String appAlias = SharedPreference.getString(context, euromsg.com.euromobileandroid.Constants.GOOGLE_APP_ALIAS);
45 | String huaweiAppAlias = SharedPreference.getString(context, Constants.HUAWEI_APP_ALIAS);
46 | EuroMobileManager.init(appAlias, huaweiAppAlias, context).sendOpenRequest(message);
47 | } else {
48 | EuroMobileManager.getInstance().sendOpenRequest(message);
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/scripts/publish-module.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'maven-publish'
2 | apply plugin: 'signing'
3 |
4 | task androidSourcesJar(type: Jar) {
5 | archiveClassifier.set('sources')
6 | if (project.plugins.findPlugin("com.android.library")) {
7 | from android.sourceSets.main.java.srcDirs
8 | from android.sourceSets.main.kotlin.srcDirs
9 | } else {
10 | from sourceSets.main.java.srcDirs
11 | from sourceSets.main.kotlin.srcDirs
12 | }
13 | }
14 |
15 | artifacts {
16 | archives androidSourcesJar
17 | }
18 |
19 | group = PUBLISH_GROUP_ID
20 | version = PUBLISH_VERSION
21 |
22 | afterEvaluate {
23 | publishing {
24 | publications {
25 | release(MavenPublication) {
26 | groupId PUBLISH_GROUP_ID
27 | artifactId PUBLISH_ARTIFACT_ID
28 | version PUBLISH_VERSION
29 | if (project.plugins.findPlugin("com.android.library")) {
30 | from components.release
31 | } else {
32 | from components.java
33 | }
34 |
35 | artifact androidSourcesJar
36 |
37 | pom {
38 | name = 'Related Digital Euromessage Android SDK'
39 | description = 'Related Digital Euromessage Android SDK'
40 | url = 'https://github.com/relateddigital/euromessage-android'
41 | licenses {
42 | license {
43 | name = 'The Apache Software License, Version 2.0'
44 | url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
45 | }
46 | }
47 | developers {
48 | developer {
49 | id = 'relateddigital'
50 | name = 'Related Digital'
51 | email = 'developer@relateddigital.com'
52 | }
53 | }
54 | scm {
55 | connection = 'scm:git@github.com/relateddigital/euromessage-android.git'
56 | developerConnection = 'scm:git@github.com/relateddigital/euromessage-android.git'
57 | url = 'https://github.com/relateddigital/euromessage-android'
58 | }
59 | }
60 | }
61 | }
62 | }
63 | }
64 |
65 | signing {
66 | sign publishing.publications
67 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/relateddigital/euromessage/SP.java:
--------------------------------------------------------------------------------
1 | package com.relateddigital.euromessage;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | public class SP {
7 |
8 | public static void saveString(Context context, String key, String value) {
9 | String appName = context.getPackageName();
10 | SharedPreferences sp = context.getSharedPreferences(appName, Context.MODE_PRIVATE);
11 | SharedPreferences.Editor spEditor = sp.edit();
12 | spEditor.putString(key, value);
13 | spEditor.apply();
14 | }
15 |
16 | public static void saveBoolean(Context context, String key,
17 | boolean value) {
18 | String appName = context.getPackageName();
19 | SharedPreferences sp = context.getSharedPreferences(appName, Context.MODE_PRIVATE);
20 | SharedPreferences.Editor spEditor = sp.edit();
21 | spEditor.putBoolean(key, value);
22 | spEditor.apply();
23 | }
24 |
25 | public static void saveLong(Context context, String key, long value) {
26 | String appName = context.getPackageName();
27 | SharedPreferences sp = context.getSharedPreferences(appName, Context.MODE_PRIVATE);
28 | SharedPreferences.Editor spEditor = sp.edit();
29 | spEditor.putLong(key, value);
30 | spEditor.apply();
31 | }
32 |
33 | public static void saveInt(Context context, String key,
34 | int value) {
35 | String appName = context.getPackageName();
36 | SharedPreferences sp = context.getSharedPreferences(appName, Context.MODE_PRIVATE);
37 | SharedPreferences.Editor spEditor = sp.edit();
38 | spEditor.putInt(key, value);
39 | spEditor.apply();
40 | }
41 |
42 |
43 | public static boolean hasString(Context context, String key) {
44 | String appName = context.getPackageName();
45 | SharedPreferences sp = context.getSharedPreferences(appName,
46 | Context.MODE_PRIVATE);
47 | return sp.contains(key);
48 | }
49 |
50 | public static int getInt(Context context, String key) {
51 | String appName = context.getPackageName();
52 | SharedPreferences sp = context.getSharedPreferences(appName, Context.MODE_PRIVATE);
53 | return sp.getInt(key, 0);
54 | }
55 |
56 | public static String getString(Context context, String key) {
57 | String appName = context.getPackageName();
58 | SharedPreferences sp = context.getSharedPreferences(appName, Context.MODE_PRIVATE);
59 | return sp.getString(key, "");
60 | }
61 |
62 | public static long getLong(Context context, String key) {
63 | String appName = context.getPackageName();
64 | SharedPreferences sp = context.getSharedPreferences(appName,
65 | Context.MODE_PRIVATE);
66 | return sp.getLong(key, 0);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | # Android Gradle Plugin & Kotlin
3 | agp = "8.11.1" # Kullandığınız sürüm
4 | googleServices = "4.3.14"
5 | nexusPublish = "1.1.0"
6 | huaweiAgconnect = "1.9.1.300"
7 | huaweiHmsPush = "6.11.0.300"
8 |
9 | # AndroidX
10 | appcompat = "1.6.1"
11 | constraintlayout = "2.1.4"
12 | multidex = "2.0.1"
13 | activity = "1.6.1"
14 | junitExt = "1.1.5"
15 | espressoCore = "3.5.1"
16 |
17 | # Google & Firebase
18 | gson = "2.9.0"
19 | firebaseMessaging = "23.3.0"
20 | playServicesBase = "18.6.0"
21 |
22 | # Diğer Kütüphaneler
23 | visilabs = "6.0.4"
24 | junit = "4.13.2"
25 | retrofit = "2.9.0"
26 | okhttp = "4.9.0"
27 |
28 |
29 | [libraries]
30 | # AndroidX
31 | androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
32 | androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
33 | androidx-multidex = { group = "androidx.multidex", name = "multidex", version.ref = "multidex" }
34 | androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
35 | androidx-test-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitExt" }
36 | androidx-test-espresso = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
37 |
38 | # Google & Firebase
39 | google-gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
40 | firebase-messaging = { group = "com.google.firebase", name = "firebase-messaging", version.ref = "firebaseMessaging" }
41 | google-play-services-base = { group = "com.google.android.gms", name = "play-services-base", version.ref = "playServicesBase" }
42 |
43 | # Huawei Kütüphaneleri
44 | huawei-agconnect-core = { group = "com.huawei.agconnect", name = "agconnect-core", version.ref = "huaweiAgconnect" }
45 | huawei-hms-push = { group = "com.huawei.hms", name = "push", version.ref = "huaweiHmsPush" }
46 |
47 |
48 | # Diğer Kütüphaneler
49 | visilabs-android = { group = "com.github.relateddigital", name = "visilabs-android", version.ref = "visilabs" }
50 | junit = { group = "junit", name = "junit", version.ref = "junit" }
51 | retrofit-core = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
52 | retrofit-adapter-rxjava2 = { group = "com.squareup.retrofit2", name = "adapter-rxjava2", version.ref = "retrofit" }
53 | retrofit-converter-gson = { group = "com.squareup.retrofit2", name = "converter-gson", version.ref = "retrofit" }
54 | okhttp-core = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp" }
55 | okhttp-logging-interceptor = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp" }
56 |
57 | [plugins]
58 | android-application = { id = "com.android.application", version.ref = "agp" }
59 | android-library = { id = "com.android.library", version.ref = "agp" }
60 | google-services = { id = "com.google.gms.google-services", version.ref = "googleServices" }
61 | nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexusPublish" }
--------------------------------------------------------------------------------
/app/src/main/java/com/relateddigital/euromessage/TestPush.java:
--------------------------------------------------------------------------------
1 | package com.relateddigital.euromessage;
2 |
3 | public class TestPush {
4 |
5 | public static String testImage = "{\n" +
6 | " \"pushType\": \"Image\",\n" +
7 | " \"url\": \"https://www.euromsg.com/\",\n" +
8 | " \"mediaUrl\": \"https://mcdn01.gittigidiyor.net/ps/banner_1583388342.jpg\",\n" +
9 | " \"pushId\": \"bea5303f-11aa-4ac7-aae8-2265ba63b535\",\n" +
10 | " \"altUrl\": \"\",\n" +
11 | " \"sound\": \"sound\",\n" +
12 | " \"message\": \"Bugünü kaçırma\",\n" +
13 | " \"title\": \"BUGÜNE ÖZEL 150 TL İNDİRİM\"\n" +
14 | "\n" +
15 | "}";;
16 |
17 |
18 | public static String testText = "{\n" +
19 | " \"pushType\": \"Text\",\n" +
20 | " \"url\": \"https://www.euromsg.com/\",\n" +
21 | " \"mediaUrl\": \"\",\n" +
22 | " \"pushId\": \"bea5303f-11aa-4ac7-aae8-2265ba63b535\",\n" +
23 | " \"altUrl\": \"\",\n" +
24 | " \"sound\": \"sound\",\n" +
25 | " \"message\": \"Buzdolabı, Soğutucu\",\n" +
26 | " \"title\": \"BUGÜNE ÖZEL 150 TL İNDİRİM\"\n" +
27 | "\n" +
28 | "}";
29 |
30 | public static String testCarousel = "{\n" +
31 | " \"pushType\": \"Text\",\n" +
32 | " \"url\": \"https://www.euromsg.com/\",\n" +
33 | " \"mediaUrl\": \"\",\n" +
34 | " \"pushId\": \"bea5303f-11aa-4ac7-aae8-2265ba63b535\",\n" +
35 | " \"altUrl\": \"\",\n" +
36 | " \"sound\": \"sound\",\n" +
37 | " \"message\": \"test carousel\",\n" +
38 | " \"title\": \"test title\",\n" +
39 | " \"elements\": [{\n" +
40 | " \"id\": 1,\n" +
41 | " \"title\": \"Süper İndirim\",\n" +
42 | " \"content\": \"Akıllı saatlerde akılalmaz indirimleri kaçırmayın. Harika bir saat\",\n" +
43 | " \"url\": \"https://www.euromsg.com/\",\n" +
44 | " \"picture\": \"https://mcdn01.gittigidiyor.net/52578/tn50/525782224_tn50_0.jpg?1583398\"\n" +
45 | " }, {\n" +
46 | " \"id\": 2,\n" +
47 | " \"title\": \"Mükemmel İndirim\",\n" +
48 | " \"content\": \"Hayatını akıllı saatlerle beraber çok kolaylaştırabilirsin. Akıllı saatleri incele!\",\n" +
49 | " \"url\": \"https://www.relateddigital.com/\",\n" +
50 | " \"picture\": \"https://mcdn01.gittigidiyor.net/49668/tn50/496687214_tn50_0.jpg?1583398\"\n" +
51 | " }, {\n" +
52 | " \"id\": 3,\n" +
53 | " \"title\": \"Şaşırtıcı İndirim\",\n" +
54 | " \"content\": \"Akıllı Saatler ! \",\n" +
55 | " \"url\": \"https://www.google.com/\",\n" +
56 | " \"picture\": \"https://mcdn01.gittigidiyor.net/49101/tn50/491019547_tn50_0.jpg?1583398\"\n" +
57 | " }\n" +
58 | " ]\n" +
59 | "}";
60 | }
61 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/utils/SharedPreference.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.utils;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | public class SharedPreference {
7 |
8 | public static void saveString(Context context, String key, String value) {
9 | String appName = context.getPackageName();
10 | SharedPreferences sp = context.getSharedPreferences(appName, Context.MODE_PRIVATE);
11 | SharedPreferences.Editor spEditor = sp.edit();
12 | spEditor.putString(key, value);
13 | spEditor.apply();
14 | }
15 |
16 | public static void saveBoolean(Context context, String key,
17 | boolean value) {
18 | String appName = context.getPackageName();
19 | SharedPreferences sp = context.getSharedPreferences(appName, Context.MODE_PRIVATE);
20 | SharedPreferences.Editor spEditor = sp.edit();
21 | spEditor.putBoolean(key, value);
22 | spEditor.apply();
23 | }
24 |
25 | public static void saveLong(Context context, String key, long value) {
26 | String appName = context.getPackageName();
27 | SharedPreferences sp = context.getSharedPreferences(appName, Context.MODE_PRIVATE);
28 | SharedPreferences.Editor spEditor = sp.edit();
29 | spEditor.putLong(key, value);
30 | spEditor.apply();
31 | }
32 |
33 | public static void saveInt(Context context, String key,
34 | int value) {
35 | String appName = context.getPackageName();
36 | SharedPreferences sp = context.getSharedPreferences(appName, Context.MODE_PRIVATE);
37 | SharedPreferences.Editor spEditor = sp.edit();
38 | spEditor.putInt(key, value);
39 | spEditor.apply();
40 | }
41 |
42 |
43 | public static boolean hasString(Context context, String key) {
44 | String appName = context.getPackageName();
45 | SharedPreferences sp = context.getSharedPreferences(appName,
46 | Context.MODE_PRIVATE);
47 | return sp.contains(key);
48 | }
49 |
50 | public static boolean getBoolean(Context context, String key) {
51 | String appName = context.getPackageName();
52 | SharedPreferences sp = context.getSharedPreferences(appName, Context.MODE_PRIVATE);
53 | return sp.getBoolean(key, true);
54 | }
55 |
56 | public static int getInt(Context context, String key) {
57 | String appName = context.getPackageName();
58 | SharedPreferences sp = context.getSharedPreferences(appName, Context.MODE_PRIVATE);
59 | return sp.getInt(key, 0);
60 | }
61 |
62 | public static String getString(Context context, String key) {
63 | String appName = context.getPackageName();
64 | SharedPreferences sp = context.getSharedPreferences(appName, Context.MODE_PRIVATE);
65 | return sp.getString(key, "");
66 | }
67 |
68 | public static long getLong(Context context, String key) {
69 | String appName = context.getPackageName();
70 | SharedPreferences sp = context.getSharedPreferences(appName,
71 | Context.MODE_PRIVATE);
72 | return sp.getLong(key, 0);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/model/CarouselItem.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.model;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 |
7 | public class CarouselItem implements Parcelable {
8 | private String id;
9 | private String title;
10 | private String description;
11 | private String photoUrl;
12 | private String imageFileLocation;
13 | private String imageFileName;
14 | private String type;
15 |
16 | public CarouselItem( String photoUrl) {
17 | this(null, null, null, photoUrl);
18 | }
19 |
20 | public CarouselItem() {
21 | this(null, null, null, null);
22 | }
23 |
24 | public CarouselItem(String id, String title, String description, String photoUrl) {
25 | this.id = id;
26 | this.title = title;
27 | this.description = description;
28 | this.photoUrl = photoUrl;
29 | }
30 |
31 | public String getId() {
32 | return id;
33 | }
34 |
35 | public void setId(String id) {
36 | this.id = id;
37 | }
38 |
39 | public String getTitle() {
40 | return title;
41 | }
42 |
43 | public void setTitle(String title) {
44 | this.title = title;
45 | }
46 |
47 | public String getDescription() {
48 | return description;
49 | }
50 |
51 | public void setDescription(String description) {
52 | this.description = description;
53 | }
54 |
55 | public String getPhotoUrl() {
56 | return photoUrl;
57 | }
58 |
59 | public void setPhotoUrl(String photoUrl) {
60 | this.photoUrl = photoUrl;
61 | }
62 |
63 | public String getImageFileLocation() {
64 | return imageFileLocation;
65 | }
66 |
67 | public void setImageFileLocation(String imageFileLocation) {
68 | this.imageFileLocation = imageFileLocation;
69 | }
70 |
71 | public String getImageFileName() {
72 | return imageFileName;
73 | }
74 |
75 | public void setImageFileName(String imageFileName) {
76 | this.imageFileName = imageFileName;
77 | }
78 |
79 | public String getType() {
80 | return type;
81 | }
82 |
83 | public void setType(String type) {
84 | this.type = type;
85 | }
86 |
87 | private CarouselItem(Parcel in) {
88 | id = in.readString();
89 | title = in.readString();
90 | description = in.readString();
91 | photoUrl = in.readString();
92 | imageFileLocation = in.readString();
93 | imageFileName = in.readString();
94 | type = in.readString();
95 | }
96 |
97 | @Override
98 | public int describeContents() {
99 | return 0;
100 | }
101 |
102 | @Override
103 | public void writeToParcel(Parcel dest, int flags) {
104 | dest.writeString(id);
105 | dest.writeString(title);
106 | dest.writeString(description);
107 | dest.writeString(photoUrl);
108 | dest.writeString(imageFileLocation);
109 | dest.writeString(imageFileName);
110 | dest.writeString(type);
111 | }
112 |
113 | @SuppressWarnings("unused")
114 | public static final Creator CREATOR = new Creator() {
115 | @Override
116 | public CarouselItem createFromParcel(Parcel in) {
117 | return new CarouselItem(in);
118 | }
119 |
120 | @Override
121 | public CarouselItem[] newArray(int size) {
122 | return new CarouselItem[size];
123 | }
124 | };
125 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/relateddigital/euromessage/RouterFCMService.java:
--------------------------------------------------------------------------------
1 | package com.relateddigital.euromessage;
2 |
3 | import android.app.NotificationChannel;
4 | import android.app.NotificationManager;
5 | import android.app.PendingIntent;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.graphics.Color;
9 | import android.os.Build;
10 | import android.util.Log;
11 | import androidx.core.app.NotificationCompat;
12 |
13 | import com.google.firebase.messaging.FirebaseMessagingService;
14 | import com.google.firebase.messaging.RemoteMessage;
15 |
16 | import java.util.Map;
17 |
18 | import euromsg.com.euromobileandroid.service.EuroMsgFCMHelper;
19 | import euromsg.com.euromobileandroid.utils.LogUtils;
20 |
21 | public class RouterFCMService extends FirebaseMessagingService {
22 |
23 | private static final String TAG = "FCMService";
24 |
25 | @Override
26 | public void onMessageReceived(RemoteMessage remoteMessage) {
27 |
28 | Map data = remoteMessage.getData();
29 |
30 | String emPushSp = data.get("emPushSp");
31 | if(emPushSp != null) {
32 | Log.d(TAG, "RMC Message received: " + remoteMessage.getData());
33 | EuroMsgFCMHelper.onMessageReceived(this,remoteMessage);
34 | }
35 | else {
36 | dispatchNonRMCMessage(remoteMessage);
37 | }
38 | }
39 |
40 | @Override
41 | public void onNewToken(String token) {
42 | Log.d(TAG, "Refreshed token: " + token);
43 |
44 | EuroMsgFCMHelper.onNewToken(this,token);
45 |
46 |
47 | }
48 |
49 | private void dispatchNonRMCMessage(RemoteMessage remoteMessage) {
50 | Log.d(TAG, "Non-RMC Message received: " + remoteMessage.getData());
51 | /* String notificationTitle = remoteMessage.getNotification().getTitle();
52 | String notificationBody = remoteMessage.getNotification().getBody();
53 |
54 | if (notificationTitle != null && notificationBody != null) {
55 | sendNotification(notificationTitle, notificationBody);
56 | }
57 | }
58 |
59 | private void sendNotification(String title, String messageBody) {
60 | int notificationId = (int) System.currentTimeMillis();
61 |
62 | Intent intent = new Intent(this, MainActivity.class);
63 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
64 | PendingIntent pendingIntent = PendingIntent.getActivity(
65 | this, 0, intent, PendingIntent.FLAG_ONE_SHOT
66 | );
67 |
68 | String channelId = "default_channel_id";
69 | NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId)
70 | .setSmallIcon(R.drawable.ic_carousel_icon)
71 | .setContentTitle(title)
72 | .setContentText(messageBody)
73 | .setAutoCancel(true)
74 | .setPriority(NotificationCompat.PRIORITY_HIGH)
75 | .setContentIntent(pendingIntent);
76 |
77 | NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
78 |
79 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
80 | NotificationChannel channel = new NotificationChannel(
81 | channelId,
82 | "Default Channel",
83 | NotificationManager.IMPORTANCE_HIGH
84 | );
85 | channel.setDescription("Default Channel for FCM");
86 | channel.enableLights(true);
87 | channel.setLightColor(Color.RED);
88 | notificationManager.createNotificationChannel(channel);
89 | }
90 |
91 | notificationManager.notify(notificationId, notificationBuilder.build());
92 |
93 | */
94 | }
95 |
96 | }
97 |
98 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | ***Jan 10, 2025*** - [Euromessage v5.3.7](https://github.com/relateddigital/euromessage-android/releases/tag/5.3.7)
8 |
9 | # Table of Contents
10 |
11 | - [Table of Contents](#table-of-contents)
12 | - [Euromessage Android](#euromessage-android)
13 | * [1.Installation](#1installation)
14 | + [Gradle](#gradle)
15 | * [2.Usage of the SDK](#2usage-of-the-sdk)
16 | * [3.Sample Applications](#4sample-applications)
17 | * [4.IYS Email Register](#4iys-email-register)
18 | * [5.Licences](#5licences)
19 |
20 |
21 | # Euromessage Android
22 |
23 | The Euromessage Android Sdk is a java implementation of an Android client for Euromessage.
24 |
25 |
26 | ### Notifications
27 |
28 |
29 | ## 1.Installation
30 |
31 | Euromessage SDK requires minimum API level 21.
32 |
33 | Add maven jitpack repository to your project/build.gradle file
34 |
35 | allprojects {
36 | repositories {
37 | ...
38 | maven { url 'https://jitpack.io' }
39 | }
40 | }
41 |
42 | Add Euromessage to the ```dependencies``` in app/build.gradle.
43 |
44 | ```java
45 | implementation 'com.github.relateddigital:euromessage-android:5.3.7'
46 | ```
47 |
48 | ## 2. Usage of SDK
49 |
50 | For more information, please check new detailed documentation :
51 |
52 | [Euromessage Türkçe Dokümantasyon](https://relateddigital.atlassian.net/wiki/spaces/RMCKBT/pages/428802131/ANDROID+SDK)
53 |
54 | [Euromessage English Documentation](https://relateddigital.atlassian.net/wiki/spaces/KB/pages/428966369/ANDROID+SDK)
55 |
56 |
57 |
58 | ###### Note :
59 | You need to add an android project in [Firebase Console](https://console.firebase.google.com/). Please follow Firebase instruction and do not forget to add google_service.json to the project.
60 |
61 |
62 | You need to add an android project in [Huawei Console](https://developer.huawei.com/consumer/en/console). Please follow Huawei instruction and do not forget to add agconnect_services.json to the project.
63 | *you may need to add your fingerprint to app in Huawei console.
64 |
65 |
66 | ## 3.Sample Applications
67 |
68 |
69 | - [Euromessage Sample Application ](https://github.com/relateddigital/euromessage-android)
70 | - [Euromessage Visilabs Shopping Application ](https://github.com/relateddigital/sample-shopping-android)
71 |
72 | - If you have a question please send an e-mail to:
73 |
74 | ## 4.IYS Email Register
75 |
76 | To register email IYS:
77 |
78 | ```java
79 | EuromessageCallback callback = new EuromessageCallback() {
80 | @Override
81 | public void success() {
82 | Toast.makeText(getApplicationContext(), "REGISTER EMAIL SUCCESS", Toast.LENGTH_LONG).show();
83 | }
84 |
85 | @Override
86 | public void fail(String errorMessage) {
87 | String message = "REGISTER EMAIL ERROR ";
88 | if(errorMessage != null) {
89 | message = message + errorMessage;
90 | }
91 | Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
92 | }
93 | };
94 | EuroMobileManager.getInstance().registerEmail("test@euromsg.com", EmailPermit.ACTIVE, false, getApplicationContext(), callback);
95 | ```
96 |
97 |
98 |
99 |
100 | ## 5.Licences
101 |
102 | - [Related Digital ](https://www.relateddigital.com/)
103 | - [Euromessage](https://www.euromsg.com/)
104 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/app/src/main/java/com/relateddigital/euromessage/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.relateddigital.euromessage;
2 | import android.app.Application;
3 | import android.text.TextUtils;
4 | import android.util.Log;
5 | import com.google.firebase.messaging.FirebaseMessaging;
6 | import euromsg.com.euromobileandroid.EuroMobileManager;
7 | import euromsg.com.euromobileandroid.enums.RDNotificationPriority;
8 | import com.huawei.agconnect.AGConnectOptionsBuilder;
9 | import com.huawei.hms.aaid.HmsInstanceId;
10 | import com.huawei.hms.common.ApiException;
11 |
12 |
13 |
14 |
15 | public class MainApplication extends Application {
16 |
17 | EuroMobileManager euroMobileManager;
18 |
19 | @Override
20 | public void onCreate() {
21 | super.onCreate();
22 |
23 | initializeEuroMessage();
24 | }
25 |
26 | public void initializeEuroMessage() {
27 |
28 | euroMobileManager = EuroMobileManager.init(Constants.GOOGLE_APP_ALIAS, Constants.HUAWEI_APP_ALIAS, getApplicationContext());
29 | euroMobileManager.registerToFCM(getBaseContext());
30 |
31 | //optional
32 | euroMobileManager.setNotificationTransparentSmallIcon(android.R.drawable.star_off, getApplicationContext());
33 | euroMobileManager.setNotificationTransparentSmallIconDarkMode(R.drawable.delete_icon_dark_mode, getApplicationContext());
34 | euroMobileManager.useNotificationLargeIcon(true);
35 | euroMobileManager.setNotificationLargeIcon(R.drawable.euromessage, getApplicationContext());
36 | euroMobileManager.setNotificationLargeIconDarkMode(R.drawable.related_digital_dark_mode, getApplicationContext());
37 | euroMobileManager.setNotificationColor("#d1dbbd");
38 | euroMobileManager.setChannelName("Demo", getApplicationContext());
39 | euroMobileManager.setPushIntent("com.relateddigital.euromessage.MainActivity", getApplicationContext());
40 | euroMobileManager.setNotificationPriority(RDNotificationPriority.NORMAL, getApplicationContext());
41 |
42 | if (EuroMobileManager.checkPlayService(getApplicationContext())) {
43 | setExistingFirebaseTokenToEuroMessage();
44 | } else {
45 | setHuaweiTokenToEuromessage();
46 | }
47 | }
48 |
49 | private void setHuaweiTokenToEuromessage() {
50 | new Thread() {
51 | @Override
52 | public void run() {
53 | try {
54 | String appId = new AGConnectOptionsBuilder().build(getApplicationContext()).getString("client/app_id");
55 | final String token = HmsInstanceId.getInstance(getApplicationContext()).getToken(appId, "HCM");
56 | if(TextUtils.isEmpty(token) || token == null) {
57 | Log.e("Huawei Token : ", "Empty token!!!");
58 | return;
59 | }
60 | euroMobileManager.subscribe(token, getApplicationContext());
61 | SP.saveString(getApplicationContext(), "HuaweiToken", token);
62 | Log.i("Huawei Token", "" + token);
63 | } catch (ApiException e) {
64 | Log.e("Huawei Token", "Getting the token failed! " + e);
65 | }
66 | }
67 | }.start();
68 | }
69 |
70 |
71 | private void setExistingFirebaseTokenToEuroMessage() {
72 | FirebaseMessaging.getInstance().getToken()
73 | .addOnCompleteListener(task -> {
74 | if (!task.isSuccessful()) {
75 | Log.e("Firebase Token : ", "Getting the token failed!!!");
76 | return;
77 | }
78 | String token = task.getResult();
79 | euroMobileManager.subscribe(token, getApplicationContext());
80 |
81 | SP.saveString(getApplicationContext(), "FirebaseToken", token);
82 | });
83 | }
84 |
85 |
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/utils/RetryCounterManager.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.utils;
2 |
3 | import android.util.Log;
4 |
5 | public class RetryCounterManager {
6 | private static final String LOG_TAG = "RetryCounterManager";
7 | private static int counter1 = -1;
8 | private static int counter2 = -1;
9 | private static int counter3 = -1;
10 | private static int counter4 = -1;
11 | private static int counter5 = -1;
12 |
13 | public static int getCounterId() {
14 | int result;
15 | if(counter1 == -1) {
16 | counter1 = 0;
17 | result = 1;
18 | } else {
19 | if (counter2 == -1) {
20 | counter2 = 0;
21 | result = 2;
22 | } else {
23 | if(counter3 == -1) {
24 | counter3 = 0;
25 | result = 3;
26 | } else {
27 | if(counter4 == -1) {
28 | counter4 = 0;
29 | result = 4;
30 | } else {
31 | if(counter5 == -1) {
32 | counter5 = 0;
33 | result = 5;
34 | } else {
35 | result = -1;
36 | Log.i(LOG_TAG, "No counter could be found for re-try!");
37 | }
38 | }
39 | }
40 | }
41 | }
42 | return result;
43 | }
44 |
45 | public static void increaseCounter(int id) {
46 | switch (id) {
47 | case 1: {
48 | counter1++;
49 | break;
50 | }
51 | case 2: {
52 | counter2++;
53 | break;
54 | }
55 | case 3: {
56 | counter3++;
57 | break;
58 | }
59 | case 4: {
60 | counter4++;
61 | break;
62 | }
63 | case 5: {
64 | counter5++;
65 | break;
66 | }
67 | default: {
68 | Log.i(LOG_TAG, "There is no counter whose id matches!");
69 | break;
70 | }
71 | }
72 | }
73 |
74 | public static int getCounterValue(int id) {
75 | int result;
76 | switch (id) {
77 | case 1: {
78 | result = counter1;
79 | break;
80 | }
81 | case 2: {
82 | result = counter2;
83 | break;
84 | }
85 | case 3: {
86 | result = counter3;
87 | break;
88 | }
89 | case 4: {
90 | result = counter4;
91 | break;
92 | }
93 | case 5: {
94 | result = counter5;
95 | break;
96 | }
97 | default: {
98 | Log.i(LOG_TAG, "There is no counter whose id matches!");
99 | result = -1;
100 | break;
101 | }
102 | }
103 | return result;
104 | }
105 |
106 | public static void clearCounter(int id) {
107 | switch (id) {
108 | case 1: {
109 | counter1 = -1;
110 | break;
111 | }
112 | case 2: {
113 | counter2 = -1;
114 | break;
115 | }
116 | case 3: {
117 | counter3 = -1;
118 | break;
119 | }
120 | case 4: {
121 | counter4 = -1;
122 | break;
123 | }
124 | case 5: {
125 | counter5 = -1;
126 | break;
127 | }
128 | default: {
129 | Log.i(LOG_TAG, "There is no counter whose id matches!");
130 | break;
131 | }
132 | }
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/model/Carousel.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.model;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import java.util.ArrayList;
7 |
8 |
9 | public class Carousel implements Parcelable {
10 |
11 | public ArrayList carouselItems;
12 |
13 | public String contentTitle;
14 | public String contentText;
15 | public String bigContentTitle;
16 | public String bigContentText;
17 | public int carouselNotificationId; //Random id 9873715 for notification. Will cancel any notification that have existing same id.
18 | public int currentStartIndex; //Variable that keeps track of where the startIndex is
19 | public String smallIcon;
20 | private int smallIconResourceId;
21 | public String largeIcon;
22 | public String caraousalPlaceholder;
23 | public CarouselItem leftItem;
24 | public CarouselItem rightItem;
25 | public boolean isImagesInCarousel;
26 |
27 | public Carousel(ArrayList carouselItems, String contentTitle, String contentText,
28 | String bigContentTitle, String bigContentText, int carouselNotificationId,
29 | int currentStartIndex, String smallIcon, int smallIconResourceId,
30 | String largeIcon, String caraousalPlaceholder, CarouselItem leftItem,
31 | CarouselItem rightItem, boolean isImagesInCarousel) {
32 | this.carouselItems = carouselItems;
33 | this.contentTitle = contentTitle;
34 | this.contentText = contentText;
35 | this.bigContentTitle = bigContentTitle;
36 | this.bigContentText = bigContentText;
37 | this.carouselNotificationId = carouselNotificationId;
38 | this.currentStartIndex = currentStartIndex;
39 | this.smallIcon = smallIcon;
40 | this.smallIconResourceId = -1;
41 | this.smallIconResourceId = smallIconResourceId;
42 | this.largeIcon = largeIcon;
43 | this.caraousalPlaceholder = caraousalPlaceholder;
44 | this.leftItem = leftItem;
45 | this.rightItem = rightItem;
46 | this.isImagesInCarousel = isImagesInCarousel;
47 | }
48 |
49 | private Carousel(Parcel in) {
50 | if (in.readByte() == 0x01) {
51 | carouselItems = new ArrayList<>();
52 | in.readList(carouselItems, CarouselItem.class.getClassLoader());
53 | } else {
54 | carouselItems = null;
55 | }
56 | contentTitle = in.readString();
57 | contentText = in.readString();
58 | bigContentTitle = in.readString();
59 | bigContentText = in.readString();
60 | carouselNotificationId = in.readInt();
61 | currentStartIndex = in.readInt();
62 | smallIcon = in.readString();
63 | smallIconResourceId = -1;
64 | smallIconResourceId = in.readInt();
65 | largeIcon = in.readString();
66 | caraousalPlaceholder = in.readString();
67 | leftItem = (CarouselItem) in.readValue(CarouselItem.class.getClassLoader());
68 | rightItem = (CarouselItem) in.readValue(CarouselItem.class.getClassLoader());
69 | isImagesInCarousel = in.readByte() != 0x00;
70 | }
71 |
72 | @Override
73 | public int describeContents() {
74 | return 0;
75 | }
76 |
77 | @Override
78 | public void writeToParcel(Parcel dest, int flags) {
79 | if (carouselItems == null) {
80 | dest.writeByte((byte) (0x00));
81 | } else {
82 | dest.writeByte((byte) (0x01));
83 | dest.writeList(carouselItems);
84 | }
85 | dest.writeString(contentTitle);
86 | dest.writeString(contentText);
87 | dest.writeString(bigContentTitle);
88 | dest.writeString(bigContentText);
89 | dest.writeInt(carouselNotificationId);
90 | dest.writeInt(currentStartIndex);
91 | dest.writeString(smallIcon);
92 | dest.writeInt(smallIconResourceId);
93 | dest.writeString(largeIcon);
94 | dest.writeString(caraousalPlaceholder);
95 | dest.writeValue(leftItem);
96 | dest.writeValue(rightItem);
97 | dest.writeByte((byte) (isImagesInCarousel ? 0x01 : 0x00));
98 | }
99 |
100 | @SuppressWarnings("unused")
101 | public static final Creator CREATOR = new Creator() {
102 | @Override
103 | public Carousel createFromParcel(Parcel in) {
104 | return new Carousel(in);
105 | }
106 |
107 | @Override
108 | public Carousel[] newArray(int size) {
109 | return new Carousel[size];
110 | }
111 | };
112 | }
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/model/GraylogModel.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import java.io.Serializable;
6 | import java.util.HashMap;
7 | import java.util.Map;
8 |
9 | public class GraylogModel implements Serializable {
10 |
11 | @SerializedName("logLevel")
12 | private String logLevel = "";
13 |
14 | @SerializedName("logMessage")
15 | private String logMessage = "";
16 |
17 | @SerializedName("logPlace")
18 | private String logPlace = "";
19 |
20 | @SerializedName("googleAppAlias")
21 | private String googleAppAlias = "";
22 |
23 | @SerializedName("huaweiAppAlias")
24 | private String huaweiAppAlias = "";
25 |
26 | @SerializedName("iosAppAlias")
27 | private String iosAppAlias = "";
28 |
29 | @SerializedName("token")
30 | private String token = "";
31 |
32 | @SerializedName("appVersion")
33 | private String appVersion = "";
34 |
35 | @SerializedName("sdkVersion")
36 | private String sdkVersion = "";
37 |
38 | @SerializedName("osType")
39 | private String osType = "";
40 |
41 | @SerializedName("osVersion")
42 | private String osVersion = "";
43 |
44 | @SerializedName("deviceName")
45 | private String deviceName = "";
46 |
47 | @SerializedName("userAgent")
48 | private String userAgent = "";
49 |
50 | @SerializedName("identifierForVendor")
51 | private String identifierForVendor = "";
52 |
53 | @SerializedName("extra")
54 | private Map extra = new HashMap<>();
55 |
56 | public void setLogLevel(String logLevel) {
57 | this.logLevel = logLevel;
58 | }
59 |
60 | public void setLogMessage(String logMessage) {
61 | this.logMessage = logMessage;
62 | }
63 |
64 | public void setLogPlace(String logPlace) {
65 | this.logPlace = logPlace;
66 | }
67 |
68 | public void setGoogleAppAlias(String googleAppAlias) {
69 | this.googleAppAlias = googleAppAlias;
70 | }
71 |
72 | public void setHuaweiAppAlias(String huaweiAppAlias) {
73 | this.huaweiAppAlias = huaweiAppAlias;
74 | }
75 |
76 | public void setIosAppAlias(String iosAppAlias) {
77 | this.iosAppAlias = iosAppAlias;
78 | }
79 |
80 | public void setToken(String token) {
81 | this.token = token;
82 | }
83 |
84 | public void setAppVersion(String appVersion) {
85 | this.appVersion = appVersion;
86 | }
87 |
88 | public void setSdkVersion(String sdkVersion) {
89 | this.sdkVersion = sdkVersion;
90 | }
91 |
92 | public void setOsType(String osType) {
93 | this.osType = osType;
94 | }
95 |
96 | public void setOsVersion(String osVersion) {
97 | this.osVersion = osVersion;
98 | }
99 |
100 | public void setDeviceName(String deviceName) {
101 | this.deviceName = deviceName;
102 | }
103 |
104 | public void setUserAgent(String userAgent) {
105 | this.userAgent = userAgent;
106 | }
107 |
108 | public void setIdentifierForVendor(String identifierForVendor) {
109 | this.identifierForVendor = identifierForVendor;
110 | }
111 |
112 | public void setExtra(Map extra) {
113 | this.extra.clear();
114 | this.extra.putAll(extra);
115 | }
116 |
117 | public String getLogLevel(){
118 | return this.logLevel;
119 | }
120 |
121 | public String getLogMessage(){
122 | return this.logMessage;
123 | }
124 |
125 | public String getLogPlace(){
126 | return this.logPlace;
127 | }
128 |
129 | public String getGoogleAppAlias(){
130 | return this.googleAppAlias;
131 | }
132 |
133 | public String getHuaweiAppAlias(){
134 | return this.huaweiAppAlias;
135 | }
136 |
137 | public String getIosAppAlias(){
138 | return this.iosAppAlias;
139 | }
140 |
141 | public String getToken(){
142 | return this.token;
143 | }
144 |
145 | public String getAppVersion(){
146 | return this.appVersion;
147 | }
148 |
149 | public String getSdkVersion(){
150 | return this.sdkVersion;
151 | }
152 |
153 | public String getOsType(){
154 | return this.osType;
155 | }
156 |
157 | public String getOsVersion(){
158 | return this.osVersion;
159 | }
160 |
161 | public String getDeviceName(){
162 | return this.deviceName;
163 | }
164 |
165 | public String getUserAgent(){
166 | return this.userAgent;
167 | }
168 |
169 | public String getIdentifierForVendor(){
170 | return this.identifierForVendor;
171 | }
172 |
173 | public Map getExtra(){
174 | return this.extra;
175 | }
176 | }
177 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/Constants.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid;
2 |
3 | public class Constants {
4 |
5 | //https://commonsware.com/blog/2020/10/14/android-studio-4p1-library-modules-version-code.html
6 | static final String SDK_VERSION = euromsg.com.euromobileandroid.BuildConfig.VERSION_NAME;
7 |
8 |
9 | public static final String EURO_CONSENT_TIME_KEY = "ConsentTime";
10 | static final String EURO_CONSENT_SOURCE_KEY = "ConsentSource";
11 | static final String EURO_CONSENT_SOURCE_VALUE = "HS_MOBIL";
12 | static final String EURO_RECIPIENT_TYPE_KEY = "RecipientType";
13 | static final String EURO_RECIPIENT_TYPE_BIREYSEL = "BIREYSEL";
14 | static final String EURO_RECIPIENT_TYPE_TACIR = "TACIR";
15 | public static final String TOKEN_KEY = "token-key";
16 |
17 | public static final String EURO_EMAIL_KEY = "email";
18 | static final String EURO_SET_ANONYMOUS_KEY = "setAnonymous";
19 | static final String EURO_TWITTER_KEY = "twitter";
20 | static final String EURO_FACEBOOK_KEY = "facebook";
21 | static final String EURO_MSISDN_KEY = "msisdn";
22 | public static final String EURO_USER_KEY = "keyID";
23 | static final String EURO_LOCATION_KEY = "location";
24 | static final String EURO_SUBSCRIPTION_KEY = "subscription";
25 | static final String ALREADY_SENT_SUBSCRIPTION_JSON = "sent_subscription";
26 | static final String LAST_SUBSCRIPTION_TIME = "last_subscription_time";
27 |
28 | public static final String LOG_TAG = "EuroMessage";
29 | public static final String HUAWEI_APP_ALIAS = "AppKeyHuwaei";
30 | public static final String GOOGLE_APP_ALIAS = "AppKeyGoogle";
31 |
32 | public static final String NOTIFICATION_TRANSPARENT_SMALL_ICON = "small_icon";
33 | public static final String NOTIFICATION_TRANSPARENT_SMALL_ICON_DARK_MODE = "small_icon_dark_mode";
34 | public static final String NOTIFICATION_LARGE_ICON = "large_icon";
35 | public static final String NOTIFICATION_LARGE_ICON_DARK_MODE = "large_icon_dark_mode";
36 | public static final String NOTIFICATION_USE_LARGE_ICON = "use_large_icon";
37 | public static final String NOTIFICATION_COLOR = "notification_color";
38 | public static final String CHANNEL_NAME = "channel_name";
39 | public static final String BADGE = "badge";
40 | public static final int ACTIVE = 1;
41 | public static final int PASSIVE = 0;
42 |
43 | public static final int EVENT_LEFT_ARROW_CLICKED = 1;
44 | public static final int EVENT_RIGHT_ARROW_CLICKED = 2;
45 | public static final int EVENT_LEFT_ITEM_CLICKED = 3;
46 | public static final int EVENT_RIGHT_ITEM_CLICKED = 4;
47 |
48 | public static final String NOTIFICATION_ID = "NotificationId";
49 |
50 | public static final String EVENT_CAROUSAL_ITEM_CLICKED_KEY = "CarouselItemClicked";
51 | public static final String CAROUSAL_IMAGE_BEGENNING = "CarouselImage";
52 | public static final String CAROUSAL_EVENT_FIRED_INTENT_FILTER = "CAROUSALNOTIFICATIONFIRED";
53 | public static final String CAROUSAL_ITEM_CLICKED_INTENT_FILTER = "CarouselItemClickIntentFilter";
54 | public static final String CAROUSAL_ITEM_CLICKED_KEY = "CarouselItemClickedKey";
55 | public static final String CAROUSEL_ITEM_CLICKED_URL = "CarouselItemClickedUrl";
56 | public static final String CAROUSAL_SET_UP_KEY = "CAROUSAL_SET_UP_KEY";
57 | public static final String CAROUSAL_SMALL_ICON_FILE_NAME = "smallIconCarousel";
58 | public static final String CAROUSAL_LARGE_ICON_FILE_NAME = "largeIconCarousel";
59 | public static final String CAROUSAL_PLACEHOLDER_ICON_FILE_NAME = "placeHolderIconCarousel";
60 |
61 | public static final String EURO_SUBSCRIPTION_NO_EMAIL_KEY = "subscription_no_email";
62 | public static final String EURO_SUBSCRIPTION_DATE_KEY = "subscription_date";
63 | public static final String EURO_SUBSCRIPTION_WITH_EMAIL_KEY = "subscription_with_email";
64 | public static final String EURO_SUBSCRIPTION_DATE_WITH_EMAIL_KEY = "subscription_date_with_email";
65 |
66 | public static final String INTENT_NAME = "intent_name";
67 | public static final int UI_FEATURES_MIN_API = 21;
68 |
69 | public static final String PAYLOAD_SP_KEY = "payload_sp";
70 | public static final String PAYLOAD_SP_ARRAY_KEY = "messages";
71 | public static final String PAYLOAD_SP_ID_KEY = "payload_sp_with_id";
72 | public static final String PAYLOAD_SP_ARRAY_ID_KEY = "messages_with_id";
73 |
74 | public static final String NOTIFICATION_CHANNEL_ID_KEY = "not_channel_id_key";
75 | public static final String NOTIFICATION_CHANNEL_NAME_KEY = "not_channel_name_key";
76 | public static final String NOTIFICATION_CHANNEL_DESCRIPTION_KEY = "not_channel_description_key";
77 | public static final String NOTIFICATION_CHANNEL_SOUND_KEY = "not_channel_sound_key";
78 | public static final String NOTIFICATION_PRIORITY_KEY = "not_priority_key";
79 |
80 | public static final String DEFAULT_ANDROID_SOUND = "default_android_sound";
81 | public static final String NOTIFICATION_LOGIN_ID_KEY = "notification_login_id_key";
82 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/utils/ImageUtils.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.utils;
2 |
3 | import android.content.Context;
4 | import android.content.ContextWrapper;
5 | import android.content.pm.ApplicationInfo;
6 | import android.content.pm.PackageManager;
7 | import android.graphics.Bitmap;
8 | import android.graphics.BitmapFactory;
9 | import android.graphics.Canvas;
10 | import android.graphics.drawable.BitmapDrawable;
11 | import android.graphics.drawable.Drawable;
12 | import android.util.Log;
13 | import android.util.TypedValue;
14 |
15 | import androidx.annotation.AttrRes;
16 | import androidx.annotation.ColorInt;
17 | import androidx.annotation.NonNull;
18 |
19 | import java.io.File;
20 | import java.io.FileInputStream;
21 | import java.io.FileNotFoundException;
22 | import java.io.FileOutputStream;
23 | import java.io.IOException;
24 |
25 |
26 | public class ImageUtils {
27 |
28 | public static Bitmap drawableToBitmap(Drawable drawable) {
29 | Bitmap bitmap;
30 |
31 | if (drawable instanceof BitmapDrawable) {
32 | BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
33 | if (bitmapDrawable.getBitmap() != null) {
34 | return bitmapDrawable.getBitmap();
35 | }
36 | }
37 |
38 | if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
39 | bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); // Single color bitmap will be created of 1x1 pixel
40 | } else {
41 | bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
42 | }
43 |
44 | Canvas canvas = new Canvas(bitmap);
45 | drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
46 | drawable.draw(canvas);
47 | return bitmap;
48 | }
49 |
50 | public static String saveBitmapToInternalStorage(Context context, Bitmap bitmapImage, String fileName) {
51 | boolean fileSaved = false;
52 | ContextWrapper cw = new ContextWrapper(context.getApplicationContext());
53 | // path to /data/data/yourapp/app_data/imageDir
54 | File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
55 | // Create imageDir
56 | File mypath = new File(directory, fileName + ".jpg");
57 |
58 | FileOutputStream fos = null;
59 | try {
60 | fos = new FileOutputStream(mypath);
61 | bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos);
62 | fileSaved = true;
63 | } catch (Exception e) {
64 | Log.e("Exception", "Error accessing file: " + e.getMessage());
65 | e.printStackTrace();
66 | } finally {
67 | try {
68 | if (fos != null) {
69 | fos.close();
70 | }
71 | } catch (IOException e) {
72 | Log.e("Exception", "Error accessing file: " + e.getMessage());
73 |
74 | e.printStackTrace();
75 | }
76 | }
77 | if (fileSaved)
78 | return directory.getAbsolutePath();
79 | else
80 | return null;
81 | }
82 |
83 | public static Bitmap loadImageFromStorage(Context context, String path, String fileName) {
84 | Bitmap b = null;
85 |
86 | try {
87 | File f = new File(path, fileName + ".jpg");
88 | b = BitmapFactory.decodeStream(new FileInputStream(f));
89 | } catch (FileNotFoundException e) {
90 | Log.e("Exception", "File not found: " + e.getMessage());
91 |
92 | e.printStackTrace();
93 | }
94 | return b;
95 | }
96 |
97 | public static int calculateInSampleSize(
98 | final int width, final int height, int reqWidth, int reqHeight) {
99 | // Raw height and width of image
100 | int inSampleSize = 1;
101 |
102 | if (height > reqHeight || width > reqWidth) {
103 |
104 | final int halfHeight = height / 2;
105 | final int halfWidth = width / 2;
106 | while ((halfHeight / inSampleSize) >= reqHeight
107 | && (halfWidth / inSampleSize) >= reqWidth) {
108 | inSampleSize *= 2;
109 | }
110 | }
111 |
112 | return inSampleSize;
113 | }
114 |
115 | public static int getAppIcon(Context context) {
116 | int appIconResId = 0;
117 | PackageManager packageManager = context.getPackageManager();
118 | final ApplicationInfo applicationInfo;
119 | try {
120 | applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
121 |
122 | appIconResId = applicationInfo.icon;
123 |
124 |
125 | } catch (PackageManager.NameNotFoundException e) {
126 | Log.e("Exception", "Error accessing file: " + e.getMessage());
127 |
128 | e.printStackTrace();
129 | }
130 |
131 | return appIconResId;
132 | }
133 |
134 | @ColorInt
135 | public static int getThemeColor
136 | (
137 | @NonNull final Context context,
138 | @AttrRes final int attributeColor
139 | )
140 | {
141 | final TypedValue value = new TypedValue();
142 | context.getTheme ().resolveAttribute (attributeColor, value, true);
143 | return value.data;
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/connection/CarouselImageDownloaderManager.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.connection;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 |
6 | import android.text.TextUtils;
7 | import android.util.Log;
8 |
9 | import androidx.annotation.NonNull;
10 |
11 | import java.util.ArrayList;
12 |
13 | import euromsg.com.euromobileandroid.Constants;
14 | import euromsg.com.euromobileandroid.model.CarouselItem;
15 | import euromsg.com.euromobileandroid.utils.AppUtils;
16 | import euromsg.com.euromobileandroid.utils.ImageUtils;
17 |
18 | public class CarouselImageDownloaderManager {
19 |
20 | private final String TAG = this.getClass().getSimpleName();
21 | private Context context;
22 | private ArrayList carouselItems;
23 | private OnDownloadsCompletedListener onDownloadsCompletedListener;
24 | private int numberOfImages;
25 | private static int currentDownloadTaskIndex = 0;
26 | private CarouselItem currentItem;
27 |
28 | public CarouselImageDownloaderManager(Context context, ArrayList carouselItems, int numberOfImages,
29 | @NonNull OnDownloadsCompletedListener onDownloadsCompletedListener) {
30 | this.carouselItems = carouselItems;
31 | this.context = context;
32 | this.onDownloadsCompletedListener = onDownloadsCompletedListener;
33 | this.numberOfImages = numberOfImages;
34 | }
35 |
36 | private OnImageLoaderListener mImageLoaderListener = new OnImageLoaderListener() {
37 | @Override
38 | public void onError(ImageError error) {
39 | updateDownLoad();
40 | }
41 |
42 | @Override
43 | public void onComplete(String resultPath) {
44 | updateDownLoad();
45 | }
46 | };
47 |
48 | private void updateDownLoad() {
49 |
50 | for (int i = (currentDownloadTaskIndex + 1); i < carouselItems.size(); i++) {
51 | if (!TextUtils.isEmpty(carouselItems.get(i).getPhotoUrl())) {
52 | currentDownloadTaskIndex = i;
53 | currentItem = carouselItems.get(i);
54 | downloadImage(currentItem.getPhotoUrl());
55 | break;
56 | }
57 | }
58 | --numberOfImages;
59 | if (numberOfImages < 1 || currentDownloadTaskIndex > carouselItems.size() - 1) {
60 | onDownloadsCompletedListener.onComplete();
61 | }
62 | }
63 |
64 | public void startAllDownloads() {
65 | if (carouselItems != null && carouselItems.size() > 0) {
66 | for (int i = 0; i < carouselItems.size(); i++) {
67 | if (!TextUtils.isEmpty(carouselItems.get(i).getPhotoUrl())) {
68 | currentDownloadTaskIndex = i;
69 | currentItem = carouselItems.get(i);
70 | downloadImage(currentItem.getPhotoUrl());
71 | break;
72 | }
73 | }
74 | }
75 | }
76 |
77 | public interface OnImageLoaderListener {
78 | void onError(ImageError error);
79 |
80 | void onComplete(String resultPath);
81 | }
82 |
83 | public interface OnDownloadsCompletedListener {
84 |
85 | void onComplete();
86 | }
87 |
88 | private void downloadImage(@NonNull final String imageUrl) {
89 |
90 | Runnable runnable = new Runnable() {
91 | @Override
92 | public void run() {
93 | String imagePath = null;
94 | long currentTimeInMillis = System.currentTimeMillis();
95 | Bitmap bitmap;
96 |
97 | bitmap = AppUtils.getBitMapFromUri(context, imageUrl);
98 |
99 | if (bitmap != null) {
100 |
101 | int sampleSize = ImageUtils.calculateInSampleSize(bitmap.getWidth(), bitmap.getHeight(), 250, 250);
102 | Bitmap bit = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth() / sampleSize, bitmap.getHeight() / sampleSize, false);
103 | imagePath = ImageUtils.saveBitmapToInternalStorage(context, bit, Constants.CAROUSAL_IMAGE_BEGENNING + currentTimeInMillis);
104 | }
105 | if (imagePath == null) {
106 | Log.e(TAG, "factory returned a null result");
107 | mImageLoaderListener.onError(new ImageError("downloaded file could not be decoded as bitmap")
108 | .setErrorCode(ImageError.ERROR_DECODE_FAILED));
109 | } else {
110 | Log.d(TAG, "download complete");
111 | if (currentItem != null) {
112 | currentItem.setImageFileLocation(imagePath);
113 | currentItem.setImageFileName(Constants.CAROUSAL_IMAGE_BEGENNING + currentTimeInMillis);
114 | }
115 | mImageLoaderListener.onComplete(imagePath);
116 | }
117 | System.gc();
118 | }
119 | };
120 |
121 | Thread thread = new Thread(runnable);
122 | thread.start();
123 | }
124 |
125 |
126 | public static final class ImageError extends Throwable {
127 |
128 | private int errorCode;
129 |
130 | static final int ERROR_GENERAL_EXCEPTION = -1;
131 |
132 | public static final int ERROR_INVALID_FILE = 0;
133 |
134 | static final int ERROR_DECODE_FAILED = 1;
135 |
136 |
137 | ImageError(@NonNull String message) {
138 | super(message);
139 | }
140 |
141 | ImageError(@NonNull Throwable error) {
142 | super(error.getMessage(), error.getCause());
143 | this.setStackTrace(error.getStackTrace());
144 | }
145 |
146 | ImageError setErrorCode(int code) {
147 | this.errorCode = code;
148 | return this;
149 | }
150 |
151 | public int getErrorCode() {
152 | return errorCode;
153 | }
154 | }
155 | }
156 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/utils/LogUtils.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.utils;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 |
6 | import androidx.annotation.NonNull;
7 |
8 | import euromsg.com.euromobileandroid.Constants;
9 | import euromsg.com.euromobileandroid.EuroMobileManager;
10 | import euromsg.com.euromobileandroid.connection.EuroApiService;
11 | import euromsg.com.euromobileandroid.connection.GraylogApiClient;
12 | import euromsg.com.euromobileandroid.model.GraylogModel;
13 | import euromsg.com.euromobileandroid.utils.LogConfigApiClient;
14 | import retrofit2.Call;
15 | import retrofit2.Callback;
16 | import retrofit2.Response;
17 |
18 | import java.io.IOException;
19 |
20 | import retrofit2.Retrofit;
21 | import retrofit2.http.GET;
22 |
23 | public final class LogUtils {
24 | private static final String LOG_TAG = "LogUtils";
25 |
26 | // Private constructor to prevent instantiation
27 | private LogUtils() {}
28 |
29 | /**
30 | * Retrofit API interface for fetching log configuration.
31 | * Equivalent to the Kotlin LogConfigApi interface nested within LogUtils.
32 | */
33 | public interface LogConfigApi {
34 | @GET("log_rc.json")
35 | Call getLogConfig();
36 | }
37 |
38 | /**
39 | * Determines whether a log should be sent based on remote configuration and customer ID.
40 | * IMPORTANT: This method performs a synchronous network call (call.execute()).
41 | * It MUST NOT be called on the main UI thread in Android.
42 | *
43 | * @param context The application context.
44 | * @return true if the log should be sent, false otherwise.
45 | */
46 | private static boolean shouldSendLog(Context context) {
47 | try {
48 | Retrofit retrofitClient = LogConfigApiClient.getClient();
49 | if (retrofitClient == null) {
50 | Log.w(LOG_TAG, "LogConfigApiClient.client is null. Defaulting to send log.");
51 | return true;
52 | }
53 | LogConfigApi apiService = retrofitClient.create(LogConfigApi.class);
54 |
55 | Call call = apiService.getLogConfig();
56 | if (call == null) {
57 | Log.w(LOG_TAG, "Failed to create call for getLogConfig. Defaulting to send log.");
58 | return true;
59 | }
60 |
61 | // Synchronous network call - MUST be on a background thread.
62 | Response response = call.execute(); // Can throw IOException
63 |
64 | LogConfig config = null;
65 | if (response != null && response.isSuccessful()) {
66 | config = response.body();
67 | }
68 |
69 | if (config == null) {
70 | Log.w(LOG_TAG, "Failed to retrieve config, response was null, not successful, or body was null. Defaulting to send log.");
71 | return true; // Config yoksa default true
72 | }
73 |
74 | if (!config.isLoggingEnabled()) {
75 | return false;
76 | }
77 |
78 |
79 | String customerId = EuroMobileManager.getInstance().subscription.getAppAlias();
80 |
81 | if (customerId == null || customerId.isEmpty()) {
82 | Log.i(LOG_TAG, "Customer ID could not be determined. Defaulting to send log.");
83 | return true;
84 | }
85 |
86 | Log.i(LOG_TAG, "Customer ID: " + customerId);
87 |
88 | if (config.getExcludedCustomerIds() == null) {
89 | Log.w(LOG_TAG, "Excluded customer IDs list is null. Assuming customer is not excluded (sending log).");
90 | return true; // Or false, based on how you want to handle missing exclusion list
91 | }
92 |
93 | return !config.getExcludedCustomerIds().contains(customerId);
94 |
95 | } catch (IOException e) {
96 | Log.e(LOG_TAG, "IOException during fetching log config: " + e.getMessage(), e);
97 | return true; // Hata durumunda default olarak log gönder
98 | } catch (Exception e) { // Catch other potential runtime exceptions
99 | Log.e(LOG_TAG, "Failed to fetch log config due to an unexpected error: " + e.getMessage(), e);
100 | return true; // Hata durumunda default olarak log gönder
101 | }
102 | }
103 |
104 | public static void sendGraylogMessage(GraylogModel graylogModel) {
105 | if(GraylogApiClient.getClient() == null) {
106 | Log.e(LOG_TAG, "Euromessage SDK requires min API level 21!");
107 | return;
108 | }
109 | EuroApiService apiService = GraylogApiClient.getClient().create(EuroApiService.class);
110 | Call call = apiService.sendLogToGraylog(graylogModel);
111 | call.enqueue(new Callback() {
112 | @Override
113 | public void onResponse(@NonNull Call call, @NonNull Response response) {
114 | if (response.isSuccessful()) {
115 | Log.i(LOG_TAG, "Sending the graylog message is successful");
116 | } else {
117 | Log.i(LOG_TAG, "Sending the graylog message is failed");
118 | }
119 | }
120 |
121 | @Override
122 | public void onFailure(@NonNull Call call, @NonNull Throwable t) {
123 | Log.i(LOG_TAG, "Sending the graylog message is failed");
124 | t.printStackTrace();
125 | }
126 | });
127 | }
128 |
129 | public static void formGraylogModel(Context context, String logLevel, String logMessage,
130 | String logPlace){
131 | if (!shouldSendLog(context)) {
132 | Log.i(LOG_TAG, "Log sending skipped due to configuration.");
133 | return;
134 | }
135 | EuroMobileManager euroMobileManager;
136 | if(EuroMobileManager.getInstance() == null) {
137 | String appAlias = SharedPreference.getString(context, Constants.GOOGLE_APP_ALIAS);
138 | String huaweiAppAlias = SharedPreference.getString(context, Constants.HUAWEI_APP_ALIAS);
139 |
140 | euroMobileManager = EuroMobileManager.init(appAlias, huaweiAppAlias, context);
141 | } else {
142 | euroMobileManager = EuroMobileManager.getInstance();
143 | }
144 | euroMobileManager.sendLogToGraylog(logLevel, logMessage, logPlace);
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/service/EuroFirebaseMessagingService.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.service;
2 |
3 | import android.app.NotificationManager;
4 | import android.content.Context;
5 | import android.content.pm.ApplicationInfo;
6 | import android.content.pm.PackageManager;
7 | import android.os.Build;
8 | import android.os.Bundle;
9 | import android.util.Log;
10 |
11 | import androidx.annotation.NonNull;
12 | import androidx.annotation.RequiresApi;
13 |
14 | import com.google.firebase.messaging.FirebaseMessagingService;
15 | import com.google.firebase.messaging.RemoteMessage;
16 | import com.google.gson.Gson;
17 |
18 |
19 | import java.util.Locale;
20 | import java.util.Map;
21 | import java.util.Random;
22 |
23 | import euromsg.com.euromobileandroid.Constants;
24 | import euromsg.com.euromobileandroid.EuroMobileManager;
25 |
26 | import euromsg.com.euromobileandroid.model.Message;
27 | import euromsg.com.euromobileandroid.notification.PushNotificationManager;
28 | import euromsg.com.euromobileandroid.utils.AppUtils;
29 | import euromsg.com.euromobileandroid.utils.EuroLogger;
30 | import euromsg.com.euromobileandroid.utils.LogUtils;
31 | import euromsg.com.euromobileandroid.utils.PayloadUtils;
32 | import euromsg.com.euromobileandroid.utils.SharedPreference;
33 |
34 | public class EuroFirebaseMessagingService extends FirebaseMessagingService {
35 |
36 | @Override
37 | public void onNewToken(@NonNull String token) {
38 | String googleAppAlias;
39 | String huaweiAppAlias;
40 | try {
41 | EuroLogger.debugLog("On new token : " + token);
42 | ApplicationInfo appInfo = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
43 | if(appInfo!=null){
44 | Bundle bundle = appInfo.metaData;
45 | if(bundle!=null){
46 | googleAppAlias = bundle.getString("GoogleAppAlias", "");
47 | huaweiAppAlias = bundle.getString("HuaweiAppAlias", "");
48 | } else {
49 | googleAppAlias = SharedPreference.getString(this, Constants.GOOGLE_APP_ALIAS);
50 | huaweiAppAlias = SharedPreference.getString(this, Constants.HUAWEI_APP_ALIAS);
51 | }
52 | } else {
53 | googleAppAlias = SharedPreference.getString(this, Constants.GOOGLE_APP_ALIAS);
54 | huaweiAppAlias = SharedPreference.getString(this, Constants.HUAWEI_APP_ALIAS);
55 | }
56 | EuroMobileManager.init(googleAppAlias, huaweiAppAlias, this).subscribe(token, this);
57 |
58 | } catch (Exception e) {
59 |
60 | EuroLogger.debugLog(e.toString());
61 | googleAppAlias = SharedPreference.getString(this, Constants.GOOGLE_APP_ALIAS);
62 | huaweiAppAlias = SharedPreference.getString(this, Constants.HUAWEI_APP_ALIAS);
63 | EuroMobileManager.init(googleAppAlias, huaweiAppAlias, this).subscribe(token, this);
64 | }
65 | }
66 |
67 | @RequiresApi(api = Build.VERSION_CODES.KITKAT)
68 | @Override
69 | public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
70 | super.onMessageReceived(remoteMessage);
71 |
72 | Map remoteMessageData = remoteMessage.getData();
73 | if(remoteMessageData.isEmpty()) {
74 | Log.e("FMessagingService", "Push message is empty!");
75 | StackTraceElement element = new Throwable().getStackTrace()[0];
76 | LogUtils.formGraylogModel(
77 | this,
78 | "e",
79 | "FMessagingService : " + "Push message is empty!",
80 | element.getClassName() + "/" + element.getMethodName() + "/" + element.getLineNumber()
81 | );
82 | return;
83 | }
84 | Message pushMessage = new Message(this, remoteMessageData);
85 |
86 | if(pushMessage.getEmPushSp() == null) {
87 | Log.i("Push Notification", "The push notification was not coming from Related Digital! Ignoring..");
88 | return;
89 | }
90 |
91 | EuroLogger.debugLog("EM FirebasePayload : " + new Gson().toJson(pushMessage));
92 |
93 | PushNotificationManager pushNotificationManager = new PushNotificationManager();
94 |
95 | EuroLogger.debugLog("Message received : " + pushMessage.getMessage());
96 |
97 | String appAlias = SharedPreference.getString(this, Constants.GOOGLE_APP_ALIAS);
98 | String huaweiAppAlias = SharedPreference.getString(this, Constants.HUAWEI_APP_ALIAS);
99 |
100 | EuroMobileManager euroMobileManager = EuroMobileManager.init(appAlias, huaweiAppAlias, this);
101 |
102 | if(pushMessage.getSilent() != null && pushMessage.getSilent().equalsIgnoreCase("true")) {
103 | Log.i("EuroFirabase", "Silent Push");
104 | euroMobileManager.reportReceived(pushMessage.getPushId(),
105 | pushMessage.getEmPushSp(), true);
106 | } else {
107 |
108 | if (pushMessage.getPushType() != null && pushMessage.getPushId() != null) {
109 |
110 | int notificationId = new Random().nextInt(Integer.MAX_VALUE);
111 | NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
112 |
113 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && notificationManager != null) {
114 | String channelName = SharedPreference.getString(this, Constants.NOTIFICATION_CHANNEL_NAME_KEY);
115 | String channelDescription = SharedPreference.getString(this, Constants.NOTIFICATION_CHANNEL_DESCRIPTION_KEY);
116 | String channelSound = SharedPreference.getString(this, Constants.NOTIFICATION_CHANNEL_SOUND_KEY);
117 |
118 | if (!channelName.equals(PushNotificationManager.getChannelName(this)) ||
119 | !channelDescription.equals(PushNotificationManager.getChannelDescription(this)) ||
120 | !channelSound.equals(pushMessage.getSound())) {
121 | String oldChannelId = SharedPreference.getString(this, Constants.NOTIFICATION_CHANNEL_ID_KEY);
122 | if (!oldChannelId.isEmpty()) {
123 | notificationManager.deleteNotificationChannel(oldChannelId);
124 | }
125 | AppUtils.getNotificationChannelId(this, true);
126 | } else {
127 | AppUtils.getNotificationChannelId(this, false);
128 | }
129 | SharedPreference.saveString(this, Constants.NOTIFICATION_CHANNEL_NAME_KEY, PushNotificationManager.getChannelName(this));
130 | SharedPreference.saveString(this, Constants.NOTIFICATION_CHANNEL_DESCRIPTION_KEY, PushNotificationManager.getChannelDescription(this));
131 | SharedPreference.saveString(this, Constants.NOTIFICATION_CHANNEL_SOUND_KEY, pushMessage.getSound());
132 | }
133 |
134 | switch (pushMessage.getPushType()) {
135 |
136 | case Image:
137 |
138 | if (pushMessage.getElements() != null) {
139 | pushNotificationManager.generateCarouselNotification(this, pushMessage, notificationId);
140 | } else {
141 | pushNotificationManager.generateNotification(this, pushMessage, AppUtils.getBitMapFromUri(this, pushMessage.getMediaUrl()), notificationId);
142 | }
143 |
144 | break;
145 |
146 | case Text:
147 | pushNotificationManager.generateNotification(this, pushMessage, null, notificationId);
148 |
149 | break;
150 |
151 | case Video:
152 | break;
153 |
154 | default:
155 | pushNotificationManager.generateNotification(this, pushMessage, null, notificationId);
156 | break;
157 | }
158 |
159 | if (pushMessage.getDeliver() != null &&
160 | pushMessage.getDeliver().toLowerCase(Locale.ROOT).equals("true")) {
161 | euroMobileManager.reportReceived(pushMessage.getPushId(),
162 | pushMessage.getEmPushSp(), false);
163 | }
164 |
165 | String notificationLoginId = SharedPreference.getString(this, Constants.NOTIFICATION_LOGIN_ID_KEY);
166 |
167 | if(notificationLoginId.isEmpty()) {
168 | PayloadUtils.addPushMessage(this, pushMessage);
169 | } else {
170 | PayloadUtils.addPushMessageWithId(this, pushMessage, notificationLoginId);
171 | }
172 | PayloadUtils.updatePayloadWithId(this,pushMessage.getPushId(),notificationId);
173 |
174 | } else {
175 | EuroLogger.debugLog("remoteMessageData transfrom problem");
176 | }
177 | }
178 | }
179 | }
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/service/EuroMsgFCMHelper.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.service;
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | import android.app.NotificationManager;
11 | import android.content.Context;
12 | import android.content.pm.ApplicationInfo;
13 | import android.content.pm.PackageManager;
14 | import android.os.Build;
15 | import android.os.Bundle;
16 | import android.util.Log;
17 |
18 | import androidx.annotation.NonNull;
19 |
20 | import com.google.firebase.messaging.RemoteMessage;
21 | import com.google.gson.Gson;
22 |
23 | import java.util.Locale;
24 | import java.util.Map;
25 | import java.util.Random;
26 |
27 | import euromsg.com.euromobileandroid.Constants;
28 | import euromsg.com.euromobileandroid.EuroMobileManager;
29 | import euromsg.com.euromobileandroid.model.Message;
30 | import euromsg.com.euromobileandroid.notification.PushNotificationManager;
31 | import euromsg.com.euromobileandroid.utils.AppUtils;
32 | import euromsg.com.euromobileandroid.utils.EuroLogger;
33 | import euromsg.com.euromobileandroid.utils.LogUtils;
34 | import euromsg.com.euromobileandroid.utils.PayloadUtils;
35 | import euromsg.com.euromobileandroid.utils.SharedPreference;
36 |
37 | public class EuroMsgFCMHelper {
38 |
39 | public static void onMessageReceived(Context context, RemoteMessage remoteMessage) {
40 |
41 | Map remoteMessageData = remoteMessage.getData();
42 | if(remoteMessageData.isEmpty()) {
43 | Log.e("FMessagingService", "Push message is empty!");
44 | StackTraceElement element = new Throwable().getStackTrace()[0];
45 | LogUtils.formGraylogModel(
46 | context,
47 | "e",
48 | "FMessagingService : " + "Push message is empty!",
49 | element.getClassName() + "/" + element.getMethodName() + "/" + element.getLineNumber()
50 | );
51 | return;
52 | }
53 | Message pushMessage = new Message(context, remoteMessageData);
54 |
55 | if(pushMessage.getEmPushSp() == null) {
56 | Log.i("Push Notification", "The push notification was not coming from Related Digital! Ignoring..");
57 | return;
58 | }
59 |
60 | EuroLogger.debugLog("EM FirebasePayload : " + new Gson().toJson(pushMessage));
61 |
62 | PushNotificationManager pushNotificationManager = new PushNotificationManager();
63 |
64 | EuroLogger.debugLog("Message received : " + pushMessage.getMessage());
65 |
66 | String appAlias = SharedPreference.getString(context, Constants.GOOGLE_APP_ALIAS);
67 | String huaweiAppAlias = SharedPreference.getString(context, Constants.HUAWEI_APP_ALIAS);
68 |
69 | EuroMobileManager euroMobileManager = EuroMobileManager.init(appAlias, huaweiAppAlias, context);
70 |
71 | if(pushMessage.getSilent() != null && pushMessage.getSilent().equalsIgnoreCase("true")) {
72 | Log.i("EuroFirabase", "Silent Push");
73 | euroMobileManager.reportReceived(pushMessage.getPushId(),
74 | pushMessage.getEmPushSp(), true);
75 | } else {
76 |
77 | if (pushMessage.getPushType() != null && pushMessage.getPushId() != null) {
78 |
79 | int notificationId = new Random().nextInt(Integer.MAX_VALUE);
80 | NotificationManager notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
81 |
82 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && notificationManager != null) {
83 | String channelName = SharedPreference.getString(context, Constants.NOTIFICATION_CHANNEL_NAME_KEY);
84 | String channelDescription = SharedPreference.getString(context, Constants.NOTIFICATION_CHANNEL_DESCRIPTION_KEY);
85 | String channelSound = SharedPreference.getString(context, Constants.NOTIFICATION_CHANNEL_SOUND_KEY);
86 |
87 | if (!channelName.equals(PushNotificationManager.getChannelName(context)) ||
88 | !channelDescription.equals(PushNotificationManager.getChannelDescription(context)) ||
89 | !channelSound.equals(pushMessage.getSound())) {
90 | String oldChannelId = SharedPreference.getString(context, Constants.NOTIFICATION_CHANNEL_ID_KEY);
91 | if (!oldChannelId.isEmpty()) {
92 | notificationManager.deleteNotificationChannel(oldChannelId);
93 | }
94 | AppUtils.getNotificationChannelId(context, true);
95 | } else {
96 | AppUtils.getNotificationChannelId(context, false);
97 | }
98 | SharedPreference.saveString(context, Constants.NOTIFICATION_CHANNEL_NAME_KEY, PushNotificationManager.getChannelName(context));
99 | SharedPreference.saveString(context, Constants.NOTIFICATION_CHANNEL_DESCRIPTION_KEY, PushNotificationManager.getChannelDescription(context));
100 | SharedPreference.saveString(context, Constants.NOTIFICATION_CHANNEL_SOUND_KEY, pushMessage.getSound());
101 | }
102 |
103 | switch (pushMessage.getPushType()) {
104 |
105 | case Image:
106 |
107 | if (pushMessage.getElements() != null) {
108 | pushNotificationManager.generateCarouselNotification(context, pushMessage, notificationId);
109 | } else {
110 | pushNotificationManager.generateNotification(context, pushMessage, AppUtils.getBitMapFromUri(context, pushMessage.getMediaUrl()), notificationId);
111 | }
112 |
113 | break;
114 |
115 | case Text:
116 | pushNotificationManager.generateNotification(context, pushMessage, null, notificationId);
117 |
118 | break;
119 |
120 | case Video:
121 | break;
122 |
123 | default:
124 | pushNotificationManager.generateNotification(context, pushMessage, null, notificationId);
125 | break;
126 | }
127 |
128 | if (pushMessage.getDeliver() != null &&
129 | pushMessage.getDeliver().toLowerCase(Locale.ROOT).equals("true")) {
130 | euroMobileManager.reportReceived(pushMessage.getPushId(),
131 | pushMessage.getEmPushSp(), false);
132 | }
133 |
134 | String notificationLoginId = SharedPreference.getString(context, Constants.NOTIFICATION_LOGIN_ID_KEY);
135 |
136 | if(notificationLoginId.isEmpty()) {
137 | PayloadUtils.addPushMessage(context, pushMessage);
138 | } else {
139 | PayloadUtils.addPushMessageWithId(context, pushMessage, notificationLoginId);
140 | }
141 | PayloadUtils.updatePayloadWithId(context,pushMessage.getPushId(),notificationId);
142 |
143 | } else {
144 | EuroLogger.debugLog("remoteMessageData transfrom problem");
145 | }
146 | }
147 | }
148 |
149 |
150 | public static void onNewToken(Context context,@NonNull String token) {
151 | String googleAppAlias;
152 | String huaweiAppAlias;
153 | try {
154 | EuroLogger.debugLog("On new token : " + token);
155 | ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
156 | if(appInfo!=null){
157 | Bundle bundle = appInfo.metaData;
158 | if(bundle!=null){
159 | googleAppAlias = bundle.getString("GoogleAppAlias", "");
160 | huaweiAppAlias = bundle.getString("HuaweiAppAlias", "");
161 | } else {
162 | googleAppAlias = SharedPreference.getString(context, Constants.GOOGLE_APP_ALIAS);
163 | huaweiAppAlias = SharedPreference.getString(context, Constants.HUAWEI_APP_ALIAS);
164 | }
165 | } else {
166 | googleAppAlias = SharedPreference.getString(context, Constants.GOOGLE_APP_ALIAS);
167 | huaweiAppAlias = SharedPreference.getString(context, Constants.HUAWEI_APP_ALIAS);
168 | }
169 | EuroMobileManager.init(googleAppAlias, huaweiAppAlias, context).subscribe(token, context);
170 |
171 | } catch (Exception e) {
172 | StackTraceElement element = new Throwable().getStackTrace()[0];
173 | LogUtils.formGraylogModel(
174 | context,
175 | "e",
176 | "Reading app alias from manifest file : " + e.getMessage(),
177 | element.getClassName() + "/" + element.getMethodName() + "/" + element.getLineNumber()
178 | );
179 | EuroLogger.debugLog(e.toString());
180 | googleAppAlias = SharedPreference.getString(context, Constants.GOOGLE_APP_ALIAS);
181 | huaweiAppAlias = SharedPreference.getString(context, Constants.HUAWEI_APP_ALIAS);
182 | EuroMobileManager.init(googleAppAlias, huaweiAppAlias, context).subscribe(token, context);
183 | }
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/model/Message.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.model;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 |
7 | import androidx.annotation.NonNull;
8 |
9 | import org.json.JSONArray;
10 | import org.json.JSONException;
11 | import org.json.JSONObject;
12 |
13 | import java.io.Serializable;
14 | import java.util.ArrayList;
15 | import java.util.HashMap;
16 | import java.util.List;
17 | import java.util.Map;
18 |
19 | import euromsg.com.euromobileandroid.enums.PushType;
20 | import euromsg.com.euromobileandroid.utils.LogUtils;
21 |
22 | public class Message implements Serializable {
23 |
24 | private String date;
25 | private String openDate;
26 | private String status;
27 | private String mediaUrl;
28 | private String altUrl;
29 | private String pushId;
30 | private String campaignId;
31 | private String url;
32 | private String from;
33 | private String message;
34 | private String title;
35 | private String sound;
36 | private String emPushSp;
37 | private String deliver;
38 | private String silent;
39 | private PushType pushType;
40 | private Integer notificationId;
41 | private String collapseKey;
42 | private Map params; // Değişiklik: Başlangıçta null bırakıldı.
43 | private ArrayList elements;
44 | private ArrayList actions;
45 | private String loginID;
46 | private String pushCategory;
47 | private String keyID;
48 | private String email;
49 |
50 | // extraData alanı kaldırıldı.
51 |
52 | public Message(Context context, @NonNull Map bundle) {
53 | try {
54 | // Değişiklik: Gelen tüm bundle verisini doğrudan params'a kopyala.
55 | this.params = new HashMap<>(bundle);
56 |
57 | // Değişiklik: Değerleri artık bundle yerine params'tan al.
58 | // Bu, kodun tutarlılığını artırır.
59 | date = params.get("date");
60 | openDate = params.get("openDate");
61 | status = params.get("status");
62 | mediaUrl = params.get("mediaUrl");
63 | pushId = params.get("pushId");
64 | url = params.get("url");
65 | altUrl = params.get("altUrl");
66 | from = params.get("from");
67 | message = params.get("message");
68 | title = params.get("title");
69 | sound = params.get("sound");
70 | if(sound == null) {
71 | sound = "";
72 | }
73 | emPushSp = params.get("emPushSp");
74 | deliver = params.get("deliver");
75 | silent = params.get("silent");
76 | campaignId = params.get("cId");
77 | if (params.get("pushType") != null) {
78 | pushType = PushType.valueOf(params.get("pushType"));
79 | } else {
80 | pushType = PushType.Text;
81 | }
82 | collapseKey = params.get("collapse_key");
83 |
84 | if (params.get("elements") != null) {
85 | convertJsonStrToElementsArray(context, params.get("elements"));
86 | }
87 | if (params.get("actions") != null) {
88 | convertJsonStrToActionsArray(context, params.get("actions"));
89 | }
90 | pushCategory = params.get("pushCategory");
91 | keyID = params.get("keyID");
92 | email = params.get("email");
93 | } catch (Exception e) {
94 | Log.e("Message", "Could not model the message!");
95 | e.printStackTrace();
96 | }
97 | }
98 |
99 | // isKnownKey metodu artık gerekli olmadığı için kaldırıldı.
100 |
101 | private void convertJsonStrToElementsArray(Context context, String elementJsonStr) {
102 | JSONArray jsonArr;
103 | try {
104 | jsonArr = new JSONArray(elementJsonStr);
105 | elements = new ArrayList<>();
106 | for (int i = 0; i < jsonArr.length(); i++) {
107 | JSONObject jsonObj = jsonArr.getJSONObject(i);
108 | Element element = new Element();
109 | element.setId(jsonObj.getString("id"));
110 | element.setTitle(jsonObj.getString("title"));
111 | element.setContent(jsonObj.getString("content"));
112 | element.setPicture(jsonObj.getString("picture"));
113 | element.setUrl(jsonObj.getString("url"));
114 | elements.add(element);
115 | }
116 | } catch (JSONException e) {
117 | StackTraceElement element = new Throwable().getStackTrace()[0];
118 | LogUtils.formGraylogModel(
119 | context,
120 | "e",
121 | "Converting JSON string to array list : " + e.getMessage(),
122 | element.getClassName() + "/" + element.getMethodName() + "/" + element.getLineNumber()
123 | );
124 | e.printStackTrace();
125 | }
126 | }
127 |
128 | private void convertJsonStrToActionsArray(Context context, String actionsJsonStr) {
129 | JSONArray jsonArr;
130 | try {
131 | jsonArr = new JSONArray(actionsJsonStr);
132 | actions = new ArrayList<>();
133 | for (int i = 0; i < jsonArr.length(); i++) {
134 | JSONObject jsonObj = jsonArr.getJSONObject(i);
135 | Actions action = new Actions();
136 | action.setAction(jsonObj.getString("action"));
137 | action.setTitle(jsonObj.getString("title"));
138 | action.setIcon(jsonObj.getString("icon"));
139 | action.setUrl(jsonObj.getString("url"));
140 | actions.add(action);
141 | }
142 | } catch (JSONException e) {
143 | StackTraceElement action = new Throwable().getStackTrace()[0];
144 | LogUtils.formGraylogModel(
145 | context,
146 | "e",
147 | "Converting JSON string to array list : " + e.getMessage(),
148 | action.getClassName() + "/" + action.getMethodName() + "/" + action.getLineNumber()
149 | );
150 | e.printStackTrace();
151 | }
152 | }
153 |
154 | public Message(@NonNull Bundle bundle) {
155 | // Bu constructor'ı da güncelleyelim, tutarlı olsun.
156 | this.params = new HashMap<>();
157 | for (String key : bundle.keySet()) {
158 | Object value = bundle.get(key);
159 | if (value != null) {
160 | params.put(key, value.toString());
161 | }
162 | }
163 | date = params.get("date");
164 | openDate = params.get("openDate");
165 | status = params.get("status");
166 | mediaUrl = params.get("mediaUrl");
167 | pushId = params.get("pushId");
168 | url = params.get("url");
169 | altUrl = params.get("altUrl");
170 | from = params.get("from");
171 | message = params.get("message");
172 | title = params.get("title");
173 | sound = params.get("sound");
174 | if(sound == null) {
175 | sound = "";
176 | }
177 | emPushSp = params.get("emPushSp");
178 | deliver = params.get("deliver");
179 | silent = params.get("silent");
180 | campaignId = params.get("cId");
181 | if (params.get("pushType") != null) {
182 | pushType = PushType.valueOf(params.get("pushType"));
183 | }
184 | collapseKey = params.get("collapse_key");
185 | elements = bundle.getParcelable("elements"); // Bundle'dan gelen parcelable özel durum
186 | pushCategory = params.get("pushCategory");
187 | keyID = params.get("keyID");
188 | email = params.get("email");
189 | }
190 |
191 | // ----- GETTER ve SETTER Metotları (Değişiklik yok) -----
192 |
193 | public void setDate(String date) { this.date = date; }
194 | public void setOpenDate(String openDate) { this.openDate = openDate; }
195 | public void setKeyID(String keyID) { this.keyID = keyID; }
196 | public void setEmail(String email) { this.email = email; }
197 | public void setStatus(String status) { this.status = status; }
198 | public Integer setNotifiactionId() { return notificationId; }
199 | public Integer getNotificationId() { return notificationId; }
200 | public String getAltUrl() { return altUrl; }
201 | public String getCampaignId() { return campaignId; }
202 | public String getDate() { return date; }
203 | public String getOpenDate() { return openDate; }
204 | public String getStatus() { return status; }
205 | public String getMediaUrl() { return mediaUrl; }
206 | public String getUrl() { return url; }
207 | public String getFrom() { return from; }
208 | public String getTitle() { return title; }
209 | public String getMessage() { return message; }
210 | public PushType getPushType() { return pushType; }
211 | public String getCollapseKey() { return collapseKey; }
212 | public void setLoginID(String loginID) { this.loginID = loginID; }
213 | public String getLoginID() { return loginID; }
214 | public String getEmPushSp() { return emPushSp; }
215 | public String getDeliver() { return deliver; }
216 | public String getSilent() { return silent; }
217 | public Map getParams() { return params; }
218 | public String getPushId() { return pushId; }
219 | public String getSound() { return sound; }
220 | public ArrayList getElements() { return elements; }
221 | public ArrayList getActions() { return actions; }
222 | public String getPushCategory() { return pushCategory; }
223 | public String getKeyID() { return keyID; }
224 | public String getEmail() { return email; }
225 |
226 | }
--------------------------------------------------------------------------------
/euromsg/src/main/res/layout/carousel_notification_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
26 |
27 |
41 |
42 |
55 |
56 |
57 |
58 |
59 |
62 |
63 |
71 |
72 |
93 |
94 |
103 |
104 |
115 |
116 |
129 |
130 |
131 |
150 |
151 |
159 |
160 |
171 |
172 |
185 |
186 |
187 |
188 |
189 |
202 |
203 |
216 |
217 |
218 |
219 |
220 |
231 |
232 |
233 |
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/model/Subscription.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.model;
2 |
3 | import android.content.Context;
4 | import android.text.TextUtils;
5 | import android.util.Log;
6 |
7 | import androidx.annotation.NonNull;
8 |
9 | import com.google.gson.Gson;
10 | import com.google.gson.annotations.SerializedName;
11 |
12 | import java.text.DateFormat;
13 | import java.text.SimpleDateFormat;
14 | import java.util.Calendar;
15 | import java.util.HashMap;
16 | import java.util.Map;
17 |
18 | import euromsg.com.euromobileandroid.Constants;
19 | import euromsg.com.euromobileandroid.utils.AppUtils;
20 | import euromsg.com.euromobileandroid.utils.LogUtils;
21 | import euromsg.com.euromobileandroid.utils.SharedPreference;
22 |
23 | public class Subscription extends BaseRequest implements Cloneable {
24 |
25 | @SerializedName("appVersion")
26 | private String appVersion;
27 |
28 | @SerializedName("appKey")
29 | private String appAlias;
30 |
31 | @SerializedName("os")
32 | private String os;
33 |
34 | @SerializedName("osVersion")
35 | private String osVersion;
36 |
37 | @SerializedName("deviceType")
38 | private String deviceType;
39 |
40 | @SerializedName("deviceName")
41 | private String deviceName;
42 |
43 | @SerializedName("carrier")
44 | private String carrier;
45 |
46 | @SerializedName("local")
47 | private String local;
48 |
49 | @SerializedName("identifierForVendor")
50 | private String identifierForVendor;
51 |
52 | @SerializedName("advertisingIdentifier")
53 | private String advertisingIdentifier;
54 |
55 | @SerializedName("sdkVersion")
56 | private String sdkVersion;
57 |
58 | @SerializedName("firstTime")
59 | private int firstTime;
60 |
61 | @SerializedName("extra")
62 | private Map extra = new HashMap<>();
63 |
64 | public void add(String key, Object value) {
65 | extra.put(key, value);
66 | }
67 |
68 | public void addAll(Map extras) {
69 | extra.putAll(extras);
70 | }
71 |
72 | public void removeAll() {
73 | this.extra.clear();
74 | }
75 |
76 | public void remove(String key) {
77 | try {
78 | if(key != null && !key.isEmpty()) {
79 | extra.remove(key);
80 | }
81 | } catch (Exception e) {
82 | Log.w("remove user property", "something went wrong!");
83 | }
84 | }
85 |
86 | public boolean isValid(Context context) {
87 | boolean res1 = !(TextUtils.isEmpty(getToken()) && TextUtils.isEmpty(appAlias));
88 | boolean res2 = true;
89 |
90 | DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
91 | String dateNow = dateFormat.format(Calendar.getInstance().getTime());
92 | String lastSubsTime = SharedPreference.getString(context, Constants.EURO_SUBSCRIPTION_DATE_KEY);
93 | if(lastSubsTime != null && !lastSubsTime.equals("")) {
94 | if(!AppUtils.isDateDifferenceGreaterThan(dateNow, lastSubsTime, 3)) {
95 | String lastSubStr = SharedPreference.getString(context, Constants.EURO_SUBSCRIPTION_NO_EMAIL_KEY);
96 | if(lastSubStr != null && !lastSubStr.isEmpty()) {
97 | try {
98 | Subscription lastSubscription = new Gson().fromJson(lastSubStr, Subscription.class);
99 | if (isEqual(lastSubscription)) {
100 | res2 = false;
101 | }
102 | } catch (Exception e) {
103 | e.printStackTrace();
104 | SharedPreference.saveString(context, Constants.EURO_SUBSCRIPTION_NO_EMAIL_KEY, "");
105 | }
106 | }
107 | }
108 | }
109 | return (res1 & res2);
110 | }
111 |
112 | public boolean isValidWithEmail(Context context) {
113 | boolean res1 = !(TextUtils.isEmpty(getToken()) && TextUtils.isEmpty(appAlias));
114 | boolean res2 = true;
115 |
116 | DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
117 | String dateNow = dateFormat.format(Calendar.getInstance().getTime());
118 | String lastSubsWithEmailTime = SharedPreference.getString(context, Constants.EURO_SUBSCRIPTION_DATE_WITH_EMAIL_KEY);
119 | if(lastSubsWithEmailTime != null && !lastSubsWithEmailTime.equals("")) {
120 | if(!AppUtils.isDateDifferenceGreaterThan(dateNow, lastSubsWithEmailTime, 3)) {
121 | String lastSubsWithEmailStr = SharedPreference.
122 | getString(context, Constants.EURO_SUBSCRIPTION_WITH_EMAIL_KEY);
123 | if(lastSubsWithEmailStr != null && !lastSubsWithEmailStr.isEmpty()) {
124 | try {
125 | Subscription lastSubscriptionWithEmail = new Gson().fromJson(lastSubsWithEmailStr,
126 | Subscription.class);
127 | if (isEqual(lastSubscriptionWithEmail)) {
128 | res2 = false;
129 | }
130 | } catch (Exception e) {
131 | e.printStackTrace();
132 | SharedPreference.saveString(context, Constants.EURO_SUBSCRIPTION_WITH_EMAIL_KEY, "");
133 | }
134 | }
135 | }
136 | }
137 | return (res1 & res2);
138 | }
139 |
140 | public boolean isEqual(Subscription previousSubscription) {
141 | boolean result;
142 | if(previousSubscription == null) {
143 | result = false;
144 | } else {
145 | result = isStringEqual(this.appVersion, previousSubscription.getAppVersion()) &&
146 | isStringEqual(this.appAlias, previousSubscription.getAppAlias()) &&
147 | isStringEqual(this.os, previousSubscription.getOs()) &&
148 | isStringEqual(this.osVersion, previousSubscription.getOsVersion()) &&
149 | isStringEqual(this.deviceType, previousSubscription.getDeviceType()) &&
150 | isStringEqual(this.deviceName, previousSubscription.getDeviceName()) &&
151 | isStringEqual(this.carrier, previousSubscription.getCarrier()) &&
152 | isStringEqual(this.local, previousSubscription.getLocal()) &&
153 | isStringEqual(this.identifierForVendor, previousSubscription.getIdentifierForVendor()) &&
154 | isStringEqual(this.advertisingIdentifier, previousSubscription.getAdvertisingIdentifier()) &&
155 | isStringEqual(this.sdkVersion, previousSubscription.getSdkVersion()) &&
156 | isStringEqual(this.getToken(), previousSubscription.getToken()) &&
157 | this.firstTime == previousSubscription.getFirstTime() &&
158 | isMapEqual(this.extra, previousSubscription.getExtra());
159 | }
160 | return result;
161 | }
162 |
163 | public void copyFrom(Subscription fromSubscription) {
164 | if(fromSubscription.getAppVersion() == null) {
165 | this.setAppVersion(null);
166 | } else {
167 | this.setAppVersion(fromSubscription.getAppVersion());
168 | }
169 | if(fromSubscription.getAppAlias() == null) {
170 | this.setAppAlias(null);
171 | } else {
172 | this.setAppAlias(fromSubscription.getAppAlias());
173 | }
174 | if(fromSubscription.getOs() == null) {
175 | this.setOs(null);
176 | } else {
177 | this.setOs(fromSubscription.getOs());
178 | }
179 | if(fromSubscription.getOsVersion() == null) {
180 | this.setOsVersion(null);
181 | } else {
182 | this.setOsVersion(fromSubscription.getOsVersion());
183 | }
184 | if(fromSubscription.getDeviceType() == null) {
185 | this.setDeviceType(null);
186 | } else {
187 | this.setDeviceType(fromSubscription.getDeviceType());
188 | }
189 | if(fromSubscription.getDeviceName() == null) {
190 | this.setDeviceName(null);
191 | } else {
192 | this.setDeviceName(fromSubscription.getDeviceName());
193 | }
194 | if(fromSubscription.getCarrier() == null) {
195 | this.setCarrier(null);
196 | } else {
197 | this.setCarrier(fromSubscription.getCarrier());
198 | }
199 | if(fromSubscription.getLocal() == null) {
200 | this.setLocal(null);
201 | } else {
202 | this.setLocal(fromSubscription.getLocal());
203 | }
204 | if(fromSubscription.getIdentifierForVendor() == null) {
205 | this.setIdentifierForVendor(null);
206 | } else {
207 | this.setIdentifierForVendor(fromSubscription.getIdentifierForVendor());
208 | }
209 | if(fromSubscription.getAdvertisingIdentifier() == null) {
210 | this.setAdvertisingIdentifier(null);
211 | } else {
212 | this.setAdvertisingIdentifier(fromSubscription.getAdvertisingIdentifier());
213 | }
214 | if(fromSubscription.getSdkVersion() == null) {
215 | this.setSdkVersion(null);
216 | } else {
217 | this.setSdkVersion(fromSubscription.getSdkVersion());
218 | }
219 | this.setFirstTime(fromSubscription.getFirstTime());
220 | if(fromSubscription.getToken() == null) {
221 | this.setToken(null);
222 | } else {
223 | this.setToken(fromSubscription.getToken());
224 | }
225 | this.extra = new HashMap<>();
226 | for(int i=0 ; i getExtra() {
237 | return extra;
238 | }
239 |
240 | public String getAppVersion() {
241 | return appVersion;
242 | }
243 |
244 | public String getAppAlias() {
245 | return appAlias;
246 | }
247 |
248 | public void setAppAlias(String appAlias) {
249 | this.appAlias = appAlias;
250 | }
251 |
252 | public String getOs() {
253 | return os;
254 | }
255 |
256 | public void setOs(String os) {
257 | this.os = os;
258 | }
259 |
260 | public String getOsVersion() {
261 | return osVersion;
262 | }
263 |
264 | public void setOsVersion(String osVersion) {
265 | this.osVersion = osVersion;
266 | }
267 |
268 | public String getDeviceType() {
269 | return deviceType;
270 | }
271 |
272 | public void setDeviceType(String deviceType) {
273 | this.deviceType = deviceType;
274 | }
275 |
276 | public String getDeviceName() {
277 | return deviceName;
278 | }
279 |
280 | public void setDeviceName(String deviceName) {
281 | this.deviceName = deviceName;
282 | }
283 |
284 | public String getCarrier() {
285 | return carrier;
286 | }
287 |
288 | public void setCarrier(String carrier) {
289 | this.carrier = carrier;
290 | }
291 |
292 | public String getLocal() {
293 | return local;
294 | }
295 |
296 | public void setLocal(String local) {
297 | this.local = local;
298 | }
299 |
300 | public String getIdentifierForVendor() {
301 | return identifierForVendor;
302 | }
303 |
304 | public void setIdentifierForVendor(String identifierForVendor) {
305 | this.identifierForVendor = identifierForVendor;
306 | }
307 |
308 | public String getAdvertisingIdentifier() {
309 | return advertisingIdentifier;
310 | }
311 |
312 | public void setAdvertisingIdentifier(String advertisingIdentifier) {
313 | this.advertisingIdentifier = advertisingIdentifier;
314 | }
315 |
316 | public String getSdkVersion() {
317 | return sdkVersion;
318 | }
319 |
320 | public void setSdkVersion(String sdkVersion) {
321 | this.sdkVersion = sdkVersion;
322 | }
323 |
324 | public int getFirstTime() {
325 | return firstTime;
326 | }
327 |
328 | public void setFirstTime(int firstTime) {
329 | this.firstTime = firstTime;
330 | }
331 |
332 | public void setExtra(Map extra) {
333 | this.extra = extra;
334 | }
335 |
336 | public void setAppVersion(String appVersion) {
337 | this.appVersion = appVersion;
338 | }
339 |
340 | public String toJson() {
341 | return new Gson().toJson(this);
342 | }
343 |
344 | private boolean isStringEqual(String first, String second) {
345 | boolean result;
346 | if(first == null || second == null) {
347 | result = first == null && second == null;
348 | } else {
349 | result = first.equals(second);
350 | }
351 | return result;
352 | }
353 |
354 | private boolean isMapEqual(Map first, Map second) {
355 | boolean result = true;
356 | if(first.size() != second.size()) {
357 | result = false;
358 | } else {
359 | for(int i=0 ; i();
391 | s.extra.putAll(this.extra);
392 |
393 | //s.extra = (Map) ((HashMap) this.extra).clone();
394 | return s;
395 | }
396 | }
--------------------------------------------------------------------------------
/euromsg/src/main/java/euromsg/com/euromobileandroid/utils/PayloadUtils.java:
--------------------------------------------------------------------------------
1 | package euromsg.com.euromobileandroid.utils;
2 |
3 | import android.content.Context;
4 | import android.os.Build;
5 | import android.util.Log;
6 |
7 | import androidx.annotation.RequiresApi;
8 |
9 | import com.google.gson.Gson;
10 |
11 | import org.json.JSONArray;
12 | import org.json.JSONException;
13 | import org.json.JSONObject;
14 |
15 | import java.text.SimpleDateFormat;
16 | import java.util.Date;
17 | import java.util.List;
18 | import java.util.Locale;
19 | import java.util.Map;
20 |
21 | import euromsg.com.euromobileandroid.Constants;
22 | import euromsg.com.euromobileandroid.EuroMobileManager;
23 | import euromsg.com.euromobileandroid.model.Message;
24 | import euromsg.com.euromobileandroid.notification.PushNotificationManager;
25 |
26 | public final class PayloadUtils {
27 | private static final String LOG_TAG = "PayloadUtils";
28 | private static final long DATE_THRESHOLD = 30;
29 |
30 | @RequiresApi(api = Build.VERSION_CODES.KITKAT)
31 | public static void addPushMessage(Context context, Message message) {
32 | String payloads = SharedPreference.getString(context, Constants.PAYLOAD_SP_KEY);
33 | if(!payloads.isEmpty()) {
34 | try {
35 | JSONObject jsonObject = new JSONObject(payloads);
36 | JSONArray jsonArray = jsonObject.getJSONArray(Constants.PAYLOAD_SP_ARRAY_KEY);
37 | if(isPushIdAvailable(context, jsonArray, message)) {
38 | return;
39 | }
40 | jsonArray = addNewOne(context, jsonArray, message);
41 | if(jsonArray == null) {
42 | return;
43 | }
44 | jsonArray = removeOldOnes(context, jsonArray);
45 | JSONObject finalObject = new JSONObject();
46 | finalObject.put(Constants.PAYLOAD_SP_ARRAY_KEY, jsonArray);
47 | SharedPreference.saveString(context, Constants.PAYLOAD_SP_KEY, finalObject.toString());
48 | } catch (Exception e) {
49 | Log.e(LOG_TAG, "Something went wrong when adding the push message to shared preferences!");
50 | Log.e(LOG_TAG, e.getMessage());
51 | }
52 | } else {
53 | createAndSaveNewOne(context, message);
54 | }
55 | }
56 |
57 | @RequiresApi(api = Build.VERSION_CODES.KITKAT)
58 | public static void addPushMessageWithId(Context context, Message message, String loginID) {
59 | String payloads = SharedPreference.getString(context, Constants.PAYLOAD_SP_ID_KEY);
60 | if(!payloads.isEmpty()) {
61 | try {
62 | JSONObject jsonObject = new JSONObject(payloads);
63 | JSONArray jsonArray = jsonObject.getJSONArray(Constants.PAYLOAD_SP_ARRAY_ID_KEY);
64 | if(isPushIdAvailable(context, jsonArray, message)) {
65 | return;
66 | }
67 | jsonArray = addNewOneWithID(context, jsonArray, message, loginID);
68 | if(jsonArray == null) {
69 | return;
70 | }
71 | jsonArray = removeOldOnes(context, jsonArray);
72 | JSONObject finalObject = new JSONObject();
73 | finalObject.put(Constants.PAYLOAD_SP_ARRAY_ID_KEY, jsonArray);
74 | SharedPreference.saveString(context, Constants.PAYLOAD_SP_ID_KEY, finalObject.toString());
75 | } catch (Exception e) {
76 | Log.e(LOG_TAG, "Something went wrong when adding the push message to shared preferences!");
77 | Log.e(LOG_TAG, e.getMessage());
78 | }
79 | } else {
80 | createAndSaveNewOneWithID(context, message, loginID);
81 | }
82 | }
83 |
84 | public static List orderPushMessages(Context context, List messages) {
85 | for (int i = 0; i < messages.size(); i++) {
86 | for (int j = 0; j < messages.size() - 1 - i; j++) {
87 | if(compareDates(context, messages.get(j).getDate(), messages.get(j+1).getDate())) {
88 | Message temp = messages.get(j);
89 | messages.set(j, messages.get(j+1));
90 | messages.set(j+1, temp);
91 | }
92 | }
93 | }
94 | return messages;
95 | }
96 |
97 | private static boolean isPushIdAvailable(Context context, JSONArray jsonArray, Message message) {
98 | boolean res = false;
99 | for(int i = 0 ; i < jsonArray.length() ; i++) {
100 | try {
101 | if (jsonArray.getJSONObject(i).getString("pushId").equals(message.getPushId())){
102 | res = true;
103 | break;
104 | }
105 | } catch (Exception e) {
106 | Log.e(LOG_TAG, e.getMessage());
107 | }
108 | }
109 | return res;
110 | }
111 |
112 | private static JSONArray addNewOne(Context context, JSONArray jsonArray, Message message){
113 | try {
114 | message.setDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(new Date()));
115 | message.setStatus("D");
116 | message.setOpenDate("");
117 | Map userExVid = EuroMobileManager.getInstance().subscription.getExtra();
118 | if (userExVid.containsKey(Constants.EURO_USER_KEY) && userExVid.get(Constants.EURO_USER_KEY) != null) {
119 | Object keyID = userExVid.get(Constants.EURO_USER_KEY);
120 | if(keyID instanceof String) {
121 | message.setKeyID(keyID.toString());
122 | }
123 | }
124 | if (userExVid.containsKey(Constants.EURO_EMAIL_KEY) && userExVid.get(Constants.EURO_EMAIL_KEY) != null) {
125 | Object email = userExVid.get(Constants.EURO_EMAIL_KEY);
126 | if(email instanceof String) {
127 | message.setEmail(email.toString());
128 | }
129 | }
130 | jsonArray.put(new JSONObject(new Gson().toJson(message)));
131 | return jsonArray;
132 | } catch (Exception e) {
133 | Log.e(LOG_TAG, "Could not save the push message!");
134 | Log.e(LOG_TAG, e.getMessage());
135 | return null;
136 | }
137 | }
138 |
139 | private static JSONArray addNewOneWithID(Context context, JSONArray jsonArray, Message message,
140 | String loginID){
141 | try {
142 | message.setLoginID(loginID);
143 | message.setDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(new Date()));
144 | message.setStatus("D");
145 | message.setOpenDate("");
146 | Map userExVid = EuroMobileManager.getInstance().subscription.getExtra();
147 | if (userExVid.containsKey(Constants.EURO_USER_KEY) && userExVid.get(Constants.EURO_USER_KEY) != null) {
148 | Object keyID = userExVid.get(Constants.EURO_USER_KEY);
149 | if(keyID instanceof String) {
150 | message.setKeyID(keyID.toString());
151 | }
152 | }
153 | if (userExVid.containsKey(Constants.EURO_EMAIL_KEY) && userExVid.get(Constants.EURO_EMAIL_KEY) != null) {
154 | Object email = userExVid.get(Constants.EURO_EMAIL_KEY);
155 | if(email instanceof String) {
156 | message.setEmail(email.toString());
157 | }
158 | }
159 | jsonArray.put(new JSONObject(new Gson().toJson(message)));
160 | return jsonArray;
161 | } catch (Exception e) {
162 | Log.e(LOG_TAG, "Could not save the push message!");
163 | Log.e(LOG_TAG, e.getMessage());
164 | return null;
165 | }
166 | }
167 |
168 | @RequiresApi(api = Build.VERSION_CODES.KITKAT)
169 | private static JSONArray removeOldOnes(Context context, JSONArray jsonArray) {
170 | for(int i = 0 ; i < jsonArray.length() ; i++) {
171 | try {
172 | if (isOld(context, jsonArray.getJSONObject(i).getString("date"))){
173 | jsonArray.remove(i);
174 | i--;
175 | }
176 | } catch (Exception e) {
177 | Log.e(LOG_TAG, e.getMessage());
178 | }
179 | }
180 | return jsonArray;
181 | }
182 |
183 | private static boolean isOld(Context context, String date) {
184 | boolean res = false;
185 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
186 | try {
187 | Date messageDate = dateFormat.parse(date);
188 | Date now = new Date();
189 | long difference = now.getTime() - messageDate.getTime();
190 | if( (difference / (1000*60*60*24)) > DATE_THRESHOLD) { //30 days
191 | res = true;
192 | }
193 | } catch (Exception e) {
194 | Log.e(LOG_TAG, "Could not parse date!");
195 | Log.e(LOG_TAG, e.getMessage());
196 | }
197 | return res;
198 | }
199 |
200 | private static void createAndSaveNewOne(Context context, Message message) {
201 | try {
202 | JSONObject jsonObject = new JSONObject();
203 | JSONArray jsonArray = new JSONArray();
204 | message.setDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(new Date()));
205 | message.setStatus("D");
206 | message.setOpenDate("");
207 | Map userExVid = EuroMobileManager.getInstance().subscription.getExtra();
208 | if (userExVid.containsKey(Constants.EURO_USER_KEY) && userExVid.get(Constants.EURO_USER_KEY) != null) {
209 | Object keyID = userExVid.get(Constants.EURO_USER_KEY);
210 | if(keyID instanceof String) {
211 | message.setKeyID(keyID.toString());
212 | }
213 | }
214 | if (userExVid.containsKey(Constants.EURO_EMAIL_KEY) && userExVid.get(Constants.EURO_EMAIL_KEY) != null) {
215 | Object email = userExVid.get(Constants.EURO_EMAIL_KEY);
216 | if(email instanceof String) {
217 | message.setEmail(email.toString());
218 | }
219 | }
220 | jsonArray.put(new JSONObject(new Gson().toJson(message)));
221 | jsonObject.put(Constants.PAYLOAD_SP_ARRAY_KEY, jsonArray);
222 | SharedPreference.saveString(context, Constants.PAYLOAD_SP_KEY, jsonObject.toString());
223 | } catch (Exception e) {
224 | Log.e(LOG_TAG, "Could not save the push message!");
225 | Log.e(LOG_TAG, e.getMessage());
226 | }
227 | }
228 |
229 | private static void createAndSaveNewOneWithID(Context context, Message message, String loginID) {
230 | try {
231 | JSONObject jsonObject = new JSONObject();
232 | JSONArray jsonArray = new JSONArray();
233 | message.setLoginID(loginID);
234 | message.setDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(new Date()));
235 | message.setStatus("D");
236 | message.setOpenDate("");
237 | Map userExVid = EuroMobileManager.getInstance().subscription.getExtra();
238 | if (userExVid.containsKey(Constants.EURO_USER_KEY) && userExVid.get(Constants.EURO_USER_KEY) != null) {
239 | Object keyID = userExVid.get(Constants.EURO_USER_KEY);
240 | if(keyID instanceof String) {
241 | message.setKeyID(keyID.toString());
242 | }
243 | }
244 | if (userExVid.containsKey(Constants.EURO_EMAIL_KEY) && userExVid.get(Constants.EURO_EMAIL_KEY) != null) {
245 | Object email = userExVid.get(Constants.EURO_EMAIL_KEY);
246 | if(email instanceof String) {
247 | message.setEmail(email.toString());
248 | }
249 | }
250 | jsonArray.put(new JSONObject(new Gson().toJson(message)));
251 | jsonObject.put(Constants.PAYLOAD_SP_ARRAY_ID_KEY, jsonArray);
252 | SharedPreference.saveString(context, Constants.PAYLOAD_SP_ID_KEY, jsonObject.toString());
253 | } catch (Exception e) {
254 | Log.e(LOG_TAG, "Could not save the push message!");
255 | Log.e(LOG_TAG, e.getMessage());
256 | }
257 | }
258 |
259 | public static void updatePayload(Context context, String pushId) {
260 | try {
261 | String jsonString = SharedPreference.getString(context, Constants.PAYLOAD_SP_KEY);
262 | JSONObject jsonObject = new JSONObject(jsonString);
263 |
264 | JSONArray payloadsArray = jsonObject.optJSONArray(Constants.PAYLOAD_SP_ARRAY_KEY);
265 |
266 | if (payloadsArray != null) {
267 | for (int i = 0; i < payloadsArray.length(); i++) {
268 | JSONObject payloadObject = payloadsArray.getJSONObject(i);
269 | String existingPushId = payloadObject.optString("pushId", "");
270 |
271 | if (existingPushId.equals(pushId)) {
272 | // Güncelleme işlemlerini yap
273 | payloadObject.put("status", "O");
274 | payloadObject.put("openDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(new Date()));
275 |
276 | // Güncellenmiş JSON'ı kaydet
277 | SharedPreference.saveString(context, Constants.PAYLOAD_SP_KEY, jsonObject.toString());
278 | return; // Güncelleme işlemi tamamlandı, fonksiyondan çık
279 | }
280 | }
281 |
282 | // Eğer bu noktaya gelinirse, belirtilen pushId ile bir payload bulunamamıştır.
283 | Log.e(LOG_TAG, "Payload with pushId " + pushId + " not found!");
284 | } else {
285 | Log.e(LOG_TAG, "Payload array is null or empty!");
286 | }
287 | } catch (JSONException e) {
288 | Log.e(LOG_TAG, "Could not update the push message!");
289 | Log.e(LOG_TAG, e.getMessage());
290 | }
291 | }
292 |
293 | public static void updatePayloadWithId(Context context, String pushId, Integer notificationId) {
294 | try {
295 | String jsonString = SharedPreference.getString(context, Constants.PAYLOAD_SP_KEY);
296 | JSONObject jsonObject = new JSONObject(jsonString);
297 |
298 | JSONArray payloadsArray = jsonObject.optJSONArray(Constants.PAYLOAD_SP_ARRAY_KEY);
299 |
300 | if (payloadsArray != null) {
301 | for (int i = 0; i < payloadsArray.length(); i++) {
302 | JSONObject payloadObject = payloadsArray.getJSONObject(i);
303 | String existingPushId = payloadObject.optString("pushId", "");
304 |
305 | if (existingPushId.equals(pushId)) {
306 | payloadObject.put("notificationId", notificationId);
307 |
308 |
309 | SharedPreference.saveString(context, Constants.PAYLOAD_SP_KEY, jsonObject.toString());
310 | return;
311 | }
312 | }
313 |
314 |
315 | Log.e(LOG_TAG, "Payload with pushId " + pushId + " not found!");
316 | } else {
317 | Log.e(LOG_TAG, "Payload array is null or empty!");
318 | }
319 | } catch (JSONException e) {
320 | Log.e(LOG_TAG, "Could not update the push message!");
321 | Log.e(LOG_TAG, e.getMessage());
322 | }
323 | }
324 |
325 |
326 |
327 | private static boolean compareDates(Context context, String str1, String str2) {
328 | boolean res = false;
329 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
330 | try {
331 | Date date1 = dateFormat.parse(str1);
332 | Date date2 = dateFormat.parse(str2);
333 | if((date1.getTime()-date2.getTime()) < 0) {
334 | res = true;
335 | }
336 | } catch (Exception e) {
337 | Log.e(LOG_TAG, "Could not parse date!");
338 | Log.e(LOG_TAG, e.getMessage());
339 | }
340 | return res;
341 | }
342 | }
343 |
--------------------------------------------------------------------------------