Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
weiqiangliu
committed
Nov 18, 2022
1 parent
5d740c0
commit 5251614
Showing
14 changed files
with
286 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 2.3.0 | ||
|
||
* 支持 Flutter 项目可视化全埋点及自定义属性 | ||
|
||
## 2.2.2 | ||
|
||
* 新增接口 bind、unbind、loginWithKey | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
.../src/main/java/com/sensorsdata/analytics/sensorsanalyticsflutterplugin/FlutterVisual.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.sensorsdata.analytics.sensorsanalyticsflutterplugin; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.IntentFilter; | ||
|
||
import com.sensorsdata.analytics.android.sdk.SALog; | ||
|
||
import io.flutter.plugin.common.MethodChannel; | ||
|
||
public class FlutterVisual { | ||
private static final String TAG = "SA.FlutterVisual"; | ||
private final DynamicReceiver mDynamicReceiver; | ||
private MethodChannel mMethodChannel; | ||
private static final String FLUTTER_ACTION = "android.intent.action.FLUTTER_VISUALIZED"; | ||
private static final String FLUTTER_EXTRA = "visualizedChanged"; | ||
private volatile boolean isRegister = false; | ||
private static volatile FlutterVisual mFlutterVisual; | ||
|
||
private FlutterVisual() { | ||
mDynamicReceiver = new DynamicReceiver(); | ||
} | ||
|
||
public static FlutterVisual getInstance() { | ||
if (mFlutterVisual == null) { | ||
synchronized (FlutterVisual.class) { | ||
if (mFlutterVisual == null) { | ||
mFlutterVisual = new FlutterVisual(); | ||
} | ||
} | ||
} | ||
return mFlutterVisual; | ||
} | ||
|
||
public void setMethodChannel(MethodChannel methodChannel) { | ||
this.mMethodChannel = methodChannel; | ||
} | ||
|
||
class DynamicReceiver extends BroadcastReceiver { | ||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
if (mMethodChannel != null && intent != null && intent.getStringExtra(FLUTTER_EXTRA) != null) { | ||
if (intent.getStringExtra(FLUTTER_EXTRA).equals("visualizedConnectionStatusChanged")) { | ||
SALog.i(TAG, "visualizedConnectionStatusChanged"); | ||
mMethodChannel.invokeMethod("visualizedConnectionStatusChanged", null); | ||
} else if (intent.getStringExtra(FLUTTER_EXTRA).equals("visualizedPropertiesConfigChanged")) { | ||
SALog.i(TAG, "visualizedPropertiesConfigChanged"); | ||
mMethodChannel.invokeMethod("visualizedPropertiesConfigChanged", null); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public synchronized void registerBroadcast(Context context) { | ||
SALog.i(TAG, "registerBroadcast:" + isRegister); | ||
if (!isRegister) { | ||
SALog.i(TAG, "registerBroadcast"); | ||
IntentFilter filter = new IntentFilter(); | ||
filter.addAction(FLUTTER_ACTION); | ||
context.registerReceiver(mDynamicReceiver, filter); | ||
isRegister = true; | ||
} | ||
} | ||
|
||
public synchronized void unRegisterBroadcast(Context context) { | ||
SALog.i(TAG, "unRegisterBroadcast"); | ||
context.unregisterReceiver(mDynamicReceiver); | ||
isRegister = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.