List of usage examples for android.text.util Linkify addLinks
public static final boolean addLinks(@NonNull TextView text, @LinkifyMask int mask)
From source file:com.acrylicgoat.devchat.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.activity_main); sharedPref = getSharedPreferences("com.acrylicgoat.devchat", MODE_PRIVATE); if (savedInstanceState != null) { currentOwner = savedInstanceState.getString("currentOwner"); }/*from w w w .j a va 2s . c om*/ if (currentOwner == null || currentOwner.equals("")) { currentOwner = sharedPref.getString("currentOwner", ""); } aBar = this.getActionBar(); today = (EditText) findViewById(R.id.editToday); today.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { Linkify.addLinks(today, Linkify.ALL); } }); devName = (TextView) findViewById(R.id.devName); yesterday = (ImageButton) findViewById(R.id.calendarButton); yesterday.setOnClickListener(new OnClickListener() { public void onClick(View v) { displayPopup(); } }); String[] items = getResources().getStringArray(R.array.nav_list); setDrawer(items); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerList = (ListView) findViewById(R.id.left_drawer); SimpleAdapter sAdapter = new SimpleAdapter(this, navTitles, R.layout.nav_drawer, from, to); // Set the adapter for the list view //drawerList.setAdapter(new ArrayAdapter<String>(this,R.layout.drawer_list_item, navTitles)); // Set the list's click listener drawerList.setOnItemClickListener(new DrawerItemClickListener()); drawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ drawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(getString(R.string.app_name)); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(getString(R.string.app_name)); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; drawerToggle.setDrawerIndicatorEnabled(true); drawerToggle.syncState(); drawerLayout.setDrawerListener(drawerToggle); aBar.setTitle(getString(R.string.app_name)); //aBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); aBar.setDisplayHomeAsUpEnabled(true); aBar.setHomeButtonEnabled(true); drawerList.setAdapter(sAdapter); }
From source file:com.jbirdvegas.mgerrit.cards.PatchSetCommentsCard.java
public View setViewValue(Cursor cursor, View convertView, ViewGroup parent) { if (convertView == null) { convertView = mInflater.inflate(R.layout.commit_comment, parent, false); }/*from w ww . j a va2 s . c o m*/ ViewHolder viewHolder = (ViewHolder) convertView.getTag(); if (viewHolder == null) { viewHolder = new ViewHolder(convertView); convertView.setTag(viewHolder); } setIndicies(cursor); TextView author = viewHolder.authorTextView; Integer authorNumber = cursor.getInt(authorId_index); author.setTag(authorNumber); author.setText(cursor.getString(authorName_index)); author.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setTrackingUser((Integer) v.getTag()); } }); String timestamp = cursor.getString(timestamp_index); if (timestamp != null) { viewHolder.timestamp.setText(Tools.prettyPrintDate(mContext, timestamp, Prefs.getServerTimeZone(mContext), Prefs.getLocalTimeZone(mContext))); } // setup styled comments // use Linkify to automatically linking http/email/addresses Linkify.addLinks(viewHolder.commentMessage, Linkify.ALL); // replace replace emoticons with drawables viewHolder.commentMessage .setText(EmoticonSupportHelper.getSmiledText(mContext, cursor.getString(message_index))); // set gravatar icon for commenter viewHolder.gravatar.setImageUrl(GravatarHelper.getGravatarUrl(cursor.getString(authorEmail_index)), new ImageLoader(mRequestQuery, new BitmapLruCache(mContext))); return convertView; }
From source file:org.firebears.scouting2846.TeamDetailFragment.java
private void onTeamLoaded(Cursor c) { if (c == null) { Log.d(TAG, "team not found"); Activity a = getActivity();/*from w ww. java 2 s. co m*/ if (a != null) { Intent intent = new Intent(); intent.putExtra(TeamListActivity.ERROR_CODE, R.string.invalid_number); a.setResult(Activity.RESULT_CANCELED, intent); a.finish(); } return; } Log.d(TAG, "team loaded"); if (null == root_view) return; Toolbar bar = (Toolbar) getActivity().findViewById(R.id.detail_toolbar); if (bar != null) { int team_num = c.getInt(c.getColumnIndex(Team.COL_TEAM_NUMBER)); String nick = c.getString(c.getColumnIndex(Team.COL_NICKNAME)); bar.setTitle("" + team_num + ' ' + nick); } setViewText(R.id.locality, c, Team.COL_LOCALITY); setViewText(R.id.region, c, Team.COL_REGION); setViewText(R.id.country, c, Team.COL_COUNTRY); TextView tv = setViewText(R.id.team_website, c, Team.COL_WEBSITE); Linkify.addLinks(tv, Linkify.WEB_URLS); tv = (TextView) root_view.findViewById(R.id.team_rookie_year); String t = c.getString(c.getColumnIndex(Team.COL_ROOKIE_YEAR)); if (t != null) tv.setText(getText(R.string.rookie_year) + " " + t); initScoutingSpinner(); setViewText(R.id.team_motto, c, Team.COL_MOTTO); }
From source file:org.ewicom.pps.unitinfo.TabPhonesFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); phoneDataSource = new PhoneDataSource(getActivity()); phoneDataSource.open();/* w w w. j ava 2 s . c o m*/ LinearLayout phonesLL = (LinearLayout) getView().findViewById(R.id.ll_phones); List<Phone> phones = new ArrayList<Phone>(); phones = phoneDataSource.getPhonesByUnitId(unitID); if (phones != null && !phones.isEmpty()) { Iterator<Phone> iterator = phones.iterator(); while (iterator.hasNext()) { Phone phone = iterator.next(); LinearLayout phoneLL = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.phone_ll, null); TextView phoneTypeTV = (TextView) phoneLL.findViewById(R.id.text_phonetype); TextView phoneTV = (TextView) phoneLL.findViewById(R.id.text_phone); phoneTypeTV.setText(phone.getType()); phoneTV.setText(phone.getPhone()); Linkify.addLinks(phoneTV, Linkify.PHONE_NUMBERS); phonesLL.addView(phoneLL); } } }
From source file:com.todoroo.astrid.notes.CommentsController.java
/** Helper method to set the contents and visibility of each field */ private void bindView(View view, NoteOrUpdate item) { // name/* w w w. j ava2 s . com*/ final TextView nameView = (TextView) view.findViewById(R.id.title); { nameView.setText(item.title); Linkify.addLinks(nameView, Linkify.ALL); } // date final TextView date = (TextView) view.findViewById(R.id.date); { CharSequence dateString = DateUtils.getRelativeTimeSpanString(item.createdAt, DateUtilities.now(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); date.setText(dateString); } // picture final ImageView commentPictureView = (ImageView) view.findViewById(R.id.comment_picture); setupImagePopupForCommentView(view, commentPictureView, item.commentBitmap, activity); }
From source file:com.avapira.bobroreader.hanabira.HanabiraParser.java
public HanabiraParser(HanabiraPost post) { Context context = Hanabira.getFlower(); if (!contextInitCompleted) { bulletMarginPerLevel = Utils.convertDpToPx(context.getApplicationContext(), 12); spoilerHiddenColor = context.getColor(R.color.dobro_dark); spoilerShownColor = context.getColor(R.color.dobro_primary_text); refLinkColor = context.getColor(R.color.dobro_ref_text); quoteColor = context.getColor(R.color.dobro_quote); showSpoilers = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("show_spoilers", false);/* w ww.ja v a 2s. c om*/ contextInitCompleted = true; } this.post = post; builder = new SpannableStringBuilder(replaceInternalLinkWithReference(post.getMessage())); Linkify.addLinks(builder, Linkify.WEB_URLS); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.LinkObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();//from ww w . j a va2s .co m TextView valueTV = new TextView(context); String title; if (content.has(TITLE)) { title = "Link: " + content.optString(TITLE); } else { title = content.optString(URI); } valueTV.setText(title); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); if (Linkify.addLinks(valueTV, Linkify.ALL)) { if (!allowInteractions) valueTV.setMovementMethod(null); } frame.addView(valueTV); }
From source file:com.idt.ontomedia.geoconsum.fragments.DetailsBaseFragment.java
protected void setAvailableText(TextView _textView, String _content, int _linkifyFlags) { if (!(_content.equalsIgnoreCase(""))) { _textView.setText(_content);//from w w w. j a va 2s.com } else { _textView.setText(R.string.not_available); } if (_linkifyFlags != -1) { Linkify.addLinks(_textView, _linkifyFlags); } }
From source file:org.ewicom.pps.unitinfo.TabLeadersFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); personDataSource = new PersonDataSource(getActivity()); personDataSource.open();//from ww w. j a va 2 s. c o m LinearLayout leadersLL = (LinearLayout) getView().findViewById(R.id.ll_leaders); List<Person> persons = new ArrayList<Person>(); persons = personDataSource.getPersonsByUnitId(unitID); if (persons != null && !persons.isEmpty()) { Iterator<Person> iterator = persons.iterator(); while (iterator.hasNext()) { final Person person = iterator.next(); LinearLayout personLL = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.person_ll, null); TextView positionTV = (TextView) personLL.findViewById(R.id.text_personposition); TextView nameTV = (TextView) personLL.findViewById(R.id.text_personname); TextView phoneTV = (TextView) personLL.findViewById(R.id.text_personphone); TextView emailTV = (TextView) personLL.findViewById(R.id.text_personemail); positionTV.setText(person.getPosition()); nameTV.setText(person.getPerson()); phoneTV.setText(person.getPhone()); emailTV.setText(person.getEmail()); Linkify.addLinks(phoneTV, Linkify.PHONE_NUMBERS); Linkify.addLinks(emailTV, Linkify.EMAIL_ADDRESSES); TextView saveContactLink = (TextView) getActivity().getLayoutInflater() .inflate(R.layout.textview_link_savecontact, null); LayoutParams linkParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); personLL.addView(saveContactLink, linkParam); saveContactLink.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent saveContactIntent = new Intent(Intents.Insert.ACTION); saveContactIntent.setType(ContactsContract.RawContacts.CONTENT_TYPE); saveContactIntent.putExtra(Intents.Insert.NAME, person.getPerson()); saveContactIntent.putExtra(Intents.Insert.JOB_TITLE, person.getPosition()); saveContactIntent.putExtra(Intents.Insert.PHONE, person.getPhone()); saveContactIntent.putExtra(Intents.Insert.EMAIL, person.getEmail()); startActivity(saveContactIntent); } }); leadersLL.addView(personLL); } } }
From source file:com.facebook.android.GraphExplorer.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mHandler = new Handler(); setContentView(R.layout.graph_explorer); url = BASE_GRAPH_URL; // Base URL mInputId = (EditText) findViewById(R.id.inputId); mOutput = (TextView) findViewById(R.id.output); mSubmitButton = (Button) findViewById(R.id.submitButton); mViewURLButton = (Button) findViewById(R.id.viewURLButton); mGetPermissionsButton = (Button) findViewById(R.id.accessTokenButton); mFieldsConnectionsButton = (Button) findViewById(R.id.fieldsAndConnectionsButton); mBackParentButton = (Button) findViewById(R.id.backParentButton); mScrollView = (ScrollView) findViewById(R.id.ScrollView01); mTextDeleteButton = (Button) findViewById(R.id.textDeleteButton); mMeButton = (Button) findViewById(R.id.meButton); if (Utility.mFacebook.isSessionValid()) { mMeButton.setVisibility(View.VISIBLE); }/*w ww . j a va2s .c om*/ params = new Bundle(); mSubmitButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(mInputId.getWindowToken(), 0); // Prepare the URL to be shown on 'View URL' click action. This // is not used by the SDK url = BASE_GRAPH_URL; // Base URL /* * Source Tag: graph_explorer */ rootString = mInputId.getText().toString(); if (!TextUtils.isEmpty(rootString)) { dialog = ProgressDialog.show(GraphExplorer.this, "", getString(R.string.please_wait), true, true); params.putString("metadata", "1"); Utility.mAsyncRunner.request(rootString, params, new graphApiRequestListener()); url += "/" + rootString; // Relative Path provided by you } } }); mViewURLButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setText(url); Linkify.addLinks(mOutput, Linkify.WEB_URLS); } }); mGetPermissionsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Utility.mFacebook.isSessionValid()) { dialog = ProgressDialog.show(GraphExplorer.this, "", getString(R.string.fetching_current_permissions), true, true); Bundle params = new Bundle(); params.putString("access_token", Utility.mFacebook.getAccessToken()); Utility.mAsyncRunner.request("me/permissions", params, new permissionsRequestListener()); } else { new PermissionsDialog(GraphExplorer.this).show(); } } }); mFieldsConnectionsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (metadataObject == null) { makeToast("No fields, connections availalbe for this object."); } else { new FieldsConnectionsDialog(GraphExplorer.this, metadataObject).show(); } } }); mTextDeleteButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { url = BASE_GRAPH_URL; // Base URL mParentObjectId = ""; mInputId.setText(""); params.clear(); metadataObject = null; setText(""); mBackParentButton.setVisibility(View.INVISIBLE); } }); mMeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mInputId.setText("me"); mSubmitButton.performClick(); } }); mBackParentButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mInputId.setText(mParentObjectId); mParentObjectId = ""; mSubmitButton.performClick(); } }); }