Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyuanxiao committed Jul 18, 2018
0 parents commit 34d7e48
Show file tree
Hide file tree
Showing 13 changed files with 239 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
.idea
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# eros-plugin-android-UMAnalytics
37 changes: 37 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 26



defaultConfig {
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true

}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

}

dependencies {

compile "com.android.support:support-v4:${PROJECT_SUPPORTLIBVERSION}"

compile project(':nexus')
//友盟数据分析
compile 'com.umeng.sdk:common:1.5.0'
compile 'com.umeng.sdk:analytics:7.5.0'

}
Binary file added libs/umeng_social_api.jar
Binary file not shown.
Binary file added libs/umeng_social_net.jar
Binary file not shown.
Binary file added libs/umeng_social_tool.jar
Binary file not shown.
21 changes: 21 additions & 0 deletions proguard-rules.pro
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
26 changes: 26 additions & 0 deletions src/androidTest/java/com/benmu/umeng/ExampleInstrumentedTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.benmu.umeng;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.benmu.umeng.test", appContext.getPackageName());
}
}
2 changes: 2 additions & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.benmu.umeng" />
47 changes: 47 additions & 0 deletions src/main/java/com/benmu/umeng/UmengModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.benmu.umeng;

import android.content.Context;
import android.text.TextUtils;

import com.alibaba.weex.plugin.annotation.WeexModule;
import com.benmu.framework.utils.DebugableUtil;
import com.taobao.weex.annotation.JSMethod;
import com.taobao.weex.common.WXModule;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;

/**
* Umeng 埋点 Module
* Created by liuyuanxiao on 2018/7/18.
*/
@WeexModule(name = "bmUMAnalytics", lazyLoad = true)
public class UmengModule extends WXModule {
@JSMethod
public void initUM(String umengAppKey) {
Context context = mWXSDKInstance.getContext();
if (!TextUtils.isEmpty(umengAppKey)) {
UMConfigure.init(context, umengAppKey, "umeng", UMConfigure.DEVICE_TYPE_PHONE, "");
MobclickAgent.setDebugMode(DebugableUtil.isDebug());
MobclickAgent.openActivityDurationTrack(false);
MobclickAgent.setCatchUncaughtExceptions(!DebugableUtil.isDebug());
MobclickAgent.setScenarioType(context, MobclickAgent.EScenarioType.E_UM_NORMAL);
}
}

@JSMethod(uiThread = true)
public void umengOnActivityResume(String name) {
UmengUtils.umengOnActivityResume(mWXSDKInstance.getContext(), name);
}

@JSMethod(uiThread = true)
public void umengOnActivityPause(String name) {
UmengUtils.umengOnActivityPause(mWXSDKInstance.getContext(), name);
}

@JSMethod(uiThread = true)
public void umengClick(String name) {
UmengUtils.umengClick(mWXSDKInstance.getContext(), name);
}


}
76 changes: 76 additions & 0 deletions src/main/java/com/benmu/umeng/UmengUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.benmu.umeng;

import android.content.Context;
import android.support.v4.app.Fragment;

import com.umeng.analytics.MobclickAgent;

/**
* Created by liuyuanxiao on 2017/1/22.
*/

public class UmengUtils {
/**
* activity的友盟统计 & 访问时长,放在onResume方法里,注意不要重复添加此方法,并且如果父类调用了此方法,那么子类就不能在调用
* 这个方法了
*
* @param activity 当前activity对象,传this
* @param name 当前activity的页面描述,目前传空就好了
*/
public static void umengOnActivityResume(Context activity, String name) {
if (activity == null)
return;

if (name != null) {
umengClick(activity, name);
}
MobclickAgent.onPageStart((name == null) ? activity.getClass().getName() : name);
MobclickAgent.onResume(activity);
}

/**
* activity的友盟统计 & 访问时长,放在onPause方法里,注意不要重复添加此方法,并且如果父类调用了此方法,那么子类就不能在调用
* 这个方法了
*
* @param activity 当前activity对象,传this
* @param name 当前activity的页面描述,目前传空就好了
*/
public static void umengOnActivityPause(Context activity, String name) {
if (activity == null)
return;
MobclickAgent.onPageEnd((name == null) ? activity.getClass().getName() : name);
MobclickAgent.onPause(activity);
}

/**
* fragment的友盟统计 & 访问时长,放在fragment的onResume中,这个方法不要重复添加,如果父类调用了此方法,那么子类无需再次调用
*
* @param fragment 传单前的fragment,传this就好了
* @param name 目前传空
*/
public static void umengOnFragmentResume(Fragment fragment, String name) {
if (fragment == null)
return;
MobclickAgent.onPageStart((name == null) ? fragment.getClass().getName() : name);
}

/**
* fragment的友盟统计 & 访问时长,放在fragment的onPause中,这个方法不要重复添加,如果父类调用了此方法,那么子类无需再次调用
*
* @param fragment 传单前的fragment,传this就好了
* @param name 目前传空
*/
public static void umengOnFragmentPause(Fragment fragment, String name) {
if (fragment == null)
return;
MobclickAgent.onPageEnd((name == null) ? fragment.getClass().getName() : name);
}

/**
* @param context
* @param pointName 需要埋的点(点击事件)的描述,写在Umeng类中.
*/
public static void umengClick(Context context, String pointName) {
MobclickAgent.onEvent(context, pointName);
}
}
3 changes: 3 additions & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">erosplug</string>
</resources>
17 changes: 17 additions & 0 deletions src/test/java/com/benmu/umeng/ExampleUnitTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.benmu.umeng;

import org.junit.Test;

import static org.junit.Assert.*;

/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}

0 comments on commit 34d7e48

Please sign in to comment.