Skip to content

Commit

Permalink
Merge pull request #6 from adjust/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
nonelse committed Mar 27, 2014
2 parents 860932a + a465e2e commit 55b072d
Show file tree
Hide file tree
Showing 185 changed files with 2,907 additions and 2,650 deletions.
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# =============== #
# Unity generated #
# =============== #
Temp/
Obj/
UnityGenerated/
Library/

# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #
ExportedObj/
*.svd
*.userprefs
*.csproj
*.pidb
*.suo
*.sln
*.user
*.unityproj
*.booproj

# ============ #
# OS generated #
# ============ #
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "Assets/Plugins/iOS/src/Adjust"]
path = Assets/Plugins/iOS/src/Adjust
url = [email protected]:adjust/ios_sdk.git
[submodule "Assets/Plugins/Android/src/Adjust"]
path = Assets/Plugins/Android/src/Adjust
url = [email protected]:adjust/android_sdk.git
Binary file added Adjust.unitypackage
Binary file not shown.
97 changes: 97 additions & 0 deletions Assets/Adjust.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
using UnityEngine;
using System.Collections.Generic;
using com.adjust.sdk;
using System;

public class Adjust : MonoBehaviour {

private static IAdjust instance = null;
private static string errorMessage = "adjust: SDK not started. Start it manually using the 'appDidLaunch' method";
private static Action<ResponseData> responseDelegate = null;

public string appToken = "{Your App Token}";
public Util.LogLevel logLevel = Util.LogLevel.Info;
public Util.Environment environment = Util.Environment.Sandbox;
public bool eventBuffering = false;
public bool startManually = false;

void Awake() {
if (!this.startManually) {
Adjust.appDidLaunch(this.appToken, this.environment, this.logLevel, this.eventBuffering);
}
}

void OnApplicationPause(bool pauseStatus) {
if (Adjust.instance == null) {
return;
}

if (pauseStatus) {
Adjust.instance.onPause();
} else {
Adjust.instance.onResume();
}
}

public static void appDidLaunch(string appToken, Util.Environment environment, Util.LogLevel logLevel, bool eventBuffering) {
if (Adjust.instance != null) {
Debug.Log("adjust: warning, SDK already started. Restarting");
}

#if UNITY_ANDROID
Adjust.instance = new AdjustAndroid();
#elif UNITY_IOS
Adjust.instance = new AdjustIOS();
#endif

if (Adjust.instance == null) {
Debug.Log("adjust: SDK can only be used in Android or iOS");
return;
}

Adjust.instance.appDidLaunch (appToken, environment, logLevel, eventBuffering);
}

public static void trackEvent(string eventToken, Dictionary<string,string> parameters = null) {
if (Adjust.instance == null) {
Debug.Log(Adjust.errorMessage);
return;
}

Adjust.instance.trackEvent (eventToken, parameters);
}

public static void trackRevenue(double cents, string eventToken = null, Dictionary<string,string> parameters = null) {
if (Adjust.instance == null) {
Debug.Log(Adjust.errorMessage);
return;
}

Adjust.instance.trackRevenue(cents ,eventToken, parameters);
}

public static void setResponseDelegate(Action<ResponseData> responseDelegate, string sceneName = "Adjust") {
if (Adjust.instance == null) {
Debug.Log(Adjust.errorMessage);
return;
}

Adjust.responseDelegate = responseDelegate;
Adjust.instance.setResponseDelegate (sceneName);
}

public void getNativeMessage (string sResponseData) {
if (Adjust.instance == null) {
Debug.Log(Adjust.errorMessage);
return;
}
if (Adjust.responseDelegate == null) {
Debug.Log("adjust: response delegate not set to receive callbacks");
return;
}

var responseData = new ResponseData (sResponseData);
Adjust.responseDelegate (responseData);
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Adjust.prefab
Binary file not shown.
4 changes: 4 additions & 0 deletions Assets/Adjust.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Assets/ExampleGUI.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions Assets/ExampleGUI/ExampleGUI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
using com.adjust.sdk;

public class ExampleGUI : MonoBehaviour {

private int nr_buttons = 4;

void OnGUI () {
if (GUI.Button (new Rect (0, Screen.height * 0 / nr_buttons, Screen.width, Screen.height / nr_buttons),
"manual launch")) {
Adjust.appDidLaunch("querty123456", Util.Environment.Sandbox, Util.LogLevel.Verbose, false);
}

if (GUI.Button (new Rect (0, Screen.height * 1 / nr_buttons, Screen.width, Screen.height / nr_buttons),
"track Event")) {
Adjust.trackEvent("eve001");

var parameters = new System.Collections.Generic.Dictionary<string, string> (2);
parameters.Add("key", "value");
parameters.Add("foo", "bar");
Adjust.trackEvent("eve002", parameters);
}

if (GUI.Button (new Rect (0, Screen.height * 2 / nr_buttons, Screen.width, Screen.height / nr_buttons),
"track Revenue")) {
Adjust.trackRevenue(3.44);

Adjust.trackRevenue(3.45, "rev001");

var parameters = new System.Collections.Generic.Dictionary<string, string> (2);
parameters.Add("key", "value");
parameters.Add("foo", "bar");
Adjust.trackRevenue(0.1, "rev002", parameters);
}

if (GUI.Button (new Rect (0, Screen.height * 3 / nr_buttons, Screen.width, Screen.height / nr_buttons),
"callback")) {
Adjust.setResponseDelegate(responseDelegate);
}
}

public void responseDelegate (ResponseData responseData)
{
Debug.Log ("activitykind " + responseData.activityKind.ToString ());
Debug.Log ("trackerName " + responseData.trackerName);
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/ExampleGUI/ExampleGUI.prefab
Binary file not shown.
4 changes: 4 additions & 0 deletions Assets/ExampleGUI/ExampleGUI.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/ExampleGUI/ExampleGUI.unity
Binary file not shown.
4 changes: 4 additions & 0 deletions Assets/ExampleGUI/ExampleGUI.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Assets/Plugins.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Assets/Plugins/Android.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions Assets/Plugins/Android/AdjustAndroid.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

namespace com.adjust.sdk {
#if UNITY_ANDROID
public class AdjustAndroid : IAdjust {

private AndroidJavaClass ajcAdjust;
private AndroidJavaClass ajcAdjustUnity;
private AndroidJavaObject ajoCurrentActivity;

public AdjustAndroid() {
ajcAdjust = new AndroidJavaClass("com.adjust.sdk.Adjust");
ajcAdjustUnity = new AndroidJavaClass("com.adjust.sdk.AdjustUnity");
AndroidJavaClass ajcUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
ajoCurrentActivity = ajcUnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
}

public void appDidLaunch(string appToken, Util.Environment environment, Util.LogLevel logLevel, bool eventBuffering) {

string sEnvironment = environment.ToString ().ToLower ();
string sLogLevel = logLevel.ToString ().ToLower ();

ajcAdjust.CallStatic("appDidLaunch",
ajoCurrentActivity,
appToken,
sEnvironment,
sLogLevel,
eventBuffering);
ajcAdjust.CallStatic("setSdkPrefix","unity3.0.0");

onResume ();
}

public void trackEvent(string eventToken, Dictionary<string,string> parameters = null) {
var javaParameters = ConvertDicToJava (parameters);
ajcAdjust.CallStatic("trackEvent", eventToken, javaParameters);
}

public void trackRevenue(double cents, string eventToken = null, Dictionary<string,string> parameters = null) {
var javaParameters = ConvertDicToJava (parameters);
ajcAdjust.CallStatic("trackRevenue", cents, eventToken, javaParameters);
}

public void onPause() {
ajcAdjust.CallStatic ("onPause");
}

public void onResume() {
ajcAdjust.CallStatic("onResume", ajoCurrentActivity);
}

public void setResponseDelegate(string sceneName)
{
ajcAdjustUnity.CallStatic ("setResponseDelegate", sceneName);
}

private AndroidJavaObject ConvertDicToJava(Dictionary<string, string> dictonary)
{
if (dictonary == null) {
return null;
}

AndroidJavaObject javaDic = new AndroidJavaObject("java.util.HashMap", dictonary.Count);

foreach (var pair in dictonary) {
javaDic.Call<string>("put", pair.Key, pair.Value);
}

return javaDic;
}
}
#endif
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/Android/AdjustUnity.jar
Binary file not shown.
4 changes: 4 additions & 0 deletions Assets/Plugins/Android/AdjustUnity.jar.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Assets/Plugins/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.adjust.sdk" android:theme="@android:style/Theme.NoTitleBar" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
<receiver
android:name="com.adjust.sdk.ReferrerReceiver"
android:exported="true" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
4 changes: 4 additions & 0 deletions Assets/Plugins/Android/AndroidManifest.xml.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/Android/adjust.jar
Binary file not shown.
4 changes: 4 additions & 0 deletions Assets/Plugins/Android/adjust.jar.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Assets/Plugins/Android/src/Adjust
Submodule Adjust added at dda07b
Binary file added Assets/Plugins/Android/src/AdjustUnity.jar
Binary file not shown.
3 changes: 3 additions & 0 deletions Assets/Plugins/Android/src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Created-By: 1.6.0_65 (Apple Inc.)

Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 55b072d

Please sign in to comment.