Search in sources :

Example 1 with NoUnderlineClickableSpan

use of org.chromium.ui.text.NoUnderlineClickableSpan in project AndroidChromium by JackyAndroid.

the class ContextualSearchPromoControl method onFinishInflate.

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    View view = getView();
    // "Allow" button.
    Button allowButton = (Button) view.findViewById(R.id.contextual_search_allow_button);
    allowButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ContextualSearchPromoControl.this.handlePromoChoice(true);
        }
    });
    // "No thanks" button.
    Button noThanksButton = (Button) view.findViewById(R.id.contextual_search_no_thanks_button);
    noThanksButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ContextualSearchPromoControl.this.handlePromoChoice(false);
        }
    });
    // Fill in text with link to Settings.
    TextView promoText = (TextView) view.findViewById(R.id.contextual_search_promo_text);
    NoUnderlineClickableSpan settingsLink = new NoUnderlineClickableSpan() {

        @Override
        public void onClick(View view) {
            ContextualSearchPromoControl.this.handleClickSettingsLink();
        }
    };
    promoText.setText(SpanApplier.applySpans(view.getResources().getString(R.string.contextual_search_short_description), new SpanApplier.SpanInfo("<link>", "</link>", settingsLink)));
    promoText.setMovementMethod(LinkMovementMethod.getInstance());
    calculatePromoHeight();
}
Also used : Button(android.widget.Button) NoUnderlineClickableSpan(org.chromium.ui.text.NoUnderlineClickableSpan) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with NoUnderlineClickableSpan

use of org.chromium.ui.text.NoUnderlineClickableSpan in project AndroidChromium by JackyAndroid.

the class AccountSigninView method showConfirmSigninPage.

private void showConfirmSigninPage() {
    mSignedIn = true;
    updateSignedInAccountInfo();
    mSigninChooseView.setVisibility(View.GONE);
    mSigninConfirmationView.setVisibility(View.VISIBLE);
    setButtonsEnabled(true);
    setUpConfirmButton();
    setUpUndoButton();
    NoUnderlineClickableSpan settingsSpan = new NoUnderlineClickableSpan() {

        @Override
        public void onClick(View widget) {
            mListener.onAccountSelected(getSelectedAccountName(), true);
            RecordUserAction.record("Signin_Signin_WithAdvancedSyncSettings");
        }
    };
    mSigninSettingsControl.setText(SpanApplier.applySpans(getSettingsControlDescription(mIsChildAccount), new SpanInfo(SETTINGS_LINK_OPEN, SETTINGS_LINK_CLOSE, settingsSpan)));
}
Also used : NoUnderlineClickableSpan(org.chromium.ui.text.NoUnderlineClickableSpan) SpanInfo(org.chromium.ui.text.SpanApplier.SpanInfo) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 3 with NoUnderlineClickableSpan

use of org.chromium.ui.text.NoUnderlineClickableSpan in project AndroidChromium by JackyAndroid.

the class PasswordGenerationAdapter method getViewForType.

/**
     * Builds the view of this type.
     * @param type The type of view to build.
     * @return The view for this viewType.
     */
private View getViewForType(int type) {
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = null;
    switch(type) {
        case SUGGESTION:
            view = inflater.inflate(R.layout.password_generation_popup_suggestion, null);
            ((TextView) view.findViewById(R.id.password_generation_title)).setText(mSuggestionTitle);
            ((TextView) view.findViewById(R.id.password_generation_password)).setText(mPassword);
            break;
        case EXPLANATION:
            view = inflater.inflate(R.layout.password_generation_popup_explanation, null);
            TextView explanation = (TextView) view.findViewById(R.id.password_generation_explanation);
            SpannableString explanationSpan = new SpannableString(mExplanationText);
            explanationSpan.setSpan(new NoUnderlineClickableSpan() {

                @Override
                public void onClick(View view) {
                    mDelegate.onSavedPasswordsLinkClicked();
                }
            }, mExplanationTextLinkRangeStart, mExplanationTextLinkRangeEnd, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
            explanation.setText(explanationSpan);
            explanation.setMovementMethod(LinkMovementMethod.getInstance());
            explanation.setLayoutParams(new LayoutParams(mSuggestionMeasuredWidth, LayoutParams.WRAP_CONTENT));
            break;
        default:
            assert false : "Unknown view type";
            break;
    }
    return view;
}
Also used : SpannableString(android.text.SpannableString) LayoutParams(android.widget.RelativeLayout.LayoutParams) LayoutInflater(android.view.LayoutInflater) NoUnderlineClickableSpan(org.chromium.ui.text.NoUnderlineClickableSpan) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 4 with NoUnderlineClickableSpan

use of org.chromium.ui.text.NoUnderlineClickableSpan in project AndroidChromium by JackyAndroid.

the class UsbChooserDialog method show.

/**
     * Shows the UsbChooserDialog.
     *
     * @param activity Activity which is used for launching a dialog.
     * @param origin The origin for the site wanting to connect to the USB device.
     * @param securityLevel The security level of the connection to the site wanting to connect to
     *                      the USB device. For valid values see SecurityStateModel::SecurityLevel.
     */
@VisibleForTesting
void show(Activity activity, String origin, int securityLevel) {
    // Emphasize the origin.
    Profile profile = Profile.getLastUsedProfile();
    SpannableString originSpannableString = new SpannableString(origin);
    OmniboxUrlEmphasizer.emphasizeUrl(originSpannableString, activity.getResources(), profile, securityLevel, false, /* isInternalPage */
    true, /* useDarkColors */
    true);
    // Construct a full string and replace the origin text with emphasized version.
    SpannableString title = new SpannableString(activity.getString(R.string.usb_chooser_dialog_prompt, origin));
    int start = title.toString().indexOf(origin);
    TextUtils.copySpansFrom(originSpannableString, 0, originSpannableString.length(), Object.class, title, start);
    String searching = "";
    String noneFound = activity.getString(R.string.usb_chooser_dialog_no_devices_found_prompt);
    SpannableString statusActive = SpanApplier.applySpans(activity.getString(R.string.usb_chooser_dialog_footnote_text), new SpanInfo("<link>", "</link>", new NoUnderlineClickableSpan() {

        @Override
        public void onClick(View view) {
            if (mNativeUsbChooserDialogPtr == 0) {
                return;
            }
            nativeLoadUsbHelpPage(mNativeUsbChooserDialogPtr);
            // Get rid of the highlight background on selection.
            view.invalidate();
        }
    }));
    SpannableString statusIdleNoneFound = statusActive;
    SpannableString statusIdleSomeFound = statusActive;
    String positiveButton = activity.getString(R.string.usb_chooser_dialog_connect_button_text);
    ItemChooserDialog.ItemChooserLabels labels = new ItemChooserDialog.ItemChooserLabels(title, searching, noneFound, statusActive, statusIdleNoneFound, statusIdleSomeFound, positiveButton);
    mItemChooserDialog = new ItemChooserDialog(activity, this, labels);
}
Also used : SpannableString(android.text.SpannableString) NoUnderlineClickableSpan(org.chromium.ui.text.NoUnderlineClickableSpan) SpanInfo(org.chromium.ui.text.SpanApplier.SpanInfo) SpannableString(android.text.SpannableString) View(android.view.View) Profile(org.chromium.chrome.browser.profiles.Profile) VisibleForTesting(org.chromium.base.VisibleForTesting)

Example 5 with NoUnderlineClickableSpan

use of org.chromium.ui.text.NoUnderlineClickableSpan in project AndroidChromium by JackyAndroid.

the class LightweightFirstRunActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)) {
        completeFirstRunExperience();
    }
    setContentView(LayoutInflater.from(LightweightFirstRunActivity.this).inflate(R.layout.lightweight_fre_tos, null));
    NoUnderlineClickableSpan clickableTermsSpan = new NoUnderlineClickableSpan() {

        @Override
        public void onClick(View widget) {
            EmbedContentViewActivity.show(LightweightFirstRunActivity.this, R.string.terms_of_service_title, R.string.chrome_terms_of_service_url);
        }
    };
    NoUnderlineClickableSpan clickablePrivacySpan = new NoUnderlineClickableSpan() {

        @Override
        public void onClick(View widget) {
            EmbedContentViewActivity.show(LightweightFirstRunActivity.this, R.string.privacy_notice_title, R.string.chrome_privacy_notice_url);
        }
    };
    ((TextView) findViewById(R.id.lightweight_fre_tos_and_privacy)).setText(SpanApplier.applySpans(getString(R.string.lightweight_fre_tos_and_privacy), new SpanInfo("<LINK1>", "</LINK1>", clickableTermsSpan), new SpanInfo("<LINK2>", "</LINK2>", clickablePrivacySpan)));
    ((TextView) findViewById(R.id.lightweight_fre_tos_and_privacy)).setMovementMethod(LinkMovementMethod.getInstance());
    ((Button) findViewById(R.id.lightweight_fre_terms_accept)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            sGlue.acceptTermsOfService(false);
            completeFirstRunExperience();
        }
    });
    ((Button) findViewById(R.id.lightweight_fre_cancel)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            abortFirstRunExperience();
        }
    });
}
Also used : Button(android.widget.Button) NoUnderlineClickableSpan(org.chromium.ui.text.NoUnderlineClickableSpan) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) SpanInfo(org.chromium.ui.text.SpanApplier.SpanInfo) TextView(android.widget.TextView) View(android.view.View)

Aggregations

View (android.view.View)9 NoUnderlineClickableSpan (org.chromium.ui.text.NoUnderlineClickableSpan)9 TextView (android.widget.TextView)8 SpanInfo (org.chromium.ui.text.SpanApplier.SpanInfo)5 SpannableString (android.text.SpannableString)4 LayoutInflater (android.view.LayoutInflater)2 OnClickListener (android.view.View.OnClickListener)2 Button (android.widget.Button)2 ImageView (android.widget.ImageView)2 SpanApplier (org.chromium.ui.text.SpanApplier)2 AlertDialog (android.support.v7.app.AlertDialog)1 LayoutParams (android.widget.RelativeLayout.LayoutParams)1 VisibleForTesting (org.chromium.base.VisibleForTesting)1 Profile (org.chromium.chrome.browser.profiles.Profile)1 TabDelegate (org.chromium.chrome.browser.tabmodel.document.TabDelegate)1