summaryrefslogtreecommitdiffstats
path: root/mobile/android/thirdparty/com/adjust/sdk/AdjustConfig.java
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /mobile/android/thirdparty/com/adjust/sdk/AdjustConfig.java
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'mobile/android/thirdparty/com/adjust/sdk/AdjustConfig.java')
-rw-r--r--mobile/android/thirdparty/com/adjust/sdk/AdjustConfig.java128
1 files changed, 128 insertions, 0 deletions
diff --git a/mobile/android/thirdparty/com/adjust/sdk/AdjustConfig.java b/mobile/android/thirdparty/com/adjust/sdk/AdjustConfig.java
new file mode 100644
index 000000000..148a5f670
--- /dev/null
+++ b/mobile/android/thirdparty/com/adjust/sdk/AdjustConfig.java
@@ -0,0 +1,128 @@
+package com.adjust.sdk;
+
+import android.content.Context;
+
+/**
+ * Created by pfms on 06/11/14.
+ */
+public class AdjustConfig {
+ Context context;
+ String appToken;
+ String environment;
+ LogLevel logLevel;
+ String sdkPrefix;
+ Boolean eventBufferingEnabled;
+ String defaultTracker;
+ OnAttributionChangedListener onAttributionChangedListener;
+ String referrer;
+ long referrerClickTime;
+ Boolean knownDevice;
+
+ public static final String ENVIRONMENT_SANDBOX = "sandbox";
+ public static final String ENVIRONMENT_PRODUCTION = "production";
+
+ public AdjustConfig(Context context, String appToken, String environment) {
+ if (!isValid(context, appToken, environment)) {
+ return;
+ }
+
+ this.context = context.getApplicationContext();
+ this.appToken = appToken;
+ this.environment = environment;
+
+ // default values
+ this.logLevel = LogLevel.INFO;
+ this.eventBufferingEnabled = false;
+ }
+
+ public void setEventBufferingEnabled(Boolean eventBufferingEnabled) {
+ this.eventBufferingEnabled = eventBufferingEnabled;
+ }
+
+ public void setLogLevel(LogLevel logLevel) {
+ this.logLevel = logLevel;
+ }
+
+ public void setSdkPrefix(String sdkPrefix) {
+ this.sdkPrefix = sdkPrefix;
+ }
+
+ public void setDefaultTracker(String defaultTracker) {
+ this.defaultTracker = defaultTracker;
+ }
+
+ public void setOnAttributionChangedListener(OnAttributionChangedListener onAttributionChangedListener) {
+ this.onAttributionChangedListener = onAttributionChangedListener;
+ }
+
+ public boolean hasListener() {
+ return onAttributionChangedListener != null;
+ }
+
+ public boolean isValid() {
+ return appToken != null;
+ }
+
+ private boolean isValid(Context context, String appToken, String environment) {
+ if (!checkAppToken(appToken)) return false;
+ if (!checkEnvironment(environment)) return false;
+ if (!checkContext(context)) return false;
+
+ return true;
+ }
+
+ private static boolean checkContext(Context context) {
+ ILogger logger = AdjustFactory.getLogger();
+ if (context == null) {
+ logger.error("Missing context");
+ return false;
+ }
+
+ if (!Util.checkPermission(context, android.Manifest.permission.INTERNET)) {
+ logger.error("Missing permission: INTERNET");
+ return false;
+ }
+
+ return true;
+ }
+
+ private static boolean checkAppToken(String appToken) {
+ ILogger logger = AdjustFactory.getLogger();
+ if (appToken == null) {
+ logger.error("Missing App Token.");
+ return false;
+ }
+
+ if (appToken.length() != 12) {
+ logger.error("Malformed App Token '%s'", appToken);
+ return false;
+ }
+
+ return true;
+ }
+
+ private static boolean checkEnvironment(String environment) {
+ ILogger logger = AdjustFactory.getLogger();
+ if (environment == null) {
+ logger.error("Missing environment");
+ return false;
+ }
+
+ if (environment == AdjustConfig.ENVIRONMENT_SANDBOX) {
+ logger.Assert("SANDBOX: Adjust is running in Sandbox mode. " +
+ "Use this setting for testing. " +
+ "Don't forget to set the environment to `production` before publishing!");
+ return true;
+ }
+ if (environment == AdjustConfig.ENVIRONMENT_PRODUCTION) {
+ logger.Assert(
+ "PRODUCTION: Adjust is running in Production mode. " +
+ "Use this setting only for the build that you want to publish. " +
+ "Set the environment to `sandbox` if you want to test your app!");
+ return true;
+ }
+
+ logger.error("Unknown environment '%s'", environment);
+ return false;
+ }
+} \ No newline at end of file