diff --git a/app/build.gradle b/app/build.gradle index ca5548e..f21eb7b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index f1b4245..cf19ffb 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -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.** {*;} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5f75326..e8521d7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,11 +3,13 @@ package="com.finogeeks.mop.demo"> + - \ No newline at end of file diff --git a/app/src/main/java/com/finogeeks/mop/demo/MainActivity.java b/app/src/main/java/com/finogeeks/mop/demo/MainActivity.java index dae407c..81d18eb 100644 --- a/app/src/main/java/com/finogeeks/mop/demo/MainActivity.java +++ b/app/src/main/java/com/finogeeks/mop/demo/MainActivity.java @@ -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 callback = new FinCallback() { - @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 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(); -// } -// }); + profileButton.setOnClickListener(v -> FinAppClient.INSTANCE.getAppletApiManager().startApplet(MainActivity.this, "5f3e1c9d8d4295000144d400")); } - - @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); - } -} +} \ No newline at end of file diff --git a/app/src/main/java/com/finogeeks/mop/demo/MopApplication.java b/app/src/main/java/com/finogeeks/mop/demo/MopApplication.java new file mode 100644 index 0000000..b94b0ac --- /dev/null +++ b/app/src/main/java/com/finogeeks/mop/demo/MopApplication.java @@ -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() { + @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) { + + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index b9a02d1..76fc81e 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -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"> - - \ No newline at end of file diff --git a/build.gradle b/build.gradle index a2753c6..470eb60 100644 --- a/build.gradle +++ b/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 { @@ -43,4 +32,4 @@ allprojects { task clean(type: Delete) { delete rootProject.buildDir -} +} \ No newline at end of file