Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
149 changed files
with
6,160 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# Files for the Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
*/build/ | ||
|
||
# Android Studio | ||
*.iml | ||
.idea | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# OSX files | ||
.DS_Store | ||
|
||
# Windows files | ||
Thumbs.db | ||
*.bak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
language: android | ||
jdk: oraclejdk8 | ||
env: | ||
global: | ||
- ANDROID_TARGET=android-15 | ||
- ANDROID_ABI=armeabi-v7a | ||
|
||
android: | ||
components: | ||
- tools | ||
- platform-tools | ||
- build-tools-23.0.2 | ||
- android-23 | ||
- extra-android-support | ||
- extra-google-m2repository | ||
- sys-img-armeabi-v7a-android-19 | ||
- extra-android-m2repository | ||
|
||
before_install: | ||
- pip install --user codecov | ||
|
||
script: | ||
- ./gradlew check test | ||
|
||
after_success: | ||
- ./gradlew jacocoFullReport | ||
- bash <(curl -s https://codecov.io/bash) | ||
- codecov | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'jacoco-android' | ||
|
||
def STRING = "String" | ||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion "23.0.2" | ||
|
||
defaultConfig { | ||
minSdkVersion 15 | ||
targetSdkVersion 23 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
buildConfigField STRING, "API_URL", '"http://dashboard.sandbox.applivery.com"' | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
// buildConfigField STRING, "API_URL", '"https://dashboard.applivery.com"' | ||
} | ||
} | ||
|
||
testOptions { | ||
unitTests.returnDefaultValues = true | ||
} | ||
|
||
sourceSets { | ||
test { | ||
resources { | ||
srcDir "test" | ||
} | ||
} | ||
} | ||
|
||
lintOptions { | ||
abortOnError false | ||
} | ||
} | ||
|
||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1' | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
|
||
compile 'com.android.support:appcompat-v7:23.0.1' | ||
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' | ||
compile 'com.squareup.okhttp:logging-interceptor:2.6.0' | ||
compile 'com.squareup.retrofit:retrofit:2.0.0-beta1' | ||
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1' | ||
compile 'com.squareup.okhttp:okhttp:2.5.0' | ||
compile 'com.google.code.gson:gson:2.3.1' | ||
compile 'com.karumi:dexter:2.1.2' | ||
|
||
testCompile 'junit:junit:4.12' | ||
testCompile 'org.mockito:mockito-all:2.0.2-beta' | ||
testCompile 'com.squareup.okhttp:mockwebserver:2.6.0' | ||
compile 'org.mockito:mockito-all:2.0.2-beta' | ||
} | ||
|
||
|
||
|
||
apply from: '../maven_push.gradle' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/sergio.martinez/Library/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
13 changes: 13 additions & 0 deletions
13
applvsdklib/src/androidTest/java/com/applivery/applvsdklib/ApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.applivery.applvsdklib; | ||
|
||
import android.app.Application; | ||
import android.test.ApplicationTestCase; | ||
|
||
/** | ||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | ||
*/ | ||
public class ApplicationTest extends ApplicationTestCase<Application> { | ||
public ApplicationTest() { | ||
super(Application.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.applivery.applvsdklib"> | ||
|
||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<!--Using Android M request permissions System--> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
|
||
<application android:allowBackup="true" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
> | ||
|
||
</application> | ||
|
||
</manifest> |
27 changes: 27 additions & 0 deletions
27
applvsdklib/src/main/java/com/applivery/applvsdklib/Applivery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.applivery.applvsdklib; | ||
|
||
import android.app.Application; | ||
|
||
/** | ||
* Created by Sergio Martinez Rodriguez | ||
* Date 17/1/16. | ||
*/ | ||
public class Applivery { | ||
/** | ||
* Initializes Sdk for the current app and developer. Call this method from your application | ||
* instance when onCreate method is called. Pay attention to description of isPlayStoreRelease | ||
* param | ||
* @param app your app instance, it can't be null. | ||
* @param applicationId your app id. You can find this value at applivery dashboard in your | ||
* app section | ||
* @param appClientToken your developer secret key. You can find this value at | ||
* applivery dashboard in developer section | ||
* @param isPlayStoreRelease this flag MUST be null when application is candidate to be Google | ||
* Play Store release, because otherwise app can show dialogs from applivery about updates that | ||
* can redirect end users to applivery beta versions. | ||
*/ | ||
public static void init(Application app, | ||
String applicationId, String appClientToken, boolean isPlayStoreRelease) { | ||
AppliverySdk.sdkInitialize(app, applicationId, appClientToken, isPlayStoreRelease); | ||
} | ||
} |
172 changes: 172 additions & 0 deletions
172
applvsdklib/src/main/java/com/applivery/applvsdklib/AppliverySdk.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
package com.applivery.applvsdklib; | ||
|
||
import android.app.Activity; | ||
import android.app.Application; | ||
import android.content.Context; | ||
import android.os.AsyncTask; | ||
import android.util.Log; | ||
import com.applivery.applvsdklib.domain.exceptions.NotForegroundActivityAvailable; | ||
import com.applivery.applvsdklib.network.api.AppliveryApiService; | ||
import com.applivery.applvsdklib.network.api.AppliveryApiServiceBuilder; | ||
import com.applivery.applvsdklib.domain.appconfig.ObtainAppConfigInteractor; | ||
import com.applivery.applvsdklib.tools.androidimplementations.AndroidCurrentAppInfo; | ||
import com.applivery.applvsdklib.tools.androidimplementations.AppliveryActivityLifecycleCallbacks; | ||
import com.applivery.applvsdklib.tools.utils.Validate; | ||
import com.applivery.applvsdklib.tools.permissions.AndroidPermissionCheckerImpl; | ||
import com.applivery.applvsdklib.tools.permissions.PermissionChecker; | ||
import java.util.concurrent.*; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
/** | ||
* Created by Sergio Martinez Rodriguez | ||
* Date 18/10/15. | ||
*/ | ||
public class AppliverySdk { | ||
|
||
private static final String TAG = AppliverySdk.class.getCanonicalName(); | ||
private static volatile Executor executor; | ||
private static volatile String applicationId; | ||
private static volatile String appClientToken; | ||
private static boolean isPlayStoreRelease = false; | ||
private static volatile AppliveryApiService appliveryApiService; | ||
private static volatile boolean isDebugEnabled = BuildConfig.DEBUG; | ||
private static Context applicationContext; | ||
private static PermissionChecker permissionRequestManager; | ||
private static AppliveryActivityLifecycleCallbacks activityLifecycle; | ||
private static final Object LOCK = new Object(); | ||
|
||
private static Boolean sdkInitialized = false; | ||
|
||
public static synchronized void sdkInitialize(Application app, | ||
String applicationId, String appClientToken, boolean isPlayStoreRelease) { | ||
|
||
if (sdkInitialized) { | ||
|
||
obtainAppConfig(); | ||
|
||
return; | ||
|
||
}else{ | ||
|
||
initializeAppliveryConstants(app, applicationId, appClientToken, isPlayStoreRelease); | ||
|
||
sdkInitialized = true; | ||
|
||
obtainAppConfig(); | ||
} | ||
|
||
} | ||
|
||
private static void initializeAppliveryConstants(Application app, String applicationId, | ||
String appClientToken, boolean isPlayStoreRelease) { | ||
|
||
//region validate some requirements | ||
Context applicationContext = Validate.notNull(app, "Application").getApplicationContext(); | ||
Validate.notNull(applicationContext, "applicationContext"); | ||
Validate.hasInternetPermissions(applicationContext, false); | ||
//endregion | ||
|
||
AppliverySdk.applicationId = applicationId; | ||
AppliverySdk.appClientToken = appClientToken; | ||
AppliverySdk.isPlayStoreRelease = isPlayStoreRelease; | ||
|
||
AppliverySdk.applicationContext = applicationContext; | ||
|
||
AppliverySdk.appliveryApiService = AppliveryApiServiceBuilder.getAppliveryApiInstance(); | ||
AppliverySdk.activityLifecycle = new AppliveryActivityLifecycleCallbacks(applicationContext); | ||
AppliverySdk.permissionRequestManager = new AndroidPermissionCheckerImpl(applicationContext, AppliverySdk.activityLifecycle); | ||
|
||
app.registerActivityLifecycleCallbacks(activityLifecycle); | ||
} | ||
|
||
private static void obtainAppConfig() { | ||
if (!isPlayStoreRelease){ | ||
getExecutor().execute(ObtainAppConfigInteractor.getInstance(appliveryApiService, | ||
AppliverySdk.applicationId, AppliverySdk.appClientToken, | ||
new AndroidCurrentAppInfo(applicationContext))); | ||
} | ||
} | ||
|
||
public static Executor getExecutor() { | ||
synchronized (LOCK) { | ||
if (AppliverySdk.executor == null) { | ||
AppliverySdk.executor = AsyncTask.THREAD_POOL_EXECUTOR; | ||
} | ||
} | ||
return AppliverySdk.executor; | ||
} | ||
|
||
public static void setExecutor(Executor executor) { | ||
Validate.notNull(executor, "executor"); | ||
synchronized (LOCK) { | ||
AppliverySdk.executor = executor; | ||
} | ||
} | ||
|
||
public static Context getApplicationContext() { | ||
Validate.sdkInitialized(); | ||
return applicationContext; | ||
} | ||
|
||
public static PermissionChecker getPermissionRequestManager() { | ||
Validate.sdkInitialized(); | ||
return permissionRequestManager; | ||
} | ||
|
||
public static Activity getCurrentActivity() throws NotForegroundActivityAvailable { | ||
Validate.sdkInitialized(); | ||
Activity activity = activityLifecycle.getCurrentActivity(); | ||
if (activity!=null){ | ||
return activity; | ||
}else{ | ||
throw new NotForegroundActivityAvailable("There is not any available ActivityContext"); | ||
} | ||
} | ||
|
||
public static boolean isContextAvailable() { | ||
Validate.sdkInitialized(); | ||
return (activityLifecycle.getCurrentActivity()!=null)? true : false; | ||
} | ||
|
||
public static synchronized boolean isInitialized() { | ||
return sdkInitialized; | ||
} | ||
|
||
public static void obtainAppConfigForCheckUpdates() { | ||
Validate.sdkInitialized(); | ||
obtainAppConfig(); | ||
} | ||
|
||
public static String getToken() { | ||
Validate.sdkInitialized(); | ||
return appClientToken; | ||
} | ||
|
||
public static void continuePendingPermissionsRequestsIfPossible() { | ||
Validate.sdkInitialized(); | ||
permissionRequestManager.continuePendingPermissionsRequestsIfPossible(); | ||
} | ||
|
||
public static boolean isStoreRelease() { | ||
return isPlayStoreRelease; | ||
} | ||
|
||
public static void cleanAllStatics() { | ||
appliveryApiService = null; | ||
executor = null; | ||
applicationId = appClientToken = null; | ||
isPlayStoreRelease = isDebugEnabled = sdkInitialized = false; | ||
applicationContext = null; | ||
permissionRequestManager = null ; | ||
activityLifecycle = null; | ||
} | ||
|
||
public static class Logger { | ||
private static volatile boolean debug = isDebugEnabled; | ||
public static void log(String text){ | ||
if (debug){ | ||
Log.d(TAG, text); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.