Skip to content

Commit

Permalink
Fire App Builder v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
creeld committed May 2, 2017
1 parent 2d000b4 commit 75d66dd
Show file tree
Hide file tree
Showing 16 changed files with 284 additions and 53 deletions.
7 changes: 7 additions & 0 deletions AmazonInAppPurchaseComponent/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ permissions and limitations under the License.

<meta-data android:name="AMZNAP@AmazonInAppPurchase"
android:value="IPurchase@com.amazon.inapppurchase.AmazonInAppPurchaseImplCreator"/>
<receiver android:name="com.amazon.device.iap.ResponseReceiver">
<intent-filter>
<action
android:name="com.amazon.inapp.purchasing.NOTIFY"
android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY"/>
</intent-filter>
</receiver>
</application>

</manifest>
5 changes: 2 additions & 3 deletions Application/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ android {
applicationId "com.amazon.android.calypso"
minSdkVersion 21
targetSdkVersion 23
versionCode 7
versionName "1.0.3"
versionCode 8
versionName "1.0.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
Expand Down Expand Up @@ -98,6 +98,5 @@ dependencies {
compile project(':AMZNMediaPlayerComponent')
compile project(':PassThroughAdsComponent')
compile project(':PassThroughLoginComponent')
compile project(':AmazonInAppPurchaseComponent')
compile project(':LoggerAnalyticsComponent')
}
4 changes: 2 additions & 2 deletions Application/app/src/custom-feeds/config/Navigator.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"config" : {
"showRecommendedContent" : true,
"categoryDefaultRecommendation" : true,
"showRelatedContent": true,
"useCategoryAsDefaultRelatedContent": true,
"searchAlgo" : "basic"
},
"branding" : {
Expand Down
4 changes: 2 additions & 2 deletions Application/app/src/custom-feeds/default/Navigator.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"config": {
"showRecommendedContent": true,
"categoryDefaultRecommendation": true,
"showRelatedContent": true,
"useCategoryAsDefaultRelatedContent": true,
"searchAlgo": "basic"
},
"branding": {
Expand Down
4 changes: 1 addition & 3 deletions Application/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ include ':app',
':PassThroughAdsComponent',
':AMZNMediaPlayerComponent',
':PassThroughLoginComponent',
':AmazonInAppPurchaseComponent',
':LoggerAnalyticsComponent'

/* Frameworks */
Expand All @@ -59,5 +58,4 @@ project(':PurchaseInterface').projectDir = new File(rootProject.projectDir, '../
project(':AMZNMediaPlayerComponent').projectDir = new File(rootProject.projectDir, '../AMZNMediaPlayerComponent')
project(':PassThroughAdsComponent').projectDir = new File(rootProject.projectDir, '../PassThroughAdsComponent')
project(':PassThroughLoginComponent').projectDir = new File(rootProject.projectDir, '../PassThroughLoginComponent')
project(':AmazonInAppPurchaseComponent').projectDir = new File(rootProject.projectDir, '../AmazonInAppPurchaseComponent')
project(':LoggerAnalyticsComponent').projectDir = new File(rootProject.projectDir, '../LoggerAnalyticsComponent')
project(':LoggerAnalyticsComponent').projectDir = new File(rootProject.projectDir, '../LoggerAnalyticsComponent')
5 changes: 1 addition & 4 deletions ComponentTestFramework/EmptyAndroidApp/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ include ':app',
':AmazonInAppPurchaseComponent',
':AMZNMediaPlayerComponent',
':UAMP',
':BrightCoveMediaPlayerComponent',
':ContentBrowser',
':CrashlyticsComponent',
':FlurryAnalyticsComponent',
':FreeWheelAdsComponent',
':GoogleAnalyticsComponent',
':ImageViewerComponent',
':VastAdsComponent',
':TVUIComponent',
':Application'
Expand All @@ -65,13 +63,12 @@ project(':AdobepassAuthComponent').projectDir = new File(rootProject.projectDir,
project(':AmazonInAppPurchaseComponent').projectDir = new File(rootProject.projectDir, "../../AmazonInAppPurchaseComponent")
project(':AMZNMediaPlayerComponent').projectDir = new File(rootProject.projectDir, "../../AMZNMediaPlayerComponent")
project(':UAMP').projectDir = new File(rootProject.projectDir, "../../UAMP")
project(':BrightCoveMediaPlayerComponent').projectDir = new File(rootProject.projectDir, "../../BrightCoveMediaPlayerComponent")
project(':ContentBrowser').projectDir = new File(rootProject.projectDir, "../../ContentBrowser")
project(':CrashlyticsComponent').projectDir = new File(rootProject.projectDir, "../../CrashlyticsComponent")
project(':FlurryAnalyticsComponent').projectDir = new File(rootProject.projectDir, "../../FlurryAnalyticsComponent")
project(':FreeWheelAdsComponent').projectDir = new File(rootProject.projectDir, "../../FreeWheelAdsComponent")
project(':GoogleAnalyticsComponent').projectDir = new File(rootProject.projectDir, "../../GoogleAnalyticsComponent")
project(':ImageViewerComponent').projectDir = new File(rootProject.projectDir, "../../ImageViewerComponent")
project(':VastAdsComponent').projectDir = new File(rootProject.projectDir, "../../VastAdsComponent")
project(':Application').projectDir = new File(rootProject.projectDir, "../../Application/app")
project(':TVUIComponent').projectDir = new File(rootProject.projectDir, "../../TVUIComponent/lib")

14 changes: 1 addition & 13 deletions ComponentTestFramework/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,12 @@
"componentName": "ContentBrowser",
"dir": "../ContentBrowser"
},
{
"componentName": "ImageViewerComponent",
"dir": "../ImageViewerComponent"
},
{
"componentName": "AmazonInAppPurchaseComponent",
"dir": "../AmazonInAppPurchaseComponent"
},
{
"componentName": "FlurryAnalyticsComponent",
"dir": "../FlurryAnalyticsComponent"
},
{
"componentName": "BrightCoveMediaPlayerComponent",
"dir": "../BrightCoveMediaPlayerComponent"
},
{
"componentName": "Application",
"dir": "../Application/app"
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ public void handleOnActivityResult(Activity activity, int requestCode, int resul
* @param screenName Screen name
* @param iScreenSwitchListener Screen switch listener.
*/
private void verifyScreenSwitch(String screenName,
public void verifyScreenSwitch(String screenName,
IScreenSwitchListener iScreenSwitchListener) {

UINode uiNode = (UINode) mNavigator.getNodeObjectByScreenName(screenName);
Expand Down
9 changes: 1 addition & 8 deletions PurchaseInterface/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,10 @@ express or implied. See the License for the specific language governing
permissions and limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amazon.auth">
package="com.amazon.purchase">

<application android:allowBackup="true"
android:supportsRtl="true">
<receiver android:name="com.amazon.device.iap.ResponseReceiver">
<intent-filter>
<action
android:name="com.amazon.inapp.purchasing.NOTIFY"
android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY"/>
</intent-filter>
</receiver>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import com.amazon.android.recipe.Recipe;
import com.amazon.android.utils.FileHelper;
import com.amazon.auth.R;
import com.amazon.purchase.model.Product;
import com.amazon.purchase.model.Receipt;
import com.amazon.purchase.model.SkuData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.amazon.purchase.model.Receipt;
import com.amazon.purchase.model.Response;

import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@
import com.amazon.android.contentbrowser.database.ContentDatabaseHelper;
import com.amazon.android.contentbrowser.database.RecentRecord;
import com.amazon.android.contentbrowser.helper.AnalyticsHelper;
import com.amazon.android.contentbrowser.helper.AuthHelper;
import com.amazon.android.model.content.Content;
import com.amazon.android.module.ModuleManager;

import com.amazon.android.navigator.Navigator;
import com.amazon.android.navigator.UINode;
import com.amazon.android.recipe.Recipe;
import com.amazon.android.tv.tenfoot.R;
import com.amazon.android.uamp.DrmProvider;
Expand Down Expand Up @@ -255,12 +258,9 @@ protected void onStart() {
}

/**
* {@inheritDoc}
* resume Playback Activity if user Authentication is success
*/
@Override
public void onResume() {

super.onResume();
private void resumePlaybackAfterAuthentication() {

// Start tracking video position changes.
mVideoPositionTrackingHandler.post(mVideoPositionTrackingRunnable);
Expand Down Expand Up @@ -318,6 +318,60 @@ public void onResume() {
}
}

/**
* Authenticate User On Resume of PlayBackActivity.
*
* @param screenName Screen name
*/
private void authenticateUserOnResume(String screenName) {

Navigator mNavigator = ContentBrowser.getInstance(this).getNavigator();
AuthHelper mAuthHelper = ContentBrowser.getInstance(this).getAuthHelper();
UINode uiNode = (UINode) mNavigator.getNodeObjectByScreenName(screenName);
Log.d(TAG, "AuthenticateUserOnResume called in:" + screenName);
Log.d(TAG, "AuthenticateUserOnResume needed:" + uiNode.isVerifyScreenAccess());
//check if this Screen need Access verification
if (uiNode.isVerifyScreenAccess()) {
boolean loginLater = Preferences.getBoolean(AuthHelper.LOGIN_LATER_PREFERENCES_KEY);
//Check if Authentication can be deferred or not
if (!mAuthHelper.getIAuthentication().isAuthenticationCanBeDoneLater() ||
(!loginLater && mAuthHelper.getIAuthentication()
.isAuthenticationCanBeDoneLater())) {
//Check if user is Authenticated for the content
mAuthHelper.isAuthenticated().subscribe(extras -> {
if (extras.getBoolean(AuthHelper.RESULT)) {
//Playback activity need to be resumed as Authentication succeeded.
resumePlaybackAfterAuthentication();
}
else {
//Playback activity need to be closed as Authentication failed.
finish();
Log.i(TAG, "Traversing to details page since user is not authenticated " +
"any more");
}
});
}
else {
resumePlaybackAfterAuthentication();
}
}
else {
resumePlaybackAfterAuthentication();
}
}

/**
* {@inheritDoc}
*/
@Override
public void onResume() {

super.onResume();
//Check before resume as user might not authenticated any more. One such scenario is
// coming back from next/prev screen when user account has been disabled from server.
authenticateUserOnResume(ContentBrowser.CONTENT_RENDERER_SCREEN);
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -382,6 +436,20 @@ protected void onStop() {
}
}

/**
* {@inheritDoc}
*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

Log.v(TAG, "onActivityResult called with requestCode:" + requestCode +
" resultCode:" + requestCode + " intent:" + data);
super.onActivityResult(requestCode, resultCode, data);

ContentBrowser.getInstance(this)
.handleOnActivityResult(this, requestCode, resultCode, data);
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,19 @@ public void onActionClicked(Action action) {
}
else if (action.getId() == mSkipNextAction.getId()) {
trackAnalyticsAction(AnalyticsTags.ACTION_PLAYBACK_CONTROL_NEXT);
next();
ContentBrowser.getInstance(getActivity()).verifyScreenSwitch(ContentBrowser
.CONTENT_RENDERER_SCREEN, extra ->
next());
}
else if (action.getId() == mClosedCaptioningAction.getId()) {
toggleCloseCaption();
trackAnalyticsAction(AnalyticsTags.ACTION_PLAYBACK_CONTROL_TOGGLE_CC);
}
else if (action.getId() == mSkipPreviousAction.getId()) {
trackAnalyticsAction(AnalyticsTags.ACTION_PLAYBACK_CONTROL_PRE);
prev();
ContentBrowser.getInstance(getActivity()).verifyScreenSwitch(ContentBrowser
.CONTENT_RENDERER_SCREEN, extra ->
prev());
}
else if (action.getId() == mFastForwardAction.getId()) {
fastForward();
Expand Down Expand Up @@ -934,7 +938,9 @@ public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
Content content = (Content) item;
trackAnalyticsAction(AnalyticsTags.ACTION_RECOMMENDED_CONTENT_CLICKED, content);

mCallback.changeContent(content);
ContentBrowser.getInstance(getActivity()).verifyScreenSwitch(ContentBrowser
.CONTENT_RENDERER_SCREEN, extra ->
mCallback.changeContent(content));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

import java.io.IOException;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

/**
* Tests for {@link NetworkUtils}
Expand Down Expand Up @@ -58,4 +61,76 @@ public void testGetDataLocatedAtUrlWithInvalidUrl() throws IOException {

NetworkUtils.getDataLocatedAtUrl("");
}

/**
* Tests the {@link NetworkUtils#urlContainsParameter(String, String)} method.
*/
@Test
public void testUrlContainsParameter() throws Exception {

String par1 = "param1";
String par2 = "app_id";
String par3 = "action";
String par4 = "empty";
String url1 = "http://www.lightcast.com/api/firetv/channels" +
".php?app_id=257&app_key=0ojbgtfcsq12&action" +
"=channels_videos";
String url2 = url1 + "&" + par4 + "=";
String url3 = "www.badurls.comm";

assertFalse("Parameter should not be found", NetworkUtils.urlContainsParameter(url1, par1));
assertTrue("Parameter should be found", NetworkUtils.urlContainsParameter(url1, par2));
assertTrue("Parameter should be found", NetworkUtils.urlContainsParameter(url1, par3));
assertFalse("Parameter should not be found", NetworkUtils.urlContainsParameter(url2, par4));
assertFalse("URL is bad, should be false", NetworkUtils.urlContainsParameter(url3, par1));
}

/**
* Tests the {@link NetworkUtils#addParameterToUrl(String, String, String)} method.
*/
@Test
public void testAddParameterToUrl() throws Exception {

String url1 = "http://www.lightcast.com/api/firetv/channels" +
".php?app_id=257&app_key=0ojbgtfcsq12&action" +
"=channels_videos";
String url2 = "http://www.lightcast.com/api/firetv/channels" +
".php?app_id=257&app_key=0ojbgtfcsq12&action" +
"=channels_videos&newparam=";
String url3 = "http://www.lightcast.com/api/firetv/channels" +
".php?app_id=257&app_key=0ojbgtfcsq12&newparam=&action" +
"=channels_videos";
String url4 = "http://www.lightcast.com/api/firetv/channels" +
".php?app_id=257&app_key=0ojbgtfcsq12&action" +
"=channels_videos&newparam=differentvalue";

String param = "newparam";
String value = "value1";

// Contains new param at the end
String expected1 = "http://www.lightcast.com/api/firetv/channels" +
".php?app_id=257&app_key=0ojbgtfcsq12&action" +
"=channels_videos&newparam=value1";
// Contains new param in the middle
String expected2 = "http://www.lightcast.com/api/firetv/channels" +
".php?app_id=257&app_key=0ojbgtfcsq12&newparam=value1&action" +
"=channels_videos";
// Contains a different value for newparam.
String expected3 = "http://www.lightcast.com/api/firetv/channels" +
".php?app_id=257&app_key=0ojbgtfcsq12&action" +
"=channels_videos&newparam=differentvalue";

// Test adding a new parameter completely
assertEquals("value1 should have been added.",
expected1, NetworkUtils.addParameterToUrl(url1, param, value));
// Test adding a new parameter if it just has no value in the url
assertEquals("value1 should have been added.",
expected1, NetworkUtils.addParameterToUrl(url2, param, value));
// Test adding a new parameter into the middle of a url
assertEquals("value1 should have been added.",
expected2, NetworkUtils.addParameterToUrl(url3, param, value));
// Test adding a new parameter to url that already contains the parameter.
assertEquals("value1 should not have been added.",
expected3, NetworkUtils.addParameterToUrl(url4, param, value));
}
}
Loading

0 comments on commit 75d66dd

Please sign in to comment.