Skip to content

Commit fb3ee2f

Browse files
committed
Merge pull request #9 from adjust/development
New version v3.2.0
2 parents 98b56cf + e02ac14 commit fb3ee2f

32 files changed

+300
-56
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ Icon?
3232
ehthumbs.db
3333
Thumbs.db
3434

35+
# ==================== #
36+
# Adjust SDK generated #
37+
# ==================== #
38+
*.pyc*
39+
AndroidManifest.xml*

Adjust.unitypackage

1.55 MB
Binary file not shown.

Assets/Adjust.cs

+16-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ public static void setResponseDelegate(Action<ResponseData> responseDelegate, st
8080
Adjust.instance.setResponseDelegate (sceneName);
8181
}
8282

83+
public static void setEnabled(bool enabled) {
84+
if (Adjust.instance == null) {
85+
Debug.Log(Adjust.errorMessage);
86+
return;
87+
}
88+
Adjust.instance.setEnabled(enabled);
89+
}
90+
91+
public static bool isEnabled() {
92+
if (Adjust.instance == null) {
93+
Debug.Log(Adjust.errorMessage);
94+
return false;
95+
}
96+
return Adjust.instance.isEnabled ();
97+
}
98+
8399
public void getNativeMessage (string sResponseData) {
84100
if (Adjust.instance == null) {
85101
Debug.Log(Adjust.errorMessage);
@@ -93,5 +109,4 @@ public void getNativeMessage (string sResponseData) {
93109
var responseData = new ResponseData (sResponseData);
94110
Adjust.responseDelegate (responseData);
95111
}
96-
97112
}

Assets/Editor/AdjustEditor.cs

+38-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@
66

77
public class AdjustEditor : MonoBehaviour {
88

9+
static string iOSBuildPath = "";
10+
static bool isEnabled = true;
11+
912
[PostProcessBuild]
1013
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) {
14+
if (!isEnabled) {
15+
return;
16+
}
17+
1118
var exitCode = RunPostBuildScript (preBuild: false, pathToBuiltProject: pathToBuiltProject);
1219

1320
if (exitCode == -1) {
@@ -43,6 +50,32 @@ static void FixAndroidManifest() {
4350
#endif
4451
}
4552

53+
[MenuItem("Adjust/Set iOS build path")]
54+
static void SetiOSBuildPath() {
55+
#if UNITY_IOS
56+
AdjustEditor.iOSBuildPath = EditorUtility.OpenFolderPanel(
57+
title: "iOs build path",
58+
folder: EditorUserBuildSettings.GetBuildLocation(BuildTarget.iPhone),
59+
defaultName: "");
60+
if (AdjustEditor.iOSBuildPath == "") {
61+
UnityEngine.Debug.Log("iOS build path reset to default path");
62+
} else {
63+
UnityEngine.Debug.Log(string.Format("iOS build path: {0}", AdjustEditor.iOSBuildPath));
64+
}
65+
#else
66+
EditorUtility.DisplayDialog("Adjust", "Option only valid for the Android platform.", "OK");
67+
#endif
68+
}
69+
70+
[MenuItem("Adjust/Change post processing status")]
71+
static void ChangePostProcessingStatus() {
72+
isEnabled = !isEnabled;
73+
EditorUtility.DisplayDialog("Adjust",
74+
"The post processing for adjust is now " +
75+
(isEnabled ? "enabled." : "disabled."),
76+
"OK");
77+
}
78+
4679
static int RunPostBuildScript (bool preBuild, string pathToBuiltProject = "") {
4780
string pathToScript = null;
4881
string arguments = null;
@@ -54,7 +87,11 @@ static int RunPostBuildScript (bool preBuild, string pathToBuiltProject = "") {
5487
arguments = "--pre-build " + arguments;
5588
#elif UNITY_IOS
5689
pathToScript = "/Editor/AdjustPostBuildiOS";
57-
arguments = pathToBuiltProject;
90+
if (AdjustEditor.iOSBuildPath == "") {
91+
arguments = pathToBuiltProject;
92+
} else {
93+
arguments = AdjustEditor.iOSBuildPath;
94+
}
5895
#else
5996
return -1;
6097
#endif

Assets/ExampleGUI/ExampleGUI.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
public class ExampleGUI : MonoBehaviour {
77

8-
private int nr_buttons = 4;
8+
private int nr_buttons = 5;
9+
private static bool isEnabled = false;
910

1011
void OnGUI () {
1112
if (GUI.Button (new Rect (0, Screen.height * 0 / nr_buttons, Screen.width, Screen.height / nr_buttons),
1213
"manual launch")) {
1314
Adjust.appDidLaunch("querty123456", Util.Environment.Sandbox, Util.LogLevel.Verbose, false);
15+
isEnabled = true;
1416
}
1517

1618
if (GUI.Button (new Rect (0, Screen.height * 1 / nr_buttons, Screen.width, Screen.height / nr_buttons),
@@ -39,6 +41,13 @@ void OnGUI () {
3941
"callback")) {
4042
Adjust.setResponseDelegate(responseDelegate);
4143
}
44+
45+
var switch_sdk = isEnabled ? "disable sdk" : "enable sdk";
46+
if (GUI.Button (new Rect (0, Screen.height * 4 / nr_buttons, Screen.width, Screen.height / nr_buttons),
47+
switch_sdk)) {
48+
isEnabled = !Adjust.isEnabled();
49+
Adjust.setEnabled(isEnabled);
50+
}
4251
}
4352

4453
public void responseDelegate (ResponseData responseData)

Assets/ExampleGUI/ExampleGUI.unity

48 Bytes
Binary file not shown.

Assets/Plugins/Android/AdjustAndroid.cs

+31-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using UnityEngine;
22
using System.Collections;
33
using System.Collections.Generic;
4+
using System;
45

56
namespace com.adjust.sdk {
67
#if UNITY_ANDROID
@@ -51,11 +52,36 @@ public void onResume() {
5152
ajcAdjust.CallStatic("onResume", ajoCurrentActivity);
5253
}
5354

54-
public void setResponseDelegate(string sceneName)
55-
{
55+
public void setResponseDelegate(string sceneName) {
5656
ajcAdjustUnity.CallStatic ("setResponseDelegate", sceneName);
5757
}
5858

59+
public void setEnabled(bool enabled) {
60+
ajcAdjust.CallStatic ("setEnabled", ConvertBoolToJava(enabled));
61+
}
62+
63+
public bool isEnabled() {
64+
var ajo = ajcAdjust.CallStatic<AndroidJavaObject> ("isEnabled");
65+
return ConvertBoolFromJava (ajo) ?? false;
66+
}
67+
68+
private AndroidJavaObject ConvertBoolToJava(bool value) {
69+
AndroidJavaObject javaBool = new AndroidJavaObject ("java.lang.Boolean", value.ToString ().ToLower ());
70+
return javaBool;
71+
}
72+
73+
private bool? ConvertBoolFromJava(AndroidJavaObject ajo) {
74+
if (ajo == null) {
75+
return null;
76+
}
77+
var sBool = ajo.Call<string>("toString");
78+
try {
79+
return Convert.ToBoolean (sBool);
80+
} catch (FormatException) {
81+
return null;
82+
}
83+
}
84+
5985
private AndroidJavaObject ConvertDicToJava(Dictionary<string, string> dictonary)
6086
{
6187
if (dictonary == null) {
@@ -65,7 +91,9 @@ private AndroidJavaObject ConvertDicToJava(Dictionary<string, string> dictonary)
6591
AndroidJavaObject javaDic = new AndroidJavaObject("java.util.HashMap", dictonary.Count);
6692

6793
foreach (var pair in dictonary) {
68-
javaDic.Call<string>("put", pair.Key, pair.Value);
94+
if (pair.Value != null) {
95+
javaDic.Call<string>("put", pair.Key, pair.Value);
96+
}
6997
}
7098

7199
return javaDic;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
package="com.unity3d.player"
5+
android:installLocation="preferExternal"
6+
android:theme="@android:style/Theme.NoTitleBar"
7+
android:versionCode="1"
8+
android:versionName="1.0">
9+
<supports-screens
10+
android:smallScreens="true"
11+
android:normalScreens="true"
12+
android:largeScreens="true"
13+
android:xlargeScreens="true"
14+
android:anyDensity="true"/>
15+
16+
<application
17+
android:icon="@drawable/app_icon"
18+
android:label="@string/app_name"
19+
android:debuggable="true">
20+
<receiver
21+
android:name="com.adjust.sdk.ReferrerReceiver"
22+
android:exported="true" >
23+
<intent-filter>
24+
<action android:name="com.android.vending.INSTALL_REFERRER" />
25+
</intent-filter>
26+
</receiver>
27+
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
28+
android:label="@string/app_name">
29+
<intent-filter>
30+
<action android:name="android.intent.action.MAIN" />
31+
<category android:name="android.intent.category.LAUNCHER" />
32+
</intent-filter>
33+
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
34+
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
35+
</activity>
36+
</application>
37+
<uses-permission android:name="android.permission.INTERNET" />
38+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
39+
</manifest>

Assets/Plugins/Android/AndroidManifest.xml.meta Assets/Plugins/Android/AdjustAndroidManifest.xml.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins/Android/AndroidManifest.xml

-24
This file was deleted.

Assets/Plugins/Android/adjust.jar

1.14 KB
Binary file not shown.
1.79 MB
Binary file not shown.

Assets/Plugins/Android/google-play-services.jar.meta

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.

Assets/Plugins/IAdjust.cs

+2
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ public interface IAdjust
1111
void onPause ();
1212
void onResume();
1313
void setResponseDelegate(string sceneName);
14+
void setEnabled(bool enabled);
15+
bool isEnabled();
1416
}
1517
}

Assets/Plugins/ResponseData.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ namespace com.adjust.sdk
66
public class ResponseData
77
{
88
public enum ActivityKind {
9-
UNKNOWN, SESSION, EVENT, REVENUE
9+
UNKNOWN, SESSION, EVENT, REVENUE, REATTRIBUTION
1010
}
1111

1212
public ActivityKind activityKind { get; private set; }
13+
public string activityKindString { get; private set; }
1314
public bool success { get; private set; }
1415
public bool willRetry { get; private set; }
1516
public string error { get; private set; }
@@ -20,6 +21,7 @@ public ResponseData(string jsonString) {
2021
var jsonNode = JSON.Parse (jsonString);
2122

2223
activityKind = ParseActivityKind(jsonNode["activityKind"].Value);
24+
activityKindString = activityKind.ToString ().ToLower ();
2325
success = jsonNode ["success"].AsBool;
2426
willRetry = jsonNode ["willRetry"].AsBool;
2527
error = jsonNode ["error"].Value;
@@ -35,6 +37,8 @@ private ActivityKind ParseActivityKind(string sActivityKind)
3537
return ActivityKind.EVENT;
3638
else if ("revenue" == sActivityKind)
3739
return ActivityKind.REVENUE;
40+
else if ("reattribution" == sActivityKind)
41+
return ActivityKind.REATTRIBUTION;
3842
else
3943
return ActivityKind.UNKNOWN;
4044
}

Assets/Plugins/iOS/AIActivityHandler.h

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
withParameters:(NSDictionary *)parameters;
3131

3232
- (void)finishedTrackingWithResponse:(AIResponseData *)response;
33+
- (void)setEnabled:(BOOL)enabled;
34+
- (BOOL)isEnabled;
3335

3436
@end
3537

0 commit comments

Comments
 (0)