Skip to content

Commit

Permalink
Merge pull request #162 from adjust/deep_linking
Browse files Browse the repository at this point in the history
Deep linking improvement
  • Loading branch information
uerceg committed Dec 22, 2015
2 parents 34397b6 + b8676dc commit a35422b
Show file tree
Hide file tree
Showing 30 changed files with 330 additions and 59 deletions.
13 changes: 9 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,17 @@ Thumbs.db

# gradle directory
.gradle
.gradletasknamecache
gradlew
gradlew.bat
gradle/
build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

#for oh-my-zsh jira plugin (https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins#jira)
.jira-url
atlassian-ide-plugin.xml
Expand Down
6 changes: 0 additions & 6 deletions Adjust/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion Adjust/adjust/.gitignore

This file was deleted.

10 changes: 5 additions & 5 deletions Adjust/adjust/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
minSdkVersion 9
targetSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "4.1.5"
versionName "4.2.0"
}
}

Expand All @@ -18,4 +18,4 @@ dependencies {

task jar(type: Jar) {
from 'src/main/java'
}
}
27 changes: 17 additions & 10 deletions Adjust/adjust/src/main/java/com/adjust/sdk/ActivityHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,9 @@ private class ReferrerClickTime {
}
}

private void updateStatus() {
private void updateHandlersStatus() {
Message message = Message.obtain();
message.arg1 = SessionHandler.UPDATE_STATUS;
message.arg1 = SessionHandler.UPDATE_HANDLERS_STATUS;
sessionHandler.sendMessage(message);
}

Expand All @@ -338,7 +338,7 @@ private static final class SessionHandler extends Handler {
private static final int FINISH_TRACKING = BASE_ADDRESS + 5;
private static final int DEEP_LINK = BASE_ADDRESS + 6;
private static final int SEND_REFERRER = BASE_ADDRESS + 7;
private static final int UPDATE_STATUS = BASE_ADDRESS + 8;
private static final int UPDATE_HANDLERS_STATUS = BASE_ADDRESS + 8;
private static final int TIMER_FIRED = BASE_ADDRESS + 9;

private final WeakReference<ActivityHandler> sessionHandlerReference;
Expand Down Expand Up @@ -383,8 +383,8 @@ public void handleMessage(Message message) {
ReferrerClickTime referrerClickTime = (ReferrerClickTime) message.obj;
sessionHandler.sendReferrerInternal(referrerClickTime.referrer, referrerClickTime.clickTime);
break;
case UPDATE_STATUS:
sessionHandler.updateStatusInternal();
case UPDATE_HANDLERS_STATUS:
sessionHandler.updateHandlersStatusInternal();
break;
case TIMER_FIRED:
sessionHandler.timerFiredInternal();
Expand Down Expand Up @@ -450,7 +450,7 @@ private void startInternal() {
return;
}

updateStatusInternal();
updateHandlersStatusInternal();

processSession();

Expand Down Expand Up @@ -675,7 +675,7 @@ private boolean trySetAttribution(AdjustAttribution queryStringAttribution,
return false;
}

private void updateStatusInternal() {
private void updateHandlersStatusInternal() {
updateAttributionHandlerStatus();
updatePackageHandlerStatus();
}
Expand All @@ -700,9 +700,16 @@ private void launchDeeplinkMain(String deeplink) {
if (deeplink == null) return;

Uri location = Uri.parse(deeplink);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);
final Intent mapIntent;
if (adjustConfig.deepLinkComponent == null) {
mapIntent = new Intent(Intent.ACTION_VIEW, location);
} else {
mapIntent = new Intent(Intent.ACTION_VIEW, location, adjustConfig.context, adjustConfig.deepLinkComponent);
}
mapIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

mapIntent.setPackage(adjustConfig.context.getPackageName());

// Verify it resolves
PackageManager packageManager = adjustConfig.context.getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(mapIntent, 0);
Expand Down Expand Up @@ -782,7 +789,7 @@ private void timerFiredInternal() {

private void readActivityState() {
try {
activityState = Util.readObject(adjustConfig.context, ACTIVITY_STATE_FILENAME, ACTIVITY_STATE_NAME);
activityState = Util.readObject(adjustConfig.context, ACTIVITY_STATE_FILENAME, ACTIVITY_STATE_NAME, ActivityState.class);
} catch (Exception e) {
logger.error("Failed to read %s file (%s)", ACTIVITY_STATE_NAME, e.getMessage());
activityState = null;
Expand All @@ -791,7 +798,7 @@ private void readActivityState() {

private void readAttribution() {
try {
attribution = Util.readObject(adjustConfig.context, ATTRIBUTION_FILENAME, ATTRIBUTION_NAME);
attribution = Util.readObject(adjustConfig.context, ATTRIBUTION_FILENAME, ATTRIBUTION_NAME, AdjustAttribution.class);
} catch (Exception e) {
logger.error("Failed to read %s file (%s)", ATTRIBUTION_NAME, e.getMessage());
attribution = null;
Expand Down
11 changes: 10 additions & 1 deletion Adjust/adjust/src/main/java/com/adjust/sdk/AdjustConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class AdjustConfig {
OnAttributionChangedListener onAttributionChangedListener;
String referrer;
long referrerClickTime;
Boolean knownDevice;
Boolean deviceKnown;
Class deepLinkComponent;

public static final String ENVIRONMENT_SANDBOX = "sandbox";
public static final String ENVIRONMENT_PRODUCTION = "production";
Expand Down Expand Up @@ -58,6 +59,14 @@ public void setOnAttributionChangedListener(OnAttributionChangedListener onAttri
this.onAttributionChangedListener = onAttributionChangedListener;
}

public void setDeviceKnown(boolean deviceKnown) {
this.deviceKnown = deviceKnown;
}

public void setDeepLinkComponent(Class deepLinkComponent) {
this.deepLinkComponent = deepLinkComponent;
}

public boolean hasListener() {
return onAttributionChangedListener != null;
}
Expand Down
2 changes: 1 addition & 1 deletion Adjust/adjust/src/main/java/com/adjust/sdk/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface Constants {
String BASE_URL = "https://app.adjust.com";
String SCHEME = "https";
String AUTHORITY = "app.adjust.com";
String CLIENT_SDK = "android4.1.5";
String CLIENT_SDK = "android4.2.0";
String LOGTAG = "Adjust";
String REFTAG = "reftag";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private void injectDeviceInfoIds(Map<String, String> parameters) {
private void injectConfig(Map<String, String> parameters) {
addString(parameters, "app_token", adjustConfig.appToken);
addString(parameters, "environment", adjustConfig.environment);
addBoolean(parameters, "device_known", adjustConfig.knownDevice);
addBoolean(parameters, "device_known", adjustConfig.deviceKnown);
addBoolean(parameters, "needs_attribution_data", adjustConfig.hasListener());

String playAdId = Util.getPlayAdId(adjustConfig.context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private void sendNextInternal() {

private void readPackageQueue() {
try {
packageQueue = Util.readObject(context, PACKAGE_QUEUE_FILENAME, PACKAGE_QUEUE_NAME);
packageQueue = Util.readObject(context, PACKAGE_QUEUE_FILENAME, PACKAGE_QUEUE_NAME, List.class);
} catch (Exception e) {
logger.error("Failed to read %s file (%s)", PACKAGE_QUEUE_NAME, e.getMessage());
packageQueue = null;
Expand Down
5 changes: 2 additions & 3 deletions Adjust/adjust/src/main/java/com/adjust/sdk/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ public static Boolean isPlayTrackingEnabled(Context context) {
return Reflection.isPlayTrackingEnabled(context);
}

public static <T> T readObject(Context context, String filename, String objectName) {
public static <T> T readObject(Context context, String filename, String objectName, Class<T> type) {
Closeable closable = null;
@SuppressWarnings("unchecked")
T object = null;
try {
FileInputStream inputStream = context.openFileInput(filename);
Expand All @@ -108,7 +107,7 @@ public static <T> T readObject(Context context, String filename, String objectNa
closable = objectStream;

try {
object = (T) objectStream.readObject();
object = type.cast(objectStream.readObject());
getLogger().debug("Read %s: %s", objectName, object);
} catch (ClassNotFoundException e) {
getLogger().error("Failed to find %s class (%s)", objectName, e.getMessage());
Expand Down
2 changes: 1 addition & 1 deletion Adjust/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.android.tools.build:gradle:1.5.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
1 change: 0 additions & 1 deletion Adjust/example/.gitignore

This file was deleted.

12 changes: 6 additions & 6 deletions Adjust/example/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.adjust.example"
minSdkVersion 14
targetSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
Expand All @@ -21,12 +21,12 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
// imported module
compile project(":adjust")
// running mvn package
//compile fileTree(dir: '../target', include: ['*.jar'])
// using maven repository
//compile 'com.adjust.sdk:adjust-android:4.1.5'
//compile 'com.adjust.sdk:adjust-android:4.2.0'
}
Binary file added Adjust/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions Adjust/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Mon Dec 14 16:05:02 CET 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
Loading

0 comments on commit a35422b

Please sign in to comment.