Search in sources :

Example 1 with Action

use of com.amazon.android.model.Action in project zype-firebuilder by zype.

the class ContentBrowser method setupMyLibraryAction.

private void setupMyLibraryAction() {
    if (ZypeSettings.LIBRARY_ENABLED) {
        Action libraryAction = createMyLibrarySettingsAction();
        addSettingsAction(libraryAction);
        addSettingsHomeAction(libraryAction);
    }
}
Also used : Action(com.amazon.android.model.Action)

Example 2 with Action

use of com.amazon.android.model.Action in project zype-firebuilder by zype.

the class ContentBrowser method getContentActionList.

/**
 * Get content action list.
 *
 * @param content Content.
 * @return List of action for provided content.
 */
public List<Action> getContentActionList(Content content) {
    if (content == null) {
        return Collections.emptyList();
    }
    List<Action> contentActionList = new ArrayList<>();
    boolean isSubscriptionNotRequired = !content.isSubscriptionRequired();
    if (isSubscriptionNotRequired && mOverrideAllContentsSubscriptionFlag) {
        isSubscriptionNotRequired = false;
    }
    /* Zype, Evgeny Cherkasov */
    // if (mSubscribed || isSubscriptionNotRequired || mIAPDisabled) {
    boolean showWatch = false;
    boolean showSubscribe = false;
    boolean showPurchase = false;
    boolean showPurchasePlaylist = false;
    boolean showAdFree = false;
    boolean showFavorites = false;
    boolean subscriptionRequired = content.isSubscriptionRequired();
    boolean purchaseRequired = false;
    boolean playlistPurchaseRequired = false;
    boolean entitled = entitlementsManager.isVideoEntitled(content);
    if (ZypeConfiguration.isUniversalTVODEnabled(mAppContext)) {
        purchaseRequired = content.getExtraValueAsBoolean(Content.EXTRA_PURCHASE_REQUIRED);
        if (ZypeSettings.PLAYLIST_PURCHASE_ENABLED) {
            ContentContainer playlist = getRootContentContainer().findContentContainerById(content.getExtraValueAsString(Content.EXTRA_PLAYLIST_ID));
            if (playlist != null) {
                playlistPurchaseRequired = playlist.getExtraValueAsBoolean(ContentContainer.EXTRA_PURCHASE_REQUIRED);
            // if (!entitled && playlistPurchaseRequired && content.getExtras().containsKey(Content.EXTRA_ENTITLED)) {
            // entitled = content.getExtraValueAsBoolean(Content.EXTRA_ENTITLED);
            // }
            }
        }
    }
    if (isSubscriptionNotRequired && !purchaseRequired && !playlistPurchaseRequired || mIAPDisabled) {
        showWatch = true;
    } else if (subscriptionRequired && purchaseRequired) {
        if (!isUserSubscribed() && !entitled) {
            showSubscribe = true;
            showPurchase = true;
        } else {
            showWatch = true;
        }
    } else {
        if (subscriptionRequired) {
            if (isUserSubscribed()) {
                showWatch = true;
            } else {
                if (ZypeConfiguration.isNativeSubscriptionEnabled(mAppContext) || ZypeConfiguration.marketplaceConnectSvodEnabled(mAppContext)) {
                    showSubscribe = true;
                } else {
                    showWatch = true;
                }
            }
        }
        if (purchaseRequired) {
            if (entitled) {
                showWatch = true;
            } else {
                if (ZypeConfiguration.isNativeTVODEnabled(mAppContext)) {
                    showPurchase = true;
                }
            }
        }
        if (playlistPurchaseRequired) {
            if (entitled) {
                showWatch = true;
            } else {
                if (ZypeConfiguration.isNativeTVODEnabled(mAppContext)) {
                    showPurchasePlaylist = true;
                    showWatch = false;
                }
            }
        }
    }
    if (ZypeConfiguration.isSubscribeToWatchAdFreeEnabled(mAppContext) && !showSubscribe && !ZypeConfiguration.isNativeSubscriptionEnabled(mAppContext) && !userLoggedIn) {
        showAdFree = true;
    }
    showFavorites = true;
    boolean registrationRequired = content.getExtraValueAsBoolean(Content.EXTRA_REGISTRATION_REQUIRED);
    if (registrationRequired) {
        if (!isUserLoggedIn()) {
            showWatch = false;
        } else {
            registrationRequired = false;
        }
    }
    if (showWatch) {
        // Check if the content is meant for live watching. Live content requires only a
        // watch now button.
        boolean liveContent = content.getExtraValue(Recipe.LIVE_FEED_TAG) != null && Boolean.valueOf(content.getExtraValue(Recipe.LIVE_FEED_TAG).toString());
        // Check database for stored playback position of content.
        if (!liveContent) {
            RecentRecord record = getRecentRecord(content);
            // Add "Resume" button if content playback is not complete.
            if (record != null && !record.isPlaybackComplete()) {
                contentActionList.add(createActionButton(1, CONTENT_ACTION_RESUME, R.string.resume_1, R.string.resume_2));
                // Add "Watch From Beginning" button to start content over.
                contentActionList.add(createActionButton(CONTENT_ACTION_WATCH_FROM_BEGINNING, R.string.watch_from_beginning_1, R.string.watch_from_beginning_2));
            } else // If the content has not been played yet, add the "Watch Now" button.
            {
                contentActionList.add(createActionButton(1, CONTENT_ACTION_WATCH_NOW, R.string.watch_now_1, R.string.watch_now_2));
            }
            if (isWatchlistRowEnabled()) {
                addWatchlistAction(contentActionList, content.getId());
            }
        } else {
            contentActionList.add(createActionButton(1, CONTENT_ACTION_WATCH_NOW, R.string.watch_now_1, R.string.watch_now_2));
        }
    }
    if (registrationRequired) {
        contentActionList.add(createActionButton(2, CONTENT_REGISTRATION_REQUIRED, R.string.action_signup_to_watch1, R.string.action_signup_to_watch2));
        if (content.hasTrailer()) {
            contentActionList.add(createActionButton(CONTENT_PLAY_TRAILER, R.string.action_play_trailer_1, R.string.action_play_trailer_2));
        }
        return contentActionList;
    }
    if (showSubscribe) {
        contentActionList.add(createActionButton(3, CONTENT_ACTION_CHOOSE_PLAN, R.string.action_subscription_1, R.string.action_subscription_2));
    }
    if (showPurchase) {
        contentActionList.add(createActionButton(4, CONTENT_ACTION_CONFIRM_PURCHASE, R.string.action_buy_video_1, R.string.action_buy_video_2));
    }
    if (showPurchasePlaylist) {
        ContentContainer playlist = getRootContentContainer().findContentContainerById(content.getExtraValueAsString(Content.EXTRA_PLAYLIST_ID));
        if (playlist != null) {
            String purchasePrice = playlist.getExtraStringValue(ContentContainer.EXTRA_PURCHASE_PRICE);
            int itemCount = playlist.getExtraValueAsInt(ContentContainer.EXTRA_PLAYLIST_ITEM_COUNT);
            Action action = createActionButton(5, CONTENT_ACTION_CONFIRM_PURCHASE_PLAYLIST, R.string.action_buy_playlist_1, R.string.action_buy_playlist_2);
            action.setLabel1(5, String.format(mAppContext.getResources().getString(R.string.action_buy_playlist_1), String.valueOf(itemCount)));
            action.setLabel2(5, String.format(mAppContext.getResources().getString(R.string.action_buy_playlist_2), purchasePrice));
            contentActionList.add(action);
        }
    }
    if (showAdFree) {
        contentActionList.add(createActionButton(CONTENT_ACTION_SWAF, R.string.action_swaf_1, R.string.action_swaf_2));
    }
    if (showFavorites) {
        ContentContainer favoritesContainer = getRootContentContainer().findContentContainerById(ZypeSettings.ROOT_FAVORITES_PLAYLIST_ID);
        if (favoritesContainer != null) {
            if (isFavoritesLoaded()) {
                if (!VideoFavoritesHelper.getInstance().recordExists(mAppContext, content.getId())) {
                    contentActionList.add(createActionButton(CONTENT_ACTION_FAVORITES_ADD, R.string.action_favorites_add_1, R.string.action_favorites_add_2));
                } else {
                    contentActionList.add(createActionButton(CONTENT_ACTION_FAVORITES_REMOVE, R.string.action_favorites_remove_1, R.string.action_favorites_remove_2));
                }
            } else {
                if (ZypeConfiguration.isFavoritesViaApiEnabled(mAppContext)) {
                    // Set next page to 1 for initial loading
                    favoritesContainer.getContentContainers().get(0).setExtraValue(ExtraKeys.NEXT_PAGE, 1);
                    loadFavoritesVideos(favoritesContainer);
                } else {
                    loadLocalFavoritesVideos(favoritesContainer);
                }
            }
        }
    }
    // contentActionList.add(new Action()
    // .setId(CONTENT_ACTION_SUBSCRIPTION)
    // .setLabel1(mAppContext.getResources()
    // .getString(R.string.premium_1))
    // .setLabel2(mAppContext.getResources()
    // .getString(R.string.premium_2)));
    // 
    // contentActionList.add(new Action()
    // .setId(CONTENT_ACTION_DAILY_PASS)
    // .setLabel1(mAppContext.getResources()
    // .getString(R.string.daily_pass_1))
    // .setLabel2(mAppContext.getResources()
    // .getString(R.string.daily_pass_2)));
    contentActionList.addAll(mGlobalContentActionList);
    if (content.hasTrailer()) {
        contentActionList.add(createActionButton(CONTENT_PLAY_TRAILER, R.string.action_play_trailer_1, R.string.action_play_trailer_2));
    }
    return contentActionList;
}
Also used : Action(com.amazon.android.model.Action) ArrayList(java.util.ArrayList) ContentContainer(com.amazon.android.model.content.ContentContainer) RecentRecord(com.amazon.android.contentbrowser.database.records.RecentRecord)

Example 3 with Action

use of com.amazon.android.model.Action in project zype-firebuilder by zype.

the class ContentBrowser method createSlideShowAction.

/**
 * Creates slide show action.
 *
 * @return The slide show action.
 */
private Action createSlideShowAction() {
    Action slideShow = new Action(CONTENT_ACTION_SLIDESHOW, SLIDE_SHOW, R.drawable.lb_ic_play);
    slideShow.setId(ContentBrowser.CONTENT_ACTION_SLIDESHOW);
    slideShow.setAction(SLIDE_SHOW);
    return slideShow;
}
Also used : Action(com.amazon.android.model.Action)

Example 4 with Action

use of com.amazon.android.model.Action in project zype-firebuilder by zype.

the class ContentBrowseActivity method onItemSelected.

/**
 * {@inheritDoc}
 * Called by the browse fragment ({@link ContentBrowseFragment}. Switches the content
 * title, description, and image.
 */
@Override
public void onItemSelected(Object item, Row row, boolean isLastContentRow) {
    if (item != null) {
        lastRowSelected = isLastContentRow;
    }
    if (row != lastSelectedRow && item != null) {
        lastSelectedRow = row;
        lastSelectedRowChanged = true;
    } else {
        lastSelectedRowChanged = false;
    }
    lastSelectedItemIndex = ((ArrayObjectAdapter) ((ListRow) row).getAdapter()).indexOf(item);
    if (item instanceof Content) {
        Content content = (Content) item;
        callImageLoadSubscription(content.getTitle(), content.getDescription(), content.getBackgroundImageUrl());
    } else // Update screen background with selected playlist (category) image
    if (item instanceof ContentContainer) {
        ContentContainer contentContainer = (ContentContainer) item;
        callImageLoadSubscription(contentContainer.getName(), contentContainer.getExtraStringValue("description"), contentContainer.getExtraStringValue(Content.BACKGROUND_IMAGE_URL_FIELD_NAME));
    } else if (item instanceof Action) {
        Action settingsAction = (Action) item;
        // Terms of use action.
        if (ContentBrowser.TERMS.equals(settingsAction.getAction())) {
            callImageLoadSubscription(getString(R.string.terms_title), getString(R.string.terms_description), null);
        } else // Login and logout action.
        if (ContentBrowser.LOGIN_LOGOUT.equals(settingsAction.getAction())) {
            if (settingsAction.getState() == LogoutSettingsFragment.TYPE_LOGOUT) {
                callImageLoadSubscription(getString(R.string.logout_label), getString(R.string.logout_description), null);
            } else {
                callImageLoadSubscription(getString(R.string.login_label), getString(R.string.login_description), null);
            }
        }
    }
}
Also used : Action(com.amazon.android.model.Action) Content(com.amazon.android.model.content.Content) ContentContainer(com.amazon.android.model.content.ContentContainer) ListRow(androidx.leanback.widget.ListRow)

Example 5 with Action

use of com.amazon.android.model.Action in project zype-firebuilder by zype.

the class ContentDetailsFragment method updateActions.

public void updateActions() {
    List<Action> contentActionList = ContentBrowser.getInstance(getActivity()).getContentActionList(mSelectedContent);
    int i = 0;
    mActionAdapter.clear();
    for (Action action : contentActionList) {
        mActionAdapter.set(i++, LeanbackHelpers.translateActionToLeanBackAction(action));
    }
    mActionInProgress = false;
}
Also used : Action(com.amazon.android.model.Action) PlaylistAction(com.amazon.android.model.PlaylistAction)

Aggregations

Action (com.amazon.android.model.Action)28 ListRow (androidx.leanback.widget.ListRow)6 ContentContainer (com.amazon.android.model.content.ContentContainer)6 PlaylistAction (com.amazon.android.model.PlaylistAction)5 Content (com.amazon.android.model.content.Content)5 Handler (android.os.Handler)4 ArrayList (java.util.ArrayList)4 Resources (android.content.res.Resources)3 ArrayObjectAdapter (androidx.leanback.widget.ArrayObjectAdapter)3 ImageCardView (androidx.leanback.widget.ImageCardView)3 NoSuchElementException (java.util.NoSuchElementException)3 Bitmap (android.graphics.Bitmap)2 Drawable (android.graphics.drawable.Drawable)2 LargeTest (android.test.suitebuilder.annotation.LargeTest)2 ImageView (android.widget.ImageView)2 HeaderItem (androidx.leanback.widget.HeaderItem)2 FlakyTest (androidx.test.filters.FlakyTest)2 SettingsCardPresenter (com.amazon.android.tv.tenfoot.presenter.SettingsCardPresenter)2 GlideHelper (com.amazon.android.utils.GlideHelper)2 GlideAnimation (com.bumptech.glide.request.animation.GlideAnimation)2