Fix AppCenter SDK

This commit is contained in:
Grishka 2022-02-19 03:04:04 +03:00
parent c382668049
commit f4e71cf130
4 changed files with 15 additions and 7 deletions

View File

@ -10,7 +10,7 @@ android {
applicationId "org.joinmastodon.android"
minSdk 23
targetSdk 31
versionCode 2
versionCode 3
versionName "0.1"
}
@ -23,7 +23,8 @@ android {
debuggable true
}
appcenterPrivateBeta{
initWith debug
initWith release
minifyEnabled false
versionNameSuffix "-priv-beta"
}
appcenterPublicBeta{

View File

@ -12,6 +12,8 @@ public class AppCenterWrapper{
private static final String TAG="AppCenterWrapper";
public static void init(Application app){
if(AppCenter.isConfigured())
return;
Log.i(TAG, "initializing AppCenter SDK, build type is "+BuildConfig.BUILD_TYPE);
if(BuildConfig.BUILD_TYPE.equals("appcenterPrivateBeta"))

View File

@ -1,11 +1,14 @@
package org.joinmastodon.android;
import android.app.Application;
import android.os.Bundle;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.fragments.HomeFragment;
import org.joinmastodon.android.fragments.SplashFragment;
import java.lang.reflect.InvocationTargetException;
import androidx.annotation.Nullable;
import me.grishka.appkit.FragmentStackActivity;
@ -26,5 +29,12 @@ public class MainActivity extends FragmentStackActivity{
showFragmentClearingBackStack(fragment);
}
}
if(BuildConfig.BUILD_TYPE.startsWith("appcenter")){
// 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, getApplication());
}catch(ClassNotFoundException|NoSuchMethodException|IllegalAccessException|InvocationTargetException ignore){}
}
}
}

View File

@ -23,10 +23,5 @@ public class MastodonApp extends Application{
ImageCache.setParams(params);
NetworkUtils.setUserAgent("MastodonAndroid/"+BuildConfig.VERSION_NAME);
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){}
}
}