-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #227 from apptentive/branch_5.6.4
Release 5.6.4
- Loading branch information
Showing
16 changed files
with
275 additions
and
21 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @frankus @twinklesharma1311 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
.../com/apptentive/android/sdk/module/engagement/logic/DefaultRandomPercentProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.apptentive.android.sdk.module.engagement.logic; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class DefaultRandomPercentProviderTest { | ||
// private final Context context = InstrumentationRegistry.getInstrumentation().getContext(); | ||
// | ||
// @Before | ||
// public void before() { | ||
// DefaultRandomPercentProvider.clear(context); | ||
// } | ||
// | ||
// @Test | ||
// public void testRandomPercent() { | ||
// final RandomPercentProvider provider = new DefaultRandomPercentProvider(context, "id"); | ||
// final double percent1 = provider.getPercent("key"); | ||
// final double percent2 = provider.getPercent("key"); | ||
// assertEquals(percent1, percent2, 0.0000001f); | ||
// } | ||
} |
70 changes: 70 additions & 0 deletions
70
...androidTest/java/com/apptentive/android/sdk/module/engagement/logic/FieldManagerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.apptentive.android.sdk.module.engagement.logic; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
|
||
import com.apptentive.android.sdk.storage.AppRelease; | ||
import com.apptentive.android.sdk.storage.Device; | ||
import com.apptentive.android.sdk.storage.EventData; | ||
import com.apptentive.android.sdk.storage.Person; | ||
import com.apptentive.android.sdk.storage.VersionHistory; | ||
|
||
import org.junit.Test; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class FieldManagerTest { | ||
// private final Context context = InstrumentationRegistry.getInstrumentation().getContext(); | ||
// | ||
// @Test | ||
// public void testRandomPercentWithKey() { | ||
// final FieldManager fieldManager = createFieldManager(50); | ||
// final Comparable expected = new BigDecimal(50); | ||
// final Comparable actual = fieldManager.getValue("random/abc123xyz/percent"); | ||
// assertEquals(expected, actual); | ||
// } | ||
// | ||
// @Test | ||
// public void testRandomPercentWithoutKey() { | ||
// final FieldManager fieldManager = createFieldManager(50); | ||
// final Comparable expected = new BigDecimal(50); | ||
// final Comparable actual = fieldManager.getValue("random/percent"); | ||
// assertEquals(expected, actual); | ||
// } | ||
// | ||
// @Test | ||
// public void testRandomPercentWithKeyDescription() { | ||
// final FieldManager fieldManager = createFieldManager(50); | ||
// final String expected = "random percent for key 'abc123xyz'"; | ||
// final String actual = fieldManager.getDescription("random/abc123xyz/percent"); | ||
// assertEquals(expected, actual); | ||
// } | ||
// | ||
// @Test | ||
// public void testRandomPercentWithoutKeyDescription() { | ||
// final FieldManager fieldManager = createFieldManager(50); | ||
// final String expected = "random percent"; | ||
// final String actual = fieldManager.getDescription("random/percent"); | ||
// assertEquals(expected, actual); | ||
// } | ||
// | ||
// private FieldManager createFieldManager(double percent) { | ||
// return new FieldManager(context, new VersionHistory(), new EventData(), new Person(), new Device(), new AppRelease(), new MockRandomPercentProvider(percent)); | ||
// } | ||
// | ||
// private static class MockRandomPercentProvider implements RandomPercentProvider { | ||
// private final double percent; | ||
// | ||
// private MockRandomPercentProvider(double percent) { | ||
// this.percent = percent; | ||
// } | ||
// | ||
// @Override | ||
// public double getPercent(String key) { | ||
// return percent; | ||
// } | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...java/com/apptentive/android/sdk/module/engagement/logic/DefaultRandomPercentProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.apptentive.android.sdk.module.engagement.logic; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
|
||
import androidx.annotation.VisibleForTesting; | ||
|
||
import com.apptentive.android.sdk.util.ApplicationInfo; | ||
import com.apptentive.android.sdk.util.RuntimeUtils; | ||
|
||
import java.util.Random; | ||
|
||
/** | ||
* A concrete implementation of [RandomPercentProvider] which only generates a random percent for a | ||
* give key once and stores it in shared preferences. | ||
*/ | ||
public class DefaultRandomPercentProvider implements RandomPercentProvider { | ||
// private final Context context; | ||
// private final String id; | ||
// | ||
// /** | ||
// * @param id - unique key for making a distinction between same keys used in different conversations. | ||
// */ | ||
// public DefaultRandomPercentProvider(Context context, String id) { | ||
// if (context == null) { | ||
// throw new IllegalArgumentException("Context is null"); | ||
// } | ||
// if (id == null) { | ||
// throw new IllegalArgumentException("Id is null"); | ||
// } | ||
// this.context = context.getApplicationContext(); | ||
// this.id = id; | ||
// } | ||
// | ||
// @Override | ||
// public double getPercent(String key) { | ||
// final SharedPreferences prefs = getPrefs(context); | ||
// if (key == null) { | ||
// return getRandomPercent(); | ||
// } else { | ||
// final String prefsKey = id + "_" + key; | ||
// if (prefs.contains(prefsKey)) { | ||
// return prefs.getFloat(prefsKey, 0.0f); | ||
// } | ||
// final float percent = getRandomPercent(); | ||
// prefs.edit().putFloat(prefsKey, percent).apply(); | ||
// return percent; | ||
// } | ||
// } | ||
// | ||
// private float getRandomPercent() { | ||
// ApplicationInfo applicationInfo = RuntimeUtils.getApplicationInfo(context); | ||
// | ||
// if (applicationInfo.isDebuggable()) { | ||
// return (float) 50; | ||
// } else { | ||
// return new Random().nextFloat() * 100; | ||
// } | ||
// } | ||
// | ||
// private static SharedPreferences getPrefs(Context context) { | ||
// return context.getSharedPreferences("com.apptentive.RandomPercentProvider", Context.MODE_PRIVATE); | ||
// } | ||
// | ||
// @VisibleForTesting | ||
// public static void clear(Context context) { | ||
// getPrefs(context).edit().clear().apply(); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...c/main/java/com/apptentive/android/sdk/module/engagement/logic/RandomPercentProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.apptentive.android.sdk.module.engagement.logic; | ||
|
||
/** | ||
* Represents an object which returns a random percent for a give key. | ||
*/ | ||
public interface RandomPercentProvider { | ||
// /** | ||
// * Returns a random percent for a give key in range from [0..100] | ||
// */ | ||
// double getPercent(String key); | ||
} |
Oops, something went wrong.