Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
added statistics of launchers for improvement of next release
Browse files Browse the repository at this point in the history
  • Loading branch information
xingrz committed Nov 5, 2015
1 parent ec8f7f1 commit b99178f
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 14 deletions.
12 changes: 5 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ android {

targetSdkVersion 23

versionCode 10402
versionName "1.4.2"
versionCode 10403
versionName "1.4.3"

if (project.hasProperty('FIR_API_TOKEN')) {
buildConfigField "String", "FIR_API_TOKEN", "\"${FIR_API_TOKEN}\""
} else {
buildConfigField "String", "FIR_API_TOKEN", "null"
}
buildConfigField "boolean", "FIR_ENABLED", "!DEBUG && ${project.hasProperty('FIR_API_TOKEN')}"
buildConfigField "String", "FIR_API_TOKEN",
project.hasProperty('FIR_API_TOKEN') ? "\"${FIR_API_TOKEN}\"" : "null"
}

dataBinding {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,27 @@

import com.umeng.analytics.MobclickAgent;

import java.util.HashMap;

import im.fir.sdk.FIR;

public class MaterializeApplication extends Application {

@Override
public void onCreate() {
super.onCreate();

MobclickAgent.setCatchUncaughtExceptions(false);

if (!BuildConfig.DEBUG) {
if (BuildConfig.FIR_ENABLED) {
FIR.init(this);
}

super.onCreate();
MaterializeSharedState.init(this);

HashMap<String, String> event = new HashMap<>();
event.put("launcher", MaterializeSharedState.getInstance().getLauncher());
MobclickAgent.onEvent(this, "launcher", event);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Materialize - Materialize all those not material
* Copyright (C) 2015 XiNGRZ <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package ooo.oxo.apps.materialize;

import android.content.Context;

import ooo.oxo.apps.materialize.util.LauncherUtil;

public class MaterializeSharedState {

private static MaterializeSharedState instance;

private final String launcher;

private MaterializeSharedState(Context context) {
this.launcher = LauncherUtil.resolveLauncherApp(context);
}

static void init(Context context) {
instance = new MaterializeSharedState(context);
}

public static MaterializeSharedState getInstance() {
return instance;
}

public String getLauncher() {
return launcher;
}

}
13 changes: 13 additions & 0 deletions app/src/main/java/ooo/oxo/apps/materialize/util/LauncherUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.support.annotation.Nullable;

public class LauncherUtil {

Expand All @@ -32,4 +34,15 @@ public static void installShortcut(Context context, Intent shortcut, String labe
context.sendBroadcast(intent);
}

@Nullable
public static String resolveLauncherApp(Context context) {
try {
return context.getPackageManager().resolveActivity(
new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME),
PackageManager.MATCH_DEFAULT_ONLY).activityInfo.applicationInfo.packageName;
} catch (Exception e) {
return null; // 日了狗了
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@
public class UpdateUtil {

public static void checkForUpdateAndPrompt(Context context) {
if (BuildConfig.DEBUG) {
return;
}

if (TextUtils.isEmpty(BuildConfig.FIR_API_TOKEN)) {
if (!BuildConfig.FIR_ENABLED) {
return;
}

Expand Down

0 comments on commit b99178f

Please sign in to comment.