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)));
}
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);
}
}));
}
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;
}
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;
}
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);
}
Aggregations