Skip to content

Commit

Permalink
Update domob AD library and add Umeng analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
lsyiverson committed Jun 3, 2013
1 parent 8c115e0 commit 7c064a9
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 8 deletions.
7 changes: 7 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="UMENG_APPKEY"
android:value="51ac4c1d56240b0392012dd1" />
<meta-data
android:name="UMENG_CHANNEL"
android:value="debug" />

<activity
android:name="cn.domob.android.ads.DomobActivity"
android:theme="@android:style/Theme.Translucent" >
Expand Down
Binary file modified libs/domob_android_sdk.jar
Binary file not shown.
Binary file added libs/umeng_sdk.jar
Binary file not shown.
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@

<!-- Domob Ad string -->
<string name="publisher_id">56OJzuCIuNcnno4QRL</string>
<string name="InlinePPID">16TLmNLoAp4rwY2-8FE73syk</string>

</resources>
14 changes: 14 additions & 0 deletions src/com/lsyiverson/smc/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import android.widget.TextView;
import cn.domob.android.ads.DomobUpdater;

import com.umeng.analytics.MobclickAgent;

public class AboutActivity extends Activity {

@Override
Expand Down Expand Up @@ -64,4 +66,16 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
}

@Override
protected void onPause() {
super.onPause();
MobclickAgent.onPause(this);
}

@Override
protected void onResume() {
super.onResume();
MobclickAgent.onResume(this);
}

}
14 changes: 10 additions & 4 deletions src/com/lsyiverson/smc/ActionReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import android.preference.PreferenceManager;
import android.util.Log;

import com.umeng.analytics.MobclickAgent;

public class ActionReceiver extends BroadcastReceiver {
private static final String LOG_TAG = "ActionRecevier";

Expand All @@ -21,10 +23,14 @@ public void onReceive(Context context, Intent intent) {
fluxCtrlIntent.addFlags(Utils.AUTOMATIC_FLAG);

if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
if (sp.getBoolean(res.getString(R.string.key_auto_run), false)
&& sp.getBoolean(res.getString(R.string.key_mobile_data), false)) {
Log.d(LOG_TAG, "System boot completed, start FluxCtrlService");
context.startService(fluxCtrlIntent);
if (sp.getBoolean(res.getString(R.string.key_auto_run), false)) {
MobclickAgent.onEvent(context, Utils.UMENG_AUTO_RUN, "true");
if (sp.getBoolean(res.getString(R.string.key_mobile_data), false)) {
Log.d(LOG_TAG, "System boot completed, start FluxCtrlService");
context.startService(fluxCtrlIntent);
}
} else {
MobclickAgent.onEvent(context, Utils.UMENG_AUTO_RUN, "false");
}
} else if (intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED)) {
String pkgName = intent.getData().getSchemeSpecificPart();
Expand Down
5 changes: 4 additions & 1 deletion src/com/lsyiverson/smc/FluxCtrlService.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import android.preference.PreferenceManager;
import android.util.Log;

import com.umeng.analytics.MobclickAgent;

public class FluxCtrlService extends Service {
private static final String LOG_TAG = "FluxCtrlService";

Expand Down Expand Up @@ -85,7 +87,8 @@ public void onReceive(Context context, Intent intent) {
Log.d(LOG_TAG, "Screen OFF");
String delayTime = PreferenceManager.getDefaultSharedPreferences(
FluxCtrlService.this).getString(
getResources().getString(R.string.key_delay_time), "0");
getResources().getString(R.string.key_delay_time), "0");
MobclickAgent.onEvent(FluxCtrlService.this, Utils.UMENG_DELAY_TIME, delayTime);
mTask = new DelayDisableFluxTask();
mTask.execute(Integer.valueOf(delayTime).intValue());
}
Expand Down
24 changes: 21 additions & 3 deletions src/com/lsyiverson/smc/SwitchActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.app.ActivityManager.RunningServiceInfo;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
Expand All @@ -29,6 +30,8 @@
import cn.domob.android.ads.DomobAdManager.ErrorCode;
import cn.domob.android.ads.DomobAdView;

import com.umeng.analytics.MobclickAgent;

public class SwitchActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
private static final String LOG_TAG = "SwitchActivity";

Expand All @@ -51,6 +54,7 @@ public class SwitchActivity extends PreferenceActivity implements OnSharedPrefer
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MobclickAgent.onError(this);
addPreferencesFromResource(R.xml.settings);
setContentView(R.layout.activity_switch);
mSmartSettings = PreferenceManager.getDefaultSharedPreferences(this);
Expand All @@ -70,12 +74,13 @@ protected void onResume() {
setPreferenceState(fluxCtrl);
}
super.onResume();
MobclickAgent.onResume(this);
}

private void setupAdView() {
mAdContainer = (RelativeLayout)findViewById(R.id.ad_container);

mAdView320x50 = new DomobAdView(this, getResources().getString(R.string.publisher_id),
mAdView320x50 = new DomobAdView(this, getResources().getString(R.string.publisher_id), getResources().getString(R.string.InlinePPID),
DomobAdView.INLINE_SIZE_320X50);
mAdView320x50.setAdEventListener(new DomobAdEventListener() {

Expand All @@ -96,8 +101,7 @@ public void onDomobAdOverlayDismissed(DomobAdView arg0) {

@Override
public void onDomobAdClicked(DomobAdView arg0) {
// TODO Auto-generated method stub

MobclickAgent.onEvent(SwitchActivity.this, Utils.UMENG_AD_CLICKED);
}

@Override
Expand All @@ -111,6 +115,12 @@ public void onDomobLeaveApplication(DomobAdView arg0) {
// TODO Auto-generated method stub

}

@Override
public Context onDomobAdRequiresCurrentContext() {
// TODO Auto-generated method stub
return null;
}
});

mAdContainer.addView(mAdView320x50);
Expand Down Expand Up @@ -152,13 +162,21 @@ private void ctrlServiceByPreference(boolean fluxCtrl) {
setPreferenceState(fluxCtrl);
if (fluxCtrl) {
Log.d(LOG_TAG, "switch turn on");
MobclickAgent.onEvent(this, Utils.UMENG_SWITCH_ON);
startService(mFluxCtrlIntent);
} else {
Log.d(LOG_TAG, "switch turn off");
MobclickAgent.onEvent(this, Utils.UMENG_SWITCH_OFF);
stopService(mFluxCtrlIntent);
}
}

@Override
protected void onPause() {
super.onPause();
MobclickAgent.onPause(this);
}

@Override
protected void onDestroy() {
mSmartSettings.unregisterOnSharedPreferenceChangeListener(this);
Expand Down
25 changes: 25 additions & 0 deletions src/com/lsyiverson/smc/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,31 @@ public class Utils {

public static final String MOBILE_DATA_CHANGED = "com.lsyiverson.smc.MOBILE_DATA_CHANGED";

/**
* Umeng analytics event: turn switch on
*/
public static final String UMENG_SWITCH_ON = "SWITCH_ON";

/**
* Umeng analytics event: turn switch off
*/
public static final String UMENG_SWITCH_OFF = "SWITCH_OFF";

/**
* Umeng analytics event: turn mobile data delay time before screen off
*/
public static final String UMENG_DELAY_TIME = "DELAY_TIME";

/**
* Umeng analytics event: auto run service when system boot completed
*/
public static final String UMENG_AUTO_RUN = "AUTO_RUN";

/**
* Umeng analystic event: ad clicked
*/
public static final String UMENG_AD_CLICKED = "AD_CLICKED";

/**
* Get the mobile data status
*
Expand Down

0 comments on commit 7c064a9

Please sign in to comment.