コード例 #1
0
 private void clearNewFields() {
   newPassphraseEditText.getEditableText().clear();
   confirmNewPassphraseEditText.getEditableText().clear();
 }
コード例 #2
0
 public void insertBBCode(BBCODE code) {
   if (selectionStart < 0) { // we might be getting this from an earlier point
     selectionStart = mMessage.getSelectionStart();
     selectionEnd = mMessage.getSelectionEnd();
   }
   boolean highlighted = selectionStart != selectionEnd;
   String startTag = null;
   String endTag = null;
   switch (code) {
     case BOLD:
       startTag = "[b]";
       endTag = "[/b]";
       break;
     case ITALICS:
       startTag = "[i]";
       endTag = "[/i]";
       break;
     case UNDERLINE:
       startTag = "[u]";
       endTag = "[/u]";
       break;
     case STRIKEOUT:
       startTag = "[s]";
       endTag = "[/s]";
       break;
     case URL:
       /* clipboard code, probably need to implement an alertdialog for this
       String link = null;
       if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB){
       	ClipboardManager cb = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
       	String copy = String.valueOf(cb.getText());
       	if(copy.startsWith("http://") || copy.startsWith("https://")){
       		link = copy;
       	}
       }else{
       	android.content.ClipboardManager cb = (android.content.ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
       	String copy = String.valueOf(cb.getText());
       	if(copy.startsWith("http://") || copy.startsWith("https://")){
       		link = copy;
       	}
       }
       if(link != null){
       	startTag = "[url="+link+"]";
       }else{
       	startTag = "[url]";
       }
       */
       startTag = "[url]";
       endTag = "[/url]";
       break;
     case QUOTE:
       startTag = "[quote]";
       endTag = "[/quote]";
       break;
     case IMAGE:
       startTag = "[img]";
       endTag = "[/img]";
       break;
     case SPOILER:
       startTag = "[spoiler]";
       endTag = "[/spoiler]";
       break;
     case CODE:
       startTag = "[code]";
       endTag = "[/code]";
       break;
   }
   if (startTag != null && endTag != null) {
     if (highlighted) {
       mMessage.getEditableText().insert(selectionStart, startTag);
       mMessage.getEditableText().insert(selectionEnd + startTag.length(), endTag);
       mMessage.setSelection(selectionStart + startTag.length());
     } else {
       mMessage.getEditableText().insert(selectionStart, startTag + endTag);
       mMessage.setSelection(selectionStart + startTag.length());
     }
   }
   selectionStart = -1; // reset them for next time
   selectionEnd = -1;
 }