Skip to content

Commit 2d000b4

Browse files
committed
Fire App Builder v1.0.3
1 parent 9ee53af commit 2d000b4

File tree

8 files changed

+124
-83
lines changed

8 files changed

+124
-83
lines changed

Application/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ android {
4444
applicationId "com.amazon.android.calypso"
4545
minSdkVersion 21
4646
targetSdkVersion 23
47-
versionCode 6
48-
versionName "1.0.2"
47+
versionCode 7
48+
versionName "1.0.3"
4949
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
5050
multiDexEnabled true
5151
}

ContentBrowser/src/main/java/com/amazon/android/contentbrowser/helper/AnalyticsHelper.java

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -194,34 +194,41 @@ public static void trackContentDetailsAction(Content content, int actionId) {
194194

195195

196196
/**
197-
* Track that the given content started/resumed playback.
197+
* Track that the given content started or resumed playback.
198198
*
199-
* @param content Content that started/resumed playback.
200-
* @param duration Total duration of the content.
199+
* @param content Content that started/resumed playback.
200+
* @param duration Total duration of the content.
201+
* @param currentPosition The current playback position.
201202
*/
202-
public static void trackContentStarted(Content content, long duration) {
203+
public static void trackPlaybackStarted(Content content, long duration, long currentPosition) {
203204

204205
Map<String, Object> attributes = getBasicAnalyticsAttributesForContent(content);
205206
attributes.putAll(getDetailedContentAttributes(content));
206207

207208
// Get Content extras
208209
attributes.putAll(ExtraContentAttributes.getExtraAttributes(content.getExtras()));
209210
attributes.put(AnalyticsTags.ATTRIBUTE_VIDEO_DURATION, duration);
211+
attributes.put(AnalyticsTags.ATTRIBUTE_VIDEO_CURRENT_POSITION, currentPosition);
210212

211213
sendAnalytics(AnalyticsTags.ACTION_PLAYBACK_STARTED, attributes);
212214
}
213215

214216
/**
215-
* Tracks the ending of a content.
217+
* Tracks that a content's playback finished. This could be that the content was played to
218+
* completion or that the player was exited.
216219
*
217-
* @param content Content to track.
218-
* @param duration The duration for which the content was played.
220+
* @param content Content to track.
221+
* @param startingPosition The position that this playback session started at.
222+
* @param currentPosition The current playback position.
219223
*/
220-
public static void trackContentFinished(Content content, long duration) {
224+
public static void trackPlaybackFinished(Content content, long startingPosition,
225+
long currentPosition) {
221226

222227
// Get the attributes for the selected movie.
223228
Map<String, Object> attributes = getBasicAnalyticsAttributesForContent(content);
224-
attributes.put(AnalyticsTags.ATTRIBUTE_VIDEO_SECONDS_WATCHED, duration);
229+
attributes.put(AnalyticsTags.ATTRIBUTE_VIDEO_SECONDS_WATCHED,
230+
currentPosition - startingPosition);
231+
attributes.put(AnalyticsTags.ATTRIBUTE_VIDEO_CURRENT_POSITION, currentPosition);
225232

226233
sendAnalytics(AnalyticsTags.ACTION_PLAYBACK_FINISHED, attributes);
227234
}
@@ -242,13 +249,14 @@ public static void trackPurchaseResult(String sku, boolean purchaseResult) {
242249
}
243250

244251
/**
245-
* Tracks playback actions of the content.
252+
* Tracks when users interact with the playback controls of the player.
246253
*
247254
* @param action Action taken on this content.
248255
* @param content Content on which the action was taken.
249256
* @param currentPosition Current position in the content playback that the ad finished.
250257
*/
251-
public static void trackContentAction(String action, Content content, long currentPosition) {
258+
public static void trackPlaybackControlAction(String action, Content content,
259+
long currentPosition) {
252260

253261
// Get the attributes for the selected content.
254262
Map<String, Object> attributes = getBasicAnalyticsAttributesForContent(content);
@@ -357,15 +365,15 @@ public static void trackAppEntry() {
357365
/**
358366
* Tracks requests received from launcher to play content
359367
*
360-
* @param contentId contentId of the content requested to be played
361-
* @param content content corresponding to the contentId
368+
* @param contentId contentId of the content requested to be played
369+
* @param content content corresponding to the contentId
362370
* @param requestSource Source of request, it could be Catalog integration or Recommendations
363371
*/
364372
public static void trackLauncherRequest(String contentId, Content content,
365373
String requestSource) {
366374

367375
HashMap<String, Object> attributes = new HashMap<>();
368-
if(requestSource != null) {
376+
if (requestSource != null) {
369377
attributes.put(AnalyticsTags.ATTRIBUTE_REQUEST_SOURCE, requestSource);
370378
}
371379
if (content != null) {

ContentModel/src/androidTest/java/com/amazon/android/model/translators/ContentContainerTranslatorTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import static org.junit.Assert.assertEquals;
3333
import static org.junit.Assert.assertFalse;
3434
import static org.junit.Assert.assertNotNull;
35+
import static org.junit.Assert.assertNull;
3536
import static org.junit.Assert.assertTrue;
3637

3738
/**
@@ -180,14 +181,15 @@ public void testMapToModel() throws Exception {
180181
* Tests the {@link ContentContainerTranslator#mapToModel(Map, Recipe)} method with a bad
181182
* recipe.
182183
*/
183-
@Test(expected = AModelTranslator.TranslationException.class)
184+
@Test
184185
public void testMapToModelWithBadRecipe() throws Exception {
185186

186187
Recipe badRecipe = Recipe.newInstance(FileHelper.readFile(InstrumentationRegistry
187188
.getContext(),
188189
"BadContainerRecipe.json"));
189190

190-
mTranslator.mapToModel(createValidMap(), badRecipe);
191+
ContentContainer container = mTranslator.mapToModel(createValidMap(), badRecipe);
192+
assertNull("ContentContainer should be null", container);
191193
}
192194

193195
/**

ContentModel/src/androidTest/java/com/amazon/android/model/translators/ContentTranslatorTest.java

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616

1717
import com.amazon.android.model.content.Content;
1818
import com.amazon.android.recipe.Recipe;
19-
import com.amazon.android.model.AModelTranslator;
2019
import com.amazon.android.utils.FileHelper;
2120

22-
import org.json.JSONException;
2321
import org.junit.Before;
2422
import org.junit.Test;
2523

@@ -33,6 +31,7 @@
3331
import static org.junit.Assert.assertEquals;
3432
import static org.junit.Assert.assertFalse;
3533
import static org.junit.Assert.assertNotNull;
34+
import static org.junit.Assert.assertNull;
3635
import static org.junit.Assert.assertTrue;
3736

3837
/**
@@ -321,60 +320,69 @@ public void testMapToModel() throws Exception {
321320
* Tests the {@link ContentTranslator#mapToModel(Map, Recipe)} with a recipe that's missing the
322321
* title field.
323322
*/
324-
@Test(expected = AModelTranslator.TranslationException.class)
323+
@Test
325324
public void testMapToModelWithBadRecipeTitle() throws Exception {
326325

327326
Recipe badRecipe = Recipe.newInstance(getBadContentRecipeJsonString("title"));
328327

329-
mContentTranslator.mapToModel(createValidMap(), badRecipe);
328+
Content content = mContentTranslator.mapToModel(createValidMap(), badRecipe);
329+
assertNull("Content should be null due to bad translation", content);
330+
330331
}
331332

332333
/**
333334
* Tests the {@link ContentTranslator#mapToModel(Map, Recipe)} with a recipe that's missing the
334335
* description field.
335336
*/
336-
@Test(expected = AModelTranslator.TranslationException.class)
337+
@Test
337338
public void testMapToModelWithBadRecipeDescription() throws Exception {
338339

339340
Recipe badRecipe = Recipe.newInstance(getBadContentRecipeJsonString("description"));
340341

341-
mContentTranslator.mapToModel(createValidMap(), badRecipe);
342+
Content content = mContentTranslator.mapToModel(createValidMap(), badRecipe);
343+
assertNull("Content should be null due to bad translation", content);
344+
342345
}
343346

344347
/**
345348
* Tests the {@link ContentTranslator#mapToModel(Map, Recipe)} with a recipe that's missing the
346349
* url field.
347350
*/
348-
@Test(expected = AModelTranslator.TranslationException.class)
351+
@Test
349352
public void testMapToModelWithBadRecipeUrl() throws Exception {
350353

351354
Recipe badRecipe = Recipe.newInstance(getBadContentRecipeJsonString("url"));
352355

353-
mContentTranslator.mapToModel(createValidMap(), badRecipe);
356+
Content content = mContentTranslator.mapToModel(createValidMap(), badRecipe);
357+
assertNull("Content should be null due to bad translation", content);
354358
}
355359

356360
/**
357361
* Tests the {@link ContentTranslator#mapToModel(Map, Recipe)} with a recipe that's missing the
358362
* cardImageUrl field.
359363
*/
360-
@Test(expected = AModelTranslator.TranslationException.class)
364+
@Test
361365
public void testMapToModelWithBadRecipeCardImageUrl() throws Exception {
362366

363367
Recipe badRecipe = Recipe.newInstance(getBadContentRecipeJsonString("cardImageUrl"));
364368

365-
mContentTranslator.mapToModel(createValidMap(), badRecipe);
369+
Content content = mContentTranslator.mapToModel(createValidMap(), badRecipe);
370+
assertNull("Content should be null due to bad translation", content);
371+
366372
}
367373

368374
/**
369375
* Tests the {@link ContentTranslator#mapToModel(Map, Recipe)} with a recipe that's missing the
370376
* backgroundImageUrl field.
371377
*/
372-
@Test(expected = AModelTranslator.TranslationException.class)
378+
@Test
373379
public void testMapToModelWithBadRecipeBackgroundImageUrl() throws Exception {
374380

375381
Recipe badRecipe = Recipe.newInstance(getBadContentRecipeJsonString("backgroundImageUrl"));
376382

377-
mContentTranslator.mapToModel(createValidMap(), badRecipe);
383+
Content content = mContentTranslator.mapToModel(createValidMap(), badRecipe);
384+
assertNull("Content should be null due to bad translation", content);
385+
378386
}
379387

380388
/**
@@ -447,13 +455,15 @@ private String getBadContentRecipeJsonString(String skipMatchItem, String extraM
447455
* Tests the {@link ContentTranslator#mapToModel(Map, Recipe)} with a bad map argument. The map
448456
* is missing the title field so the model should not be valid at the end of translation.
449457
*/
450-
@Test(expected = AModelTranslator.TranslationException.class)
458+
@Test
451459
public void testMapToModelWithBadMap() throws Exception {
452460

453461
Map<String, Object> map = createValidMap();
454462
map.remove("title");
455463

456-
mContentTranslator.mapToModel(map, mGoodRecipe);
464+
Content content = mContentTranslator.mapToModel(map, mGoodRecipe);
465+
assertNull("Content should be null due to bad translation", content);
466+
457467
}
458468

459469
/**

0 commit comments

Comments
 (0)