集成最新稳定版sdk
parent
63776a96ef
commit
86d3e6ab2e
|
@ -5,15 +5,25 @@ android {
|
|||
buildToolsVersion "29.0.2"
|
||||
defaultConfig {
|
||||
applicationId "com.finogeeks.mop.demo"
|
||||
minSdkVersion 26
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
multiDexEnabled true
|
||||
|
||||
buildConfigField "String", "APP_KEY", "\"22LyZEib0gLTQdU3MUauAVUHSFDdTToYDWCqr0AgPGwA\""
|
||||
// App Secret
|
||||
buildConfigField "String", "APP_SECRET", "\"8c5c3c26420b7e66\""
|
||||
// API服务地址
|
||||
buildConfigField "String", "API_URL", "\"https://mp.finogeeks.com\""
|
||||
// API服务前缀
|
||||
buildConfigField "String", "API_PREFIX", "\"/api/v1/mop/\""
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
@ -21,16 +31,22 @@ android {
|
|||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
packagingOptions {
|
||||
// libsdkcore.so是被加固过的,不能被压缩,否则加载动态库时会报错
|
||||
doNotStrip "*/x86/libsdkcore.so"
|
||||
doNotStrip "*/x86_64/libsdkcore.so"
|
||||
doNotStrip "*/armeabi-v7a/libsdkcore.so"
|
||||
doNotStrip "*/arm64-v8a/libsdkcore.so"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
|
||||
implementation 'com.google.android.material:material:1.2.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||
implementation 'com.finogeeks.lib:finapplet:+'
|
||||
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
implementation 'com.finogeeks.lib:finapplet:2.11.13'
|
||||
}
|
|
@ -19,3 +19,5 @@
|
|||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
||||
-keep class com.finogeeks.** {*;}
|
|
@ -3,11 +3,13 @@
|
|||
package="com.finogeeks.mop.demo">
|
||||
|
||||
<application
|
||||
android:name=".MopApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
|
@ -19,5 +21,4 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -1,124 +1,36 @@
|
|||
package com.finogeeks.mop.demo;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.finogeeks.lib.applet.client.FinAppClient;
|
||||
import com.finogeeks.lib.applet.client.FinAppConfig;
|
||||
import com.finogeeks.lib.applet.interfaces.FinCallback;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import android.widget.Button;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
import com.finogeeks.lib.applet.client.FinAppClient;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (FinAppClient.INSTANCE.isFinAppProcess(this)) {
|
||||
return;
|
||||
}
|
||||
setContentView(R.layout.activity_main);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
FinAppConfig config = new FinAppConfig.Builder()
|
||||
.setAppKey("22LyZEib0gLTQdU3MUauAVUHSFDdTToYDWCqr0AgPGwA")
|
||||
.setAppSecret("8c5c3c26420b7e66")
|
||||
.setApiUrl("https://mp.finogeeks.com")
|
||||
.setApiPrefix("/api/v1/mop")
|
||||
.setGlideWithJWT(false)
|
||||
.build();
|
||||
// SDK初始化结果回调,用于接收SDK初始化状态
|
||||
FinCallback<Object> callback = new FinCallback<Object>() {
|
||||
@Override
|
||||
public void onSuccess(Object result) {
|
||||
// SDK初始化成功
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String error) {
|
||||
// SDK初始化失败
|
||||
Toast.makeText(MainActivity.this, "SDK初始化失败", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(int status, String error) {
|
||||
|
||||
}
|
||||
};
|
||||
FinAppClient.INSTANCE.init(this.getApplication(), config, callback);
|
||||
Button canvasButton = findViewById(R.id.btnCanvas);
|
||||
Button demoButton = findViewById(R.id.btnDemo);
|
||||
Button profileButton = findViewById(R.id.btnProfile);
|
||||
canvasButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FinAppClient.INSTANCE.getAppletApiManager().startApplet(MainActivity.this, "5ea03fa563cb900001d73863",
|
||||
new HashMap(){
|
||||
{
|
||||
put("path","/pages/index/index");
|
||||
}
|
||||
});
|
||||
}
|
||||
canvasButton.setOnClickListener(v -> {
|
||||
Map<String, String> startParams = new HashMap<>();
|
||||
startParams.put("path", "/pages/index/index");
|
||||
FinAppClient.INSTANCE.getAppletApiManager().startApplet(MainActivity.this, "5e3c147a188211000141e9b1", startParams);
|
||||
});
|
||||
|
||||
demoButton.setOnClickListener(new View.OnClickListener() {
|
||||
demoButton.setOnClickListener(v -> FinAppClient.INSTANCE.getAppletApiManager().startApplet(MainActivity.this, "5e4d123647edd60001055df1"));
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FinAppClient.INSTANCE.getAppletApiManager().startApplet(MainActivity.this, "5ea0401463cb900001d73865");
|
||||
}
|
||||
});
|
||||
|
||||
profileButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FinAppClient.INSTANCE.getAppletApiManager().startApplet(MainActivity.this, "5ea0412663cb900001d73867");
|
||||
}
|
||||
});
|
||||
|
||||
// FloatingActionButton fab = findViewById(R.id.fab);
|
||||
// fab.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(MainActivity.this, "5e3c147a188211000141e9b1");
|
||||
//
|
||||
//// Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
||||
//// .setAction("Action", null).show();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
profileButton.setOnClickListener(v -> FinAppClient.INSTANCE.getAppletApiManager().startApplet(MainActivity.this, "5f3e1c9d8d4295000144d400"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.finogeeks.mop.demo;
|
||||
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.multidex.MultiDexApplication;
|
||||
|
||||
import com.finogeeks.lib.applet.client.FinAppClient;
|
||||
import com.finogeeks.lib.applet.client.FinAppConfig;
|
||||
import com.finogeeks.lib.applet.interfaces.FinCallback;
|
||||
|
||||
public class MopApplication extends MultiDexApplication {
|
||||
|
||||
private static final String TAG = "SampleApplication";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
if (FinAppClient.INSTANCE.isFinAppProcess(this)) {
|
||||
// 小程序进程不执行任何初始化操作
|
||||
return;
|
||||
}
|
||||
|
||||
FinAppConfig.UIConfig uiConfig = new FinAppConfig.UIConfig();
|
||||
uiConfig.setHideNavigationBarCloseButton(true);
|
||||
FinAppConfig config = new FinAppConfig.Builder()
|
||||
.setAppKey(BuildConfig.APP_KEY)
|
||||
.setAppSecret(BuildConfig.APP_SECRET)
|
||||
.setApiUrl(BuildConfig.API_URL)
|
||||
.setApiPrefix(BuildConfig.API_PREFIX)
|
||||
.setDebugMode(BuildConfig.DEBUG)
|
||||
.setGlideWithJWT(false)
|
||||
.setUiConfig(uiConfig)
|
||||
.setEncryptionType(FinAppConfig.ENCRYPTION_TYPE_SM)
|
||||
.build();
|
||||
|
||||
FinAppClient.INSTANCE.init(this, config, new FinCallback<Object>() {
|
||||
@Override
|
||||
public void onSuccess(Object result) {
|
||||
Log.d(TAG, "init result : " + result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String error) {
|
||||
Toast.makeText(MopApplication.this, "SDK初始化失败", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(int status, String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -3,8 +3,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -20,14 +19,6 @@
|
|||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:srcCompat="@android:drawable/ic_dialog_email" />
|
||||
|
||||
<include layout="@layout/content_main" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
13
build.gradle
13
build.gradle
|
@ -4,25 +4,14 @@ buildscript {
|
|||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven {
|
||||
url "https://gradle.finogeeks.club/repository/applet/"
|
||||
credentials {
|
||||
username "applet"
|
||||
password "123321"
|
||||
}
|
||||
}
|
||||
maven { url "https://jitpack.io" }
|
||||
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.60"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
allprojects {
|
||||
|
|
Loading…
Reference in New Issue