Skip to content

Commit

Permalink
Adjustments to use new appWillOpenUrl method signature
Browse files Browse the repository at this point in the history
  • Loading branch information
uerceg committed Jun 8, 2018
1 parent 56fcb66 commit a3fa3a0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Assets/Adjust/Android/AdjustAndroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ public static void ResetSessionCallbackParameters()

public static void AppWillOpenUrl(string url)
{
AndroidJavaClass ajcUri = new AndroidJavaClass ("android.net.Uri");
AndroidJavaClass ajcUri = new AndroidJavaClass("android.net.Uri");
AndroidJavaObject ajoUri = ajcUri.CallStatic<AndroidJavaObject>("parse", url);
ajcAdjust.CallStatic("appWillOpenUrl", ajoUri);
ajcAdjust.CallStatic("appWillOpenUrl", ajoUri, ajoCurrentActivity);
}

// Android specific methods.
Expand Down Expand Up @@ -372,7 +372,7 @@ public static string GetAmazonAdId()
// Used for testing only.
public static void SetTestOptions(AdjustTestOptions testOptions)
{
AndroidJavaObject ajoTestOptions = testOptions.ToAndroidJavaObject (ajoCurrentActivity);
AndroidJavaObject ajoTestOptions = testOptions.ToAndroidJavaObject(ajoCurrentActivity);
ajcAdjust.CallStatic("setTestOptions", ajoTestOptions);
}

Expand Down
14 changes: 6 additions & 8 deletions Assets/Adjust/Test/AdjustTestOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class AdjustTestOptions
public bool? Teardown { get; set; }
public bool? DeleteState { get; set; }
public bool? UseTestConnectionOptions { get; set; }
public bool? NoBackoffWait { get; set; }

// Default value => Constants.ONE_MINUTE
public long? TimerIntervalInMilliseconds { get; set; }
Expand All @@ -33,52 +34,49 @@ public AndroidJavaObject ToAndroidJavaObject(AndroidJavaObject ajoCurrentActivit
{
ajoTestOptions.Set<String>("basePath", BasePath);
}

if (!string.IsNullOrEmpty(GdprPath))
{
ajoTestOptions.Set<String>("gdprPath", GdprPath);
}

if (DeleteState.GetValueOrDefault(false) && ajoCurrentActivity != null)
{
ajoTestOptions.Set<AndroidJavaObject>("context", ajoCurrentActivity);
}

if (UseTestConnectionOptions.HasValue)
{
AndroidJavaObject ajoUseTestConnectionOptions = new AndroidJavaObject("java.lang.Boolean", UseTestConnectionOptions.Value);
ajoTestOptions.Set<AndroidJavaObject>("useTestConnectionOptions", ajoUseTestConnectionOptions);
}

if (TimerIntervalInMilliseconds.HasValue)
{
AndroidJavaObject ajoTimerIntervalInMilliseconds = new AndroidJavaObject("java.lang.Long", TimerIntervalInMilliseconds.Value);
ajoTestOptions.Set<AndroidJavaObject>("timerIntervalInMilliseconds", ajoTimerIntervalInMilliseconds);
}

if (TimerStartInMilliseconds.HasValue)
{
AndroidJavaObject ajoTimerStartInMilliseconds = new AndroidJavaObject("java.lang.Long", TimerStartInMilliseconds.Value);
ajoTestOptions.Set<AndroidJavaObject>("timerStartInMilliseconds", ajoTimerStartInMilliseconds);
}

if (SessionIntervalInMilliseconds.HasValue)
{
AndroidJavaObject ajoSessionIntervalInMilliseconds = new AndroidJavaObject("java.lang.Long", SessionIntervalInMilliseconds.Value);
ajoTestOptions.Set<AndroidJavaObject>("sessionIntervalInMilliseconds", ajoSessionIntervalInMilliseconds);
}

if (SubsessionIntervalInMilliseconds.HasValue)
{
AndroidJavaObject ajoSubsessionIntervalInMilliseconds = new AndroidJavaObject("java.lang.Long", SubsessionIntervalInMilliseconds.Value);
ajoTestOptions.Set<AndroidJavaObject>("subsessionIntervalInMilliseconds", ajoSubsessionIntervalInMilliseconds);
}

if (Teardown.HasValue)
{
AndroidJavaObject ajoTeardown = new AndroidJavaObject("java.lang.Boolean", Teardown.Value);
ajoTestOptions.Set<AndroidJavaObject>("teardown", ajoTeardown);
}
if (NoBackoffWait.HasValue)
{
AndroidJavaObject ajoNoBackoffWait = new AndroidJavaObject("java.lang.Boolean", NoBackoffWait.Value);
ajoTestOptions.Set<AndroidJavaObject>("noBackoffWait", ajoNoBackoffWait);
}

return ajoTestOptions;
}
Expand Down
10 changes: 5 additions & 5 deletions Assets/Adjust/Test/CommandExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,31 +89,31 @@ private void TestOptions()
BasePath = _command.GetFirstParameterValue("basePath");
GdprPath = _command.GetFirstParameterValue("basePath");
}

if (_command.ContainsParameter("timerInterval"))
{
long timerInterval = long.Parse(_command.GetFirstParameterValue("timerInterval"));
testOptions.TimerIntervalInMilliseconds = timerInterval;
}

if (_command.ContainsParameter("timerStart"))
{
long timerStart = long.Parse(_command.GetFirstParameterValue("timerStart"));
testOptions.TimerStartInMilliseconds = timerStart;
}

if (_command.ContainsParameter("sessionInterval"))
{
long sessionInterval = long.Parse(_command.GetFirstParameterValue("sessionInterval"));
testOptions.SessionIntervalInMilliseconds = sessionInterval;
}

if (_command.ContainsParameter("subsessionInterval"))
{
long subsessionInterval = long.Parse(_command.GetFirstParameterValue("subsessionInterval"));
testOptions.SubsessionIntervalInMilliseconds = subsessionInterval;
}

if (_command.ContainsParameter("noBackoffWait"))
{
bool noBackoffWait = bool.Parse(_command.GetFirstParameterValue("noBackoffWait"));
testOptions.NoBackoffWait = noBackoffWait;
}
if (_command.ContainsParameter("teardown"))
{
List<string> teardownOptions = _command.Parameters["teardown"];
Expand Down
6 changes: 5 additions & 1 deletion Assets/Adjust/iOS/AdjustUnity.mm
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ void _AdjustSetTestOptions(const char* baseUrl,
long sessionIntervalInMilliseconds,
long subsessionIntervalInMilliseconds,
int teardown,
int deleteState) {
int deleteState,
int noBackoffWait) {
AdjustTestOptions *testOptions = [[AdjustTestOptions alloc] init];

NSString *stringBaseUrl = isStringValid(baseUrl) == true ? [NSString stringWithUTF8String:baseUrl] : nil;
Expand Down Expand Up @@ -430,6 +431,9 @@ void _AdjustSetTestOptions(const char* baseUrl,
if (deleteState != -1) {
[testOptions setDeleteState:(BOOL)deleteState];
}
if (noBackoffWait != -1) {
[testOptions setNoBackoffWait:(BOOL)noBackoffWait];
}

[Adjust setTestOptions:testOptions];
}
Expand Down
7 changes: 5 additions & 2 deletions Assets/Adjust/iOS/AdjustiOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ private static extern void _AdjustSetTestOptions(
long sessionIntervalInMilliseconds,
long subsessionIntervalInMilliseconds,
int teardown,
int deleteState);
int deleteState,
int noBackoffWait);

[DllImport("__Internal")]
private static extern void _AdjustTrackSubsessionStart();
Expand Down Expand Up @@ -287,6 +288,7 @@ public static void SetTestOptions(AdjustTestOptions testOptions)
long subsessionIntMls = testOptions.SubsessionIntervalInMilliseconds.HasValue ? testOptions.SubsessionIntervalInMilliseconds.Value : -1;
bool teardown = testOptions.Teardown.HasValue ? testOptions.Teardown.Value : false;
bool deleteState = testOptions.DeleteState.HasValue ? testOptions.DeleteState.Value : false;
bool noBackoffWait = testOptions.NoBackoffWait.HasValue ? testOptions.NoBackoffWait.Value : false;

_AdjustSetTestOptions(
testOptions.BaseUrl,
Expand All @@ -298,7 +300,8 @@ public static void SetTestOptions(AdjustTestOptions testOptions)
sessionIntMls,
subsessionIntMls,
AdjustUtils.ConvertBool(teardown),
AdjustUtils.ConvertBool(deleteState));
AdjustUtils.ConvertBool(deleteState),
AdjustUtils.ConvertBool(noBackoffWait));
}

public static void TrackSubsessionStart()
Expand Down

0 comments on commit a3fa3a0

Please sign in to comment.