Skip to content

Commit 356a4a6

Browse files
committed
Merge branch 'release/1.4.2'
2 parents bcbaf88 + bdec601 commit 356a4a6

File tree

7 files changed

+83
-22
lines changed

7 files changed

+83
-22
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// GENERATED BY Leanplum.
2+
buildscript {
3+
repositories {
4+
jcenter()
5+
}
6+
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:2.3.1'
9+
}
10+
}
11+
12+
allprojects {
13+
repositories {
14+
flatDir {
15+
dirs 'libs'
16+
}
17+
}
18+
}
19+
20+
apply plugin: 'com.android.application'
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
}
25+
26+
android {
27+
compileSdkVersion 25
28+
buildToolsVersion '25.0.2'
29+
30+
defaultConfig {
31+
targetSdkVersion 25
32+
}
33+
34+
lintOptions {
35+
abortOnError false
36+
}
37+
38+
buildTypes {
39+
debug {
40+
jniDebuggable true
41+
}
42+
release {
43+
// Set minifyEnabled to true if you want to run ProGuard on your project
44+
minifyEnabled false
45+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
46+
47+
}
48+
}
49+
50+
}
51+

LeanplumSample/Assets/WebPlayerTemplates/DoNotCompile/Leanplum/LeanplumNative/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ internal class Keys
7878
internal const string VARS_FROM_CODE = "varsFromCode";
7979
internal const string USER_INFO = "userInfo";
8080
internal const string URL = "url";
81+
internal const string VARIANTS = "variants";
8182
internal const string VARS = "vars";
8283
}
8384

LeanplumSample/Assets/WebPlayerTemplates/DoNotCompile/Leanplum/LeanplumNative/LeanplumNative.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ public override void Start(string userId, IDictionary<string, object> attributes
422422
IDictionary<string, object> fileAttributes =
423423
Util.GetValueOrDefault(response, Constants.Keys.FILE_ATTRIBUTES) as
424424
IDictionary<string, object> ?? new Dictionary<string, object>();
425+
List<object> variants = Util.GetValueOrDefault(response, Constants.Keys.VARIANTS) as
426+
List<object> ?? new List<object>();
425427
bool isRegistered = (bool) Util.GetValueOrDefault(response,
426428
Constants.Keys.IS_REGISTERED, false);
427429

@@ -462,7 +464,7 @@ public override void Start(string userId, IDictionary<string, object> attributes
462464
}
463465
}
464466

465-
VarCache.ApplyVariableDiffs(values, fileAttributes);
467+
VarCache.ApplyVariableDiffs(values, fileAttributes, variants);
466468
_hasStarted = true;
467469
startSuccessful = true;
468470
OnStarted(true);
@@ -707,11 +709,10 @@ public override void ResumeState()
707709
/// <summary>
708710
/// Return variant ids.
709711
/// Used only for debugging purposes and advanced use cases.
710-
/// Not supported on Native.
711712
/// </summary>
712713
public override List<object> Variants()
713714
{
714-
return new List<object>();
715+
return VarCache.Variants;
715716
}
716717

717718
/// <summary>

LeanplumSample/Assets/WebPlayerTemplates/DoNotCompile/Leanplum/LeanplumNative/VarCache.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ internal static class VarCache
1919
private static IDictionary<string, object> diffs = new Dictionary<string, object>();
2020
private static IDictionary<string, object> devModeValuesFromServer;
2121
private static IDictionary<string, object> fileAttributes = new Dictionary<string, object>();
22+
private static List<object> variants = new List<object>();
2223
private static object merged;
2324

2425
public static bool HasReceivedDiffs { get; private set; }
@@ -34,6 +35,11 @@ public static IDictionary<string, object> Diffs
3435
get { return diffs; }
3536
private set { diffs = value; }
3637
}
38+
public static List<object> Variants
39+
{
40+
get { return variants; }
41+
private set { variants = value; }
42+
}
3743
public static int downloadsPending;
3844

3945
public delegate void updateEventHandler();
@@ -268,7 +274,8 @@ public static void SaveDiffs()
268274
}
269275

270276
public static void ApplyVariableDiffs(IDictionary<string, object> diffs,
271-
IDictionary<string, object> fileAttributes = null)
277+
IDictionary<string, object> fileAttributes = null,
278+
List<object> variants = null)
272279
{
273280
if (fileAttributes != null)
274281
{
@@ -282,6 +289,10 @@ public static void ApplyVariableDiffs(IDictionary<string, object> diffs,
282289
Diffs = diffs;
283290
ComputeMergedDictionary();
284291
}
292+
if (variants != null)
293+
{
294+
Variants = variants;
295+
}
285296

286297
foreach (Var lpVariable in vars.Values)
287298
{
@@ -321,10 +332,10 @@ internal static void CheckVarsUpdate(Action callback)
321332
var getVariablesResponse = Util.GetLastResponse(varsUpdate) as IDictionary<string, object>;
322333
var newVarValues = Util.GetValueOrDefault(getVariablesResponse, Constants.Keys.VARS) as IDictionary<string, object>;
323334
var newVarFileAttributes = Util.GetValueOrDefault(getVariablesResponse, Constants.Keys.FILE_ATTRIBUTES) as IDictionary<string, object>;
324-
if (!newVarValues.Equals(VarCache.Diffs) || !newVarFileAttributes.Equals(VarCache.FileAttributes))
325-
{
326-
ApplyVariableDiffs(newVarValues, newVarFileAttributes);
327-
}
335+
var newVariants = Util.GetValueOrDefault(getVariablesResponse, Constants.Keys.VARIANTS) as List<object> ?? new List<object>();
336+
337+
ApplyVariableDiffs(newVarValues, newVarFileAttributes, newVariants);
338+
328339
if (callback != null)
329340
{
330341
callback();
@@ -348,7 +359,7 @@ internal static bool SendVariablesIfChanged()
348359
var parameters = new Dictionary<string, string>();
349360
parameters[Constants.Params.VARIABLES] = Json.Serialize(valuesFromClient);
350361
parameters[Constants.Params.KINDS] = Json.Serialize(defaultKinds);
351-
LeanplumRequest.Post(Constants.Methods.SET_VARS, parameters).SendNow();
362+
LeanplumUnityHelper.QueueOnMainThread(() => LeanplumRequest.Post(Constants.Methods.SET_VARS, parameters).SendNow());
352363
return true;
353364
}
354365
return false;

LeanplumSample/Assets/WebPlayerTemplates/DoNotCompile/Leanplum/SharedConstants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace LeanplumSDK
77
/// </summary>
88
public class SharedConstants
99
{
10-
public const string SDK_VERSION = "1.4.1";
10+
public const string SDK_VERSION = "1.4.2";
1111

1212
public class Kinds
1313
{

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Native, iOS & Android Leanplum SDK for Unity3D.
88
brew install maven
99
brew install gradle
1010
brew install bash
11-
brew install android-sdk
11+
brew install wget
12+
brew install Caskroom/cask/android-sdk
1213
brew install Caskroom/cask/unity
1314
```
1415
- Download iOS and Android module in Unity.

build.sh

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
#
66
set -eo pipefail; [[ $DEBUG ]] && set -x
77

8-
# Copied from "$LPM_PLUGIN_PATH/_common/constants.sh"
9-
UNITY_VERSION=1.4.2-SNAPSHOT
10-
11-
# Copied from "$LPM_PLUGIN_PATH/_common/functions.sh"
128
#######################################
139
# Downloads the iOS SDK from internal repository.
1410
# Globals:
@@ -109,25 +105,24 @@ build() {
109105

110106
echo "Compiling Unity SDK..."
111107

112-
PATH_TO_UNITY="/Applications/Unity/Unity.app/Contents/MacOS/Unity"
113-
PATH_TO_UNITYENGINE="/Applications/Unity/Unity.app/Contents/Managed/UnityEngine.dll"
108+
PATH_TO_UNITY_ROOT="/Applications/Unity/Unity.app"
109+
PATH_TO_UNITY="$PATH_TO_UNITY_ROOT/Contents/MacOS/Unity"
110+
PATH_TO_UNITYENGINE="$PATH_TO_UNITY_ROOT/Contents/Managed/UnityEngine.dll"
114111

115112
PATH_TO_LP_IN_PROJECT="Assets/WebPlayerTemplates/DoNotCompile/Leanplum"
116113
PATH_TO_PROJECT="$(pwd)/LeanplumSample"
117114

118115
OUT_DLL="$PATH_TO_PROJECT/Assets/Standard Assets/Leanplum/LeanplumSDK.dll"
119-
export OUT_PKG="Leanplum_Unity-$UNITY_VERSION_STRING.unitypackage"
116+
export OUT_PKG="Leanplum_Unity-${UNITY_VERSION_STRING}.unitypackage"
120117

121118
# Compile dll and place into project.
122-
/Applications/Unity/Unity.app/Contents/Mono/bin/gmcs -r:"$PATH_TO_UNITYENGINE" \
119+
$PATH_TO_UNITY_ROOT/Contents/Mono/bin/gmcs -r:"$PATH_TO_UNITYENGINE" \
123120
-target:library -out:"$OUT_DLL" -recurse:"$PATH_TO_PROJECT/$PATH_TO_LP_IN_PROJECT/*.cs"
124121

125122
# Export unitypackage.
126123
$PATH_TO_UNITY -quit -batchmode -projectPath "$PATH_TO_PROJECT" -exportPackage \
127124
"Assets/LeanplumSample" "Assets/Standard Assets/Leanplum" "Assets/Plugins" "$OUT_PKG"
128125

129-
export UNITY_BINARY="$PATH_TO_PROJECT/$OUT_PKG"
130-
131126
echo "Done"
132127
}
133128

@@ -145,7 +140,8 @@ main() {
145140
if [[ -z "${BUILD_NUMBER+x}" ]]; then
146141
BUILD_NUMBER=$(date "+%s")
147142
fi
148-
export UNITY_VERSION_STRING="$UNITY_VERSION+$BUILD_NUMBER"
143+
default="${UNITY_VERSION}_${BUILD_NUMBER}"
144+
export UNITY_VERSION_STRING=${UNITY_VERSION_STRING:-$default}
149145

150146
for i in "$@"; do
151147
case $i in

0 commit comments

Comments
 (0)