Skip to content

Commit 926996e

Browse files
committed
Revert "improvement: Offloaded work on background threads. (#2394)"
This reverts commit 6fa661d.
1 parent ff59cfc commit 926996e

File tree

96 files changed

+1217
-6585
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1217
-6585
lines changed

Examples/OneSignalDemo/app/build.gradle

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
id 'com.android.application'
3-
id 'kotlin-android'
43
}
54

65
android {
@@ -49,18 +48,6 @@ android {
4948
// signingConfig null
5049
// productFlavors.huawei.signingConfig signingConfigs.huawei
5150
debuggable true
52-
// Note: profileable is automatically enabled when debuggable=true
53-
// Enable method tracing for detailed performance analysis
54-
testCoverageEnabled false
55-
}
56-
// Profileable release build for performance testing
57-
profileable {
58-
initWith release
59-
debuggable false
60-
profileable true
61-
minifyEnabled false
62-
signingConfig signingConfigs.debug
63-
matchingFallbacks = ['release']
6451
}
6552
}
6653

@@ -91,7 +78,6 @@ android {
9178

9279
dependencies {
9380
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
94-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
9581
implementation 'androidx.multidex:multidex:2.0.1'
9682
implementation 'androidx.cardview:cardview:1.0.0'
9783
implementation 'androidx.appcompat:appcompat:1.5.1'

Examples/OneSignalDemo/app/src/huawei/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package="com.onesignal.sdktest">
66

77
<application
8-
android:name=".application.MainApplicationKT">
8+
android:name=".application.MainApplication">
99

1010
<service
1111
android:name="com.onesignal.sdktest.notification.HmsMessageServiceAppLevel"

Examples/OneSignalDemo/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<uses-permission android:name="android.permission.WAKE_LOCK" />
2121

2222
<application
23-
android:name=".application.MainApplicationKT"
23+
android:name=".application.MainApplication"
2424
android:allowBackup="true"
2525
android:icon="@mipmap/ic_onesignal_launcher"
2626
android:label="@string/app_name"

Examples/OneSignalDemo/app/src/main/java/com/onesignal/sdktest/application/MainApplication.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,18 @@
3333
import java.util.concurrent.ExecutorService;
3434
import java.util.concurrent.Executors;
3535

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

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

5044
@SuppressLint("NewApi")
5145
@Override
5246
public void onCreate() {
5347
super.onCreate();
54-
Log.w(Tag.LOG_TAG, "DEPRECATED: Using MainApplication (Java). Please migrate to MainApplicationKT (Kotlin) for better async support.");
55-
5648
OneSignal.getDebug().setLogLevel(LogLevel.DEBUG);
5749

5850
// OneSignal Initialization

Examples/OneSignalDemo/app/src/main/java/com/onesignal/sdktest/application/MainApplicationKT.kt

Lines changed: 0 additions & 158 deletions
This file was deleted.

Examples/OneSignalDemo/app/src/main/java/com/onesignal/sdktest/model/MainActivityViewModel.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.onesignal.sdktest.model;
22

3-
import android.annotation.SuppressLint;
43
import android.app.Activity;
54
import android.content.Context;
65
import com.google.android.material.appbar.AppBarLayout;
@@ -55,9 +54,6 @@
5554
import java.util.ArrayList;
5655
import java.util.HashMap;
5756
import java.util.Map;
58-
import java.util.concurrent.CompletableFuture;
59-
import java.util.concurrent.ExecutorService;
60-
import java.util.concurrent.Executors;
6157

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

796792
private void setupSubscriptionSwitch() {
797793
refreshSubscriptionState();
794+
795+
pushSubscriptionEnabledRelativeLayout.setOnClickListener(v -> {
796+
boolean isSubscriptionEnabled = !pushSubscriptionEnabledSwitch.isChecked();
797+
pushSubscriptionEnabledSwitch.setChecked(isSubscriptionEnabled);
798+
});
799+
798800
// Add a listener to toggle the push notification enablement for the push subscription.
799801
pushSubscriptionEnabledSwitch.setOnClickListener(v -> {
800802
IPushSubscription subscription = OneSignal.getUser().getPushSubscription();
@@ -809,12 +811,7 @@ private void setupSubscriptionSwitch() {
809811

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

Examples/OneSignalDemo/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ buildscript {
1313
}
1414
dependencies {
1515
classpath 'com.android.tools.build:gradle:8.8.2'
16-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1716
classpath 'com.google.gms:google-services:4.3.10'
1817
classpath 'com.huawei.agconnect:agcp:1.9.1.304'
1918

Examples/OneSignalDemo/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ android.enableJetifier=false
1717

1818
# This is the name of the SDK to use when building your project.
1919
# This will be fed from the GitHub Actions workflow.
20-
SDK_VERSION=5.4.0-alpha-03
20+
SDK_VERSION=5.1.38

OneSignalSDK/build.gradle

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@ buildscript {
1515
huaweiHMSPushVersion = '6.3.0.304'
1616
huaweiHMSLocationVersion = '4.0.0.300'
1717
kotlinVersion = '1.9.25'
18-
coroutinesVersion = '1.7.3'
1918
kotestVersion = '5.8.0'
20-
ioMockVersion = '1.13.2'
21-
// AndroidX Lifecycle and Activity versions
22-
lifecycleVersion = '2.6.2'
23-
activityVersion = '1.7.2'
24-
ktlintVersion = '0.50.0' // Used by Spotless for Kotlin formatting (compatible with Kotlin 1.7.10)
19+
ktlintVersion = '1.0.1' // Used by Spotless for Kotlin formatting
2520
spotlessVersion = '6.25.0'
2621
tdunningJsonForTest = '1.0' // DO NOT upgrade for tests, using an old version so it matches AOSP
2722

@@ -61,24 +56,6 @@ allprojects {
6156
// Huawei maven
6257
maven { url 'https://developer.huawei.com/repo/' }
6358
}
64-
65-
// Force all modules to use the same Kotlin version
66-
configurations.all {
67-
resolutionStrategy {
68-
force "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
69-
force "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion"
70-
71-
// Exclude deprecated jdk7/jdk8 variants
72-
eachDependency { details ->
73-
if (details.requested.group == 'org.jetbrains.kotlin') {
74-
if (details.requested.name == 'kotlin-stdlib-jdk7' ||
75-
details.requested.name == 'kotlin-stdlib-jdk8') {
76-
details.useTarget "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
77-
}
78-
}
79-
}
80-
}
81-
}
8259
}
8360

8461
// Aggregate Detekt tasks at the root so CI can call them once

OneSignalSDK/gradle.properties

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@
2323
# Remove when creating an .aar build.
2424
#android.enableAapt2=false
2525

26-
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError
27-
28-
# Gradle daemon optimization
29-
org.gradle.daemon=true
30-
org.gradle.parallel=true
31-
org.gradle.caching=true
32-
org.gradle.configureondemand=true
26+
org.gradle.jvmargs=-Xmx1536m
3327

3428
# Enables D8 for all modules.
3529
android.enableD8 = true
@@ -39,4 +33,4 @@ android.useAndroidX = true
3933

4034
# This is the name of the SDK to use when building your project.
4135
# This will be fed from the GitHub Actions workflow.
42-
SDK_VERSION=5.4.0-alpha-03
36+
SDK_VERSION=5.1.38

0 commit comments

Comments
 (0)