Add AppCenter SDK
This commit is contained in:
parent
6a35d78f99
commit
006fde1686
|
@ -6,7 +6,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "com.android.tools.build:gradle:7.0.4"
|
classpath "com.android.tools.build:gradle:7.0.4"
|
||||||
|
classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1"
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.android.application'
|
id 'com.android.application'
|
||||||
|
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
@ -10,7 +11,7 @@ android {
|
||||||
minSdk 23
|
minSdk 23
|
||||||
targetSdk 31
|
targetSdk 31
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "0.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -18,12 +19,31 @@ android {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
|
debug{
|
||||||
|
debuggable true
|
||||||
|
}
|
||||||
|
appcenterPrivateBeta{
|
||||||
|
initWith debug
|
||||||
|
versionNameSuffix "-priv-beta"
|
||||||
|
}
|
||||||
|
appcenterPublicBeta{
|
||||||
|
initWith release
|
||||||
|
versionNameSuffix "-beta"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_15
|
sourceCompatibility JavaVersion.VERSION_15
|
||||||
targetCompatibility JavaVersion.VERSION_15
|
targetCompatibility JavaVersion.VERSION_15
|
||||||
coreLibraryDesugaringEnabled true
|
coreLibraryDesugaringEnabled true
|
||||||
}
|
}
|
||||||
|
sourceSets{
|
||||||
|
appcenterPrivateBeta{
|
||||||
|
setRoot "src/appcenter"
|
||||||
|
}
|
||||||
|
appcenterPublicBeta{
|
||||||
|
setRoot "src/appcenter"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -43,4 +63,10 @@ dependencies {
|
||||||
implementation 'org.parceler:parceler-api:1.1.12'
|
implementation 'org.parceler:parceler-api:1.1.12'
|
||||||
annotationProcessor 'org.parceler:parceler:1.1.12'
|
annotationProcessor 'org.parceler:parceler:1.1.12'
|
||||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
|
||||||
|
|
||||||
|
def appCenterSdkVersion = "4.4.2"
|
||||||
|
appcenterPrivateBetaImplementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
|
||||||
|
appcenterPrivateBetaImplementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}"
|
||||||
|
appcenterPublicBetaImplementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
|
||||||
|
appcenterPublicBetaImplementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}"
|
||||||
}
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.joinmastodon.android;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.microsoft.appcenter.AppCenter;
|
||||||
|
import com.microsoft.appcenter.crashes.Crashes;
|
||||||
|
import com.microsoft.appcenter.distribute.Distribute;
|
||||||
|
import com.microsoft.appcenter.distribute.UpdateTrack;
|
||||||
|
|
||||||
|
public class AppCenterWrapper{
|
||||||
|
private static final String TAG="AppCenterWrapper";
|
||||||
|
|
||||||
|
public static void init(Application app){
|
||||||
|
Log.i(TAG, "initializing AppCenter SDK, build type is "+BuildConfig.BUILD_TYPE);
|
||||||
|
|
||||||
|
if(BuildConfig.BUILD_TYPE.equals("appcenterPrivateBeta"))
|
||||||
|
Distribute.setUpdateTrack(UpdateTrack.PRIVATE);
|
||||||
|
AppCenter.start(app, BuildConfig.appCenterKey, Distribute.class, Crashes.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,8 @@ import android.annotation.SuppressLint;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
import me.grishka.appkit.imageloader.ImageCache;
|
import me.grishka.appkit.imageloader.ImageCache;
|
||||||
import me.grishka.appkit.utils.NetworkUtils;
|
import me.grishka.appkit.utils.NetworkUtils;
|
||||||
|
|
||||||
|
@ -21,5 +23,10 @@ public class MastodonApp extends Application{
|
||||||
ImageCache.setParams(params);
|
ImageCache.setParams(params);
|
||||||
NetworkUtils.setUserAgent("MastodonAndroid/"+BuildConfig.VERSION_NAME);
|
NetworkUtils.setUserAgent("MastodonAndroid/"+BuildConfig.VERSION_NAME);
|
||||||
context=getApplicationContext();
|
context=getApplicationContext();
|
||||||
|
|
||||||
|
// Call the appcenter SDK wrapper through reflection because it is only present in beta builds
|
||||||
|
try{
|
||||||
|
Class.forName("org.joinmastodon.android.AppCenterWrapper").getMethod("init", Application.class).invoke(null, this);
|
||||||
|
}catch(ClassNotFoundException|NoSuchMethodException|IllegalAccessException|InvocationTargetException ignore){}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue