Skip to content

Commit

Permalink
Lowered required support library revision and geo tag fix
Browse files Browse the repository at this point in the history
* No longer requires revision 23 of the Android Support Library. 22 is need for all features but an older one can be used safely.
* Fixed bug where geo tag permission prompt did not work if used from the Application class on Android 6.0
* Updated example project.
  • Loading branch information
jkasten2 committed Dec 16, 2015
1 parent fbf105a commit 664cfac
Show file tree
Hide file tree
Showing 18 changed files with 206 additions and 70 deletions.
3 changes: 1 addition & 2 deletions Examples/AndroidStudio/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Examples/AndroidStudio/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ dependencies {
compile 'com.google.android.gms:play-services-gcm:+'
compile 'com.google.android.gms:play-services-analytics:+'
compile "com.google.android.gms:play-services-location:+"
compile 'com.android.support:appcompat-v7:23.1.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public void onCreate() {

OneSignal.startInit(this)
.setNotificationOpenedHandler(new ExampleNotificationOpenedHandler())
.setAutoPromptLocation(true)
.init();
}

Expand Down
2 changes: 1 addition & 1 deletion Examples/AndroidStudio/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.tools.build:gradle:1.5.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Binary file modified OneSignalSDK.jar
Binary file not shown.
20 changes: 15 additions & 5 deletions OneSignalSDK/app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-analytics/7.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/7.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-gcm/7.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/7.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-maps/7.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
Expand All @@ -83,9 +88,14 @@
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="play-services-maps-7.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-base-7.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-location-7.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-gcm-7.0.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-analytics-7.0.0" level="project" />
<orderEntry type="module" module-name="onesignal" exported="" />
</component>
</module>
18 changes: 12 additions & 6 deletions OneSignalSDK/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,23 @@ repositories {

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

// Use for SDK Development
compile project(':onesignal')
compile(project(':onesignal')) {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.google.android.gms', module: 'play-services-gcm'
exclude group: 'com.google.android.gms', module: 'play-services-analytics'
exclude group: 'com.google.android.gms', module: 'play-services-location'
}

// Use for released SDK
//compile 'com.onesignal:OneSignal:2.+@aar'
//compile "com.google.android.gms:play-services-gcm:8.3.0"
//compile "com.google.android.gms:play-services-analytics:8.3.0"
//compile "com.google.android.gms:play-services-location:8.3.0"
//compile 'com.android.support:appcompat-v7:23.1.1'

compile "com.google.android.gms:play-services-gcm:7.0.0"
compile "com.google.android.gms:play-services-analytics:7.0.0"
compile "com.google.android.gms:play-services-location:7.0.0"
// compile 'com.android.support:support-v4:23.0.0'

// testCompile 'junit:junit:4.12'
// testCompile 'org.robolectric:shadows-support-v4:3.0'
Expand Down
17 changes: 3 additions & 14 deletions OneSignalSDK/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme"
android:name=".OneSignalExampleApp">

<!--
<amazon:enable-feature android:name="com.amazon.device.messaging" android:required="false"/>
Expand Down Expand Up @@ -72,19 +73,7 @@
</activity>




<activity
android:name=".MainActivity2Activity"
android:label="@string/title_activity_main_activity2"
android:exported="false" >
<!-- <intent-filter>
<action android:name="com.onesignal.NotificationOpened.RECEIVE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
-->
</activity>
<!--
<!--
<receiver
android:name="com.onesignal.example.TestNotificationOpenedReceiver"
android:exported="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,12 @@ protected void onCreate(Bundle savedInstanceState) {

currentActivity = this;

// Enable Logging below to debug issues. (LogCat level, Visual level);
// OneSignal.setLogLevel(OneSignal.LOG_LEVEL.DEBUG, OneSignal.LOG_LEVEL.NONE);

OneSignal.startInit(this)
.setAutoPromptLocation(true)
.setNotificationOpenedHandler(new ExampleNotificationOpenedHandler())
.init();

OneSignal.enableInAppAlertNotification(true);
OneSignal.enableNotificationsWhenActive(false);
OneSignal.sendTag("test1", "test1");
OneSignal.sendTag("test3", "test3");
//OneSignal.setSubscription(false);


// OneSignal.idsAvailable(new OneSignal.IdsAvailableHandler() {
// @Override
// public void idsAvailable(String userId, String registrationId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.onesignal.example;

import android.app.Application;

import com.onesignal.OneSignal;

public class OneSignalExampleApp extends Application {

@Override
public void onCreate() {
super.onCreate();
OneSignal.setLogLevel(OneSignal.LOG_LEVEL.DEBUG, OneSignal.LOG_LEVEL.NONE);
OneSignal.startInit(this)
.setAutoPromptLocation(true)
// .setNotificationOpenedHandler(new ExampleNotificationOpenedHandler())
.init();
}
}
10 changes: 6 additions & 4 deletions OneSignalSDK/onesignal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ android {

dependencies {
provided fileTree(dir: 'libs', include: ['*.jar'])
compile "com.google.android.gms:play-services-gcm:8.3.0"
compile "com.google.android.gms:play-services-analytics:8.3.0"
compile "com.google.android.gms:play-services-location:8.3.0"
compile 'com.android.support:appcompat-v7:23.1.1'

// Compiling oldest version so we know the minimum required version at compile time.
// 7.0.0 depends on Android Support Library v4 22.0.0
compile "com.google.android.gms:play-services-gcm:7.0.0"
compile "com.google.android.gms:play-services-analytics:7.0.0"
compile "com.google.android.gms:play-services-location:7.0.0"
}

apply from: 'maven-push.gradle'
17 changes: 7 additions & 10 deletions OneSignalSDK/onesignal/onesignal.iml
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,14 @@
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
<orderEntry type="library" exported="" name="play-services-location-8.3.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
<orderEntry type="library" exported="" name="play-services-maps-7.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-base-7.0.0" level="project" />
<orderEntry type="library" exported="" name="in-app-purchasing-2.0.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="play-services-base-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-gcm-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-analytics-8.3.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-location-7.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-gcm-7.0.0" level="project" />
<orderEntry type="library" exported="" name="amazon-device-messaging-1.0.1" level="project" />
<orderEntry type="library" exported="" name="play-services-maps-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-measurement-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-basement-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-analytics-7.0.0" level="project" />
</component>
</module>
2 changes: 2 additions & 0 deletions OneSignalSDK/onesignal/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
Vibration settings of the device still apply. -->
<uses-permission android:name="android.permission.VIBRATE" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application>
<meta-data android:name="onesignal_app_id" android:value="${onesignal_app_id}" />
<meta-data android:name="onesignal_google_project_number" android:value="str:${onesignal_google_project_number}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,45 @@
package com.onesignal;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.util.Log;

class ActivityLifecycleHandler {

interface ActivityAvailableListener {
void available(Activity activity);
}

static Activity curActivity;
private static ActivityAvailableListener mActivityAvailableListener;
static FocusHandlerThread focusHandlerThread = new FocusHandlerThread();

static void onActivityCreated(Activity activity) {
curActivity = activity;
// Note: Only supports one callback, create a list when this needs to be used by more than the permissions dialog.
static void setActivityAvailableListener(ActivityAvailableListener activityAvailableListener) {
if (curActivity != null) {
activityAvailableListener.available(curActivity);
mActivityAvailableListener = activityAvailableListener;
}
else
mActivityAvailableListener = activityAvailableListener;
}

logCurActivity();
handleFocus();
public static void removeActivityAvailableListener(ActivityAvailableListener activityAvailableListener) {
mActivityAvailableListener = null;
}

static void onActivityStarted(Activity activity) {
private static void setCurActivity(Activity activity) {
curActivity = activity;

logCurActivity();
handleFocus();
if (mActivityAvailableListener != null)
mActivityAvailableListener.available(curActivity);
}

static void onActivityCreated(Activity activity) {}
static void onActivityStarted(Activity activity) {}

static void onActivityResumed(Activity activity) {
curActivity = activity;
setCurActivity(activity);

logCurActivity();
handleFocus();
Expand Down Expand Up @@ -88,7 +100,7 @@ static void onActivityDestroyed(Activity activity) {
}

static private void logCurActivity() {
OneSignal.Log(OneSignal.LOG_LEVEL.DEBUG, "curActivity is NOW: " + (curActivity != null ? curActivity.getClass().getName() : "null"));
OneSignal.Log(OneSignal.LOG_LEVEL.DEBUG, "curActivity is NOW: " + (curActivity != null ? "" + curActivity.getClass().getName() + ":" + curActivity : "null"));
}

static private void handleLostFocus() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Modified MIT License
* Copyright 2015 OneSignal
*
* Internals Copyright (C) 2012 The Android Open Source Project
* Licensed under the Apache License, Version 2.0 (the "License");
*
* 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:
*
* 1. The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 2. All copies of substantial portions of the Software may only be used in connection
* with services provided by OneSignal.
*
* 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 android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;

// 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.
class AndroidSupportV4Compat {

static class ContextCompat {
static int checkSelfPermission(@NonNull Context context, @NonNull String permission) {
if (permission == null)
throw new IllegalArgumentException("permission is null");

return context.checkPermission(permission, android.os.Process.myPid(), android.os.Process.myUid());
}
}

interface RequestPermissionsRequestCodeValidator {
void validateRequestPermissionsRequestCode(int requestCode);
}

static class ActivityCompat {
static void requestPermissions(final @NonNull Activity activity, final @NonNull String[] permissions, final int requestCode) {
// OneSignal SDK code already checks that device is Android M, omit else code from the support library.
ActivityCompatApi23.requestPermissions(activity, permissions, requestCode);
}
}

@TargetApi(23)
static class ActivityCompatApi23 {
static void requestPermissions(Activity activity, String[] permissions, int requestCode) {
if (activity instanceof RequestPermissionsRequestCodeValidator)
((RequestPermissionsRequestCodeValidator) activity).validateRequestPermissionsRequestCode(requestCode);
activity.requestPermissions(permissions, requestCode);
}
}
}
Loading

0 comments on commit 664cfac

Please sign in to comment.