Skip to content

Commit

Permalink
RMET-2824 OneSignal-Android-SDK - Remove android support library and …
Browse files Browse the repository at this point in the history
…migrate to AndroidX (#20)

* feat: replace android's Support Library with AndroidX

Context: MABS 10 builds won't work if there are dependencies to the Support Library, so we must migrate.

References: https://outsystemsrd.atlassian.net/browse/RMET-2824

* misc: raise version and comment lines to generate new .aar

* fix: enableJetifier

Context: So that the Android plugin automatically migrate existing third-party libraries to use AndroidX dependencies. More info: https://developer.android.com/jetpack/androidx#using_androidx_libraries_in_your_project

References: https://outsystemsrd.atlassian.net/browse/RMET-2824

* misc: raise version to test

* chore: raise version to 3.15.5.-OS4

References: https://outsystemsrd.atlassian.net/browse/RMET-2824

* refactor: remove extra line

References: https://outsystemsrd.atlassian.net/browse/RMET-2824

* misc: uncomment previously commented lines

* refactor: fix spacing

References: https://outsystemsrd.atlassian.net/browse/RMET-2824

* refactor: remove extra lines

References: https://outsystemsrd.atlassian.net/browse/RMET-2824
  • Loading branch information
alexgerardojacinto authored Sep 19, 2023
1 parent 60ba816 commit df0e12e
Show file tree
Hide file tree
Showing 123 changed files with 234 additions and 271 deletions.
18 changes: 7 additions & 11 deletions OneSignalSDK/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ apply plugin: 'com.android.application'
//apply plugin: com.onesignal.androidsdk.GradleProjectPlugin

android {
compileSdkVersion 28
compileSdkVersion 31
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.onesignal.example"
manifestPlaceholders = [onesignal_app_id: "b2f7f966-d8cc-11e4-bed1-df8f05be55ba",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "REMOTE"]
minSdkVersion 17
targetSdkVersion 28
minSdkVersion 26
targetSdkVersion 31
versionCode 1
versionName "1.0"
}

lintOptions {
abortOnError false
checkReleaseBuilds false
}

buildTypes {
Expand All @@ -39,12 +40,11 @@ android {
}

repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'

// Use for SDK Development
implementation(project(':onesignal')) {
Expand All @@ -56,6 +56,8 @@ dependencies {
// exclude group: 'com.google.firebase', module: 'firebase-messaging'
}

implementation 'androidx.annotation:annotation-jvm:1.7.0'

// Use snapshot
// compile 'com.onesignal:OneSignal:4.0.0-SNAPSHOT'
// compile 'com.onesignal:OneSignal:4.0.0-20171206.043726-5'
Expand All @@ -69,10 +71,4 @@ dependencies {
// Old Instructions - Use for released SDK
// compile 'com.onesignal:OneSignal:3.+@aar'

implementation 'com.google.android.gms:play-services-location:16.0.0'

// For Chrome tabs
implementation 'com.android.support:customtabs:28.0.0'
}

//apply plugin: 'com.google.gms.google-services'
21 changes: 0 additions & 21 deletions OneSignalSDK/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,3 @@
public static <fields>;
}

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**

# Understand the @Keep support annotation.
-keep class android.support.annotation.Keep

-keep @android.support.annotation.Keep class * {*;}

-keepclasseswithmembers class * {
@android.support.annotation.Keep <methods>;
}

-keepclasseswithmembers class * {
@android.support.annotation.Keep <fields>;
}

-keepclasseswithmembers class * {
@android.support.annotation.Keep <init>(...);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.onesignal.example;

import android.support.v4.app.NotificationCompat;
import androidx.core.app.NotificationCompat;

import com.onesignal.OSNotificationPayload;
import com.onesignal.NotificationExtenderService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.os.StrictMode;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.onesignal.OSNotification;
import com.onesignal.OSNotificationOpenResult;
import com.onesignal.OneSignal;
Expand Down
13 changes: 2 additions & 11 deletions OneSignalSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,9 @@ buildscript {
maven { url 'http://developer.huawei.com/repo/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'

classpath 'com.google.gms:google-services:4.3.2'
classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.huawei.agconnect:agcp:1.2.1.301'

// com.huawei.agconnect Gradle Plugin

// OneSignal-Gradle-Plugin - Local testing
// classpath 'com.onesignal:onesignal-gradle-plugin:[0.8.1, 0.99.99]'

// OneSignal-Gradle-Plugin - Public version
// classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.8.1, 0.99.99]'
}
}

Expand Down
9 changes: 3 additions & 6 deletions OneSignalSDK/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ android.databinding.incremental = false
kapt.incremental.apt = false
android.testConfig.useRelativePath = false

# Disables R8 for Android Library modules only
android.enableR8.libraries = false
# Disables R8 for all modules.
android.enableR8 = true
# Enables D8 for all modules.
android.enableD8 = true

# Android X settings
android.enableJetifier = false
android.useAndroidX = false
android.enableJetifier = true
android.useAndroidX = true
2 changes: 1 addition & 1 deletion OneSignalSDK/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
39 changes: 20 additions & 19 deletions OneSignalSDK/onesignal/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
compileSdkVersion 31
defaultConfig {
// Normally we shouldn't need to redefine manifestPlaceholders for our onesignal project
// but Android Studio gets a sync error if these are not here.
Expand All @@ -10,7 +10,8 @@ android {
manifestPlaceholders = [onesignal_app_id: '${onesignal_app_id}',
// Project number pulled from dashboard, local value is ignored
onesignal_google_project_number: '${onesignal_google_project_number}']
minSdkVersion 15
minSdkVersion 26
targetSdkVersion 31
consumerProguardFiles 'consumer-proguard-rules.pro'
}

Expand Down Expand Up @@ -44,37 +45,37 @@ dependencies {
compileOnly 'com.google.android.gms:play-services-gcm:16.1.0'

// play-services-location:16.0.0 is the last version before going to AndroidX
// Can be compileOnly in 4.0.0, can't change until then as some projects may rely on this
implementation 'com.google.android.gms:play-services-location:[10.2.1, 16.0.99]'
// play-services-location:17.0.0 is the first version using AndroidX
compileOnly 'com.google.android.gms:play-services-location:[17.0.0, 17.99.99]'

// play-services-ads-identifier:15.0.0 first version
// Classes used to live in play-services-base before this
// play-services-ads-identifier:16.0.0 is the last version before going to AndroidX
implementation 'com.google.android.gms:play-services-ads-identifier:[15.0.0, 16.0.99]'
// play-services-ads-identifier:17.0.0 is the first version using AndroidX
// Classes used to live in play-services-base before this
implementation 'com.google.android.gms:play-services-ads-identifier:[17.0.0, 17.99.99]'

// :play-services-base:16.1.0 is the last version before going to AndroidX
// play-services-base:16.1.0 is the last version before going to AndroidX
// play-services-base:17.0.0 is the first version using AndroidX
// Required for GoogleApiAvailability
implementation 'com.google.android.gms:play-services-base:[10.2.1, 16.1.99]'
implementation 'com.google.android.gms:play-services-base:[17.0.0, 17.99.99]'

// firebase-messaging:18.0.0 is the last version before going to AndroidX
// firebase-messaging:17.6.0 is the max version since we still have code looking for FirebaseInstanceIdService
api 'com.google.firebase:firebase-messaging:[10.2.1, 17.3.99]'
api 'com.google.firebase:firebase-messaging:17.6.0'

// Huawei PushKit
// KEEP as "compileOnly", so OneSignal isn't a direct dependency in the POM file.
compileOnly 'com.huawei.hms:push:4.0.3.301'
compileOnly 'com.huawei.hms:location:4.0.0.300'

// Keep under 28 until we switch to AndroidX
// otherwise app can get dup classes between 26 & 28 when mixing these versions.
// Also note, firebase & gms libraries use android.support:26.
// - They never refer to 27 or 28
api 'com.android.support:cardview-v7:[26.0.0, 27.99.99]'
api 'com.android.support:support-fragment:[26.0.0, 27.99.99]'
api 'com.android.support:customtabs:[26.0.0, 27.99.99]'
api 'androidx.cardview:cardview:[1.0.0, 1.99.99]'
api 'androidx.legacy:legacy-support-v4:[1.0.0, 1.99.99]'
api 'androidx.browser:browser:[1.0.0, 1.99.99]'
api 'androidx.appcompat:appcompat:[1.0.0, 1.99.99]'

// compileOnly as this is just for fallback code if AppCompatActivity wasn't added to the project.
compileOnly 'com.android.support:appcompat-v7:26.1.0'
implementation 'androidx.annotation:annotation-jvm:1.7.0'

implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.22"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22"
}

apply from: 'maven-push.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import android.view.ViewTreeObserver;

import java.lang.ref.WeakReference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import android.content.ComponentCallbacks;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

class ActivityLifecycleListener implements Application.ActivityLifecycleCallbacks {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import androidx.annotation.NonNull;
import android.util.Log;

// Designed as a compat for use of Android Support v4 revision 23.+ methods when an older revision of the library is included with the app developer's project.
Expand Down Expand Up @@ -84,7 +83,7 @@ static void requestPermissions(Activity activity, String[] permissions, int requ
}

static boolean shouldShowRequestPermissionRationale(Activity activity, String permission) {
return android.support.v4.app.ActivityCompat.shouldShowRequestPermissionRationale(activity, permission);
return androidx.core.app.ActivityCompat.shouldShowRequestPermissionRationale(activity, permission);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import android.os.Build;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;
import android.support.annotation.RequiresApi;
import androidx.annotation.RequiresApi;

import com.onesignal.OneSignalDbContract.NotificationTable;
import com.onesignal.shortcutbadger.ShortcutBadgeException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import android.os.Bundle;
import android.os.Parcelable;
import android.os.PersistableBundle;
import android.support.annotation.RequiresApi;
import androidx.annotation.RequiresApi;

public interface BundleCompat<T> {
void putString(String key, String value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import android.content.Context;
import android.content.res.Resources;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ViewDragHelper;
import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import androidx.customview.widget.ViewDragHelper;
import android.view.MotionEvent;
import android.view.View;
import android.widget.RelativeLayout;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.onesignal;

import android.os.SystemClock;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.WorkerThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;

import com.onesignal.influence.model.OSInfluence;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import android.location.Location;
import android.os.Bundle;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v4.content.WakefulBroadcastReceiver;
import androidx.annotation.Nullable;
import androidx.legacy.content.WakefulBroadcastReceiver;

import com.onesignal.NotificationBundleProcessor.ProcessedBundleResult;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;

// Uses modified JobIntentService class that's part of the onesignal package

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
import android.net.Uri;
import android.os.Build;
import android.service.notification.StatusBarNotification;
import android.support.annotation.RequiresApi;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import android.text.SpannableString;
import android.text.style.StyleSpan;
import android.widget.RemoteViews;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.widget.PopupWindowCompat;
import android.support.v7.widget.CardView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.widget.PopupWindowCompat;
import androidx.cardview.widget.CardView;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.onesignal;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.json.JSONArray;
import org.json.JSONException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
import android.os.Build;
import android.os.IBinder;
import android.os.PowerManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import android.util.Log;

import java.util.ArrayList;
Expand Down
Loading

0 comments on commit df0e12e

Please sign in to comment.