Skip to content

Commit e0f517e

Browse files
author
刘伟强
committed
Merge branch 'zw_feature_id3' into 'master'
[feature]适配 IDM3 SDK-5921 See merge request sensors-analytics/sdk/sensors_analytics_flutter_plugin!24
2 parents be563ad + 3f74b85 commit e0f517e

File tree

22 files changed

+277
-178
lines changed

22 files changed

+277
-178
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ android {
3333
}
3434

3535
dependencies {
36-
api 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:6.5.1'
36+
api 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:6.5.4'
3737
//implementation 'org.json:json:20220320'
3838
}

android/src/main/java/com/sensorsdata/analytics/sensorsanalyticsflutterplugin/SensorsAnalyticsFlutterPlugin.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import androidx.annotation.NonNull;
77

8-
import com.sensorsdata.analytics.android.sdk.PropertyBuilder;
98
import com.sensorsdata.analytics.android.sdk.SAConfigOptions;
109
import com.sensorsdata.analytics.android.sdk.SALog;
1110
import com.sensorsdata.analytics.android.sdk.SensorsDataAPI;
@@ -181,6 +180,15 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
181180
case "init":
182181
startWithConfig(list, result);
183182
break;
183+
case "bind":
184+
bind(list, result);
185+
break;
186+
case "unbind":
187+
unbind(list, result);
188+
break;
189+
case "loginWithKey":
190+
loginWithKey(list, result);
191+
break;
184192
default:
185193
result.notImplemented();
186194
break;
@@ -608,6 +616,40 @@ public void properties(SAPropertiesFetcher fetcher) {
608616
result.success(null);
609617
}
610618

619+
private void bind(List list, Result result) {
620+
try {
621+
String key = (String) list.get(0);
622+
String value = (String) list.get(1);
623+
SensorsDataAPI.sharedInstance().bind(key, value);
624+
result.success(null);
625+
} catch (Exception e) {
626+
SALog.printStackTrace(e);
627+
}
628+
}
629+
630+
private void unbind(List list, Result result) {
631+
try {
632+
String key = (String) list.get(0);
633+
String value = (String) list.get(1);
634+
SensorsDataAPI.sharedInstance().unbind(key, value);
635+
result.success(null);
636+
} catch (Exception e) {
637+
SALog.printStackTrace(e);
638+
}
639+
}
640+
641+
private void loginWithKey(List list, Result result) {
642+
try {
643+
String key = (String) list.get(0);
644+
String value = (String) list.get(1);
645+
JSONObject properties = assertProperties2(list.get(2));
646+
SensorsDataAPI.sharedInstance().loginWithKey(key, value, properties);
647+
result.success(null);
648+
} catch (Exception e) {
649+
SALog.printStackTrace(e);
650+
}
651+
}
652+
611653
private JSONObject assertProperties(Map map) {
612654
if (map != null) {
613655
return new JSONObject(map);

example/.metadata

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# This file tracks properties of this Flutter project.
22
# Used by Flutter tool to assess capabilities and perform upgrades etc.
33
#
4-
# This file should be version controlled and should not be manually edited.
4+
# This file should be version controlled.
55

66
version:
7-
revision: f7a6a7906be96d2288f5d63a5a54c515a6e987fe
7+
revision: eb6d86ee27deecba4a83536aa20f366a6044895c
88
channel: stable
99

1010
project_type: app

example/analysis_options.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at
17+
# https://dart-lang.github.io/linter/lints/index.html.
18+
#
19+
# Instead of disabling a lint rule for the entire project in the
20+
# section below, it can also be suppressed for a single line of code
21+
# or a specific dart file by using the `// ignore: name_of_lint` and
22+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
23+
# producing the lint.
24+
rules:
25+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
26+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27+
28+
# Additional information about this file can be found at
29+
# https://dart.dev/guides/language/analysis-options

example/android/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ gradle-wrapper.jar
55
/gradlew.bat
66
/local.properties
77
GeneratedPluginRegistrant.java
8+
9+
# Remember to never publicly share your keystore.
10+
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11+
key.properties
12+
**/*.keystore
13+
**/*.jks

example/android/app/build.gradle

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,33 @@ if (flutterVersionName == null) {
2222
}
2323

2424
apply plugin: 'com.android.application'
25+
apply plugin: 'kotlin-android'
2526
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2627

2728
android {
28-
compileSdkVersion 28
29+
compileSdkVersion flutter.compileSdkVersion
30+
ndkVersion flutter.ndkVersion
2931

30-
lintOptions {
31-
disable 'InvalidPackage'
32+
compileOptions {
33+
sourceCompatibility JavaVersion.VERSION_1_8
34+
targetCompatibility JavaVersion.VERSION_1_8
35+
}
36+
37+
kotlinOptions {
38+
jvmTarget = '1.8'
39+
}
40+
41+
sourceSets {
42+
main.java.srcDirs += 'src/main/kotlin'
3243
}
3344

3445
defaultConfig {
3546
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
36-
applicationId "com.sensorsdata.analytics.sensorsanalyticsflutterplugin_example"
37-
minSdkVersion 16
38-
targetSdkVersion 28
47+
applicationId "cn.sensorsdata.example"
48+
// You can update the following values to match your application needs.
49+
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
50+
minSdkVersion flutter.minSdkVersion
51+
targetSdkVersion flutter.targetSdkVersion
3952
versionCode flutterVersionCode.toInteger()
4053
versionName flutterVersionName
4154
}
@@ -45,11 +58,14 @@ android {
4558
// TODO: Add your own signing config for the release build.
4659
// Signing with the debug keys for now, so `flutter run --release` works.
4760
signingConfig signingConfigs.debug
48-
4961
}
5062
}
5163
}
5264

5365
flutter {
5466
source '../..'
5567
}
68+
69+
dependencies {
70+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
71+
}

example/android/app/src/debug/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.sensorsdata.analytics.sensorsanalyticsflutterplugin_example">
3-
<!-- Flutter needs it to communicate with the running application
2+
package="cn.sensorsdata.example">
3+
<!-- The INTERNET permission is required for development. Specifically,
4+
the Flutter tool needs it to communicate with the running application
45
to allow setting breakpoints, to provide hot reload, etc.
56
-->
67
<uses-permission android:name="android.permission.INTERNET"/>
Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.sensorsdata.analytics.sensorsanalyticsflutterplugin_example">
3-
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
4-
calls FlutterMain.startInitialization(this); in its onCreate method.
5-
In most cases you can leave this as-is, but you if you want to provide
6-
additional functionality it is fine to subclass or reimplement
7-
FlutterApplication and put your custom class here. -->
8-
9-
10-
<uses-permission android:name="android.permission.INTERNET"/>
11-
12-
<application
13-
android:name=".App"
14-
android:label="sensorsanalyticsflutterplugin_example"
2+
package="cn.sensorsdata.example">
3+
<application
4+
android:label="example"
5+
android:name="${applicationName}"
156
android:icon="@mipmap/ic_launcher">
167
<activity
178
android:name=".MainActivity"
9+
android:exported="true"
1810
android:launchMode="singleTop"
1911
android:theme="@style/LaunchTheme"
2012
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
@@ -28,15 +20,6 @@
2820
android:name="io.flutter.embedding.android.NormalTheme"
2921
android:resource="@style/NormalTheme"
3022
/>
31-
<!-- Displays an Android View that continues showing the launch screen
32-
Drawable until Flutter paints its first frame, then this splash
33-
screen fades out. A splash screen is useful to avoid any visual
34-
gap between the end of Android's launch screen and the painting of
35-
Flutter's first frame. -->
36-
<meta-data
37-
android:name="io.flutter.embedding.android.SplashScreenDrawable"
38-
android:resource="@drawable/launch_background"
39-
/>
4023
<intent-filter>
4124
<action android:name="android.intent.action.MAIN"/>
4225
<category android:name="android.intent.category.LAUNCHER"/>
@@ -47,9 +30,5 @@
4730
<meta-data
4831
android:name="flutterEmbedding"
4932
android:value="2" />
50-
51-
<meta-data
52-
android:name="com.sensorsdata.analytics.android.EnableLogging"
53-
android:value="true" />
5433
</application>
5534
</manifest>

example/android/app/src/main/java/com/sensorsdata/analytics/sensorsanalyticsflutterplugin_example/App.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

example/android/app/src/main/java/com/sensorsdata/analytics/sensorsanalyticsflutterplugin_example/MainActivity.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)