|
@@ -1,15 +1,25 @@
|
|
|
package com.dar.nbook.components.activities;
|
|
package com.dar.nbook.components.activities;
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.annotation.SuppressLint;
|
|
|
|
|
+import android.app.Activity;
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
import android.content.SharedPreferences;
|
|
import android.content.SharedPreferences;
|
|
|
import android.content.pm.PackageInfo;
|
|
import android.content.pm.PackageInfo;
|
|
|
import android.content.pm.PackageManager;
|
|
import android.content.pm.PackageManager;
|
|
|
import android.content.pm.Signature;
|
|
import android.content.pm.Signature;
|
|
|
|
|
+import android.os.Bundle;
|
|
|
|
|
|
|
|
|
|
+import androidx.annotation.NonNull;
|
|
|
|
|
+import androidx.annotation.Nullable;
|
|
|
import androidx.appcompat.app.AppCompatDelegate;
|
|
import androidx.appcompat.app.AppCompatDelegate;
|
|
|
import androidx.multidex.MultiDexApplication;
|
|
import androidx.multidex.MultiDexApplication;
|
|
|
|
|
|
|
|
|
|
+import com.adjust.sdk.Adjust;
|
|
|
|
|
+import com.adjust.sdk.AdjustAttribution;
|
|
|
|
|
+import com.adjust.sdk.AdjustConfig;
|
|
|
|
|
+import com.adjust.sdk.AdjustLinkResolution;
|
|
|
|
|
+import com.adjust.sdk.LogLevel;
|
|
|
|
|
+import com.adjust.sdk.OnAttributionChangedListener;
|
|
|
import com.dar.nbook.BuildConfig;
|
|
import com.dar.nbook.BuildConfig;
|
|
|
import com.dar.nbook.R;
|
|
import com.dar.nbook.R;
|
|
|
import com.dar.nbook.api.local.LocalGallery;
|
|
import com.dar.nbook.api.local.LocalGallery;
|
|
@@ -22,6 +32,8 @@ import com.dar.nbook.settings.Global;
|
|
|
import com.dar.nbook.settings.TagV2;
|
|
import com.dar.nbook.settings.TagV2;
|
|
|
import com.dar.nbook.utility.LogUtility;
|
|
import com.dar.nbook.utility.LogUtility;
|
|
|
import com.dar.nbook.utility.network.NetworkUtil;
|
|
import com.dar.nbook.utility.network.NetworkUtil;
|
|
|
|
|
+import com.google.gson.Gson;
|
|
|
|
|
+import com.google.gson.GsonBuilder;
|
|
|
|
|
|
|
|
import org.acra.ACRA;
|
|
import org.acra.ACRA;
|
|
|
import org.acra.ReportField;
|
|
import org.acra.ReportField;
|
|
@@ -45,6 +57,43 @@ import java.security.NoSuchAlgorithmException;
|
|
|
public class CrashApplication extends MultiDexApplication {
|
|
public class CrashApplication extends MultiDexApplication {
|
|
|
private static final String SIGNATURE_GITHUB = "ce96fdbcc89991f083320140c148db5f";
|
|
private static final String SIGNATURE_GITHUB = "ce96fdbcc89991f083320140c148db5f";
|
|
|
|
|
|
|
|
|
|
+ private static final class AdjustLifecycleCallbacks implements ActivityLifecycleCallbacks {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivityStarted(@NonNull Activity activity) {
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivityResumed(@NonNull Activity activity) {
|
|
|
|
|
+ Adjust.onResume();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivityPaused(@NonNull Activity activity) {
|
|
|
|
|
+ Adjust.onPause();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivityStopped(@NonNull Activity activity) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivityDestroyed(@NonNull Activity activity) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void onCreate() {
|
|
public void onCreate() {
|
|
|
super.onCreate();
|
|
super.onCreate();
|
|
@@ -62,27 +111,42 @@ public class CrashApplication extends MultiDexApplication {
|
|
|
TagV2.initMinCount(this);
|
|
TagV2.initMinCount(this);
|
|
|
TagV2.initSortByName(this);
|
|
TagV2.initSortByName(this);
|
|
|
DownloadGalleryV2.loadDownloads(this);
|
|
DownloadGalleryV2.loadDownloads(this);
|
|
|
|
|
+
|
|
|
|
|
+ String appToken = "fxw7vkxfnl6o";
|
|
|
|
|
+ String environment = BuildConfig.BUILD_TYPE.equals("release") ? AdjustConfig.ENVIRONMENT_PRODUCTION : AdjustConfig.ENVIRONMENT_SANDBOX;
|
|
|
|
|
+ AdjustConfig config = new AdjustConfig(this, appToken, environment);
|
|
|
|
|
+ config.setLogLevel(LogLevel.VERBOSE);
|
|
|
|
|
+ config.setOnAttributionChangedListener(attribution -> {
|
|
|
|
|
+ LogUtility.d(new GsonBuilder().serializeSpecialFloatingPointValues().create().toJson(attribution));
|
|
|
|
|
+ });
|
|
|
|
|
+ Adjust.onCreate(config);
|
|
|
|
|
+
|
|
|
|
|
+ registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private boolean signatureCheck() {
|
|
private boolean signatureCheck() {
|
|
|
- try {
|
|
|
|
|
- @SuppressLint("PackageManagerGetSignatures")
|
|
|
|
|
- PackageInfo packageInfo = getPackageManager().getPackageInfo(
|
|
|
|
|
- getPackageName(), PackageManager.GET_SIGNATURES);
|
|
|
|
|
- //note sample just checks the first signature
|
|
|
|
|
-
|
|
|
|
|
- for (Signature signature : packageInfo.signatures) {
|
|
|
|
|
- // MD5 is used because it is not a secure data
|
|
|
|
|
- MessageDigest m = MessageDigest.getInstance("MD5");
|
|
|
|
|
- m.update(signature.toByteArray());
|
|
|
|
|
- String hash = new BigInteger(1, m.digest()).toString(16);
|
|
|
|
|
- LogUtility.d("Find signature: " + hash);
|
|
|
|
|
- if (SIGNATURE_GITHUB.equals(hash)) return true;
|
|
|
|
|
- }
|
|
|
|
|
- } catch (NullPointerException | PackageManager.NameNotFoundException | NoSuchAlgorithmException e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ return true;
|
|
|
|
|
+// try {
|
|
|
|
|
+// @SuppressLint("PackageManagerGetSignatures")
|
|
|
|
|
+// PackageInfo packageInfo = getPackageManager().getPackageInfo(
|
|
|
|
|
+// getPackageName(), PackageManager.GET_SIGNATURES);
|
|
|
|
|
+// //note sample just checks the first signature
|
|
|
|
|
+//
|
|
|
|
|
+// for (Signature signature : packageInfo.signatures) {
|
|
|
|
|
+// // MD5 is used because it is not a secure data
|
|
|
|
|
+// MessageDigest m = MessageDigest.getInstance("MD5");
|
|
|
|
|
+// m.update(signature.toByteArray());
|
|
|
|
|
+// String hash = new BigInteger(1, m.digest()).toString(16);
|
|
|
|
|
+// LogUtility.d("Find signature: " + hash);
|
|
|
|
|
+// if (SIGNATURE_GITHUB.equals(hash)) return true;
|
|
|
|
|
+// }
|
|
|
|
|
+// } catch (NullPointerException | PackageManager.NameNotFoundException |
|
|
|
|
|
+// NoSuchAlgorithmException e) {
|
|
|
|
|
+// e.printStackTrace();
|
|
|
|
|
+// }
|
|
|
|
|
+// return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void afterUpdateChecks(SharedPreferences preferences, String oldVersion, String actualVersion) {
|
|
private void afterUpdateChecks(SharedPreferences preferences, String oldVersion, String actualVersion) {
|