Java Code Examples for android.text.Spanned

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project agit, under directory /agit/src/main/java/com/madgag/agit/.

Source file: BlobViewFragment.java

  22 
vote

public void displayBlob(){
  Uri data=Uri.parse("file://" + tempFile.getAbsolutePath());
  Intent intent=new Intent(android.content.Intent.ACTION_VIEW);
  intent.setDataAndType(data,mimeType);
  if (isIntentAvailable(getActivity(),intent)) {
    startActivity(intent);
  }
 else {
    Spanned messageHtml=fromHtml(getString(R.string.no_viewer_available_for_file,boldCode(nameString)));
    Toast.makeText(getActivity(),messageHtml,Toast.LENGTH_LONG).show();
  }
  getActivity().finish();
}
 

Example 2

From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/activity/.

Source file: AboutActivity.java

  22 
vote

@Override public View getChildView(int groupPosition,int childPosition,boolean isLastChild,View convertView,ViewGroup parent){
  if (convertView == null) {
    convertView=layoutInflater.inflate(R.layout.about_content,null);
  }
  String text=contents[groupPosition];
  Spanned spanned=Html.fromHtml(text);
  spanned=stripUnderlines(spanned);
  TextView view=(TextView)convertView.findViewById(R.id.content);
  view.setText(spanned);
  view.setMovementMethod(LinkMovementMethod.getInstance());
  return convertView;
}
 

Example 3

From project android-client, under directory /xwiki-android-components/src/hu/scythe/droidwriter/.

Source file: DroidWriterEditText.java

  22 
vote

public void setImageInsertButton(View button,final String imageResource){
  button.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      int position=Selection.getSelectionStart(DroidWriterEditText.this.getText());
      Spanned e=Html.fromHtml("<img src=\"" + imageResource + "\">",imageGetter,null);
      DroidWriterEditText.this.getText().insert(position,e);
    }
  }
);
}
 

Example 4

From project android_packages_apps_QuickSearchBox, under directory /tests/src/com/android/quicksearchbox/.

Source file: LevenshteinFormatterTest.java

  22 
vote

private void verifyFormatSuggestion(String query,String suggestion,SpanFormat... spans){
  Spanned s=mFormatter.formatSuggestion(query,suggestion);
  for (  SpanFormat span : spans) {
    span.verify(s);
  }
}
 

Example 5

From project friendica-for-android, under directory /mw-android-friendica-01/src/de/wikilab/android/friendica01/.

Source file: Max.java

  22 
vote

public static void setHtmlWithImages(TextView t,String html){
  Spanned spanned=Html.fromHtml(html);
  Spannable htmlSpannable;
  if (spanned instanceof SpannableStringBuilder) {
    htmlSpannable=(SpannableStringBuilder)spanned;
  }
 else {
    htmlSpannable=new SpannableStringBuilder(spanned);
  }
  t.setText(htmlSpannable);
  new ImageLoadTask(t.getContext(),htmlSpannable,t).execute();
}
 

Example 6

From project Jota-Text-Editor, under directory /src/jp/sblo/pandora/jota/text/.

Source file: Layout.java

  22 
vote

/** 
 * Get the alignment of the specified paragraph, taking into account markup attached to it.
 */
public final Alignment getParagraphAlignment(int line){
  Alignment align=mAlignment;
  if (mSpannedText) {
    Spanned sp=(Spanned)mText;
    AlignmentSpan[] spans=sp.getSpans(getLineStart(line),getLineEnd(line),AlignmentSpan.class);
    int spanLength=spans.length;
    if (spanLength > 0) {
      align=spans[spanLength - 1].getAlignment();
    }
  }
  return align;
}
 

Example 7

From project MyHeath-Android, under directory /actionbarlib/src/com/actionbarsherlock/widget/.

Source file: SearchViewSherlock.java

  22 
vote

private boolean onItemClicked(int position,int actionKey,String actionMsg){
  if (mOnSuggestionListener == null || !mOnSuggestionListener.onSuggestionClick(position)) {
    Spanned query=mSuggestionsAdapter.getItem(position);
    if (mOnQueryChangeListener != null) {
      mOnQueryChangeListener.onQueryTextSubmit(query.toString());
    }
    setImeVisibility(false);
    dismissSuggestions();
    setQueryWithoutSuggestion(query);
    return true;
  }
  return false;
}
 

Example 8

From project PageTurner, under directory /src/main/java/net/nightwhistler/pageturner/view/.

Source file: BookView.java

  22 
vote

public boolean hasLinkAt(float x,float y){
  Integer offset=findOffsetForPosition(x,y);
  if (offset == null) {
    return false;
  }
  Spanned text=(Spanned)childView.getText();
  ClickableSpan[] spans=text.getSpans(offset,offset,ClickableSpan.class);
  return spans != null && spans.length > 0;
}
 

Example 9

From project platform_packages_apps_contacts, under directory /src/com/android/contacts/util/.

Source file: HtmlUtils.java

  22 
vote

/** 
 * Converts HTML string to a  {@link Spanned} text, adjusting formatting. Any extra new linecharacters at the end of the text will be trimmed.
 */
public static Spanned fromHtml(Context context,String text){
  if (TextUtils.isEmpty(text)) {
    return null;
  }
  Spanned spanned=Html.fromHtml(text);
  return postprocess(context,spanned);
}
 

Example 10

From project RebeLauncher, under directory /src/com/dirtypepper/rebelauncher/.

Source file: AlmostNexusSettingsHelper.java

  22 
vote

public static AlertDialog create(Context context) throws NameNotFoundException {
  String aboutTitle=String.format("%s Changelog",context.getString(R.string.rl_version));
  Spanned aboutText=Html.fromHtml(context.getString(R.string.adw_changelog,TextView.BufferType.SPANNABLE));
  ScrollView mainView=new ScrollView(context);
  final TextView message=new TextView(context);
  mainView.addView(message);
  message.setPadding(5,5,5,5);
  message.setText(aboutText);
  return new AlertDialog.Builder(context).setTitle(aboutTitle).setCancelable(true).setIcon(R.drawable.ic_launcher_home).setPositiveButton(context.getString(android.R.string.ok),null).setView(mainView).create();
}
 

Example 11

From project reddit-is-fun, under directory /src/com/andrewshu/android/reddit/comments/.

Source file: ProcessCommentsTask.java

  22 
vote

/** 
 * @param bodyHtml escaped HTML (like in reddit Thing's body_html)
 */
private CharSequence createSpanned(String bodyHtml){
  try {
    bodyHtml=Html.fromHtml(bodyHtml).toString();
    bodyHtml=Util.convertHtmlTags(bodyHtml);
    Spanned body=Html.fromHtml(bodyHtml);
    if (body.length() > 2)     return body.subSequence(0,body.length() - 2);
 else     return "";
  }
 catch (  Exception e) {
    if (Constants.LOGGING)     Log.e(TAG,"createSpanned failed",e);
    return null;
  }
}
 

Example 12

From project zxing-android, under directory /src/com/laundrylocker/barcodescanner/result/supplement/.

Source file: SupplementalInfoRetriever.java

  22 
vote

final void append(final String newText) throws InterruptedException {
  final TextView textView=textViewRef.get();
  if (textView == null) {
    throw new InterruptedException();
  }
  handler.post(new Runnable(){
    public void run(){
      Spanned html=Html.fromHtml(newText + '\n');
      textView.append(html);
    }
  }
);
}
 

Example 13

From project CineShowTime-Android, under directory /Libraries/CineShowTime/src/com/binomed/showtime/android/layout/dialogs/last/.

Source file: LastChangeDialog.java

  21 
vote

/** 
 * @see android.app.Dialog#onCreate(android.os.Bundle)
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.dialog_last);
  try {
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(mainContext);
    Editor editor=prefs.edit();
    editor.remove(CineShowtimeCst.PREF_KEY_APP_ENGINE);
    editor.commit();
  }
 catch (  Exception e) {
  }
  Button btnClose=(Button)findViewById(R.id.lastBtnClose);
  btnClose.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View arg0){
      LastChangeDialog.this.dismiss();
    }
  }
);
  setTitle(mainContext.getResources().getString(R.string.dialogLastChangeTitle));
  TextView contentLastChange=(TextView)findViewById(R.id.lastChangetText);
  Spanned spanned=Html.fromHtml("<b>v3.0.12</b><br><br>" + " * * Fix crash for tablet when change portrait to landscape <br>" + "<br>"+ "<b>v3.0.11</b><br><br>"+ " * * Fix somes crash bug <br>"+ "<br>"+ "<b>v3.0.10</b><br><br>"+ " * * Fix somes crash bug <br>"+ "<br>"+ "<b>v3.0.9</b><br><br>"+ " * Improve fast scrolling in results <br>"+ "<br>"+ "<b>v3.0.8</b><br><br>"+ " * Fix somes crash bug (call, widgets, sort...)<br>"+ "<br>"+ "<b>v3.0.7</b><br><br>"+ " * Fix somes crash bug (call, results, ...)<br>"+ "<br>"+ "<b>v3.0.6</b><br><br>"+ " * Fix somes crash bug<br>"+ "<br>"+ "<b>v3.0.5</b><br><br>"+ " * Fix somes crash bug<br>"+ "<br>"+ "<b>v3.0.4</b><br><br>"+ " * Fix crash bug for search movies<br>"+ " * Fix widgets crash<br>"+ "<br>"+ "<b>v3.0.3</b><br><br>"+ " * Fix crash bug for donuts phones<br>"+ "<br>"+ "<b>v3.0.2</b><br><br>"+ " * Fix starting crash<br>"+ "<br>"+ "<b>v3.0.1</b><br><br>"+ " * Fix some server bug<br>"+ " * New translation for italian<br>"+ "<br>"+ "<b>v3.0.0</b><br><br>"+ " * Reset Widgets<br>"+ " * Multi Widgets support<br>"+ " * Add of Action bar<br>"+ " * Tablet screen support<br>"+ " * Improve UI<br>"+ " * Fix some crash problems<br>"+ " * Integration of Chinese langages<br>"+ "<br>"+ "<b>v2.1.1</b><br><br>"+ " * Fix some crash problems<br>"+ "<br>"+ "<b>v2.1.0</b><br><br>"+ " * Add of SplashScreen<br>"+ " * Add of Google Analytics<br>"+ " * Add of menu in movie screen<br>"+ " * App2Sd support<br>"+ " * Add of GPS animation<br>"+ " * Fix some crash problems<br>"+ "<br>"+ "<b>v2.0.3</b><br><br>"+ " * Fix some crash problems<br>"+ "<br>"+ "<b>v2.0.2</b><br><br>"+ " * Fix some crash problems<br>"+ "<br>"+ "<b>v2.0.1</b><br><br>"+ " * Fix landscape problem for search screen<br>"+ " * Fix some crash problems<br>"+ "<br>"+ "<b>v2.0.0</b><br><br>"+ " * New UI<br>"+ " * Add Themes management<br>"+ " * Add tab review in movie screen<br>"+ " * Add trailers directly in movie screen<br>"+ " * Possibility to reserve if infomation is available<br>"+ "<br>"+ "<b>v1.10.1</b><br><br>"+ " * Minor fix corresponding to crash reports<br>"+ " * Suppression of gps message when launching app<br>"+ "<br>"+ "<b>v1.10.0</b><br><br>"+ " * Fix with favorites<br>"+ " * Fix with distance<br>"+ "<br>"+ "<b>v1.9.2</b><br><br>"+ " * Fix for archos tablet<br>"+ "<br>"+ "<b>v1.9.1</b><br><br>"+ " * Minor bug correction with favorites<br>"+ " * Change of icon<br>"+ " * <b>Please update your favorites cinemas (delete, recreate) if there is an error<b><br>"+ "<br>"+ "<b>v1.9.0</b><br><br>"+ " * Support of japanese langage and italian<br>"+ " * Change of icon<br>"+ " * Change of widget : you have to reset your widget<br>"+ "<br>"+ "<b>v1.8.1</b><br><br>"+ " * Minor fix for bookmark bug"+ "<br>"+ "<b>v1.8.0</b><br><br>"+ " * Location bugs correction<br>"+ " * crash bug correction<br>"+ " * correction on server for movie descriptions<br>"+ " * integration of 'es' langage, complete rewrite of 'en' traductions.<br>"+ " * managment of widget in cupcake in multi-screen and multi resolutions<br>"+ "<br>"+ "<b>v1.7.2 and 1.7.3</b><br>"+ "<br>"+ " * Location bugs correction<br>"+ " * crash bug correction<br>"+ " * correction on server for movie times<br>"+ " * integration of pt, pt_BR, and cz langages<br>"+ "<br>"+ "<b>v1.7.1</b><br>"+ "<br>"+ " * Minor update for integrating message when no results come from server<br>"+ "<br>"+ "<b>v1.7.0</b><br>"+ "<br>"+ " * Management of Turkish langage<br>"+ " * Management of widget for multiScreen (Add of widget for cupcake)<br>"+ "<br>"+ "<b>v1.6.2 and v1.6.3</b><br>"+ "<br>"+ " * Minor update correcting widget bug<br>"+ "<br>"+ "<b>v1.6.1</b><br>"+ "<br>"+ " * Enhance UI<br>"+ " * Management of deutch langage<br>"+ "<br>"+ "<b>v1.6.0</b><br>"+ "<br>"+ " * Integration of SkyHook? framework => you can search near your wifi position, ip position<br>"+ " * Correction of bugs with bookmarks theater.<br>"+ " * Integration of projection langage.<br>"+ " * Warning ! this version will reset your bookmark theater and the widget.<br>"+ "<br>"+ "<b>v1.5.0</b><br>"+ "<br>"+ " * Management of time of adds before movies showtime in preferences<br>"+ " * Correction of bug of gps localisation invisible buttons, for android 1.1 and 1.5<br>"+ " * Support of ru langage (Thanks Stan)<br>"+ "<br>"+ "<b>v1.4.0</b><br>"+ "<br>"+ " * Add of button Bookmarks on main screen<br>"+ " * Click on widget now open directly on theater showtimes<br>"+ " * Add of possibility to have drive direction to theaters<br>"+ " * Possibility of multi-page in widget search<br>"+ " * Add search speech for name of city and name of movie (if speech available). Works for english word only (wait for google :))<br>"+ " * Increase number of day in spinner<br>"+ " * Improve of way to get movie summary<br>"+ "<br>"+ "<b>v1.3.1</b><br>"+ "<br>"+ " * Correction for motorola blur (but many other phone could be concerned) for text of buttons invisible<br>"+ "<br>"+ "<b>v1.3.0</b><br>"+ "<br>"+ " * Management of drive time to go to theater. You could have only showtime reachables.<br>"+ " * You can add a showtime into calendar application.<br>"+ " * You can localise you with network position.<br>"+ " * Correction of issues 1,2,3 and 4.<br>"+ " * Add of option in menu for management of localisation.<br>"+ "<br>"+ "<b>v1.2.0</b><br>"+ "<br>"+ " * Add of about menu (version informations)<br>"+ " * Add of help menu<br>"+ " * Correction of bug with showtimes accross days and theaters<br>"+ " * Improve UI fast<br>"+ "<br>"+ "<b>v1.1.0</b><br>"+ "<br>"+ " * Widget management<br>"+ " * Improve UI<br>"+ " * Correction of some bugs<br>"+ "<br>"+ "<b>v1.0.0</b><br>"+ "<br>"+ " * Search theaters according to position and show movie list and showtimes corresponding<br>"+ " * You can call theaters<br>"+ " * You can launch maps to localize the theaters<br>"+ " * You can search trailers of the movies<br>"+ " * You can manage theaters bookmarks<br>"+ " * For each movie, there is a description screen with several information on the movie<br>"+ " * You can use your GPS to localise you and search show time near your position<br>"+ " * You can sort your results by :<br>"+ " * Distance of the theater<br>"+ " * Name of the theater<br>"+ " * The closest showtime<br>"+ " * You can see what's on screens during the 3 next day<br>"+ " * Search showtimes by movie name<br>"+ " * You can invite your friends by sms or mail to a film event<br>"+ " * Management of langage :<br>"+ " ->en<br>"+ " ->fr<br>"+ " ->de<br>"+ " ->pt<br>");
  contentLastChange.setText(spanned);
}
 

Example 14

From project devoxx-france-android-in-fine, under directory /src/com/infine/android/devoxx/ui/.

Source file: SessionsFragment.java

  21 
vote

/** 
 * {@inheritDoc} 
 */
@Override public void bindView(View view,Context context,Cursor cursor){
  final TextView titleView=(TextView)view.findViewById(R.id.session_title);
  final TextView subtitleView=(TextView)view.findViewById(R.id.session_subtitle);
  final TextView subtitleTagView=(TextView)view.findViewById(R.id.session_subtitle_tag);
  titleView.setText(cursor.getString(SessionsQuery.TITLE));
  final long blockStart=cursor.getLong(SessionsQuery.BLOCK_START);
  final long blockEnd=cursor.getLong(SessionsQuery.BLOCK_END);
  final String roomName=cursor.getString(SessionsQuery.ROOM_NAME);
  final Spanned subtitle=formatSessionSubtitle(blockStart,blockEnd,roomName,context);
  subtitleView.setText(subtitle);
  subtitleTagView.setText(cursor.getString(SessionsQuery.SESSION_THEME));
  final boolean starred=cursor.getInt(SessionsQuery.STARRED) != 0;
  view.findViewById(R.id.star_button).setVisibility(starred ? View.VISIBLE : View.INVISIBLE);
  UIUtils.setSessionTitleColor(blockStart,blockEnd,titleView,subtitleView);
}
 

Example 15

From project HtmlSpanner, under directory /src/main/java/net/nightwhistler/htmlspanner/handlers/.

Source file: TableHandler.java

  21 
vote

private void readNode(Object node,Table table){
  if (node instanceof ContentNode) {
    return;
  }
  TagNode tagNode=(TagNode)node;
  if (tagNode.getName().equals("td")) {
    Spanned result=this.getSpanner().fromTagNode(tagNode);
    table.addCell(result);
    return;
  }
  if (tagNode.getName().equals("tr")) {
    table.addRow();
  }
  for (  Object child : tagNode.getChildren()) {
    readNode(child,table);
  }
}
 

Example 16

From project k-9, under directory /src/com/fsck/k9/activity/.

Source file: AccessibleEmailContentActivity.java

  21 
vote

/** 
 * Called when the activity is first created.
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  String htmlSource=getIntent().getStringExtra("content");
  Spanned parsedHtml=Html.fromHtml(htmlSource,null,null);
  String[] rawListItems=parsedHtml.toString().split("\n");
  ArrayList<String> cleanedList=new ArrayList<String>();
  for (  String rawListItem : rawListItems) {
    if (rawListItem.trim().length() > 0) {
      addToCleanedList(cleanedList,rawListItem);
    }
  }
  String[] listItems=cleanedList.toArray(EMPTY_STRING_ARRAY);
  setContentView(com.fsck.k9.R.layout.accessible_email_content);
  setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,listItems));
}
 

Example 17

From project PinDroid, under directory /src/com/pindroid/fragment/.

Source file: ViewBookmarkFragment.java

  21 
vote

@Override protected Article doInBackground(String... args){
  if (args.length > 0 && args[0] != null && args[0] != "") {
    url=args[0];
    Article a=NetworkUtilities.getArticleText(url);
    if (a != null && a.getContent() != null) {
      Spanned s=Html.fromHtml(a.getContent(),new Html.ImageGetter(){
        public Drawable getDrawable(        String source){
          Drawable d=null;
          try {
            InputStream src=imageFetch(source);
            d=Drawable.createFromStream(src,"src");
            if (d != null) {
              int containerWidth=container.getWidth() - (Integer.parseInt(base.readingMargins) * 2);
              int width=Math.min(containerWidth,d.getIntrinsicWidth());
              int height=d.getIntrinsicHeight();
              if (containerWidth < d.getIntrinsicWidth()) {
                double scale=((double)containerWidth / (double)d.getIntrinsicWidth());
                double newWidth=d.getIntrinsicHeight() * scale;
                height=(int)Math.floor(newWidth);
              }
              d.setBounds(0,0,width,height);
            }
          }
 catch (          MalformedURLException e) {
            e.printStackTrace();
          }
catch (          IOException e) {
            e.printStackTrace();
          }
          return d;
        }
      }
,null);
      a.setSpan(s);
    }
    return a;
  }
 else   return null;
}
 

Example 18

From project platform_packages_apps_mms, under directory /src/com/android/mms/ui/.

Source file: RecipientsEditor.java

  21 
vote

@Override protected ContextMenuInfo getContextMenuInfo(){
  if ((mLongPressedPosition >= 0)) {
    Spanned text=getText();
    if (mLongPressedPosition <= text.length()) {
      int start=mTokenizer.findTokenStart(text,mLongPressedPosition);
      int end=mTokenizer.findTokenEnd(text,start);
      if (end != start) {
        String number=getNumberAt(getText(),start,end,getContext());
        Contact c=Contact.get(number,false);
        return new RecipientContextMenuInfo(c);
      }
    }
  }
  return null;
}
 

Example 19

From project TextSecure, under directory /src/org/thoughtcrime/securesms/contacts/.

Source file: RecipientsEditor.java

  21 
vote

public List<String> getNumbers(){
  Spanned sp=mList.getText();
  int len=sp.length();
  List<String> list=new ArrayList<String>();
  int start=0;
  int i=0;
  while (i < len + 1) {
    char c;
    if ((i == len) || ((c=sp.charAt(i)) == ',') || (c == ';')) {
      if (i > start) {
        list.add(getNumberAt(sp,start,i,mContext));
        int spanLen=getSpanLength(sp,start,i,mContext);
        if (spanLen > i) {
          i=spanLen;
        }
      }
      i++;
      while ((i < len) && (sp.charAt(i) == ' ')) {
        i++;
      }
      start=i;
    }
 else {
      i++;
    }
  }
  return list;
}
 

Example 20

From project TransportsRennes, under directory /TransportsBordeaux/src/fr/ybo/transportsbordeaux/activity/.

Source file: TransportsBordeaux.java

  21 
vote

private void showDialog(){
  AlertDialog.Builder builder=new AlertDialog.Builder(this);
  View view=LayoutInflater.from(this).inflate(R.layout.infoapropos,null);
  TextView textView=(TextView)view.findViewById(R.id.textAPropos);
  Spanned spanned=Html.fromHtml(getString(R.string.dialogAPropos));
  if (UIUtils.isHoneycomb()) {
    textView.setTextColor(AbstractTransportsApplication.getTextColor(this));
  }
  textView.setText(spanned,TextView.BufferType.SPANNABLE);
  textView.setMovementMethod(LinkMovementMethod.getInstance());
  builder.setView(view);
  builder.setTitle(getString(R.string.titleTransportsBordeaux,Version.getVersionCourante(getApplicationContext())));
  builder.setCancelable(false);
  builder.setNeutralButton(getString(R.string.Terminer),new TransportsBordeaux.TerminerClickListener());
  builder.create().show();
}
 

Example 21

From project wheelmap-android, under directory /wheelmap/wheelmap/src/main/java/org/wheelmap/android/fragment/.

Source file: LoginDialogFragment.java

  21 
vote

@Override public void onResume(){
  super.onResume();
  AlertDialog dialog=(AlertDialog)getDialog();
  Button button=dialog.getButton(AlertDialog.BUTTON_NEUTRAL);
  button.setOnClickListener(this);
  mEmailText=(EditText)dialog.findViewById(R.id.login_email);
  mEmailText.setOnEditorActionListener(this);
  mPasswordText=(EditText)dialog.findViewById(R.id.login_password);
  mPasswordText.setOnEditorActionListener(this);
  String formattedHtml=UtilsMisc.formatHtmlLink(getString(R.string.login_link_wheelmap),getString(R.string.login_link_text));
  Spanned spannedText=Html.fromHtml(formattedHtml);
  mRegisterText=(TextView)dialog.findViewById(R.id.login_register);
  mRegisterText.setText(spannedText);
  mRegisterText.setMovementMethod(LinkMovementMethod.getInstance());
  load();
  mProgressBar=(ProgressBar)dialog.findViewById(R.id.progressbar);
}
 

Example 22

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/core/activity/.

Source file: TopLevelActivity.java

  19 
vote

public Void doInBackground(CursorGenerator... params){
  String[] perspectives=getResources().getStringArray(R.array.perspectives);
  int colour=getResources().getColor(R.drawable.pale_blue);
  ForegroundColorSpan span=new ForegroundColorSpan(colour);
  CharSequence[] labels=new CharSequence[perspectives.length];
  int length=perspectives.length;
  for (int i=0; i < length; i++) {
    labels[i]="  " + perspectives[i];
  }
  int[] cachedCounts=Preferences.getTopLevelCounts(TopLevelActivity.this);
  if (cachedCounts != null && cachedCounts.length == length) {
    for (int i=0; i < length; i++) {
      CharSequence label=labels[i] + "  (" + cachedCounts[i]+ ")";
      SpannableString spannable=new SpannableString(label);
      spannable.setSpan(span,labels[i].length(),label.length(),Spanned.SPAN_INCLUSIVE_INCLUSIVE);
      labels[i]=spannable;
    }
  }
  publishProgress(labels);
  String cachedCountStr="";
  for (int i=0; i < length; i++) {
    CursorGenerator generator=params[i];
    Cursor cursor=generator.generate();
    int count=cursor.getCount();
    cursor.close();
    CharSequence label="  " + perspectives[i] + "  ("+ count+ ")";
    SpannableString spannable=new SpannableString(label);
    spannable.setSpan(span,perspectives[i].length() + 2,label.length(),Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    labels[i]=spannable;
    publishProgress(labels);
    cachedCountStr+=count;
    if (i < length - 1) {
      cachedCountStr+=",";
    }
  }
  SharedPreferences.Editor editor=Preferences.getEditor(TopLevelActivity.this);
  editor.putString(Preferences.TOP_LEVEL_COUNTS_KEY,cachedCountStr);
  editor.commit();
  return null;
}
 

Example 23

From project android-thaiime, under directory /common/src/com/android/common/.

Source file: Rfc822InputFilter.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (end - start != 1 || source.charAt(start) != ' ') {
    return null;
  }
  int scanBack=dstart;
  boolean dotFound=false;
  while (scanBack > 0) {
    char c=dest.charAt(--scanBack);
switch (c) {
case '.':
      dotFound=true;
    break;
case ',':
  return null;
case '@':
if (!dotFound) {
  return null;
}
if (source instanceof Spanned) {
SpannableStringBuilder sb=new SpannableStringBuilder(",");
sb.append(source);
return sb;
}
 else {
return ", ";
}
default :
}
}
return null;
}
 

Example 24

From project androidquery, under directory /src/com/androidquery/.

Source file: AbstractAQuery.java

  19 
vote

/** 
 * Set the text of a TextView.
 * @param text the text
 * @return self
 */
public T text(Spanned text){
  if (view instanceof TextView) {
    TextView tv=(TextView)view;
    tv.setText(text);
  }
  return self();
}
 

Example 25

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/bluetooth/.

Source file: BluetoothNamePreference.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  int srcByteCount=0;
  for (int i=start; i < end; i++) {
    char c=source.charAt(i);
    srcByteCount+=(c < 0x0080) ? 1 : (c < 0x0800 ? 2 : 3);
  }
  int destLen=dest.length();
  int destByteCount=0;
  for (int i=0; i < destLen; i++) {
    if (i < dstart || i >= dend) {
      char c=dest.charAt(i);
      destByteCount+=(c < 0x0080) ? 1 : (c < 0x0800 ? 2 : 3);
    }
  }
  int keepBytes=mMaxBytes - destByteCount;
  if (keepBytes <= 0) {
    return "";
  }
 else   if (keepBytes >= srcByteCount) {
    return null;
  }
 else {
    for (int i=start; i < end; i++) {
      char c=source.charAt(i);
      keepBytes-=(c < 0x0080) ? 1 : (c < 0x0800 ? 2 : 3);
      if (keepBytes < 0) {
        return source.subSequence(start,i);
      }
    }
    return null;
  }
}
 

Example 26

From project android_frameworks_ex, under directory /common/java/com/android/common/.

Source file: Rfc822InputFilter.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (end - start != 1 || source.charAt(start) != ' ') {
    return null;
  }
  int scanBack=dstart;
  boolean dotFound=false;
  while (scanBack > 0) {
    char c=dest.charAt(--scanBack);
switch (c) {
case '.':
      dotFound=true;
    break;
case ',':
  return null;
case '@':
if (!dotFound) {
  return null;
}
if (source instanceof Spanned) {
SpannableStringBuilder sb=new SpannableStringBuilder(",");
sb.append(source);
return sb;
}
 else {
return ", ";
}
default :
}
}
return null;
}
 

Example 27

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/widget/.

Source file: AncientNumberPicker.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (mDisplayedValues == null) {
    return mNumberInputFilter.filter(source,start,end,dest,dstart,dend);
  }
  CharSequence filtered=String.valueOf(source.subSequence(start,end));
  String result=String.valueOf(dest.subSequence(0,dstart)) + filtered + dest.subSequence(dend,dest.length());
  String str=String.valueOf(result).toLowerCase();
  for (  String val : mDisplayedValues) {
    val=val.toLowerCase();
    if (val.startsWith(str)) {
      return filtered;
    }
  }
  return "";
}
 

Example 28

From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/compat/.

Source file: SuggestionSpanUtils.java

  19 
vote

public static CharSequence getTextWithAutoCorrectionIndicatorUnderline(Context context,CharSequence text){
  if (TextUtils.isEmpty(text) || CONSTRUCTOR_SuggestionSpan == null || OBJ_FLAG_AUTO_CORRECTION == null || OBJ_SUGGESTION_MAX_SIZE == null) {
    return text;
  }
  final Spannable spannable=text instanceof Spannable ? (Spannable)text : new SpannableString(text);
  final Object[] args={context,null,new String[]{},(int)OBJ_FLAG_AUTO_CORRECTION,(Class<?>)SuggestionSpanPickedNotificationReceiver.class};
  final Object ss=CompatUtils.newInstance(CONSTRUCTOR_SuggestionSpan,args);
  if (ss == null) {
    Log.w(TAG,"Suggestion span was not created.");
    return text;
  }
  spannable.setSpan(ss,0,text.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING);
  return spannable;
}
 

Example 29

From project andstatus, under directory /src/org/andstatus/app/util/.

Source file: AtTokenizer.java

  19 
vote

/** 
 * @see android.widget.MultiAutoCompleteTextView.Tokenizer#terminateToken(java.lang.CharSequence)
 */
public CharSequence terminateToken(CharSequence text){
  int i=text.length();
  while (i > 0 && text.charAt(i - 1) == ' ')   i--;
  if (i > 0 && text.charAt(i - 1) == '@') {
    return text;
  }
 else {
    if (text instanceof Spanned) {
      SpannableString sp=new SpannableString(text);
      TextUtils.copySpansFrom((Spanned)text,0,text.length(),Object.class,sp,0);
      return sp;
    }
 else {
      return text;
    }
  }
}
 

Example 30

From project andtweet, under directory /src/com/xorcode/andtweet/util/.

Source file: AtTokenizer.java

  19 
vote

/** 
 * @see android.widget.MultiAutoCompleteTextView.Tokenizer#terminateToken(java.lang.CharSequence)
 */
public CharSequence terminateToken(CharSequence text){
  int i=text.length();
  while (i > 0 && text.charAt(i - 1) == ' ')   i--;
  if (i > 0 && text.charAt(i - 1) == '@') {
    return text;
  }
 else {
    if (text instanceof Spanned) {
      SpannableString sp=new SpannableString(text);
      TextUtils.copySpansFrom((Spanned)text,0,text.length(),Object.class,sp,0);
      return sp;
    }
 else {
      return text;
    }
  }
}
 

Example 31

From project Anki-Android, under directory /src/com/ichi2/anki/.

Source file: AnkiDroidWidget.java

  19 
vote

private CharSequence getDeckText(){
  String deckName=formatDeckName();
  SpannableStringBuilder sb=new SpannableStringBuilder();
  sb.append(deckName);
  sb.append(" ");
  SpannableString red=new SpannableString(Integer.toString(mFailedCards));
  red.setSpan(new ForegroundColorSpan(Color.RED),0,red.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  SpannableString black=new SpannableString(Integer.toString(mDueCards));
  black.setSpan(new ForegroundColorSpan(Color.BLACK),0,black.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  SpannableString blue=new SpannableString(Integer.toString(mNewCards));
  blue.setSpan(new ForegroundColorSpan(Color.BLUE),0,blue.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  sb.append(red);
  sb.append(" ");
  sb.append(black);
  sb.append(" ");
  sb.append(blue);
  return sb;
}
 

Example 32

From project CalendarView_1, under directory /src/org/kazzz/view/numberpicker/.

Source file: NumberPicker.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (displayedValues == null) {
    return numberInputFilter.filter(source,start,end,dest,dstart,dend);
  }
  CharSequence filtered=String.valueOf(source.subSequence(start,end));
  String result=String.valueOf(dest.subSequence(0,dstart)) + filtered + dest.subSequence(dend,dest.length());
  String str=String.valueOf(result).toLowerCase();
  for (  String val : displayedValues) {
    val=val.toLowerCase();
    if (val.startsWith(str)) {
      return filtered;
    }
  }
  return "";
}
 

Example 33

From project creamed_glacier_app_settings, under directory /src/com/android/settings/bluetooth/.

Source file: Utf8ByteLengthFilter.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  int srcByteCount=0;
  for (int i=start; i < end; i++) {
    char c=source.charAt(i);
    srcByteCount+=(c < (char)0x0080) ? 1 : (c < (char)0x0800 ? 2 : 3);
  }
  int destLen=dest.length();
  int destByteCount=0;
  for (int i=0; i < destLen; i++) {
    if (i < dstart || i >= dend) {
      char c=dest.charAt(i);
      destByteCount+=(c < (char)0x0080) ? 1 : (c < (char)0x0800 ? 2 : 3);
    }
  }
  int keepBytes=mMaxBytes - destByteCount;
  if (keepBytes <= 0) {
    return "";
  }
 else   if (keepBytes >= srcByteCount) {
    return null;
  }
 else {
    for (int i=start; i < end; i++) {
      char c=source.charAt(i);
      keepBytes-=(c < (char)0x0080) ? 1 : (c < (char)0x0800 ? 2 : 3);
      if (keepBytes < 0) {
        return source.subSequence(start,i);
      }
    }
    return null;
  }
}
 

Example 34

From project cw-advandroid, under directory /RichText/Search/src/com/commonsware/android/rich/search/.

Source file: RichTextSearchActivity.java

  19 
vote

private void searchFor(String text){
  TextView prose=(TextView)findViewById(R.id.prose);
  Spannable raw=new SpannableString(prose.getText());
  BackgroundColorSpan[] spans=raw.getSpans(0,raw.length(),BackgroundColorSpan.class);
  for (  BackgroundColorSpan span : spans) {
    raw.removeSpan(span);
  }
  int index=TextUtils.indexOf(raw,text);
  while (index >= 0) {
    raw.setSpan(new BackgroundColorSpan(0xFF8B008B),index,index + text.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    index=TextUtils.indexOf(raw,text,index + text.length());
  }
  prose.setText(raw);
}
 

Example 35

From project cw-omnibus, under directory /RichText/Search/src/com/commonsware/android/rich/search/.

Source file: RichTextSearchActivity.java

  19 
vote

private void searchFor(String text){
  TextView prose=(TextView)findViewById(R.id.prose);
  Spannable raw=new SpannableString(prose.getText());
  BackgroundColorSpan[] spans=raw.getSpans(0,raw.length(),BackgroundColorSpan.class);
  for (  BackgroundColorSpan span : spans) {
    raw.removeSpan(span);
  }
  int index=TextUtils.indexOf(raw,text);
  while (index >= 0) {
    raw.setSpan(new BackgroundColorSpan(0xFF8B008B),index,index + text.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    index=TextUtils.indexOf(raw,text,index + text.length());
  }
  prose.setText(raw);
}
 

Example 36

From project daily-money, under directory /dailymoney/src/com/bottleworks/dailymoney/calculator2/.

Source file: CalculatorDisplay.java

  19 
vote

protected void setLogic(Logic logic){
  mLogic=logic;
  NumberKeyListener calculatorKeyListener=new NumberKeyListener(){
    public int getInputType(){
      return InputType.TYPE_NULL;
    }
    protected char[] getAcceptedChars(){
      return ACCEPTED_CHARS;
    }
    public CharSequence filter(    CharSequence source,    int start,    int end,    Spanned dest,    int dstart,    int dend){
      return null;
    }
  }
;
  Editable.Factory factory=new CalculatorEditable.Factory(logic);
  for (int i=0; i < 2; ++i) {
    EditText text=(EditText)getChildAt(i);
    text.setBackgroundDrawable(null);
    text.setEditableFactory(factory);
    text.setKeyListener(calculatorKeyListener);
  }
}
 

Example 37

From project dreamDroid, under directory /libraries/numberpicker/src/com/michaelnovakjr/numberpicker/.

Source file: NumberPicker.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (mDisplayedValues == null) {
    return mNumberInputFilter.filter(source,start,end,dest,dstart,dend);
  }
  CharSequence filtered=String.valueOf(source.subSequence(start,end));
  String result=String.valueOf(dest.subSequence(0,dstart)) + filtered + dest.subSequence(dend,dest.length());
  String str=String.valueOf(result).toLowerCase();
  for (  String val : mDisplayedValues) {
    val=val.toLowerCase();
    if (val.startsWith(str)) {
      return filtered;
    }
  }
  return "";
}
 

Example 38

From project droidkit, under directory /src/org/droidkit/util/tricks/.

Source file: ViewTricks.java

  19 
vote

public static void makeTextViewFakeLink(TextView tv,final View.OnClickListener onClickListener,int selectorBgResId){
  String text=tv.getText().toString();
  SpannableString spanString=new SpannableString(text);
  ClickableSpan clickSpan=new ClickableSpan(){
    @Override public void onClick(    View widget){
    }
  }
;
  spanString.setSpan(clickSpan,0,text.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  tv.setLinksClickable(false);
  tv.setMovementMethod(LinkMovementMethod.getInstance());
  tv.setBackgroundResource(selectorBgResId);
  tv.setText(spanString);
  tv.setOnClickListener(onClickListener);
}
 

Example 39

From project droidparts, under directory /sample/modern/src/org/droidparts/gram/adapter/.

Source file: ImageListAdapter.java

  19 
vote

private Spanned buildDescription(Image img){
  StringBuilder sb=new StringBuilder();
  sb.append("<b>").append(img.filter.name).append("</b>");
  sb.append(" ");
  sb.append(join(img.tags,", ",null));
  return Html.fromHtml(sb.toString());
}
 

Example 40

From project evodroid, under directory /src/com/sonorth/evodroid/util/.

Source file: AppHtml.java

  19 
vote

/** 
 * Returns displayable styled text from the provided HTML string. Any &lt;img&gt; tags in the HTML will use the specified ImageGetter to request a representation of the image (use null if you don't want this) and the specified TagHandler to handle unknown tags (specify null if you don't want this). <p> This uses TagSoup to handle real HTML, including all of the brokenness found in the wild.
 */
public static Spanned fromHtml(String source,ImageGetter imageGetter,TagHandler tagHandler,Context ctx,Post post){
  Parser parser=new Parser();
  try {
    parser.setProperty(Parser.schemaProperty,HtmlParser.schema);
  }
 catch (  org.xml.sax.SAXNotRecognizedException e) {
    throw new RuntimeException(e);
  }
catch (  org.xml.sax.SAXNotSupportedException e) {
    throw new RuntimeException(e);
  }
  HtmlToSpannedConverter converter=new HtmlToSpannedConverter(source,imageGetter,tagHandler,parser,ctx,post);
  return converter.convert();
}
 

Example 41

From project fanfoudroid, under directory /src/com/ch_linghu/fanfoudroid/ui/module/.

Source file: MyTextView.java

  19 
vote

@Override public boolean onTouchEvent(MotionEvent event){
  CharSequence text=getText();
  int action=event.getAction();
  if (!(text instanceof Spannable)) {
    return super.onTouchEvent(event);
  }
  Spannable buffer=(Spannable)text;
  if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE) {
    TextView widget=this;
    int x=(int)event.getX();
    int y=(int)event.getY();
    x-=widget.getTotalPaddingLeft();
    y-=widget.getTotalPaddingTop();
    x+=widget.getScrollX();
    y+=widget.getScrollY();
    Layout layout=widget.getLayout();
    int line=layout.getLineForVertical(y);
    int off=layout.getOffsetForHorizontal(line,x);
    URLSpan[] link=buffer.getSpans(off,off,URLSpan.class);
    if (link.length != 0) {
      if (action == MotionEvent.ACTION_UP) {
        if (mCurrentLink == link[0]) {
          link[0].onClick(widget);
        }
        mCurrentLink=null;
        buffer.removeSpan(mLinkFocusStyle);
      }
 else       if (action == MotionEvent.ACTION_DOWN) {
        mCurrentLink=link[0];
        buffer.setSpan(mLinkFocusStyle,buffer.getSpanStart(link[0]),buffer.getSpanEnd(link[0]),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
      }
      return true;
    }
  }
  mCurrentLink=null;
  buffer.removeSpan(mLinkFocusStyle);
  return super.onTouchEvent(event);
}
 

Example 42

From project hiofenigma-android, under directory /opentimer/src/com/quietlycoding/android/picker/.

Source file: NumberPicker.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (mDisplayedValues == null) {
    return mNumberInputFilter.filter(source,start,end,dest,dstart,dend);
  }
  CharSequence filtered=String.valueOf(source.subSequence(start,end));
  String result=String.valueOf(dest.subSequence(0,dstart)) + filtered + dest.subSequence(dend,dest.length());
  String str=String.valueOf(result).toLowerCase();
  for (  String val : mDisplayedValues) {
    val=val.toLowerCase();
    if (val.startsWith(str)) {
      return filtered;
    }
  }
  return "";
}
 

Example 43

From project ICS_LatinIME_QHD, under directory /java/src/com/android/inputmethod/compat/.

Source file: SuggestionSpanUtils.java

  19 
vote

public static CharSequence getTextWithAutoCorrectionIndicatorUnderline(Context context,CharSequence text){
  if (TextUtils.isEmpty(text) || CONSTRUCTOR_SuggestionSpan == null || OBJ_FLAG_AUTO_CORRECTION == null || OBJ_SUGGESTION_MAX_SIZE == null) {
    return text;
  }
  final Spannable spannable=text instanceof Spannable ? (Spannable)text : new SpannableString(text);
  final Object[] args={context,null,new String[]{},(int)OBJ_FLAG_AUTO_CORRECTION,(Class<?>)SuggestionSpanPickedNotificationReceiver.class};
  final Object ss=CompatUtils.newInstance(CONSTRUCTOR_SuggestionSpan,args);
  if (ss == null) {
    Log.w(TAG,"Suggestion span was not created.");
    return text;
  }
  spannable.setSpan(ss,0,text.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING);
  return spannable;
}
 

Example 44

From project kumvandroid, under directory /src/com/ijuru/kumva/ui/.

Source file: Format.java

  19 
vote

/** 
 * Formats a definition's meanings into a single string
 * @param examples the examples
 * @return the formatted string
 */
public static Spanned examples(List<Example> examples){
  StringBuilder sb=new StringBuilder();
  for (int e=0; e < examples.size(); ++e) {
    Example example=examples.get(e);
    sb.append(example.getUsage() + "<br /><i>" + example.getMeaning()+ "</i>");
    if (e < examples.size() - 1)     sb.append("<br /><br />");
  }
  return Html.fromHtml(sb.toString());
}
 

Example 45

From project maven-android-plugin-samples, under directory /apidemos-android-10/application/src/main/java/com/example/android/apis/text/.

Source file: Link.java

  19 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.link);
  TextView t2=(TextView)findViewById(R.id.text2);
  t2.setMovementMethod(LinkMovementMethod.getInstance());
  TextView t3=(TextView)findViewById(R.id.text3);
  t3.setText(Html.fromHtml("<b>text3:</b>  Text with a " + "<a href=\"http://www.google.com\">link</a> " + "created in the Java source code using HTML."));
  t3.setMovementMethod(LinkMovementMethod.getInstance());
  SpannableString ss=new SpannableString("text4: Click here to dial the phone.");
  ss.setSpan(new StyleSpan(Typeface.BOLD),0,6,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  ss.setSpan(new URLSpan("tel:4155551212"),13,17,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  TextView t4=(TextView)findViewById(R.id.text4);
  t4.setText(ss);
  t4.setMovementMethod(LinkMovementMethod.getInstance());
}
 

Example 46

From project Mobile-Tour-Guide, under directory /zxing-2.0/android/src/com/google/zxing/client/android/result/supplement/.

Source file: SupplementalInfoRetriever.java

  19 
vote

final void append(String itemID,String source,String[] newTexts,String linkURL) throws InterruptedException {
  final TextView textView=textViewRef.get();
  if (textView == null) {
    throw new InterruptedException();
  }
  StringBuilder newTextCombined=new StringBuilder();
  if (source != null) {
    newTextCombined.append(source).append(" : ");
  }
  int linkStart=newTextCombined.length();
  boolean first=true;
  for (  String newText : newTexts) {
    if (first) {
      newTextCombined.append(newText);
      first=false;
    }
 else {
      newTextCombined.append(" [");
      newTextCombined.append(newText);
      newTextCombined.append(']');
    }
  }
  int linkEnd=newTextCombined.length();
  String newText=newTextCombined.toString();
  final Spannable content=new SpannableString(newText + "\n\n");
  if (linkURL != null) {
    content.setSpan(new URLSpan(linkURL),linkStart,linkEnd,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  }
  handler.post(new Runnable(){
    @Override public void run(){
      textView.append(content);
      textView.setMovementMethod(LinkMovementMethod.getInstance());
    }
  }
);
  historyManager.addHistoryItemDetails(itemID,newText);
}
 

Example 47

From project Notes, under directory /src/net/micode/notes/ui/.

Source file: NoteEditText.java

  19 
vote

@Override protected void onCreateContextMenu(ContextMenu menu){
  if (getText() instanceof Spanned) {
    int selStart=getSelectionStart();
    int selEnd=getSelectionEnd();
    int min=Math.min(selStart,selEnd);
    int max=Math.max(selStart,selEnd);
    final URLSpan[] urls=((Spanned)getText()).getSpans(min,max,URLSpan.class);
    if (urls.length == 1) {
      int defaultResId=0;
      for (      String schema : sSchemaActionResMap.keySet()) {
        if (urls[0].getURL().indexOf(schema) >= 0) {
          defaultResId=sSchemaActionResMap.get(schema);
          break;
        }
      }
      if (defaultResId == 0) {
        defaultResId=R.string.note_link_other;
      }
      menu.add(0,0,0,defaultResId).setOnMenuItemClickListener(new OnMenuItemClickListener(){
        public boolean onMenuItemClick(        MenuItem item){
          urls[0].onClick(NoteEditText.this);
          return true;
        }
      }
);
    }
  }
  super.onCreateContextMenu(menu);
}
 

Example 48

From project ohmagePhone, under directory /src/org/ohmage/.

Source file: NumberPicker.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (mDisplayedValues == null) {
    return mNumberInputFilter.filter(source,start,end,dest,dstart,dend);
  }
  CharSequence filtered=String.valueOf(source.subSequence(start,end));
  String result=String.valueOf(dest.subSequence(0,dstart)) + filtered + dest.subSequence(dend,dest.length());
  String str=String.valueOf(result).toLowerCase();
  for (  String val : mDisplayedValues) {
    val=val.toLowerCase();
    if (val.startsWith(str)) {
      return filtered;
    }
  }
  return "";
}
 

Example 49

From project Ohmage_Phone, under directory /src/org/ohmage/.

Source file: NumberPicker.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (mDisplayedValues == null) {
    return mNumberInputFilter.filter(source,start,end,dest,dstart,dend);
  }
  CharSequence filtered=String.valueOf(source.subSequence(start,end));
  String result=String.valueOf(dest.subSequence(0,dstart)) + filtered + dest.subSequence(dend,dest.length());
  String str=String.valueOf(result).toLowerCase();
  for (  String val : mDisplayedValues) {
    val=val.toLowerCase();
    if (val.startsWith(str)) {
      return filtered;
    }
  }
  return "";
}
 

Example 50

From project packages_apps_God_Mode, under directory /src/com/t3hh4xx0r/god_mode/utils/.

Source file: NumberPicker.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (mDisplayedValues == null) {
    return mNumberInputFilter.filter(source,start,end,dest,dstart,dend);
  }
  CharSequence filtered=String.valueOf(source.subSequence(start,end));
  String result=String.valueOf(dest.subSequence(0,dstart)) + filtered + dest.subSequence(dend,dest.length());
  String str=String.valueOf(result).toLowerCase();
  for (  String val : mDisplayedValues) {
    val=val.toLowerCase();
    if (val.startsWith(str)) {
      return filtered;
    }
  }
  return "";
}
 

Example 51

From project Pixelesque, under directory /src/com/rj/pixelesque/.

Source file: NumberPicker.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (mDisplayedValues == null) {
    return mNumberInputFilter.filter(source,start,end,dest,dstart,dend);
  }
  CharSequence filtered=String.valueOf(source.subSequence(start,end));
  String result=String.valueOf(dest.subSequence(0,dstart)) + filtered + dest.subSequence(dend,dest.length());
  String str=String.valueOf(result).toLowerCase();
  for (  String val : mDisplayedValues) {
    val=val.toLowerCase();
    if (val.startsWith(str)) {
      return filtered;
    }
  }
  return "";
}
 

Example 52

From project platform_frameworks_ex, under directory /chips/src/com/android/ex/chips/.

Source file: RecipientEditTextView.java

  19 
vote

/** 
 * Create a chip that represents just the email address of a recipient. At some later point, this chip will be attached to a real contact entry, if one exists.
 */
private void createReplacementChip(int tokenStart,int tokenEnd,Editable editable){
  if (alreadyHasChip(tokenStart,tokenEnd)) {
    return;
  }
  String token=editable.toString().substring(tokenStart,tokenEnd);
  int commitCharIndex=token.trim().lastIndexOf(COMMIT_CHAR_COMMA);
  if (commitCharIndex == token.length() - 1) {
    token=token.substring(0,token.length() - 1);
  }
  RecipientEntry entry=createTokenizedEntry(token);
  if (entry != null) {
    String destText=createAddressText(entry);
    int textLength=destText.length() - 1;
    SpannableString chipText=new SpannableString(destText);
    int end=getSelectionEnd();
    int start=mTokenizer.findTokenStart(getText(),end);
    RecipientChip chip=null;
    try {
      if (!mNoChips) {
        chip=constructChipSpan(entry,start,false);
        chipText.setSpan(chip,0,textLength,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
      }
    }
 catch (    NullPointerException e) {
      Log.e(TAG,e.getMessage(),e);
    }
    editable.replace(tokenStart,tokenEnd,chipText);
    if (chip != null) {
      if (mTemporaryRecipients == null) {
        mTemporaryRecipients=new ArrayList<RecipientChip>();
      }
      chip.setOriginalText(chipText.toString());
      mTemporaryRecipients.add(chip);
    }
  }
}
 

Example 53

From project platform_frameworks_support, under directory /v4/java/android/support/v4/app/.

Source file: ShareCompat.java

  19 
vote

/** 
 * Get the styled HTML text shared with the target activity. If no HTML text was supplied but  {@link Intent#EXTRA_TEXT} containedstyled text, it will be converted to HTML if possible and returned. If the text provided by  {@link Intent#EXTRA_TEXT} was not styled text,it will be escaped by  {@link android.text.Html#escapeHtml(CharSequence)}and returned. If no text was provided at all, this method will return null.
 * @return Styled text provided by the sender as HTML.
 */
public String getHtmlText(){
  String result=mIntent.getStringExtra(IntentCompat.EXTRA_HTML_TEXT);
  if (mIntent == null) {
    CharSequence text=getText();
    if (text instanceof Spanned) {
      result=Html.toHtml((Spanned)text);
    }
 else     if (text != null) {
      result=IMPL.escapeHtml(text);
    }
  }
  return result;
}
 

Example 54

From project platform_packages_apps_calculator, under directory /src/com/android/calculator2/.

Source file: CalculatorDisplay.java

  19 
vote

protected void setLogic(Logic logic){
  NumberKeyListener calculatorKeyListener=new NumberKeyListener(){
    public int getInputType(){
      return InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
    }
    @Override protected char[] getAcceptedChars(){
      return ACCEPTED_CHARS;
    }
    @Override public CharSequence filter(    CharSequence source,    int start,    int end,    Spanned dest,    int dstart,    int dend){
      return null;
    }
  }
;
  Editable.Factory factory=new CalculatorEditable.Factory(logic);
  for (int i=0; i < 2; ++i) {
    EditText text=(EditText)getChildAt(i);
    text.setBackgroundDrawable(null);
    text.setEditableFactory(factory);
    text.setKeyListener(calculatorKeyListener);
    text.setSingleLine();
  }
}
 

Example 55

From project platform_packages_apps_settings, under directory /src/com/android/settings/bluetooth/.

Source file: Utf8ByteLengthFilter.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  int srcByteCount=0;
  for (int i=start; i < end; i++) {
    char c=source.charAt(i);
    srcByteCount+=(c < (char)0x0080) ? 1 : (c < (char)0x0800 ? 2 : 3);
  }
  int destLen=dest.length();
  int destByteCount=0;
  for (int i=0; i < destLen; i++) {
    if (i < dstart || i >= dend) {
      char c=dest.charAt(i);
      destByteCount+=(c < (char)0x0080) ? 1 : (c < (char)0x0800 ? 2 : 3);
    }
  }
  int keepBytes=mMaxBytes - destByteCount;
  if (keepBytes <= 0) {
    return "";
  }
 else   if (keepBytes >= srcByteCount) {
    return null;
  }
 else {
    for (int i=start; i < end; i++) {
      char c=source.charAt(i);
      keepBytes-=(c < (char)0x0080) ? 1 : (c < (char)0x0800 ? 2 : 3);
      if (keepBytes < 0) {
        return source.subSequence(start,i);
      }
    }
    return null;
  }
}
 

Example 56

From project rbb, under directory /src/com/btmura/android/reddit/text/.

Source file: InputFilters.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  for (int i=start; i < end; i++) {
    char c=source.charAt(i);
    if (Character.isWhitespace(c)) {
      return "";
    }
  }
  return null;
}
 

Example 57

From project reader, under directory /src/com/quietlycoding/android/reader/widget/.

Source file: NumberPicker.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (mDisplayedValues == null) {
    return mNumberInputFilter.filter(source,start,end,dest,dstart,dend);
  }
  CharSequence filtered=String.valueOf(source.subSequence(start,end));
  String result=String.valueOf(dest.subSequence(0,dstart)) + filtered + dest.subSequence(dend,dest.length());
  String str=String.valueOf(result).toLowerCase();
  for (  String val : mDisplayedValues) {
    val=val.toLowerCase();
    if (val.startsWith(str)) {
      return filtered;
    }
  }
  return "";
}
 

Example 58

From project ReGalAndroid, under directory /regalandroid/src/main/java/net/dahanne/android/regalandroid/utils/modified_android_source/.

Source file: NumberPicker.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (mDisplayedValues == null) {
    return mNumberInputFilter.filter(source,start,end,dest,dstart,dend);
  }
  CharSequence filtered=String.valueOf(source.subSequence(start,end));
  String result=String.valueOf(dest.subSequence(0,dstart)) + filtered + dest.subSequence(dend,dest.length());
  String str=String.valueOf(result).toLowerCase();
  for (  String val : mDisplayedValues) {
    val=val.toLowerCase();
    if (val.startsWith(str)) {
      return filtered;
    }
  }
  return "";
}
 

Example 59

From project SeriesGuide, under directory /SeriesGuide/src/com/battlelancer/seriesguide/ui/dialogs/.

Source file: ListManageDialogFragment.java

  19 
vote

@Override public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  for (int i=start; i < end; i++) {
    if (!(Character.isLetterOrDigit(source.charAt(i)) || Character.isWhitespace(source.charAt(i)))) {
      return "";
    }
  }
  return null;
}
 

Example 60

From project SimpleMoney-Android, under directory /Zxing/bin/src/com/google/zxing/client/android/result/supplement/.

Source file: SupplementalInfoRetriever.java

  19 
vote

final void append(String itemID,String source,String[] newTexts,String linkURL) throws InterruptedException {
  final TextView textView=textViewRef.get();
  if (textView == null) {
    throw new InterruptedException();
  }
  StringBuilder newTextCombined=new StringBuilder();
  if (source != null) {
    newTextCombined.append(source).append(" : ");
  }
  int linkStart=newTextCombined.length();
  boolean first=true;
  for (  String newText : newTexts) {
    if (first) {
      newTextCombined.append(newText);
      first=false;
    }
 else {
      newTextCombined.append(" [");
      newTextCombined.append(newText);
      newTextCombined.append(']');
    }
  }
  int linkEnd=newTextCombined.length();
  String newText=newTextCombined.toString();
  final Spannable content=new SpannableString(newText + "\n\n");
  if (linkURL != null) {
    content.setSpan(new URLSpan(linkURL),linkStart,linkEnd,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  }
  handler.post(new Runnable(){
    @Override public void run(){
      textView.append(content);
      textView.setMovementMethod(LinkMovementMethod.getInstance());
    }
  }
);
  historyManager.addHistoryItemDetails(itemID,newText);
}
 

Example 61

From project smsdroid, under directory /src/de/ub0r/android/smsdroid/.

Source file: SmileyParser.java

  19 
vote

/** 
 * Adds ImageSpans to a CharSequence that replace textual emoticons such as :-) with a graphical version.
 * @param text A CharSequence possibly containing emoticons
 * @return A CharSequence annotated with ImageSpans covering any recognizedemoticons.
 */
public CharSequence addSmileySpans(final CharSequence text){
  SpannableStringBuilder builder=new SpannableStringBuilder(text);
  Matcher matcher=this.mPattern.matcher(text);
  while (matcher.find()) {
    int resId=this.mSmileyToRes.get(matcher.group());
    builder.setSpan(new ImageSpan(this.mContext,resId),matcher.start(),matcher.end(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  }
  return builder;
}
 

Example 62

From project Something-Awful-Android, under directory /application/src/com/ferg/awfulapp/widget/.

Source file: NumberPicker.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (mDisplayedValues == null) {
    return mNumberInputFilter.filter(source,start,end,dest,dstart,dend);
  }
  CharSequence filtered=String.valueOf(source.subSequence(start,end));
  String result=String.valueOf(dest.subSequence(0,dstart)) + filtered + dest.subSequence(dend,dest.length());
  String str=String.valueOf(result).toLowerCase();
  for (  String val : mDisplayedValues) {
    val=val.toLowerCase();
    if (val.startsWith(str)) {
      return filtered;
    }
  }
  return "";
}
 

Example 63

From project SoundFuse, under directory /src/org/androidaalto/soundfuse/picker/.

Source file: NumberPicker.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (mDisplayedValues == null) {
    return mNumberInputFilter.filter(source,start,end,dest,dstart,dend);
  }
  CharSequence filtered=String.valueOf(source.subSequence(start,end));
  String result=String.valueOf(dest.subSequence(0,dstart)) + filtered + dest.subSequence(dend,dest.length());
  String str=String.valueOf(result).toLowerCase();
  for (  String val : mDisplayedValues) {
    val=val.toLowerCase();
    if (val.startsWith(str)) {
      return filtered;
    }
  }
  return "";
}
 

Example 64

From project SWADroid, under directory /SWADroid/src/es/ugr/swad/swadroid/widget/.

Source file: NumberPicker.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (mDisplayedValues == null) {
    return mNumberInputFilter.filter(source,start,end,dest,dstart,dend);
  }
  CharSequence filtered=String.valueOf(source.subSequence(start,end));
  String result=String.valueOf(dest.subSequence(0,dstart)) + filtered + dest.subSequence(dend,dest.length());
  String str=String.valueOf(result).toLowerCase();
  for (  String val : mDisplayedValues) {
    val=val.toLowerCase();
    if (val.startsWith(str)) {
      return filtered;
    }
  }
  return "";
}
 

Example 65

From project ToDo-List-Widget, under directory /src/org/chrisbailey/todo/widgets/.

Source file: NumberPicker.java

  19 
vote

public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
  if (mDisplayedValues == null) {
    return mNumberInputFilter.filter(source,start,end,dest,dstart,dend);
  }
  CharSequence filtered=String.valueOf(source.subSequence(start,end));
  String result=String.valueOf(dest.subSequence(0,dstart)) + filtered + dest.subSequence(dend,dest.length());
  String str=String.valueOf(result).toLowerCase();
  for (  String val : mDisplayedValues) {
    val=val.toLowerCase();
    if (val.startsWith(str)) {
      return filtered;
    }
  }
  return "";
}
 

Example 66

From project TweakGS2, under directory /src/net/sakuramilk/TweakGS2/MultiBoot/.

Source file: RomSettingPreferenceActivity.java

  19 
vote

@Override public boolean onPreferenceClick(Preference preference){
  if (preference == mLabelText) {
    TextInputDialog dlg=new TextInputDialog(this);
    InputFilter[] filters=new InputFilter[1];
    filters[0]=new InputFilter(){
      @Override public CharSequence filter(      CharSequence source,      int start,      int end,      Spanned dest,      int dstart,      int dend){
        int length=end;
        char c;
        StringBuffer sb=new StringBuffer(length);
        for (int i=0; i < end; i++) {
          c=source.charAt(i);
          if (c >= 0x20 && c <= 0x7E) {
            sb.append(c);
          }
        }
        String s=sb.toString();
        if (!Misc.isNullOfEmpty(s) && source instanceof Spanned) {
          SpannableString sp=new SpannableString(s);
          TextUtils.copySpansFrom((Spanned)source,start,length,null,sp,0);
          return sp;
        }
        return s;
      }
    }
;
    dlg.getInputField().setFilters(filters);
    dlg.setFinishTextInputListener(new TextInputDialog.FinishTextInputListener(){
      @Override public void onFinishTextInput(      CharSequence input){
        String inputText=input.toString();
        inputText=inputText.replace("\n","").trim();
        mMbsConf.setLabel(mRomId,inputText);
        mLabelText.setSummary((Misc.getCurrentValueText(mContext,inputText)));
      }
    }
);
    dlg.show(R.string.rom_label_title,R.string.rom_label_message,mMbsConf.getLabel(mRomId));
  }
  return false;
}
 

Example 67

From project twidere, under directory /src/org/mariotaku/twidere/activity/.

Source file: FileSaveAsActivity.java

  19 
vote

@Override public CharSequence filter(final CharSequence source,final int start,final int end,final Spanned dest,final int dstart,final int dend){
  for (int i=start; i < end; i++) {
    final char c=source.charAt(i);
switch (c) {
case '/':
case '\\':
case ':':
case '"':
case '*':
case '?':
case '<':
case '>':
case '|':
      return "";
  }
}
return null;
}
 

Example 68

From project ub0rlib, under directory /src/de/ub0r/android/lib/.

Source file: DonationHelper.java

  19 
vote

/** 
 * Show "donate" dialog.
 * @param context {@link Context}
 * @param title title
 * @param btnDonate button text for donate
 * @param btnNoads button text for "i did a donation"
 * @param messages messages for dialog body
 */
public static void showDonationDialog(final Activity context,final String title,final String btnDonate,final String btnNoads,final String[] messages){
  final Intent marketIntent=Market.getInstallAppIntent(context,DONATOR_PACKAGE,null);
  String btnTitle=String.format(btnDonate,"Play Store");
  SpannableStringBuilder sb=new SpannableStringBuilder();
  for (  String m : messages) {
    sb.append(m);
    sb.append("\n");
  }
  sb.delete(sb.length() - 1,sb.length());
  sb.setSpan(new RelativeSizeSpan(0.75f),0,sb.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  AlertDialog.Builder b=new AlertDialog.Builder(context);
  b.setTitle(title);
  b.setMessage(sb);
  b.setCancelable(true);
  b.setPositiveButton(btnTitle,new DialogInterface.OnClickListener(){
    @Override public void onClick(    final DialogInterface dialog,    final int which){
      try {
        context.startActivity(marketIntent);
      }
 catch (      ActivityNotFoundException e) {
        Log.e(TAG,"activity not found",e);
        Toast.makeText(context,"activity not found",Toast.LENGTH_LONG).show();
      }
    }
  }
);
  b.setNeutralButton(btnNoads,new DialogInterface.OnClickListener(){
    @Override public void onClick(    final DialogInterface dialog,    final int which){
      try {
        context.startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("http://code.google.com/p/ub0rapps/downloads/list?" + "can=3&q=Product%3DDonator")));
      }
 catch (      ActivityNotFoundException e) {
        Log.e(TAG,"activity not found",e);
        Toast.makeText(context,"activity not found",Toast.LENGTH_LONG).show();
      }
    }
  }
);
  b.show();
}
 

Example 69

From project Wordpress-Android-App, under directory /src/org/wordpress/android/util/.

Source file: WPHtml.java

  19 
vote

/** 
 * Returns displayable styled text from the provided HTML string. Any &lt;img&gt; tags in the HTML will use the specified ImageGetter to request a representation of the image (use null if you don't want this) and the specified TagHandler to handle unknown tags (specify null if you don't want this). <p> This uses TagSoup to handle real HTML, including all of the brokenness found in the wild.
 */
public static Spanned fromHtml(String source,ImageGetter imageGetter,TagHandler tagHandler,Context ctx,Post post){
  Parser parser=new Parser();
  try {
    parser.setProperty(Parser.schemaProperty,HtmlParser.schema);
  }
 catch (  org.xml.sax.SAXNotRecognizedException e) {
    throw new RuntimeException(e);
  }
catch (  org.xml.sax.SAXNotSupportedException e) {
    throw new RuntimeException(e);
  }
  HtmlToSpannedConverter converter=new HtmlToSpannedConverter(source,imageGetter,tagHandler,parser,ctx,post);
  return converter.convert();
}
 

Example 70

From project Yeno-Checklist, under directory /src/com/yeno/checklist/view/.

Source file: ChecklistSelectionActivity.java

  19 
vote

private void reviewProblems(){
  List<Task> problematicTasks=new ArrayList<Task>();
  for (  Checklist checklist : checklistGroup.getChecklists()) {
    for (    Task task : checklist.getTasks()) {
      if (task.getTaskState().equals(TaskState.PROBLEM)) {
        problematicTasks.add(task);
      }
    }
  }
  SpannableStringBuilder sb=new SpannableStringBuilder();
  if (!problematicTasks.isEmpty()) {
    for (    Task problemTask : problematicTasks) {
      sb.append("   - ");
      sb.append(problemTask.getName());
      String problem=problemTask.getProblem();
      if (!TextUtils.isEmpty(problem)) {
        int start=sb.length();
        sb.append("\n      \u21B3 ");
        sb.append(problem);
        int end=sb.length();
        sb.setSpan(new StyleSpan(Typeface.BOLD),start,end,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        sb.setSpan(new ForegroundColorSpan(0xffc54d39),start,end,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
      }
      sb.append('\n');
    }
  }
 else {
    sb.append(getString(R.string.no_problem_label));
  }
  new AlertDialog.Builder(this).setTitle(R.string.problems_review_menu).setMessage(sb).setPositiveButton(R.string.clear_all_button,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      for (      Checklist checklist : checklistGroup.getChecklists()) {
        checklist.clearAllProblems();
      }
      adapter.notifyDataSetChanged();
    }
  }
).setNeutralButton(R.string.close_button_label,null).show();
}
 

Example 71

From project ZebroGaMQ, under directory /game/aMazing-application/src/de/rwth/aMazing/.

Source file: GameActivity.java

  19 
vote

@Override public boolean onOptionsItemSelected(MenuItem item){
  InputFilter[] filters=new InputFilter[1];
  filters[0]=new InputFilter(){
    public CharSequence filter(    CharSequence source,    int start,    int end,    Spanned dest,    int dstart,    int dend){
      for (int i=start; i < end; i++) {
        if (!Character.isLetterOrDigit(source.charAt(i))) {
          return "";
        }
      }
      return null;
    }
  }
;
switch (item.getItemId()) {
case 3000:
    mapView.setSatellite(!mapView.isSatellite());
  break;
case 4000:
GeoPoint myLastLocation=locOverlay.getMyLocation();
if (myLastLocation != null) {
controller.animateTo(myLastLocation);
}
 else {
Toast toast=Toast.makeText(getApplicationContext(),"Waiting for a location...",Toast.LENGTH_LONG);
toast.show();
}
break;
default :
break;
}
return super.onOptionsItemSelected(item);
}
 

Example 72

From project zxing, under directory /android/src/com/google/zxing/client/android/result/supplement/.

Source file: SupplementalInfoRetriever.java

  19 
vote

final void append(String itemID,String source,String[] newTexts,String linkURL){
  StringBuilder newTextCombined=new StringBuilder();
  if (source != null) {
    newTextCombined.append(source).append(" : ");
  }
  int linkStart=newTextCombined.length();
  boolean first=true;
  for (  String newText : newTexts) {
    if (first) {
      newTextCombined.append(newText);
      first=false;
    }
 else {
      newTextCombined.append(" [");
      newTextCombined.append(newText);
      newTextCombined.append(']');
    }
  }
  int linkEnd=newTextCombined.length();
  String newText=newTextCombined.toString();
  Spannable content=new SpannableString(newText + "\n\n");
  if (linkURL != null) {
    if (linkURL.startsWith("HTTP://")) {
      linkURL="http" + linkURL.substring(4);
    }
 else     if (linkURL.startsWith("HTTPS://")) {
      linkURL="https" + linkURL.substring(5);
    }
    content.setSpan(new URLSpan(linkURL),linkStart,linkEnd,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  }
  newContents.add(content);
  newHistories.add(new String[]{itemID,newText});
}