List of usage examples for android.text.method LinkMovementMethod getInstance
public static MovementMethod getInstance()
From source file:org.de.jmg.learn._MainActivity.java
void EndEdit2() throws Exception { if (_txtedWord == null) return;// www .j a va2s. c om if (_txtedWord.getVisibility() == View.VISIBLE) { _txtWord.setVisibility(View.VISIBLE); _txtKom.setVisibility(View.VISIBLE); _txtedWord.setVisibility(View.GONE); _txtWord.setText(lib.getSpanableString(_txtedWord.getText().toString())); View LayWord = findViewById(R.id.LayWord); assert LayWord != null; RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) LayWord.getLayoutParams(); assert params != null; params.width = LayoutParams.WRAP_CONTENT; LayWord.setLayoutParams(params); _txtedKom.setVisibility(View.GONE); _txtKom.setText(lib.getSpanableString(_txtedKom.getText().toString())); _txtedWord.setImeOptions(EditorInfo.IME_ACTION_NONE); _txtedKom.setImeOptions(EditorInfo.IME_ACTION_NONE); _txtMeaning1.setImeOptions(EditorInfo.IME_ACTION_DONE); _txtMeaning2.setImeOptions(EditorInfo.IME_ACTION_DONE); _txtMeaning3.setImeOptions(EditorInfo.IME_ACTION_DONE); lib.setBgEditText(_txtMeaning1, _MeaningBG); lib.setBgEditText(_txtMeaning2, _MeaningBG); lib.setBgEditText(_txtMeaning3, _MeaningBG); /*_txtMeaning1.setBackgroundResource(0); _txtMeaning2.setBackgroundResource(0); _txtMeaning3.setBackgroundResource(0);*/ if (!_vok.getCardMode()) { _txtMeaning1.setLines(1); _txtMeaning1.setSingleLine(); _txtMeaning2.setLines(1); _txtMeaning2.setSingleLine(); _txtMeaning2.setVisibility(View.VISIBLE); _txtMeaning3.setLines(1); _txtMeaning3.setSingleLine(); _txtMeaning3.setVisibility(View.VISIBLE); } else { _originalMovementmethod = _txtMeaning1.getMovementMethod(); //_txtMeaning1.setAutoLinkMask(Linkify.ALL); _txtMeaning1.setMovementMethod(LinkMovementMethod.getInstance()); //_txtMeaning1.setInputType(InputType.TYPE_NULL); //_txtMeaning1.requestFocus(); //InputMethodManager Imn = (InputMethodManager) _main.getSystemService(Context.INPUT_METHOD_SERVICE); //Imn.hideSoftInputFromInputMethod(_txtMeaning1.getWindowToken(), 0); } } getVokabel(false, false); }
From source file:com.android.launcher3.Utilities.java
public static void aboutAlertDialog(Context context) { AlertDialog builder = new AlertDialog.Builder(context, R.style.AlertDialogCustom) .setTitle(context.getResources().getString(R.string.app_name)).setCancelable(false) .setIcon(R.mipmap.ic_launcher_home).setMessage(R.string.disclaimer_dialog_message) .setPositiveButton(context.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); }//from w ww .jav a 2 s .co m }) .create(); builder.show(); ((TextView) builder.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); ((TextView) builder.findViewById(android.R.id.message)).setGravity(Gravity.CENTER_VERTICAL); builder.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); }
From source file:com.hughes.android.dictionary.DictionaryActivity.java
private void createTokenLinkSpans(final TextView textView, final Spannable spannable, final String text) { // Saw from the source code that LinkMovementMethod sets the selection! // http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.1_r1/android/text/method/LinkMovementMethod.java#LinkMovementMethod textView.setMovementMethod(LinkMovementMethod.getInstance()); final Matcher matcher = CHAR_DASH.matcher(text); while (matcher.find()) { spannable.setSpan(new NonLinkClickableSpan(textColorFg), matcher.start(), matcher.end(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); }/*from w w w .j a v a 2s. c om*/ }
From source file:com.android.launcher3.Utilities.java
public static void licenseAlertDialog(Context context) { AlertDialog builder = new AlertDialog.Builder(context, R.style.AlertDialogCustom) .setTitle(context.getResources().getString(R.string.app_name)).setCancelable(false) .setIcon(R.mipmap.ic_launcher_home).setMessage(R.string.license_dialog_message).setPositiveButton( context.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); }/*from ww w . jav a2 s. co m*/ }) .create(); builder.show(); ((TextView) builder.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); ((TextView) builder.findViewById(android.R.id.message)).setGravity(Gravity.CENTER_VERTICAL); builder.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); }
From source file:com.mantz_it.rfanalyzer.ui.activity.MainActivity.java
public void showInfoDialog() { AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(Html.fromHtml(getString(R.string.info_title, versionName))) .setMessage(Html.fromHtml(getString(R.string.info_msg_body))) .setPositiveButton("OK", (dialog1, whichButton) -> { // Do nothing }).create();//from ww w .j av a 2s. c o m dialog.show(); // make links clickable: ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:org.de.jmg.learn._MainActivity.java
public void SetViewsToVokMode() { if (_mBackgroundBack != null) _MeaningBG = _mBackgroundBack;/*from w w w .j a v a2 s .com*/ // _txtWord.setMaxLines(3); // _txtWord.setLines(1); _txtWord.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (60 * scale)); _txtWord.setHorizontallyScrolling(false); // _txtKom.setMaxLines(3); // _txtKom.setLines(2); _txtKom.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (35 * scale)); _txtKom.setHorizontallyScrolling(false); _txtMeaning1.setLines(1); _txtMeaning1.setSingleLine(); _txtMeaning1.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (40 * scale)); _txtMeaning1.setMaxLines(3); _txtMeaning1.setGravity(Gravity.CENTER_VERTICAL | Gravity.START); _txtMeaning1.setHorizontallyScrolling(false); //_txtMeaning1.setAutoLinkMask(0); if (_originalMovementmethod != null && _txtMeaning1.getMovementMethod() == LinkMovementMethod.getInstance()) { _txtMeaning1.setMovementMethod(_originalMovementmethod); } //_txtMeaning1.setVerticalScrollBarEnabled(false); //_txtMeaning1.requestFocus(); //InputMethodManager Imn = (InputMethodManager) _main.getSystemService(Context.INPUT_METHOD_SERVICE); //Imn.showSoftInputFromInputMethod(_txtMeaning1.getWindowToken(), 0); //_txtMeaning1.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); _txtMeaning2.setVisibility(View.VISIBLE); _txtMeaning2.setLines(1); _txtMeaning2.setSingleLine(); _txtMeaning2.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (40 * scale)); _txtMeaning2.setMaxLines(3); _txtMeaning2.setHorizontallyScrolling(false); _txtMeaning3.setVisibility(View.VISIBLE); _txtMeaning3.setLines(1); _txtMeaning3.setSingleLine(); _txtMeaning3.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (40 * scale)); _txtMeaning3.setMaxLines(3); _txtMeaning3.setHorizontallyScrolling(false); }
From source file:com.Beat.RingdroidEditActivity.java
void showServerPrompt(final boolean userInitiated) { final SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); final SpannableString message = new SpannableString(getResources().getText(R.string.server_prompt)); Linkify.addLinks(message, Linkify.ALL); final AlertDialog dialog = new AlertDialog.Builder(RingdroidEditActivity.this) .setTitle(R.string.server_title).setMessage(message) .setPositiveButton(R.string.server_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.putInt(PREF_STATS_SERVER_ALLOWED, SERVER_ALLOWED_YES); prefsEditor.commit(); if (userInitiated) { finish();/* w w w . j a va 2 s.c om*/ } else { sendStatsToServerAndFinish(); } } }).setNeutralButton(R.string.server_later, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int allowServerCheckIndex = prefs.getInt(PREF_STATS_SERVER_CHECK, 2); int successCount = prefs.getInt(PREF_SUCCESS_COUNT, 0); SharedPreferences.Editor prefsEditor = prefs.edit(); if (userInitiated) { prefsEditor.putInt(PREF_STATS_SERVER_CHECK, successCount + 2); } else { prefsEditor.putInt(PREF_STATS_SERVER_CHECK, allowServerCheckIndex * 2); } prefsEditor.commit(); finish(); } }).setNegativeButton(R.string.server_never, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.putInt(PREF_STATS_SERVER_ALLOWED, SERVER_ALLOWED_NO); if (userInitiated) { // If the user initiated, err on the safe side and disable // sending crash reports too. There's no way to turn them // back on now aside from clearing data from this app, but // it doesn't matter, we don't need error reports from every // user ever. prefsEditor.putInt(PREF_ERR_SERVER_ALLOWED, SERVER_ALLOWED_NO); } prefsEditor.commit(); finish(); } }).setCancelable(false).show(); // Make links clicky ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:org.de.jmg.learn._MainActivity.java
public void SetViewsToCardmode() { // _txtWord.setMaxLines(3); // _txtWord.setLines(2); // _txtKom.setMaxLines(3); // _txtKom.setLines(2); _txtWord.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (40 * scale)); _txtKom.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (30 * scale)); _txtMeaning1.setSingleLine(false);/* w w w .ja va 2s . c o m*/ _txtMeaning1.setMaxLines(1000); _txtMeaning1.setLines(16); //_txtMeaning1.setMinLines(2); _txtMeaning1.setGravity(Gravity.TOP | Gravity.START); _txtMeaning1.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (25 * scale)); //_txtMeaning1.requestFocus(); //InputMethodManager Imn = (InputMethodManager) _main.getSystemService(Context.INPUT_METHOD_SERVICE); //Imn.hideSoftInputFromInputMethod(_txtMeaning1.getWindowToken(), 0); if (_originalMovementmethod == null) _originalMovementmethod = _txtMeaning1.getMovementMethod(); //_txtMeaning1.setAutoLinkMask(Linkify.ALL); if (_txtMeaning1.getMovementMethod() != LinkMovementMethod.getInstance()) _txtMeaning1.setMovementMethod(LinkMovementMethod.getInstance()); //_txtMeaning1.setVerticalScrollBarEnabled(true); //_txtMeaning1.setInputType(InputType.TYPE_NULL); // _txtMeaning1.setImeOptions(EditorInfo.IME_NULL); // _txtMeaning1.setImeActionLabel(null, KeyEvent.KEYCODE_ENTER); // _txtMeaning1.setImeActionLabel("Custom text", // KeyEvent.KEYCODE_ENTER); _txtMeaning2.setVisibility(View.GONE); _txtMeaning3.setVisibility(View.GONE); if (_MeaningBG != null) _mBackgroundBack = _MeaningBG; _MeaningBG = null; //if (_mBackgroundBack!=null) _MeaningBG = _mBackgroundBack; }
From source file:com.android.calendar.EventInfoFragment.java
private void updateEvent(View view) { if (mEventCursor == null || view == null) { return;/*from w ww . j a va 2 s .c om*/ } Context context = view.getContext(); if (context == null) { return; } String eventName = mEventCursor.getString(EVENT_INDEX_TITLE); if (eventName == null || eventName.length() == 0) { eventName = getActivity().getString(R.string.no_title_label); } // 3rd parties might not have specified the start/end time when firing the // Events.CONTENT_URI intent. Update these with values read from the db. if (mStartMillis == 0 && mEndMillis == 0) { mStartMillis = mEventCursor.getLong(EVENT_INDEX_DTSTART); mEndMillis = mEventCursor.getLong(EVENT_INDEX_DTEND); if (mEndMillis == 0) { String duration = mEventCursor.getString(EVENT_INDEX_DURATION); if (!TextUtils.isEmpty(duration)) { try { Duration d = new Duration(); d.parse(duration); long endMillis = mStartMillis + d.getMillis(); if (endMillis >= mStartMillis) { mEndMillis = endMillis; } else { Log.d(TAG, "Invalid duration string: " + duration); } } catch (DateException e) { Log.d(TAG, "Error parsing duration string " + duration, e); } } if (mEndMillis == 0) { mEndMillis = mStartMillis; } } } mAllDay = mEventCursor.getInt(EVENT_INDEX_ALL_DAY) != 0; String location = mEventCursor.getString(EVENT_INDEX_EVENT_LOCATION); String description = mEventCursor.getString(EVENT_INDEX_DESCRIPTION); String rRule = mEventCursor.getString(EVENT_INDEX_RRULE); String eventTimezone = mEventCursor.getString(EVENT_INDEX_EVENT_TIMEZONE); mHeadlines.setBackgroundColor(mCurrentColor); // What if (eventName != null) { setTextCommon(view, R.id.title, eventName); } // When // Set the date and repeats (if any) String localTimezone = Utils.getTimeZone(mActivity, mTZUpdater); Resources resources = context.getResources(); String displayedDatetime = Utils.getDisplayedDatetime(mStartMillis, mEndMillis, System.currentTimeMillis(), localTimezone, mAllDay, context); String displayedTimezone = null; if (!mAllDay) { displayedTimezone = Utils.getDisplayedTimezone(mStartMillis, localTimezone, eventTimezone); } // Display the datetime. Make the timezone (if any) transparent. if (displayedTimezone == null) { setTextCommon(view, R.id.when_datetime, displayedDatetime); } else { int timezoneIndex = displayedDatetime.length(); displayedDatetime += " " + displayedTimezone; SpannableStringBuilder sb = new SpannableStringBuilder(displayedDatetime); ForegroundColorSpan transparentColorSpan = new ForegroundColorSpan( resources.getColor(R.color.event_info_headline_transparent_color)); sb.setSpan(transparentColorSpan, timezoneIndex, displayedDatetime.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); setTextCommon(view, R.id.when_datetime, sb); } // Display the repeat string (if any) String repeatString = null; if (!TextUtils.isEmpty(rRule)) { EventRecurrence eventRecurrence = new EventRecurrence(); eventRecurrence.parse(rRule); Time date = new Time(localTimezone); date.set(mStartMillis); if (mAllDay) { date.timezone = Time.TIMEZONE_UTC; } eventRecurrence.setStartDate(date); repeatString = EventRecurrenceFormatter.getRepeatString(mContext, resources, eventRecurrence, true); } if (repeatString == null) { view.findViewById(R.id.when_repeat).setVisibility(View.GONE); } else { setTextCommon(view, R.id.when_repeat, repeatString); } // Organizer view is setup in the updateCalendar method // Where if (location == null || location.trim().length() == 0) { setVisibilityCommon(view, R.id.where, View.GONE); } else { final TextView textView = mWhere; if (textView != null) { textView.setAutoLinkMask(0); textView.setText(location.trim()); try { textView.setText(Utils.extendedLinkify(textView.getText().toString(), true)); // Linkify.addLinks() sets the TextView movement method if it finds any links. // We must do the same here, in case linkify by itself did not find any. // (This is cloned from Linkify.addLinkMovementMethod().) MovementMethod mm = textView.getMovementMethod(); if ((mm == null) || !(mm instanceof LinkMovementMethod)) { if (textView.getLinksClickable()) { textView.setMovementMethod(LinkMovementMethod.getInstance()); } } } catch (Exception ex) { // unexpected Log.e(TAG, "Linkification failed", ex); } textView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { try { return v.onTouchEvent(event); } catch (ActivityNotFoundException e) { // ignore return true; } } }); } } // Description if (description != null && description.length() != 0) { mDesc.setText(description); } // Launch Custom App if (Utils.isJellybeanOrLater()) { updateCustomAppButton(); } }
From source file:org.thoughtland.xlocation.ActivityApp.java
@SuppressLint("InflateParams") public static void showHelp(ActivityBase context, View parent, Hook hook) { // Build dialog Dialog dlgHelp = new Dialog(context); dlgHelp.requestWindowFeature(Window.FEATURE_LEFT_ICON); dlgHelp.setTitle(R.string.app_name); dlgHelp.setContentView(R.layout.helpfunc); dlgHelp.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, context.getThemed(R.attr.icon_launcher)); dlgHelp.setCancelable(true);//from w ww .ja v a 2 s .c om // Set title TextView tvTitle = (TextView) dlgHelp.findViewById(R.id.tvTitle); tvTitle.setText(hook.getName()); // Set info TextView tvInfo = (TextView) dlgHelp.findViewById(R.id.tvInfo); tvInfo.setText(Html.fromHtml(hook.getAnnotation())); tvInfo.setMovementMethod(LinkMovementMethod.getInstance()); // Set permissions String[] permissions = hook.getPermissions(); if (permissions != null && permissions.length > 0) if (!permissions[0].equals("")) { TextView tvPermissions = (TextView) dlgHelp.findViewById(R.id.tvPermissions); tvPermissions.setText(Html.fromHtml(TextUtils.join("<br />", permissions))); } dlgHelp.show(); }