Appearance
SDK Initialization
1. Initialization
Only after successful initialisation can you use the API provided by the SDK, otherwise the API call will fail.
API
kotlin
/**
* Initialize the mini program SDK
*
* @param application [android.app.Application] instance
* @param finAppConfig [FinAppConfig] instance, configuration
information for the mini program framework
* @param finCallback Initialization status callback interface
*/
fun init(application: Application, finAppConfig: FinAppConfig,
finCallback: FinCallback<Any?>?)
Example of a call to ####
Note
- Starting from
2.13.102
version, the FinClip mini program SDK supports the configuration of multiple server information to open mini program on several different servers at the same time, so we provide a way to configure multiple server information. - The method of initializing a single server with
Builder().setAppKey
andBuilder().setAppSecret
may be disabled in the future, so please use the multi-server initialization method in preference.
kotlin
val config = FinAppConfig.
.setAppKey("SDK Key")
.setAppSecret("SDK Secret")
Subscribe to DeepL Pro to edit this document.
Visit www.DeepL.com/profor more information.
.setApiUrl("server address")
.setApiPrefix("server interface request routing prefix")
.build()
FinAppClient.init(application, config, object : FinCallback<Any?> {
override fun onSuccess(result: Any?) {
}
override fun onProgress(status: Int, info: String?) {
}
override fun onError(code: Int, error: String?) {
}
})
java
FinAppConfig config = new FinAppConfig. Builder()
.setAppKey("SDK Key")
.setAppSecret("SDK Secret")
.setApiUrl("server address")
.setApiPrefix("server interface request route prefix")
.build();
FinAppClient. INSTANCE. init(this, config, new FinCallback< Object>() {
@Override
public void onSuccess(Object result) {
}
@Override
public void onError(int code, String error) {
Toast. makeText(SampleApplication. this, "SDK initialization
failed", Toast. LENGTH_SHORT). show();
}
@Override
public void onProgress(int status, String info) {
}
});
// Collection of server information
List< FinStoreConfig> storeConfigs = new ArrayList<>();
// Information on Server 1
FinStoreConfig storeConfig1 = new FinStoreConfig(
"SDK Key Information", // SDK Key
"SDK Secret information", // SDK Secret
"Address of server 1", // Server address
"Server 1's data upload server address", // the address of the data upload server
"/api/v1/mop/", // Server interface request routing prefix
"", // SDK fingerprint
"encryption method" // encryption method, national:SM, md5: MD5
);
storeConfigs. add(storeConfig1);
// Information on Server 2
FinStoreConfig storeConfig2 = new FinStoreConfig(
"SDK Key Information", // SDK Key
"SDK Secret information", // SDK Secret
"Address of server 2", // Server address
"Server 2's data upload server address", // the address of the data upload server
"/api/v1/mop/", // Server interface request routing prefix
"", // SDK fingerprint
"encryption method" // encryption method, national:SM, md5: MD5
);
storeConfigs. add(storeConfig2);
FinAppConfig config = new FinAppConfig. Builder()
.setFinStoreConfigs(storeConfigs) // A collection of server information
.build();
2. Configuration items
FinAppConfig configuration items
java
/**
* :: Configuration information for the mini program framework
*/
public class FinAppConfig {
/**
* sdkKey, issued through the Vantaa mini program Open Platform
*/
@NonNull
private String sdkKey = "";
/**
* :: sdkSecret, issued through the Vantaa Widget Open Platform
*/
@NonNull
private String sdkSecret = "";
/**
* :: SDK fingerprinting
*/
@NonNull
private String sdkFingerprint = "";
/**
* Server address
*/
@NonNull
private String apiUrl = "";
/**
* Data upload server address
*/
private String apmServer = "";
/**
* Server interface request routing prefix
*/
@NonNull
@Deprecated
private String apiPrefix = "";
/**
* User ID
*/
private String userId;
/**
* :: Customised product identification
*/
private String productIdentification = "";
/**
* Jwt
*/
@Deprecated
private String jwt;
/**
* Access Token
*/
@Deprecated
private String accessToken;
/**
* Is it currently in Debug mode
*/
private boolean isDebugMode;
/**
* Is jwt automatically added when Glide loads an image
*/
@Deprecated
private boolean isGlideWithJWT;
/**
* UI configuration
*/
private UIConfig uiConfig;
/**
* APM statistical extension information
*/
private Map< String, Object> apmExtendInfo;
/**
* Encryption method, cc:SM, md5: MD5
*/
@NonNull
private String encryptionType;
/*
* :: Whether the server is required to encrypt the returned data
*/
private boolean encryptServerData;
/**
* Whether to disable initiating runtime permission requests,
default no
*/
private boolean disableRequestPermissions;
/**
* Domains that require cookies to be removed
*/
private List< String> needToRemoveCookiesDomains;
/**
* Whether to disable the Tbs SDK
*/
private boolean disableTbs;
/**
* Custom WebView UserAgent
*/
private String customWebViewUserAgent;
/**
* WebView mixed content mode
*/
private int webViewMixedContentMode;
/**
* :: Number of scheduled batch updates of mini program
*/
private int appletIntervalUpdateLimit;
/**
* The maximum number of mini program that can be run simultaneously. If
more than this number of mini program are opened, the earliest opened mini program
will be recalled, but can still be reopened
*/
private int maxRunningApplet;
/**
* :: Collection of information on the configuration of the mini program
marketplace
*/
@NonNull
private List< FinStoreConfig> finStoreConfigs;
/**
* :: Whether to start foreground services when the appmini programlet is
running in the foreground
*/
private ForegroundServiceConfig foregroundServiceConfig;
/**
* :: mini program is bound to app process, app is killed, mini program is
closed simultaneously
*/
private boolean bindAppletWithMainProcess;
/**
* Text for closing the mini program after the app is killed
*/
private String killAppletProcessNotice;
/**
* mini program text, you can replace the "mini program" prompt in the sdk with
another name
*/
private String appletText;
/**
* :: Whether to compress the requested data when requesting the
back-end interface
*/
private boolean enableApmDataCompression;
/**
* Whether to disable calls to the mini program API for getting supervise
information {@link
com.finogeeks.lib.applet.api.supervise.SuperviseModule#API_GET_SUPERVIS
E_INFO}.
* Calling is allowed by default.
*/
private boolean disableGetSuperviseInfo;
/**
* Whether to automatically allow [applet level] permissions for
mini program applications
* If allowed automatically, no authorisation pop-up box will
appear on application.
*/
private boolean appletAutoAuthorize;
/**
* Whether to open the mini program vConsole debug button.
*/
private boolean enableAppletDebug;
/**
* Priority of the screen recording configuration item, default
GLOBAL
*/
private FinAppConfigPriority screenShotPriority;
/**
* Whether to allow screen recording, default
*/
private boolean enableScreenShot;
/**
* Priority of the watermark configuration item, default GLOBAL
*/
private FinAppConfigPriority watermarkPriority;
/**
* Whether to turn on watermarking, not by default
*/
private boolean enableWatermark;
/**
* Configuration of the specified mini program AppId
*/
private transient IAppletConfigFactory appletConfigFactory;
/**
* WatermarkView constructor
*/
private String watermarkFactoryClass;
/**
* Request header configuration priority
*/
private FinAppConfigPriority headerPriority;
/**
* the default header passed in by interfaces such as request
*/
private Map< String, String> header;
/**
* :: Offline subpackage package file fetching class implemented by
the host app
*/
private String offlinePackageFactoryClass;
/**
* :: mini program jump handling
*/
private transient NavigateDelegate navigateDelegate;
/**
* The maximum depth of the mini program page stack, while 0 means there
is no depth limit.
*/
private int pageCountLimit;
/**
* Minimum supported Android SDK version
*/
private int minAndroidSdkVersion = Build. VERSION_CODES. LOLLIPOP;
/**
* Logging levels
*/
private XLogLevel logLevel;
/**
* Maximum log file cache time in seconds.
*
* The minimum cannot be less than 1 day, i.e. not less than 1 * 24
* 60 * 60 seconds.
*/
private long logMaxAliveSec = -1;
/**
* XLog log file path
*/
private String xLogDir = null;
/**
* Offline mini program AccountInfo factory class
*/
private String offlineAccountInfoClass = null;
}
FinAppConfig configuration example
kotlin
val config = FinAppConfig.
.setDebugMode(true)
.setLogLevel(XLogLevel.LEVEL_VERBOSE)
.setEnableAppletDebug(true)
.setUiConfig(uiConfig)
.setApmExtendInfo(apmExtendInfo)
.setDisableRequestPermissions(false)
.setNeedToRemoveCookiesDomains(listOf(""))
.setDisableTbs(false)
.setAppletIntervalUpdateLimit(3)
.setMaxRunningApplet(5)
.setPageCountLimit(5)
.setBindAppletWithMainProcess(true)
.setWebViewMixedContentMode(MIXED_CONTENT_NEVER_ALLOW)
.setFinStoreConfigs(finStoreConfigs)
.setEnableApmDataCompression(true)
.setDisableGetSuperviseInfo(true)
.setCustomWebViewUserAgent("android 7.1.1")
.setUserId("13286836062")
.setProductIdentification("happy")
.setMinAndroidSdkVersion(Build.VERSION_CODES.LOLLIPOP)
.build()
FinAppClient.init(application, config, object :
FinCallback<Any?> {
setProductIdentification is used by key after version 2.38.0, it should be noted that blank characters and special characters cannot be used in productIdentification, when setProductIdentification is used for When you use setProductIdentification to customize the product identification, you need to customize the paths file, take the ProductIdentification value of happy as an example, add a new xml file named fin_applet_custom_provider_paths in the res/xml path, the file name cannot be changed. The content of the file is as follows.
xml<! -- The file name must be fin_applet_custom_provider_paths.xml, for same-name replacement --/> <?xml version="1.0" encoding="utf-8"? > <paths xmlns:android="http://schemas.android.com/apk/res/android"> <files-path name="happy_uri" path="happy" /> </paths>
After the above settings, a file with the path /internal storeage/packageName/files/happy/hello.jpg has a corresponding uri of content://com.finogeeks.finosprite.applet.provider/ happy_uri/hello.jpg.
UIConfig configuration items
java
/**
* :: UI configuration
*/
public static class UIConfig {
/**
* Whether the back button is always displayed when the
navigation bar is the default navigation bar
*/
private boolean isAlwaysShowBackInDefaultNavigationBar;
/**
* Gravity of the navigation bar title relative to the parent
control
*/
private int navigationBarTitleTextLayoutGravity = Gravity;
/**
* Navigation bar header text style
*/
@StyleRes
private int navigationBarTitleTextAppearance;
/**
* Whether to clear the background of the navigation buttons in
the navigation bar
*/
private boolean isClearNavigationBarNavButtonBackground;
/**
* :: Whether to hide the "Feedback & Complaints" menu entry in
the "More" menu
*/
private boolean isHideFeedbackAndComplaints;
/**
* Whether to hide the "Back to Home" button on the navigation
bar
*/
private boolean isHideBackHome;
/**
* Priority of the "Back to Home" button configuration item on
the navigation bar, default GLOBAL
*/
private FinAppConfigPriority isHideBackHomePriority =
FinAppConfigPriority. global;
/**
* Whether to hide the "Forward" button in the "More" menu
*/
private boolean isHideForwardMenu;
/**
* Whether to hide the "Settings" button in the "More" menu
*/
private boolean isHideSettingMenu;
/**
* :: Whether to hide the "Re-enter mini program" button in the
"More" menu
*/
private boolean isHideRefreshMenu;
/**
* :: Whether to hide the close button in the navigation bar
during the loading of the mini program (the mini program service layer has
not yet been loaded successfully and the base library has not yet
passed the mini program configuration information to the SDK)
*/
private boolean hideTransitionCloseButton;
/**
* :: Disable the side-swipe close mini program gesture
*/
private boolean disableSlideCloseAppletGesture;
/**
* "More" menu style
*/
@MoreMenuStyle
private int moreMenuStyle;
/**
* Capsule button configuration
*/
private CapsuleConfig capsuleConfig = new CapsuleConfig();
private FloatWindowConfig floatWindowConfig = new
FloatWindowConfig();
/**
* Loading page callback Class
*/
private String loadingLayoutCls;
/**
* :: Dark mode
*/
private boolean autoAdaptDarkMode;
/**
* Navigation bar back to home button configuration
*/
private NavHomeConfig navHomeConfig = new NavHomeConfig();
}
UiConfig configuration example
val uiConfig = UIConfig()
uiConfig.isHideBackHome = true
uiConfig.isHideForwardMenu = false
uiConfig.isHideFeedbackAndComplaints = false
uiConfig.isHideSettingMenu = false
uiConfig.navigationBarTitleTextAppearance
uiConfig.moreMenuStyle = UIConfig.MORE_MENU_DEFAULT
val config = FinAppConfig.
.setUiConfig(uiConfig)
CapsuleConfig configuration items
kotlin
val uiConfig = UIConfig()
uiConfig.setCapsuleConfig(CapsuleConfig())
Capsule configuration properties
java
public static class CapsuleConfig {
/**
* The width of the capsule view in the top right corner, the
default value is 88
*
*/
public float capsuleWidth = 88;
/**
* The height of the capsule view in the top right corner, the
default value is 32
*
*/
public float capsuleHeight = 32;
/**
* Right distance from top right capsule view
*/
public float capsuleRightMargin = 7;
/**
* The radius of the rounded corners of the capsule view in the
upper right corner, the default value is 5
*
*/
public float capsuleCornerRadius = 5;
/**
* The width of the border of the capsule view in the top right
corner, the default value is 0.8
*
*/
public float capsuleBorderWidth = 1f;
/**
* Capsule background colour light
*/
public int capsuleBgLightColor = 0x33000000;
/**
* Capsule background colour dark
*/
public int capsuleBgDarkColor = 0x80ffffff;
/**
* Lighter colour for the border of the capsule view in the top
right corner
*
*/
public int capsuleBorderLightColor = 0x80ffffff;
/**
* Dark colour of the border of the capsule view in the top
right corner
*
*/
public int capsuleBorderDarkColor = 0x26000000;
/**
* Capsule divider light colour
*/
public int capsuleDividerLightColor = 0x80ffffff;
/**
* Capsule divider dark colour
*/
public int capsuleDividerDarkColor = 0x26000000;
/**
* Image object of the light-coloured more button in the
capsule, if not passed, the default icon will be used
*
*/
public int moreLightImage = R. drawable. miniapps_more_light;
/**
* Image object for the darker more buttons in the capsule, if
not passed, the default icon will be used
*
*/
public int moreDarkImage = R. drawable. miniapps_more_dark;
/**
* More buttons in the capsule with a width equal to the height
*
*/
public float moreBtnWidth = 32;
/**
* Left margin of the More button in the capsule
*
*/
public float moreBtnLeftMargin = 6;
/**
* Image object of the light-coloured more button in the
capsule, if not passed, the default icon will be used
*
*/
public int closeLightImage = R. drawable. miniapps_close_light;
/**
* Image object for the darker more buttons in the capsule, if
not passed, the default icon will be used
*
*/
public int closeDarkImage = R. drawable. miniapps_close_dark;
/**
* Width of the close button in the capsule, equal in height to
width
*
*/
public float closeBtnWidth = 32;
/**
* Left distance of the close button in the capsule
*
*/
public float closeBtnLeftMargin = 6;
}
Example of a configuration capsule
kotlin
uiConfig.capsuleConfig.apply {
capsuleWidth = 86f
capsuleHeight = 31f
capsuleRightMargin = 15f
capsuleCornerRadius = 15.5f
capsuleBorderWidth = 0.5f
capsuleBgLightColor = Color.TRANSPARENT
capsuleBgDarkColor = Color.TRANSPARENT
capsuleBorderLightColor = Color.parseColor("#88ffffff")
capsuleBorderDarkColor = Color.parseColor("#a5a9b4")
moreLightImage = R.drawable.more_light
moreDarkImage = R.drawable.more_dark
moreBtnWidth = 25f
moreBtnLeftMargin = 11f
closeLightImage = R.drawable.close_light
closeDarkImage = R.drawable.close_dark
closeBtnWidth = 25f
closeBtnLeftMargin = 9f
capsuleDividerLightColor = Color.parseColor("#88ffffff")
capsuleDividerDarkColor = Color.parseColor("#a5a9b4")
}
NavHomeConfig configuration items
kotlin
val uiConfig = UIConfig()
uiConfig.setNavHomeConfig(NavHomeConfig())
The current conditions for the Back to Home button to appear are (subject to both being met).
the default navigation bar style (not custom) is used.
Not the home page or tabbar page (as defined in app.json).
is the bottom page of the page stack.
mini program can call hideHomeButton() in onShow to manually hide the Back Home button.
Navigation bar back to home button style attributes
java
public static class NavHomeConfig {
/**
* Light icon for the navigation bar back to home button, if not
passed, the default icon will be used
*/
public int lightImage = R. drawable. miniapps_home_light;
/**
* Light icon for the navigation bar back to home button, if not
passed, the default icon will be used
*/
public int darkImage = R. drawable. miniapps_home_dark;
/**
* Back to home button width, default 44
*/
public float width = 44;
/**
* Back to home button height, default 32
*/
public float height = 32;
/**
* Left margin of the Back to Home button, default 7
*/
public float leftMargin = 7;
/**
* Home button border rounding radius, default 5
*/
public float cornerRadius = 5;
/**
* Back to home button border width, default 1
*/
public float borderWidth = 1;
/**
* Back to home button light border colour, default 0X80FFFFFF
*/
public int borderLightColor = 0x80ffffff;
/**
* Back to home button dark border colour, default 0X26000000
*/
public int borderDarkColor = 0x26000000;
/**
* Back to home button light background, default 0x33000000
*/
public int bgLightColor = 0x33000000;
/**
* Back to home button dark background, default 0x33000000
*/
public int bgDarkColor = 0x80ffffff;
}
Example of configuring the back button style for the navigation
bar
kotlin
uiConfig.navHomeConfig.apply {
width = 43f
height = 31f
leftMargin = 15f
cornerRadius = 15.5f
borderWidth = 0.5f
bgLightColor = Color.TRANSPARENT
bgDarkColor = Color.TRANSPARENT
borderLightColor = Color.parseColor("#88ffffff")
borderDarkColor = Color.parseColor("#a5a9b4")
lightImage = R.drawable.home_light
darkImage = R.drawable.home_dark
}
Configure mini program to run in floating windows
On some large screen devices, the mini program can be configured to run as a floating window. When running as a floating window, the mini program is fixed in vertical mode, the position and size of the floating window can be configured, and the pages below the floating window are not interactive // After setting the hover mode, override FinAppletTheme to FinAppletTranslucentTheme in sample styles.xml at the same time
xml
<! -- Hover mode needs to override FinAppletTheme theme as
FinAppletTranslucentTheme -->
< style name="FinAppletTheme" parent="@style/FinAppletTranslucentTheme"
/>
Introduction to floating window configuration properties
kotlin
public static class FloatWindowConfig {
public boolean floatMode = true;
public int x;
public int y;
public int width;
public int height;
}
Example of a floating window configuration
kotlin
uiConfig.floatWindowConfig.apply {
floatMode = true
width = 800
height = 1400
x = application.screenWidth() / 2 - width / 2
y = application.screenHeight() / 2 - height / 2
}
Set the maximum number of mini program that can be run
This interface allows you to set the maximum number of mini program that can be run. When more mini program are opened than the maximum number, the first opened mini program will be recycled.
Note
The maximum number of runnable mini program is 5 by default and can be set in the range 1-5, numbers set <=0 or >5 do not take effect
kotlin
val config = FinAppConfig.
.setSdkKey("SDK Key")
.setSdkSecret("SDK Secret")
.setMaxRunningApplet(3) // set the maximum number of mini program that
can be run
.build()
FinAppClient.init(application, config, object : FinCallback<Any?> {})
Set up foreground services to keep the app running
When the mini program is opened, the app enters the background and runs. At this point the app may be killed by the system. It can be configured to keep the app running without being killed by the system by starting a foreground service
kotlin
val config = FinAppConfig.
.setSdkKey(BuildConfig.SDK_KEY)
.setSdkSecret(BuildConfig.SDK_SECRET)
.setForegroundServiceConfig(
FinAppConfig.ForegroundServiceConfig(
true, //whether to enable frontend services
R.drawable.ic_launcher, //icon for frontend services
"mini program is running", // title of the foreground service
"",
notificationChannelId, // notificationChannelId
notificationChannelName, // the name of the notification
channel
notificationChannelDesc, // Introduction to the
notification channel
)
)
.build()
FinAppClient.init(application, config, object : FinCallback<Any?> {})
Set the mini program process to close when the main process closes
By default, mini program can still run independently when the main app process is closed. This can be combined with the mini program process being closed when the app process is closed or killed
kotlin
val config = FinAppConfig.
.setSdkKey(BuildConfig.SDK_KEY)
.setSdkSecret(BuildConfig.SDK_SECRET)
.setBindAppletWithMainProcess(true) //when the main
process is closed the mini program process is also closed
.setKillAppletProcessNotice("The APP has been closed,
the mini program cannot be used alone, please reopen the APP before using the
mini program.")
.build()
FinAppClient.init(application, config, object : FinCallback<Any?> {})
Configure mini program debug mode
val config = FinAppConfig.
// Other configuration items omitted
.setEnableAppletDebug(true)
.build()
FinAppClient.init(application, config, object : FinCallback<Any?> {})
Whether to enable global mini program debug mode, set to true and all mini program will show vconsole, if set to false, debug mode can be enabled for development, experience and IDE preview versions via the debug button in the more menu