Search in sources :

Example 1 with SpanInfo

use of org.chromium.ui.text.SpanApplier.SpanInfo 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 2 with SpanInfo

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

the class PhysicalWebOptInActivity method getDescriptionText.

private SpannableString getDescriptionText() {
    return SpanApplier.applySpans(getString(R.string.physical_web_optin_description), new SpanInfo("<learnmore>", "</learnmore>", new ClickableSpan() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(PHYSICAL_WEB_LEARN_MORE_URL));
            // Add the SESSION extra to indicate we want a Chrome custom tab. This
            // allows the help page to open in the same task as the opt-in activity so
            // they can share a back stack.
            String session = null;
            intent.putExtra(EXTRA_CUSTOM_TABS_SESSION, session);
            PhysicalWebOptInActivity.this.startActivity(intent);
        }

        @Override
        public void updateDrawState(TextPaint ds) {
            // Color links but do not underline them.
            ds.setColor(ds.linkColor);
        }
    }));
}
Also used : SpanInfo(org.chromium.ui.text.SpanApplier.SpanInfo) Intent(android.content.Intent) SpannableString(android.text.SpannableString) ClickableSpan(android.text.style.ClickableSpan) TextView(android.widget.TextView) View(android.view.View) TextPaint(android.text.TextPaint)

Example 3 with SpanInfo

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

the class BluetoothChooserDialog method show.

/**
     * Show the BluetoothChooserDialog.
     */
@VisibleForTesting
void show() {
    // Emphasize the origin.
    Profile profile = Profile.getLastUsedProfile();
    SpannableString origin = new SpannableString(mOrigin);
    OmniboxUrlEmphasizer.emphasizeUrl(origin, mActivity.getResources(), profile, mSecurityLevel, false, true, true);
    // Construct a full string and replace the origin text with emphasized version.
    SpannableString title = new SpannableString(mActivity.getString(R.string.bluetooth_dialog_title, mOrigin));
    int start = title.toString().indexOf(mOrigin);
    TextUtils.copySpansFrom(origin, 0, origin.length(), Object.class, title, start);
    String message = mActivity.getString(R.string.bluetooth_not_found);
    SpannableString noneFound = SpanApplier.applySpans(message, new SpanInfo("<link>", "</link>", new BluetoothClickableSpan(LinkType.RESTART_SEARCH, mActivity)));
    SpannableString searching = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_searching), new SpanInfo("<link>", "</link>", new BluetoothClickableSpan(LinkType.EXPLAIN_BLUETOOTH, mActivity)));
    String positiveButton = mActivity.getString(R.string.bluetooth_confirm_button);
    SpannableString statusIdleNoneFound = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_not_seeing_it_idle_none_found), new SpanInfo("<link>", "</link>", new BluetoothClickableSpan(LinkType.EXPLAIN_BLUETOOTH, mActivity)));
    SpannableString statusActive = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_not_seeing_it), new SpanInfo("<link>", "</link>", new BluetoothClickableSpan(LinkType.EXPLAIN_BLUETOOTH, mActivity)));
    SpannableString statusIdleSomeFound = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_not_seeing_it_idle_some_found), new SpanInfo("<link1>", "</link1>", new BluetoothClickableSpan(LinkType.EXPLAIN_BLUETOOTH, mActivity)), new SpanInfo("<link2>", "</link2>", new BluetoothClickableSpan(LinkType.RESTART_SEARCH, mActivity)));
    ItemChooserDialog.ItemChooserLabels labels = new ItemChooserDialog.ItemChooserLabels(title, searching, noneFound, statusActive, statusIdleNoneFound, statusIdleSomeFound, positiveButton);
    mItemChooserDialog = new ItemChooserDialog(mActivity, this, labels);
    mActivity.registerReceiver(mLocationModeBroadcastReceiver, new IntentFilter(LocationManager.MODE_CHANGED_ACTION));
    mIsLocationModeChangedReceiverRegistered = true;
}
Also used : SpannableString(android.text.SpannableString) IntentFilter(android.content.IntentFilter) SpanInfo(org.chromium.ui.text.SpanApplier.SpanInfo) SpannableString(android.text.SpannableString) Profile(org.chromium.chrome.browser.profiles.Profile) VisibleForTesting(org.chromium.base.VisibleForTesting)

Example 4 with SpanInfo

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

the class BluetoothChooserDialog method checkLocationServicesAndPermission.

// Returns true if Location Services is on and Chrome has permission to see the user's location.
private boolean checkLocationServicesAndPermission() {
    final boolean havePermission = LocationUtils.getInstance().hasAndroidLocationPermission();
    final boolean locationServicesOn = LocationUtils.getInstance().isSystemLocationSettingEnabled();
    if (!havePermission && !mWindowAndroid.canRequestPermission(Manifest.permission.ACCESS_COARSE_LOCATION)) {
        // Immediately close the dialog because the user has asked Chrome not to request the
        // location permission.
        finishDialog(DIALOG_FINISHED_DENIED_PERMISSION, "");
        return false;
    }
    // Compute the message to show the user.
    final SpanInfo permissionSpan = new SpanInfo("<permission_link>", "</permission_link>", new BluetoothClickableSpan(LinkType.REQUEST_LOCATION_PERMISSION, mActivity));
    final SpanInfo servicesSpan = new SpanInfo("<services_link>", "</services_link>", new BluetoothClickableSpan(LinkType.REQUEST_LOCATION_SERVICES, mActivity));
    final SpannableString needLocationMessage;
    if (havePermission) {
        if (locationServicesOn) {
            // We don't need to request anything.
            return true;
        } else {
            needLocationMessage = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_need_location_services_on), servicesSpan);
        }
    } else {
        if (locationServicesOn) {
            needLocationMessage = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_need_location_permission), permissionSpan);
        } else {
            needLocationMessage = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_need_location_permission_and_services_on), permissionSpan, servicesSpan);
        }
    }
    SpannableString needLocationStatus = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_need_location_permission_help), new SpanInfo("<link>", "</link>", new BluetoothClickableSpan(LinkType.NEED_LOCATION_PERMISSION_HELP, mActivity)));
    mItemChooserDialog.setErrorState(needLocationMessage, needLocationStatus);
    return false;
}
Also used : SpannableString(android.text.SpannableString) SpanInfo(org.chromium.ui.text.SpanApplier.SpanInfo)

Example 5 with SpanInfo

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

the class BluetoothChooserDialog method notifyAdapterTurnedOff.

@VisibleForTesting
@CalledByNative
void notifyAdapterTurnedOff() {
    SpannableString adapterOffMessage = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_adapter_off), new SpanInfo("<link>", "</link>", new BluetoothClickableSpan(LinkType.ADAPTER_OFF, mActivity)));
    SpannableString adapterOffStatus = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_adapter_off_help), new SpanInfo("<link>", "</link>", new BluetoothClickableSpan(LinkType.ADAPTER_OFF_HELP, mActivity)));
    mItemChooserDialog.setErrorState(adapterOffMessage, adapterOffStatus);
}
Also used : SpannableString(android.text.SpannableString) SpanInfo(org.chromium.ui.text.SpanApplier.SpanInfo) VisibleForTesting(org.chromium.base.VisibleForTesting) CalledByNative(org.chromium.base.annotations.CalledByNative)

Aggregations

SpanInfo (org.chromium.ui.text.SpanApplier.SpanInfo)15 View (android.view.View)10 SpannableString (android.text.SpannableString)9 TextView (android.widget.TextView)9 NoUnderlineClickableSpan (org.chromium.ui.text.NoUnderlineClickableSpan)5 Intent (android.content.Intent)4 Context (android.content.Context)3 Uri (android.net.Uri)3 ClickableSpan (android.text.style.ClickableSpan)3 VisibleForTesting (org.chromium.base.VisibleForTesting)3 Resources (android.content.res.Resources)2 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)2 ForegroundColorSpan (android.text.style.ForegroundColorSpan)2 OnClickListener (android.view.View.OnClickListener)2 Profile (org.chromium.chrome.browser.profiles.Profile)2 IntentFilter (android.content.IntentFilter)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 TextPaint (android.text.TextPaint)1 TypefaceSpan (android.text.style.TypefaceSpan)1