Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/bgy/rebase #5

Merged
merged 59 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
9b7a94b
Add Update Handler for Send/Delete Tags
Nightsd01 Jul 19, 2018
c75d4f6
Maintain Array of Send Tags Handlers
Nightsd01 Jul 21, 2018
f5b2df4
Fix Tags Batching
Nightsd01 Jul 21, 2018
58218cf
Add requiresUserPrivacyConsent() getter
Nightsd01 Jul 23, 2018
88d8056
Add Additional Testcase
Nightsd01 Jul 23, 2018
7b24783
Correct wakeful service fallback to job call
jkasten2 Jul 24, 2018
7bcb166
Stylistic Change
Nightsd01 Jul 24, 2018
af55a25
Merge pull request #598 from OneSignal/public_requires_consent
Nightsd01 Jul 25, 2018
3d81d89
Merge pull request #595 from OneSignal/send_tags_handler
Nightsd01 Jul 25, 2018
5ebbd80
Merge pull request #600 from OneSignal/gcm_job_fallback_fix
Nightsd01 Jul 31, 2018
58827dc
3.10.0 Release Commit
Nightsd01 Jul 31, 2018
84618a6
Fix ANR
Nightsd01 Aug 3, 2018
9eae4fb
Change User State Method Synchronization
Nightsd01 Aug 6, 2018
7768569
Merge pull request #607 from OneSignal/anr_fix
Nightsd01 Aug 7, 2018
6808d44
Improve Android SDK Demo Project
Nightsd01 Aug 7, 2018
91f160d
3.10.1 Release Commit
Nightsd01 Aug 7, 2018
f0003bb
Merge pull request #608 from OneSignal/improve_demo
Nightsd01 Aug 9, 2018
3c76d0a
Fix invoking interface method on a null object reference
letranloc Aug 15, 2018
dc2ccd6
Added test to go with PR #611 for null callback.
jkasten2 Aug 24, 2018
494c01b
Fix FirebaseInstanceIdService Missing Exception
Nightsd01 Sep 11, 2018
032f9e5
Bundle NPE in RestoreJobService.onHandleWork
jkasten2 Sep 25, 2018
05f78f0
Fixes disabling sound & vibration in some configs
jkasten2 Sep 29, 2018
dddd03b
Importance fallback fix for notification channels
jkasten2 Oct 3, 2018
d52386e
Updated internal JobIntentService to latest
jkasten2 Oct 4, 2018
b91b887
Added useWakefulService option to JobIntetService
jkasten2 Oct 4, 2018
9360f85
Added new high priority flag to JobIntentService
jkasten2 Oct 4, 2018
ea2ce3f
Added result to GCM broadcast aborts
jkasten2 Oct 5, 2018
d2225c3
Updated test for GCM receiver result
jkasten2 Oct 5, 2018
235e15e
3.10.2 Release Commit
jkasten2 Oct 5, 2018
0da2a83
Misuse of multiple SQL statements in execSQL().
csnagy May 25, 2018
1594d6c
-Modified Random generation of values to SecureRandom
jramosMobilendo Jul 27, 2018
2678183
-Modified Random generation of values to SecureRandom
jramosMobilendo Jul 27, 2018
8a3f212
Limit number of notification restored to 49
jkasten2 Oct 9, 2018
5bbb8d2
Allow setting provideUserConsent before init
jkasten2 Oct 11, 2018
2426551
Remove Privacy Consent Requirement to Add Observers
Nightsd01 Oct 25, 2018
5a7e9f9
Add Regression Tests
Nightsd01 Oct 25, 2018
ccbd4e3
Merge pull request #655 from OneSignal/observers_consent
Nightsd01 Oct 26, 2018
8025425
Handle JobIntentService IllegalArgumentException
jkasten2 Nov 2, 2018
95b00de
Permission check added to job service setPersisted
jkasten2 Nov 2, 2018
5dc7eb3
Possible fix for "Package manager has died"
jkasten2 Nov 2, 2018
82a0a41
3.10.3 Release commit
jkasten2 Nov 2, 2018
0c986ba
Add External ID
Nightsd01 Dec 4, 2018
335ccb5
Add Tests
Nightsd01 Dec 4, 2018
ccd2a0f
Use State Synchronizer
Nightsd01 Dec 4, 2018
db0fd61
Add Test
Nightsd01 Dec 5, 2018
bd729fe
Removed ACTION_BOOT_COMPLETED for BOOT_COMPLETED
jkasten2 Dec 2, 2018
70537ee
Catch for SecurityException from JobIntentService
jkasten2 Dec 4, 2018
3af1cba
Merge pull request #679 from OneSignal/set_external_id
Nightsd01 Dec 6, 2018
79dd946
3.10.5 Release Commit
Nightsd01 Dec 6, 2018
a12e7a8
Add External ID Methods to Unity Proxy
Nightsd01 Dec 7, 2018
ed962e0
Merge pull request #682 from OneSignal/external_id_unity
Nightsd01 Dec 10, 2018
04b5cff
Making setAppContext public
jkasten2 Jan 17, 2019
62bbfe4
• This commit changes the SDK so that it maintains an array of getTag…
Nightsd01 Jan 16, 2019
ece7d2f
Add Test
Nightsd01 Jan 16, 2019
dfa57ea
Update badge count when restoring notifications
jkasten2 Jan 17, 2019
5404ab3
Badge now uses notification count from system
jkasten2 Jan 17, 2019
feb29f1
3.10.6 Release commit
jkasten2 Jan 18, 2019
6e9a24d
Rebase on 3.10.6
baptiste-nv May 9, 2018
03f29b6
REenable location tracking
baptiste-nv Mar 21, 2019
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ gen/

# Proguard folder generated by Eclipse
proguard/
.idea/
Binary file modified OneSignalSDK.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion OneSignalSDK/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dependencies {
implementation 'com.google.android.gms:play-services-location:12.0.0'

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

//apply plugin: 'com.google.gms.google-services'
213 changes: 177 additions & 36 deletions OneSignalSDK/app/src/main/java/com/onesignal/example/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,54 +28,72 @@
package com.onesignal.example;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Bundle;
import android.os.Looper;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.os.Handler;

import com.onesignal.*;
import com.onesignal.OneSignal.NotificationOpenedHandler;

import com.onesignal.example.iap.IabHelper;
import com.onesignal.example.iap.IabResult;

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

import java.util.Locale;
import java.util.ArrayList;


public class MainActivity extends Activity {
public class MainActivity extends Activity implements OSEmailSubscriptionObserver, OSPermissionObserver, OSSubscriptionObserver, NotificationOpenedHandler, OneSignal.NotificationReceivedHandler {

IabHelper mHelper;

private int[] interactiveViewIds = new int[] {R.id.subscribe, R.id.unsubscribe, R.id.sendTags, R.id.getTags, R.id.logoutEmail, R.id.setEmail, R.id.emailTextView};

private TextView debugTextView;
private TextView emailTextView;
private Button consentButton;
private Button setEmailButton;
private Button logoutEmailButton;

private int sendTagsCounter = 1;
private boolean addedObservers = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Log.e("tet", Locale.getDefault().getLanguage());
this.consentButton = (Button)this.findViewById(R.id.consentButton);
this.setEmailButton = (Button)this.findViewById(R.id.setEmail);
this.logoutEmailButton = (Button)this.findViewById(R.id.logoutEmail);

OneSignal.setInFocusDisplaying(OneSignal.OSInFocusDisplayOption.InAppAlert);
OneSignal.sendTag("test3", "test7");
//OneSignal.setSubscription(false);
if (OneSignal.requiresUserPrivacyConsent()) {
//disable all interactive views except consent button
this.changeInteractiveViewsEnabled(false);
consentButton.setText("Provide Consent");
} else {
consentButton.setText("Revoke Consent");

OneSignal.syncHashedEmail("[email protected]");
this.addObservers();

// OneSignal.idsAvailable(new OneSignal.IdsAvailableHandler() {
// @Override
// public void idsAvailable(String userId, String registrationId) {
// Log.i("OneSignal Example:", "UserID: " + userId + ", RegId: " + (registrationId != null ? registrationId : "null"));
//
// try {
// OneSignal.postNotification(new JSONObject("{'contents': {'en':'Test Message'}, 'include_player_ids': ['" + userId + "']}"), null);
// //OneSignal.postNotification(new JSONObject("{'contents': {'en':'Test Message'}, 'include_player_ids': ['" + "86480bb0-ef9a-11e4-8cf1-000c29917011', '2def6d7a-4395-11e4-890a-000c2940e62c" + "']}"), null);
// } catch (JSONException e) {
// e.printStackTrace();
// }
// }
// });
OSPermissionSubscriptionState state = OneSignal.getPermissionSubscriptionState();

this.didGetEmailStatus(state.getEmailSubscriptionStatus().getSubscribed());
}

this.debugTextView = this.findViewById(R.id.debugTextView);
this.emailTextView = this.findViewById(R.id.emailTextView);

// compute your public key and store it in base64EncodedPublicKey
mHelper = new IabHelper(this, "sdafsfds");
Expand All @@ -88,6 +106,67 @@ public void onIabSetupFinished(IabResult result) {
// Hooray, IAB is fully set up!
}
});


}

private void updateTextView(final String newText) {
//ensure that we only update the text view from the main thread.

Handler mainHandler = new Handler(Looper.getMainLooper());

Runnable runnable = new Runnable() {
@Override
public void run() {
debugTextView.setText(newText);
}
};

mainHandler.post(runnable);
}

private void addObservers() {
this.addedObservers = true;

Log.d("onesignal", "adding observers");

OneSignal.addEmailSubscriptionObserver(this);

OneSignal.addSubscriptionObserver(this);

OneSignal.addPermissionObserver(this);
}

@Override
public void onOSEmailSubscriptionChanged(OSEmailSubscriptionStateChanges stateChanges) {
updateTextView("Email Subscription State Changed: " + stateChanges.toString());

didGetEmailStatus(stateChanges.getTo().getSubscribed());
}

@Override
public void onOSSubscriptionChanged(OSSubscriptionStateChanges stateChanges) {
updateTextView("Push Subscriuption State Changed: " + stateChanges.toString());
}

@Override
public void onOSPermissionChanged(OSPermissionStateChanges stateChanges) {
updateTextView("Permission State Changed: " + stateChanges.toString());
}

@Override
public void notificationOpened(OSNotificationOpenResult result) {
updateTextView("Opened Notification: " + result.toString());
}

@Override
public void notificationReceived(OSNotification notification) {
updateTextView("Received Notification: " + notification.toString());
}

public void didGetEmailStatus(boolean hasEmailUserId) {
this.setEmailButton.setEnabled(!hasEmailUserId);
this.logoutEmailButton.setEnabled(hasEmailUserId);
}

public void onSubscribeClicked(View v) {
Expand All @@ -99,32 +178,94 @@ public void onSubscribeClicked(View v) {
nMgr.cancelAll();
}

private void changeInteractiveViewsEnabled(boolean enabled) {
for (int viewId : this.interactiveViewIds) {
this.findViewById(viewId).setEnabled(enabled);
}
}

public void onUnsubscribeClicked(View v) {
OneSignal.setSubscription(false);

this.debugTextView.setText("Unsubscribed");
}


public void onSendTagsClicked(View v) {
OneSignal.sendTags("{\"test\":\"value\"}");
try {
OneSignal.sendTags(new JSONObject("{\"counter\" : " + String.valueOf(sendTagsCounter) + ", \"test_value\" : \"test_key\"}"), new OneSignal.ChangeTagsUpdateHandler() {
@Override
public void onSuccess(JSONObject tags) {
updateTextView("Successfully sent tags: " + tags.toString());
}

@Override
public void onFailure(OneSignal.SendTagsError error) {
updateTextView("Failed to send tags: " + error.toString());
}
});

sendTagsCounter++;
} catch (JSONException exception) {
updateTextView("Failed to serialize tags into JSON: " + exception.getMessage());
}
}

public void onConsentButtonClicked(View v) {
OneSignal.provideUserConsent(!OneSignal.userProvidedPrivacyConsent());
}

// @Override
// protected void onPause() {
// super.onPause();
// if (mHelper != null)
// mHelper.dispose();
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// if (mHelper != null) mHelper.dispose();
// mHelper = null;
// }
boolean consentRequired = OneSignal.requiresUserPrivacyConsent();

//flips consent
OneSignal.provideUserConsent(consentRequired);
this.changeInteractiveViewsEnabled(consentRequired);
this.consentButton.setText(consentRequired ? "Revoke Consent" : "Provide Consent");

if (consentRequired && this.addedObservers == false)
addObservers();
}

public void onGetTagsClicked(View v) {
OneSignal.getTags(new OneSignal.GetTagsHandler() {
@Override
public void tagsAvailable(final JSONObject tags) {
updateTextView("Got Tags: " + tags.toString());
}
});
}

public void onSetEmailClicked(View v) {
String email = emailTextView.getText().toString();

if (email.length() == 0) {
Log.d("onesingal", "email not set");
return;
}

OneSignal.setEmail(email, new OneSignal.EmailUpdateHandler() {
@Override
public void onSuccess() {
updateTextView("Successfully set email");
}

@Override
public void onFailure(OneSignal.EmailUpdateError error) {
updateTextView("Failed to set email with error: " + error.getMessage());
}
});
}

public void onLogoutEmailClicked(View v) {
OneSignal.logoutEmail(new OneSignal.EmailUpdateHandler() {
@Override
public void onSuccess() {
updateTextView("Successfully logged out of email");
}

@Override
public void onFailure(OneSignal.EmailUpdateError error) {
updateTextView("Failed to logout of email with error: " + error.getMessage());
}
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
Expand Down
Loading