Java源码示例:org.chromium.chrome.browser.payments.ui.PaymentRequestSection.OptionSection

示例1
@Override
public void onPaymentOptionChanged(final OptionSection section, PaymentOption option) {
    if (section == mShippingAddressSection
            && mShippingAddressSectionInformation.getSelectedItem() != option) {
        mShippingAddressSectionInformation.setSelectedItem(option);
        mIsClientCheckingSelection = mClient.onSectionOptionSelected(
                TYPE_SHIPPING_ADDRESSES, option, mUpdateSectionsCallback);
    } else if (section == mShippingOptionSection) {
        mShippingOptionsSectionInformation.setSelectedItem(option);
        mClient.onSectionOptionSelected(TYPE_SHIPPING_OPTIONS, option, null);
    } else if (section == mContactDetailsSection) {
        mContactDetailsSectionInformation.setSelectedItem(option);
        mClient.onSectionOptionSelected(TYPE_CONTACT_DETAILS, option, null);
    } else if (section == mPaymentMethodSection) {
        mPaymentMethodSectionInformation.setSelectedItem(option);
        mClient.onSectionOptionSelected(TYPE_PAYMENT_METHODS, option, null);
    }

    if (mIsClientCheckingSelection) {
        startSectionResizeAnimation();
        section.setDisplayMode(PaymentRequestSection.DISPLAY_MODE_CHECKING);
    } else {
        expand(null);
    }
    updatePayButtonEnabled();
}
 
示例2
@Override
public void onAddPaymentOption(OptionSection section) {
    assert section != mShippingOptionSection;

    if (section == mShippingAddressSection) {
        mIsClientCheckingSelection =
                mClient.onSectionAddOption(TYPE_SHIPPING_ADDRESSES, mUpdateSectionsCallback);
    } else if (section == mContactDetailsSection) {
        mClient.onSectionAddOption(TYPE_CONTACT_DETAILS, null);
    } else if (section == mPaymentMethodSection) {
        mClient.onSectionAddOption(TYPE_PAYMENT_METHODS, null);
    }

    if (mIsClientCheckingSelection) {
        startSectionResizeAnimation();
        section.setDisplayMode(PaymentRequestSection.DISPLAY_MODE_CHECKING);
    }

    updatePayButtonEnabled();
}
 
示例3
@Override
public String getAdditionalText(OptionSection section) {
    if (section == mShippingAddressSection) {
        int selectedItemIndex = mShippingAddressSectionInformation.getSelectedItemIndex();
        boolean isNecessary = mClient.merchantNeedsShippingAddress()
                && (selectedItemIndex == SectionInformation.NO_SELECTION
                           || selectedItemIndex == SectionInformation.INVALID_SELECTION);
        return isNecessary
                ? mContext.getString(selectedItemIndex == SectionInformation.NO_SELECTION
                        ? R.string.payments_select_shipping_address_for_shipping_methods
                        : R.string.payments_unsupported_shipping_address)
                : null;
    }
    return null;
}
 
示例4
@Override
public boolean isAdditionalTextDisplayingWarning(OptionSection section) {
    return section == mShippingAddressSection
            && mShippingAddressSectionInformation != null
            && mShippingAddressSectionInformation.getSelectedItemIndex()
                    == SectionInformation.INVALID_SELECTION;
}
 
示例5
/**
 * Prepares the PaymentRequestUI for initial display.
 *
 * TODO(dfalcantara): Ideally, everything related to the request and its views would just be put
 *                    into its own class but that'll require yanking out a lot of this class.
 *
 * @param activity Activity displaying the UI.
 * @param title    Title of the page.
 * @param origin   Host of the page.
 */
private void prepareRequestView(Activity activity, String title, String origin) {
    mSpinnyLayout = mRequestView.findViewById(R.id.payment_request_spinny);

    // Indicate that we're preparing the dialog for display.
    TextView messageView = (TextView) mRequestView.findViewById(R.id.message);
    messageView.setText(R.string.payments_loading_message);

    ((TextView) mRequestView.findViewById(R.id.page_title)).setText(title);
    ((TextView) mRequestView.findViewById(R.id.hostname)).setText(origin);

    // Set up the buttons.
    mCloseButton = mRequestView.findViewById(R.id.close_button);
    mCloseButton.setOnClickListener(this);
    mPayButton = DualControlLayout.createButtonForLayout(
            activity, true, activity.getString(R.string.payments_pay_button), this);
    mEditButton = DualControlLayout.createButtonForLayout(
            activity, false, activity.getString(R.string.payments_edit_button), this);
    mButtonBar = (DualControlLayout) mRequestView.findViewById(R.id.button_bar);
    mButtonBar.setAlignment(DualControlLayout.ALIGN_END);
    mButtonBar.setStackedMargin(activity.getResources().getDimensionPixelSize(
            R.dimen.infobar_margin_between_stacked_buttons));
    mButtonBar.addView(mPayButton);
    mButtonBar.addView(mEditButton);

    // Create all the possible sections.
    mSectionSeparators = new ArrayList<SectionSeparator>();
    mPaymentContainer = (ScrollView) mRequestView.findViewById(R.id.option_container);
    mPaymentContainerLayout =
            (LinearLayout) mRequestView.findViewById(R.id.payment_container_layout);
    mOrderSummarySection = new LineItemBreakdownSection(activity,
            activity.getString(R.string.payments_order_summary_label), this);
    mShippingSummarySection = new ExtraTextSection(activity,
            activity.getString(R.string.payments_shipping_summary_label), this);
    mShippingAddressSection = new OptionSection(activity,
            activity.getString(R.string.payments_shipping_address_label),
            activity.getString(R.string.payments_select_shipping_address_prompt), this);
    mShippingOptionSection = new OptionSection(activity,
            activity.getString(R.string.payments_shipping_option_label),
            activity.getString(R.string.payments_select_shipping_option_prompt), this);
    mContactDetailsSection = new OptionSection(activity,
            activity.getString(R.string.payments_contact_details_label),
            activity.getString(R.string.payments_select_contact_details_prompt), this);
    mPaymentMethodSection = new OptionSection(activity,
            activity.getString(R.string.payments_method_of_payment_label), null, this);

    // Add the necessary sections to the layout.
    mPaymentContainerLayout.addView(mOrderSummarySection, new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    mSectionSeparators.add(new SectionSeparator(mPaymentContainerLayout));
    if (mRequestShipping) {
        // The shipping breakout sections are only added if they are needed.
        mPaymentContainerLayout.addView(mShippingSummarySection, new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        mSectionSeparators.add(new SectionSeparator(mPaymentContainerLayout));
    }
    mPaymentContainerLayout.addView(mPaymentMethodSection, new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    if (mRequestContactDetails) {
        // Contact details are optional, depending on the merchant website.
        mSectionSeparators.add(new SectionSeparator(mPaymentContainerLayout));
        mPaymentContainerLayout.addView(mContactDetailsSection, new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    }
    mRequestView.addOnLayoutChangeListener(new FadeInAnimator());
    mRequestView.addOnLayoutChangeListener(new PeekingAnimator());

    // Enabled in updatePayButtonEnabled() when the user has selected all payment options.
    mPayButton.setEnabled(false);
}
 
示例6
/**
 * Prepares the PaymentRequestUI for initial display.
 *
 * TODO(dfalcantara): Ideally, everything related to the request and its views would just be put
 *                    into its own class but that'll require yanking out a lot of this class.
 *
 * @param activity    Activity displaying the UI.
 * @param title       Title of the page.
 * @param origin      Host of the page.
 * @param canAddCards Whether new cards can be added.
 */
private void prepareRequestView(
        Activity activity, String title, String origin, boolean canAddCards) {
    mSpinnyLayout = mRequestView.findViewById(R.id.payment_request_spinny);

    // Indicate that we're preparing the dialog for display.
    TextView messageView = (TextView) mRequestView.findViewById(R.id.message);
    messageView.setText(R.string.payments_loading_message);

    ((TextView) mRequestView.findViewById(R.id.page_title)).setText(title);
    ((TextView) mRequestView.findViewById(R.id.hostname)).setText(origin);

    // Set up the buttons.
    mCloseButton = mRequestView.findViewById(R.id.close_button);
    mCloseButton.setOnClickListener(this);
    mPayButton = DualControlLayout.createButtonForLayout(
            activity, true, activity.getString(R.string.payments_pay_button), this);
    mEditButton = DualControlLayout.createButtonForLayout(
            activity, false, activity.getString(R.string.payments_edit_button), this);
    mButtonBar = (DualControlLayout) mRequestView.findViewById(R.id.button_bar);
    mButtonBar.setAlignment(DualControlLayout.ALIGN_END);
    mButtonBar.setStackedMargin(activity.getResources().getDimensionPixelSize(
            R.dimen.infobar_margin_between_stacked_buttons));
    mButtonBar.addView(mPayButton);
    mButtonBar.addView(mEditButton);

    // Create all the possible sections.
    mSectionSeparators = new ArrayList<>();
    mPaymentContainer = (ScrollView) mRequestView.findViewById(R.id.option_container);
    mPaymentContainerLayout =
            (LinearLayout) mRequestView.findViewById(R.id.payment_container_layout);
    mOrderSummarySection = new LineItemBreakdownSection(activity,
            activity.getString(R.string.payments_order_summary_label), this,
            activity.getString(R.string.payments_updated_label));
    mShippingSummarySection = new ExtraTextsSection(
            activity, activity.getString(mShippingStrings.getSummaryLabel()), this);
    mShippingAddressSection = new OptionSection(
            activity, activity.getString(mShippingStrings.getAddressLabel()), this);
    mShippingOptionSection = new OptionSection(
            activity, activity.getString(mShippingStrings.getOptionLabel()), this);
    mContactDetailsSection = new OptionSection(
            activity, activity.getString(R.string.payments_contact_details_label), this);
    mPaymentMethodSection = new OptionSection(
            activity, activity.getString(R.string.payments_method_of_payment_label), this);

    // Some sections conditionally allow adding new options.
    mShippingOptionSection.setCanAddItems(false);
    mPaymentMethodSection.setCanAddItems(canAddCards);

    // Add the necessary sections to the layout.
    mPaymentContainerLayout.addView(mOrderSummarySection, new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    mSectionSeparators.add(new SectionSeparator(mPaymentContainerLayout));
    if (mRequestShipping) {
        // The shipping breakout sections are only added if they are needed.
        mPaymentContainerLayout.addView(mShippingSummarySection, new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        mSectionSeparators.add(new SectionSeparator(mPaymentContainerLayout));
    }
    mPaymentContainerLayout.addView(mPaymentMethodSection, new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    if (mRequestContactDetails) {
        // Contact details are optional, depending on the merchant website.
        mSectionSeparators.add(new SectionSeparator(mPaymentContainerLayout));
        mPaymentContainerLayout.addView(mContactDetailsSection, new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    }
    mRequestView.addOnLayoutChangeListener(new FadeInAnimator());
    mRequestView.addOnLayoutChangeListener(new PeekingAnimator());

    // Enabled in updatePayButtonEnabled() when the user has selected all payment options.
    mPayButton.setEnabled(false);
}
 
示例7
/**
 * Sets the observer to be called when the shipping address section gains or loses focus.
 *
 * @param observer The observer to notify.
 */
public void setShippingAddressSectionFocusChangedObserver(
        OptionSection.FocusChangedObserver observer) {
    mShippingAddressSection.setOptionSectionFocusChangedObserver(observer);
}