Skip to content

Commit

Permalink
Merge pull request #15 from OutSystems/feat/RMET-316/update-android-11
Browse files Browse the repository at this point in the history
RMET-316 - Update Onesignal Android SDK to the last version released 3.15.5
  • Loading branch information
CarlsCorrea authored Nov 30, 2020
2 parents 87bdef4 + af42b3b commit 828abee
Show file tree
Hide file tree
Showing 55 changed files with 1,669 additions and 1,091 deletions.
Binary file modified OneSignalSDK.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion OneSignalSDK/onesignal/consumer-proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

-keep class com.onesignal.shortcutbadger.impl.AdwHomeBadger { <init>(...); }
-keep class com.onesignal.shortcutbadger.impl.ApexHomeBadger { <init>(...); }
-keep class com.onesignal.shortcutbadger.impl.AsusHomeLauncher { <init>(...); }
-keep class com.onesignal.shortcutbadger.impl.AsusHomeBadger { <init>(...); }
-keep class com.onesignal.shortcutbadger.impl.DefaultBadger { <init>(...); }
-keep class com.onesignal.shortcutbadger.impl.EverythingMeHomeBadger { <init>(...); }
-keep class com.onesignal.shortcutbadger.impl.HuaweiHomeBadger { <init>(...); }
Expand Down
2 changes: 1 addition & 1 deletion OneSignalSDK/onesignal/maven-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Global {
static def POM_NAME = 'OneSignal'
static def POM_ARTIFACT_ID = 'OneSignal'
static def POM_PACKAGING = 'aar'
static def VERSION_NAME = '3.15.1-OS'
static def VERSION_NAME = '3.15.5-OS'

static def GROUP_ID = 'com.onesignal'
static def POM_DESCRIPTION = 'OneSignal Android SDK'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ abstract static class ActivityAvailableListener {
void available(@NonNull Activity activity) {
}

void stopped(WeakReference<Activity> reference) {
void stopped() {
}

void lostFocus() {
}
}

Expand Down Expand Up @@ -145,7 +148,7 @@ static void onActivityStopped(Activity activity) {
}

for (Map.Entry<String, ActivityAvailableListener> entry : sActivityAvailableListeners.entrySet()) {
entry.getValue().stopped(new WeakReference<>(activity));
entry.getValue().stopped();
}

logCurActivity();
Expand Down Expand Up @@ -185,7 +188,7 @@ private static void onOrientationChanged() {
// Remove view
handleLostFocus();
for (Map.Entry<String, ActivityAvailableListener> entry : sActivityAvailableListeners.entrySet()) {
entry.getValue().stopped(new WeakReference<>(curActivity));
entry.getValue().stopped();
}

// Show view
Expand Down Expand Up @@ -260,6 +263,9 @@ public void run() {
return;

backgrounded = true;
for (Map.Entry<String, ActivityAvailableListener> entry : sActivityAvailableListeners.entrySet()) {
entry.getValue().lostFocus();
}
OneSignal.onAppLostFocus();
completed = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,19 @@

package com.onesignal;

import android.app.NotificationManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Build;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;
import android.support.annotation.RequiresApi;

import com.onesignal.OneSignalDbContract.NotificationTable;
import com.onesignal.shortcutbadger.ShortcutBadgeException;
import com.onesignal.shortcutbadger.ShortcutBadger;

import com.onesignal.OneSignalDbContract.NotificationTable;

import static com.onesignal.NotificationLimitManager.MAX_NUMBER_OF_NOTIFICATIONS_STR;

class BadgeCountUpdater {
Expand Down Expand Up @@ -75,14 +72,14 @@ private static boolean areBadgesEnabled(Context context) {
return areBadgeSettingsEnabled(context) && OSUtils.areNotificationsEnabled(context);
}

static void update(SQLiteDatabase readableDb, Context context) {
static void update(OneSignalDb db, Context context) {
if (!areBadgesEnabled(context))
return;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
updateStandard(context);
else
updateFallback(readableDb, context);
updateFallback(db, context);
}

@RequiresApi(api = Build.VERSION_CODES.M)
Expand All @@ -99,8 +96,8 @@ private static void updateStandard(Context context) {
updateCount(runningCount, context);
}

private static void updateFallback(SQLiteDatabase readableDb, Context context) {
Cursor cursor = readableDb.query(
private static void updateFallback(OneSignalDb db, Context context) {
Cursor cursor = db.query(
NotificationTable.TABLE_NAME,
null,
OneSignalDbHelper.recentUninteractedWithNotificationsWhere().toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ protected void saveInfluences(List<OSInfluence> influences) {
protected boolean timeTypeApplies(@NonNull List<OSInfluence> influences) {
for (OSInfluence influence : influences) {
// Is true is at least one channel attributed the session
if (influence.getInfluenceType().isAttributed())
if (influence.getInfluenceType().isAttributed()) {
OneSignal.Log(OneSignal.LOG_LEVEL.DEBUG, this.getClass().getSimpleName() + ":timeTypeApplies for influences: " + influences.toString() + " true");
return true;
}
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@

package com.onesignal;

import java.lang.reflect.Field;
import java.math.BigInteger;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.security.SecureRandom;
import java.util.Random;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.R.drawable;
import android.app.Activity;
import android.app.AlertDialog;
Expand All @@ -53,7 +39,6 @@
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
Expand All @@ -68,6 +53,20 @@

import com.onesignal.OneSignalDbContract.NotificationTable;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Field;
import java.math.BigInteger;
import java.net.URL;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Random;

import static com.onesignal.OSUtils.getResourceString;

class GenerateNotification {
Expand Down Expand Up @@ -528,8 +527,6 @@ private static void createSummaryNotification(NotificationGenerationJob notifJob
Cursor cursor = null;

try {
SQLiteDatabase readableDb = dbHelper.getSQLiteDatabaseWithRetries();

String[] retColumn = { NotificationTable.COLUMN_NAME_ANDROID_NOTIFICATION_ID,
NotificationTable.COLUMN_NAME_FULL_DATA,
NotificationTable.COLUMN_NAME_IS_SUMMARY,
Expand All @@ -545,7 +542,7 @@ private static void createSummaryNotification(NotificationGenerationJob notifJob
if (!updateSummary && notifJob.getAndroidId() != -1)
whereStr += " AND " + NotificationTable.COLUMN_NAME_ANDROID_NOTIFICATION_ID + " <> " + notifJob.getAndroidId();

cursor = readableDb.query(
cursor = dbHelper.query(
NotificationTable.TABLE_NAME,
retColumn,
whereStr,
Expand Down Expand Up @@ -769,28 +766,11 @@ private static Intent createBaseSummaryIntent(int summaryNotificationId, JSONObj
private static void createSummaryIdDatabaseEntry(OneSignalDbHelper dbHelper, String group, int id) {
// There currently isn't a visible notification from for this groupid.
// Save the group summary notification id so it can be updated later.
SQLiteDatabase writableDb = null;
try {
writableDb = dbHelper.getSQLiteDatabaseWithRetries();
writableDb.beginTransaction();

ContentValues values = new ContentValues();
values.put(NotificationTable.COLUMN_NAME_ANDROID_NOTIFICATION_ID, id);
values.put(NotificationTable.COLUMN_NAME_GROUP_ID, group);
values.put(NotificationTable.COLUMN_NAME_IS_SUMMARY, 1);
writableDb.insertOrThrow(NotificationTable.TABLE_NAME, null, values);
writableDb.setTransactionSuccessful();
} catch (Throwable t) {
OneSignal.Log(OneSignal.LOG_LEVEL.ERROR, "Error adding summary notification record! ", t);
} finally {
if (writableDb != null) {
try {
writableDb.endTransaction(); // May throw if transaction was never opened or DB is full.
} catch (Throwable t) {
OneSignal.Log(OneSignal.LOG_LEVEL.ERROR, "Error closing transaction! ", t);
}
}
}
ContentValues values = new ContentValues();
values.put(NotificationTable.COLUMN_NAME_ANDROID_NOTIFICATION_ID, id);
values.put(NotificationTable.COLUMN_NAME_GROUP_ID, group);
values.put(NotificationTable.COLUMN_NAME_IS_SUMMARY, 1);
dbHelper.insertOrThrow(NotificationTable.TABLE_NAME, null, values);
}

// Keep 'throws Throwable' as 'onesignal_bgimage_notif_layout' may not be available
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* Modified MIT License
* <p>
* Copyright 2020 OneSignal
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* <p>
* 1. The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 2. All copies of substantial portions of the Software may only be used in connection
* with services provided by OneSignal.
* <p>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package com.onesignal;

import org.json.JSONException;
import org.json.JSONObject;

class ImmutableJSONObject {

private final JSONObject jsonObject;

public ImmutableJSONObject() {
this.jsonObject = new JSONObject();
}

public ImmutableJSONObject(JSONObject jsonObject) {
this.jsonObject = jsonObject;
}

public long getLong(String name) throws JSONException {
return jsonObject.getLong(name);
}

public boolean has(String name) {
return jsonObject.has(name);
}

public Object opt(String name) {
return jsonObject.opt(name);
}

public String optString(String name) {
return jsonObject.optString(name);
}

public String optString(String name, String fallback) {
return jsonObject.optString(name, fallback);
}

public boolean optBoolean(String name) {
return jsonObject.optBoolean(name);
}

public boolean optBoolean(String name, boolean fallback) {
return jsonObject.optBoolean(name, fallback);
}

public long optLong(String name) {
return jsonObject.optLong(name);
}

public int optInt(String name) {
return jsonObject.optInt(name);
}

public int optInt(String name, int fallback) {
return jsonObject.optInt(name, fallback);
}

public JSONObject optJSONObject(String name) {
return jsonObject.optJSONObject(name);
}

}
Loading

0 comments on commit 828abee

Please sign in to comment.