-
Notifications
You must be signed in to change notification settings - Fork 201
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
Hulk
committed
Nov 25, 2020
0 parents
commit 9910e1b
Showing
473 changed files
with
47,570 additions
and
0 deletions.
There are no files selected for viewing
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,56 @@ | ||
# Generatee by MacOSX | ||
.DS_Store | ||
|
||
# Generated by VIM | ||
.*.swp | ||
|
||
# Built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# Files for the Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Generated by InteliJ / Android Studio | ||
.idea | ||
*.iml | ||
|
||
# Generated by Eclipse | ||
.metadata | ||
.settings | ||
.project | ||
.classpath | ||
|
||
#.idea | ||
.idea/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Generated by Maven | ||
target/ | ||
|
||
version.txt | ||
|
||
/captures | ||
/captures/* |
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,32 @@ | ||
# 小桔棱镜 Android SDK | ||
|
||
* prism-monitor模块负责收集用户操作行为 | ||
* prism-playback模块负责用户操作行为回放 | ||
|
||
## prism-monitor使用说明 | ||
|
||
``` | ||
// 在Application创建时期初始化 | ||
PrismMonitor.getInstance().init(application); | ||
// 开始并设置监听事件 | ||
PrismMonitor.getInstance().start(); | ||
PrismMonitor.getInstance().addOnPrismMonitorListener(new PrismMonitor.OnPrismMonitorListener() { | ||
@Override | ||
public void onEvent(EventData eventData) { | ||
// 可以通过此方法获取事件信息,比如文字回放等,具体使用请查看demo。 | ||
EventInfo eventInfo = PlaybackHelper.convertEventInfo(eventData); | ||
} | ||
}); | ||
``` | ||
|
||
## prism-playback使用说明 | ||
|
||
``` | ||
// 在Application创建时期初始化 | ||
PrismPlayback.getInstance().init(this); | ||
//通过PrismMonitor监听获取数据 | ||
List<EventData> mPlaybackEvents = ...; | ||
//开启回放 | ||
PrismPlayback.getInstance().playback(mPlaybackEvents); | ||
``` |
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 @@ | ||
/build |
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,36 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 29 | ||
buildToolsVersion "29.0.2" | ||
|
||
defaultConfig { | ||
applicationId "com.xiaojuchefu.prism" | ||
minSdkVersion 23 | ||
targetSdkVersion 29 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
|
||
implementation 'androidx.appcompat:appcompat:1.2.0' | ||
|
||
implementation 'com.eastwood.common:auto-quick-adapter:1.0.4' | ||
|
||
implementation project(':prism-monitor') | ||
implementation project(':prism-playback') | ||
|
||
} |
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
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,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.xiaojuchefu.prism"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:name=".MainApplication" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
|
||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity android:name=".TestActivity" /> | ||
|
||
</application> | ||
|
||
</manifest> |
172 changes: 172 additions & 0 deletions
172
Android/app/src/main/java/com/xiaojuchefu/prism/MainActivity.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,172 @@ | ||
package com.xiaojuchefu.prism; | ||
|
||
import android.content.DialogInterface; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.text.TextUtils; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.ListView; | ||
|
||
import androidx.appcompat.app.AlertDialog; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import com.eastwood.common.adapter.QuickAdapter; | ||
import com.eastwood.common.adapter.ViewHelper; | ||
import com.xiaojuchefu.prism.monitor.PrismMonitor; | ||
import com.xiaojuchefu.prism.monitor.model.EventData; | ||
import com.xiaojuchefu.prism.playback.PlaybackHelper; | ||
import com.xiaojuchefu.prism.playback.PrismPlayback; | ||
import com.xiaojuchefu.prism.playback.model.EventInfo; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
List<EventData> mPlaybackEvents = new ArrayList<>(100); | ||
PrismMonitor.OnPrismMonitorListener mOnPrismMonitorListener = new PrismMonitor.OnPrismMonitorListener() { | ||
@Override | ||
public void onEvent(EventData eventData) { | ||
Log.d("onEvent", eventData.getUnionId()); | ||
mPlaybackEvents.add(eventData); | ||
} | ||
}; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
final Button startButton = findViewById(R.id.btn_start); | ||
final Button stopButton = findViewById(R.id.btn_stop); | ||
final View playbackLayout = findViewById(R.id.ll_playback); | ||
|
||
startButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
mPlaybackEvents.clear(); | ||
PrismMonitor.getInstance().start(); | ||
PrismMonitor.getInstance().addOnPrismMonitorListener(new PrismMonitor.OnPrismMonitorListener() { | ||
@Override | ||
public void onEvent(EventData eventData) { | ||
Log.d("onEvent", eventData.getUnionId()); | ||
mPlaybackEvents.add(eventData); | ||
} | ||
}); | ||
startButton.setEnabled(false); | ||
stopButton.setEnabled(true); | ||
playbackLayout.setVisibility(View.GONE); | ||
|
||
startActivity(new Intent(MainActivity.this, TestActivity.class)); | ||
} | ||
}); | ||
stopButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
PrismMonitor.getInstance().stop(); | ||
PrismMonitor.getInstance().removeOnPrismMonitorListener(mOnPrismMonitorListener); | ||
startButton.setEnabled(true); | ||
stopButton.setEnabled(false); | ||
playbackLayout.setVisibility(View.VISIBLE); | ||
} | ||
}); | ||
|
||
findViewById(R.id.btn_playback_text).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
showTextPlayback(); | ||
} | ||
}); | ||
findViewById(R.id.btn_playback_action).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
startActivity(new Intent(MainActivity.this, TestActivity.class)); | ||
playbackLayout.postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
PrismPlayback.getInstance().playback(mPlaybackEvents); | ||
} | ||
}, 1000); | ||
} | ||
}); | ||
|
||
} | ||
|
||
private void showTextPlayback() { | ||
int count = mPlaybackEvents.size(); | ||
List<EventInfo> eventInfos = new ArrayList<>(count); | ||
long currentTime = mPlaybackEvents.get(0).eventTime; | ||
|
||
for (int i = 0; i < count; i++) { | ||
EventData eventData = mPlaybackEvents.get(i); | ||
EventInfo eventInfo = PlaybackHelper.convertEventInfo(eventData); | ||
if (eventInfo == null) continue; | ||
|
||
if (eventInfo.eventType == 0) { | ||
eventInfo.content = PlaybackHelper.getClickInfo(eventInfo); | ||
} else if (eventInfo.eventType == 1 && eventInfos.size() > 0) { | ||
EventInfo lastEventInfo = eventInfos.get(eventInfos.size() - 1); | ||
if (lastEventInfo.eventType == 6) { | ||
eventInfo.content = "(返回上级页面)"; | ||
} | ||
} else if (eventInfo.eventType == 4) { | ||
if (i + 1 < count) { | ||
EventData nextEventData = mPlaybackEvents.get(i + 1); | ||
if (nextEventData.eventType == 5) { | ||
i++; | ||
continue; | ||
} | ||
} | ||
|
||
if (eventInfos.size() > 0) { | ||
EventInfo lastEventInfo = eventInfos.get(eventInfos.size() - 1); | ||
if (lastEventInfo.eventType == 0) { | ||
eventInfo.content = "(页面弹出弹窗)"; | ||
} | ||
} | ||
} else if (eventInfo.eventType == 5 && eventInfos.size() > 0) { | ||
EventInfo lastEventInfo = eventInfos.get(eventInfos.size() - 1); | ||
if (lastEventInfo.eventType == 0) { | ||
eventInfo.content = "(页面弹窗被关闭)"; | ||
} | ||
} else if (eventInfo.eventType == 6) { | ||
String activityName = eventInfo.eventData.get("an"); | ||
if (TextUtils.isEmpty(activityName)) { | ||
return; | ||
} | ||
eventInfo.content = "跳转至 " + activityName; | ||
} | ||
|
||
eventInfo.takeTime = eventData.eventTime - currentTime; | ||
|
||
eventInfos.add(eventInfo); | ||
currentTime = eventData.eventTime; | ||
} | ||
|
||
AlertDialog.Builder builder = new AlertDialog.Builder(this); | ||
builder.setTitle("文字回放"); | ||
builder.setView(R.layout.playback_text); | ||
builder.setNegativeButton("关闭", new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
|
||
} | ||
}); | ||
AlertDialog alertDialog = builder.create(); | ||
alertDialog.show(); | ||
|
||
ListView listView = alertDialog.findViewById(R.id.listview); | ||
listView.setAdapter(new QuickAdapter<EventInfo>(this, R.layout.playback_text_item, eventInfos) { | ||
@Override | ||
protected void convert(int position, ViewHelper helper, EventInfo item) { | ||
helper.setText(R.id.tv_text_playback_event, item.eventDesc); | ||
helper.setText(R.id.tv_playback_content_text, item.content); | ||
helper.setText(R.id.tv_text_playback_time, item.takeTime / 1000 + "' " + item.takeTime % 1000 / 100 + "\""); | ||
} | ||
}); | ||
|
||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
Android/app/src/main/java/com/xiaojuchefu/prism/MainApplication.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,16 @@ | ||
package com.xiaojuchefu.prism; | ||
|
||
import android.app.Application; | ||
|
||
import com.xiaojuchefu.prism.monitor.PrismMonitor; | ||
import com.xiaojuchefu.prism.playback.PrismPlayback; | ||
|
||
public class MainApplication extends Application { | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
PrismMonitor.getInstance().init(this); | ||
PrismPlayback.getInstance().init(this); | ||
} | ||
} |
Oops, something went wrong.