Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions Examples/OneSignalDemo/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
}

android {
Expand Down Expand Up @@ -49,23 +48,7 @@ android {
// signingConfig null
// productFlavors.huawei.signingConfig signingConfigs.huawei
debuggable true
// Note: profileable is automatically enabled when debuggable=true
// Enable method tracing for detailed performance analysis
testCoverageEnabled false
}
// Profileable release build for performance testing
profileable {
initWith release
debuggable false
profileable true
minifyEnabled false
signingConfig signingConfigs.debug
matchingFallbacks = ['release']
}
}

kotlinOptions {
jvmTarget = '1.8'
}

// Forced downgrade to Java 1.8 for compiling the application due to Android N error when building
Expand All @@ -91,7 +74,6 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
Expand Down
2 changes: 1 addition & 1 deletion Examples/OneSignalDemo/app/src/huawei/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package="com.onesignal.sdktest">

<application
android:name=".application.MainApplicationKT">
android:name=".application.MainApplication">

<service
android:name="com.onesignal.sdktest.notification.HmsMessageServiceAppLevel"
Expand Down
2 changes: 1 addition & 1 deletion Examples/OneSignalDemo/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />

<application
android:name=".application.MainApplicationKT"
android:name=".application.MainApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_onesignal_launcher"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,18 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
* This Java implementation is not used any more. Use {@link MainApplicationKT} instead.
* The Kotlin version provides better async handling and modern coroutines support.
*
*/
public class MainApplication extends MultiDexApplication {
private static final int SLEEP_TIME_TO_MIMIC_ASYNC_OPERATION = 2000;

public MainApplication() {
// run strict mode to surface any potential issues easier
StrictMode.enableDefaults();
Log.w(Tag.LOG_TAG, "MainApplication (Java) is deprecated. Please use MainApplicationKT (Kotlin) instead.");
}

@SuppressLint("NewApi")
@Override
public void onCreate() {
super.onCreate();
Log.w(Tag.LOG_TAG, "DEPRECATED: Using MainApplication (Java). Please migrate to MainApplicationKT (Kotlin) for better async support.");

OneSignal.getDebug().setLogLevel(LogLevel.DEBUG);

// OneSignal Initialization
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.onesignal.sdktest.model;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import com.google.android.material.appbar.AppBarLayout;
Expand Down Expand Up @@ -55,9 +54,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@RequiresApi(api = Build.VERSION_CODES.N)
public class MainActivityViewModel implements ActivityViewModel, IPushSubscriptionObserver {
Expand Down Expand Up @@ -795,6 +791,12 @@ private void setupPushNotificationLayout() {

private void setupSubscriptionSwitch() {
refreshSubscriptionState();

pushSubscriptionEnabledRelativeLayout.setOnClickListener(v -> {
boolean isSubscriptionEnabled = !pushSubscriptionEnabledSwitch.isChecked();
pushSubscriptionEnabledSwitch.setChecked(isSubscriptionEnabled);
});

// Add a listener to toggle the push notification enablement for the push subscription.
pushSubscriptionEnabledSwitch.setOnClickListener(v -> {
IPushSubscription subscription = OneSignal.getUser().getPushSubscription();
Expand All @@ -809,12 +811,7 @@ private void setupSubscriptionSwitch() {

private void setupPromptPushButton() {
promptPushButton.setOnClickListener(v -> {
ExecutorService executor = Executors.newSingleThreadExecutor();
@SuppressLint({"NewApi", "LocalSuppress"}) CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
OneSignal.getNotifications().requestPermission(true, Continue.none());
}, executor);
future.join(); // Waits for the task to complete
executor.shutdown();
OneSignal.getUser().getPushSubscription().optIn();
});
}

Expand Down
1 change: 0 additions & 1 deletion Examples/OneSignalDemo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:8.8.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.huawei.agconnect:agcp:1.9.1.304'

Expand Down
2 changes: 1 addition & 1 deletion Examples/OneSignalDemo/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ android.enableJetifier=false

# This is the name of the SDK to use when building your project.
# This will be fed from the GitHub Actions workflow.
SDK_VERSION=5.4.0
SDK_VERSION=5.1.38
26 changes: 2 additions & 24 deletions OneSignalSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@ buildscript {
huaweiAgconnectVersion = '1.9.1.304'
huaweiHMSPushVersion = '6.3.0.304'
huaweiHMSLocationVersion = '4.0.0.300'
kotlinVersion = '1.9.25'
coroutinesVersion = '1.7.3'
kotlinVersion = '1.7.10'
kotestVersion = '5.8.0'
ioMockVersion = '1.13.2'
// AndroidX Lifecycle and Activity versions
lifecycleVersion = '2.6.2'
activityVersion = '1.7.2'
ktlintVersion = '0.50.0' // Used by Spotless for Kotlin formatting (compatible with Kotlin 1.7.10)
ktlintVersion = '1.0.1' // Used by Spotless for Kotlin formatting
spotlessVersion = '6.25.0'
tdunningJsonForTest = '1.0' // DO NOT upgrade for tests, using an old version so it matches AOSP

Expand Down Expand Up @@ -61,24 +57,6 @@ allprojects {
// Huawei maven
maven { url 'https://developer.huawei.com/repo/' }
}

// Force all modules to use the same Kotlin version
configurations.all {
resolutionStrategy {
force "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
force "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion"

// Exclude deprecated jdk7/jdk8 variants
eachDependency { details ->
if (details.requested.group == 'org.jetbrains.kotlin') {
if (details.requested.name == 'kotlin-stdlib-jdk7' ||
details.requested.name == 'kotlin-stdlib-jdk8') {
details.useTarget "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
}
}
}
}
}
}

// Aggregate Detekt tasks at the root so CI can call them once
Expand Down
10 changes: 2 additions & 8 deletions OneSignalSDK/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@
# Remove when creating an .aar build.
#android.enableAapt2=false

org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError

# Gradle daemon optimization
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx1536m

# Enables D8 for all modules.
android.enableD8 = true
Expand All @@ -39,4 +33,4 @@ android.useAndroidX = true

# This is the name of the SDK to use when building your project.
# This will be fed from the GitHub Actions workflow.
SDK_VERSION=5.4.0
SDK_VERSION=5.1.38
Loading
Loading