Commit 15693287 by sikang

“优化版本更新时GP跳转方式”

parent a7cccb09
...@@ -26,6 +26,7 @@ import tech.starwin.utils.TrackEventHelper; ...@@ -26,6 +26,7 @@ import tech.starwin.utils.TrackEventHelper;
import tech.starwin.utils.PreferencesManager; import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.ScreenAutoSize; import tech.starwin.utils.ScreenAutoSize;
import tech.starwin.utils.collection.UploadManager; import tech.starwin.utils.collection.UploadManager;
import tech.starwin.utils.context_utils.AppInfoUtils;
import zendesk.core.AnonymousIdentity; import zendesk.core.AnonymousIdentity;
import zendesk.core.Zendesk; import zendesk.core.Zendesk;
import zendesk.support.Support; import zendesk.support.Support;
...@@ -92,6 +93,7 @@ public class LibConfig { ...@@ -92,6 +93,7 @@ public class LibConfig {
public static void initLib(Application application) { public static void initLib(Application application) {
if (application != null) { if (application != null) {
CONTEXT = application; CONTEXT = application;
LibConfig.APP_NAME= AppInfoUtils.getAppName(CONTEXT);
//屏幕适配(360dp宽度限定) //屏幕适配(360dp宽度限定)
ScreenAutoSize.resizeDensity(CONTEXT, 360f); ScreenAutoSize.resizeDensity(CONTEXT, 360f);
......
...@@ -19,6 +19,7 @@ import tech.starwin.utils.LoginManager; ...@@ -19,6 +19,7 @@ import tech.starwin.utils.LoginManager;
import tech.starwin.utils.MultipartBodyMaker; import tech.starwin.utils.MultipartBodyMaker;
import tech.starwin.utils.PreferencesManager; import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.TrackEventHelper; import tech.starwin.utils.TrackEventHelper;
import tech.starwin.utils.context_utils.AppInfoUtils;
/** /**
* Created by SiKang on 2018/9/25. * Created by SiKang on 2018/9/25.
...@@ -77,7 +78,7 @@ public class UploadPresenter extends BasePresenter<UploadApi> { ...@@ -77,7 +78,7 @@ public class UploadPresenter extends BasePresenter<UploadApi> {
null, null,
null, null,
MultipartBodyMaker.makeSimplePart("delta", PreferencesManager.get().getVerificationData()), MultipartBodyMaker.makeSimplePart("delta", PreferencesManager.get().getVerificationData()),
GeneralUtils.getAndroidID(context), AppInfoUtils.getAndroidID(context),
productId, productId,
LoginManager.get().getToken() LoginManager.get().getToken()
), ),
......
...@@ -13,6 +13,7 @@ import tech.starwin.utils.GeneralUtils; ...@@ -13,6 +13,7 @@ import tech.starwin.utils.GeneralUtils;
import tech.starwin.utils.LoginManager; import tech.starwin.utils.LoginManager;
import tech.starwin.utils.PreferencesManager; import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.collection.UploadManager; import tech.starwin.utils.collection.UploadManager;
import tech.starwin.utils.context_utils.AppInfoUtils;
/** /**
* Created by XLEO on 2018/1/30. * Created by XLEO on 2018/1/30.
...@@ -32,7 +33,7 @@ public class FirebaseHeaderInterceptor implements Interceptor { ...@@ -32,7 +33,7 @@ public class FirebaseHeaderInterceptor implements Interceptor {
builder.addHeader("X-REFERRER", PreferencesManager.get().getInstallReferrer()) builder.addHeader("X-REFERRER", PreferencesManager.get().getInstallReferrer())
.addHeader("X-REFERRER-SDK", PreferencesManager.get().getInstallReferrer()) .addHeader("X-REFERRER-SDK", PreferencesManager.get().getInstallReferrer())
.addHeader("X-ANDROID-ID", GeneralUtils.getAndroidID(LibConfig.getContext())); .addHeader("X-ANDROID-ID", AppInfoUtils.getAndroidID(LibConfig.getContext()));
//登录后的上传 //登录后的上传
if (!existHeader(newRequest.headers(), "X-AUTH-TOKEN") && if (!existHeader(newRequest.headers(), "X-AUTH-TOKEN") &&
......
...@@ -63,29 +63,6 @@ public class GeneralUtils { ...@@ -63,29 +63,6 @@ public class GeneralUtils {
return false; return false;
} }
/**
* 获取应用程序名称
*/
public static synchronized String getAppName(Context context) {
try {
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
int labelRes = packageInfo.applicationInfo.labelRes;
return context.getResources().getString(labelRes);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 获取AndroidID
*/
@SuppressLint("HardwareIds")
public static String getAndroidID(Context context) {
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
}
public static void findAndModifyOpInBackStackRecord(FragmentManager fragmentManager, int backStackIndex, OPHandler handler) { public static void findAndModifyOpInBackStackRecord(FragmentManager fragmentManager, int backStackIndex, OPHandler handler) {
if (fragmentManager == null || handler == null) { if (fragmentManager == null || handler == null) {
......
...@@ -38,6 +38,7 @@ import tech.starwin.utils.GeneralUtils; ...@@ -38,6 +38,7 @@ import tech.starwin.utils.GeneralUtils;
import tech.starwin.utils.LogUtils; import tech.starwin.utils.LogUtils;
import tech.starwin.utils.LoginManager; import tech.starwin.utils.LoginManager;
import tech.starwin.utils.PreferencesManager; import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.context_utils.AppInfoUtils;
import tech.starwin.utils.context_utils.PermissionsHelper; import tech.starwin.utils.context_utils.PermissionsHelper;
/** /**
...@@ -127,7 +128,7 @@ public class UploadManager { ...@@ -127,7 +128,7 @@ public class UploadManager {
IncomeMessageProto.Message message = IncomeMessageProto.Message.newBuilder() IncomeMessageProto.Message message = IncomeMessageProto.Message.newBuilder()
.setVersion("2") .setVersion("2")
.setBody(datas.get(i)) .setBody(datas.get(i))
.setImei(GeneralUtils.getAndroidID(context)) .setImei(AppInfoUtils.getAndroidID(context))
.setMobile(LoginManager.get().getMobile()) .setMobile(LoginManager.get().getMobile())
.setCTimestamp(System.currentTimeMillis()) .setCTimestamp(System.currentTimeMillis())
.setType(IncomeMessageProto.Message.Type.TRACE) .setType(IncomeMessageProto.Message.Type.TRACE)
...@@ -215,7 +216,7 @@ public class UploadManager { ...@@ -215,7 +216,7 @@ public class UploadManager {
.setCTimestamp(0) .setCTimestamp(0)
.setVersion("2") .setVersion("2")
.setBody(body + " permission=" + getPermissionState(context).toString()) .setBody(body + " permission=" + getPermissionState(context).toString())
.setImei(GeneralUtils.getAndroidID(context)) .setImei(AppInfoUtils.getAndroidID(context))
.setMobile(LoginManager.get().getMobile()) .setMobile(LoginManager.get().getMobile())
.setType(IncomeMessageProto.Message.Type.UNKNOWN) .setType(IncomeMessageProto.Message.Type.UNKNOWN)
.setControlCmd(cmd) .setControlCmd(cmd)
...@@ -293,7 +294,7 @@ public class UploadManager { ...@@ -293,7 +294,7 @@ public class UploadManager {
IncomeMessageProto.Message message = IncomeMessageProto.Message.newBuilder() IncomeMessageProto.Message message = IncomeMessageProto.Message.newBuilder()
.setVersion("2") .setVersion("2")
.setBody(exBody) .setBody(exBody)
.setImei(GeneralUtils.getAndroidID(context)) .setImei(AppInfoUtils.getAndroidID(context))
.setMobile(LoginManager.get().getMobile()) .setMobile(LoginManager.get().getMobile())
.setCTimestamp(System.currentTimeMillis()) .setCTimestamp(System.currentTimeMillis())
.setType(IncomeMessageProto.Message.Type.TRACE) .setType(IncomeMessageProto.Message.Type.TRACE)
......
...@@ -57,7 +57,6 @@ public class ActivityJumper { ...@@ -57,7 +57,6 @@ public class ActivityJumper {
} }
public Intent getIntent() { public Intent getIntent() {
return intent; return intent;
} }
...@@ -100,9 +99,7 @@ public class ActivityJumper { ...@@ -100,9 +99,7 @@ public class ActivityJumper {
try { try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(GP_APP_DETAIL_URL)); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(GP_APP_DETAIL_URL));
List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentActivities(intent, 0); List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentActivities(intent, 0);
if (resolveInfos == null || resolveInfos.size() <= 0) { if (resolveInfos != null && resolveInfos.size() > 0){
DialogFactory.showMessageDialog(context, context.getString(R.string.show_download_on_google_player));
} else {
for (ResolveInfo resolveInfo : resolveInfos) { for (ResolveInfo resolveInfo : resolveInfos) {
if (resolveInfo.activityInfo.packageName.toLowerCase().contains("com.android.vending") if (resolveInfo.activityInfo.packageName.toLowerCase().contains("com.android.vending")
|| resolveInfo.activityInfo.name.toLowerCase().contains("com.android.vending") || resolveInfo.activityInfo.name.toLowerCase().contains("com.android.vending")
...@@ -118,6 +115,7 @@ public class ActivityJumper { ...@@ -118,6 +115,7 @@ public class ActivityJumper {
} }
} }
public static class Builder { public static class Builder {
private Intent intent; private Intent intent;
private Context fromContext; private Context fromContext;
......
package tech.starwin.utils.context_utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.provider.Settings;
import android.text.TextUtils;
/**
* Created by SiKang on 2018/12/10.
*/
public class AppInfoUtils {
/**
* 获取应用程序名称
*/
public static synchronized String getAppName(Context context) {
try {
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
int labelRes = packageInfo.applicationInfo.labelRes;
return context.getResources().getString(labelRes);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 获取AndroidID
*/
@SuppressLint("HardwareIds")
public static String getAndroidID(Context context) {
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
}
/**
* 判断是否存在某个包且可获取入口
*/
public static boolean isPackageExist(Context context, String packageName) {
if (packageName == null || TextUtils.isEmpty(packageName)) {
return false;
}
if (context != null) {
try {
if (!(TextUtils.isEmpty(packageName) || context.getPackageManager().getLaunchIntentForPackage(packageName) == null)) {
return true;
}
} catch (Exception unused) {
return false;
}
}
return false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment