Program: 15193
Project: 15193
Buggy source:
@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.edit_content);
  if (WordPress.wpDB == null)   WordPress.wpDB=new WordPressDB(this);
  if (WordPress.currentBlog == null) {
    try {
      WordPress.currentBlog=new Blog(WordPress.wpDB.getLastBlogID(this),this);
    }
 catch (    Exception e) {
      Toast.makeText(this,getResources().getText(R.string.blog_not_found),Toast.LENGTH_SHORT).show();
      finish();
    }
  }
  final ImageButton addPictureButton=(ImageButton)findViewById(R.id.addPictureButton);
  registerForContextMenu(addPictureButton);
  addPictureButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      addPictureButton.performLongClick();
    }
  }
);
  Bundle extras=getIntent().getExtras();
  if (extras != null) {
    option=extras.getString("String_Node_Str");
    if (option != null) {
      if (option.equals("String_Node_Str")) {
        launchCamera();
      }
 else       if (option.equals("String_Node_Str")) {
        launchPictureLibrary();
      }
 else       if (option.equals("String_Node_Str")) {
        launchVideoCamera();
      }
 else       if (option.equals("String_Node_Str")) {
        launchVideoLibrary();
      }
    }
    localDraft=extras.getBoolean("String_Node_Str");
  }
  final WPEditText contentEditor=(WPEditText)findViewById(R.id.postContent);
  if (WordPress.richPostContent != null) {
    try {
      contentEditor.setText(WordPress.richPostContent);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  contentEditor.setOnSelectionChangedListener(new WPEditText.OnSelectionChangedListener(){
    @Override public void onSelectionChanged(){
      if (!localDraft)       return;
      final Spannable s=contentEditor.getText();
      styleStart=contentEditor.getSelectionStart();
      Object[] spans=s.getSpans(contentEditor.getSelectionStart(),contentEditor.getSelectionStart(),Object.class);
      ToggleButton boldButton=(ToggleButton)findViewById(R.id.bold);
      ToggleButton emButton=(ToggleButton)findViewById(R.id.em);
      ToggleButton bquoteButton=(ToggleButton)findViewById(R.id.bquote);
      ToggleButton underlineButton=(ToggleButton)findViewById(R.id.underline);
      ToggleButton strikeButton=(ToggleButton)findViewById(R.id.strike);
      boldButton.setChecked(false);
      emButton.setChecked(false);
      bquoteButton.setChecked(false);
      underlineButton.setChecked(false);
      strikeButton.setChecked(false);
      for (      Object span : spans) {
        if (span instanceof StyleSpan) {
          StyleSpan ss=(StyleSpan)span;
          if (ss.getStyle() == android.graphics.Typeface.BOLD) {
            boldButton.setChecked(true);
          }
          if (ss.getStyle() == android.graphics.Typeface.ITALIC) {
            emButton.setChecked(true);
          }
        }
        if (span instanceof QuoteSpan) {
          bquoteButton.setChecked(true);
        }
        if (span instanceof WPUnderlineSpan) {
          underlineButton.setChecked(true);
        }
        if (span instanceof StrikethroughSpan) {
          strikeButton.setChecked(true);
        }
      }
    }
  }
);
  contentEditor.setOnFocusChangeListener(new View.OnFocusChangeListener(){
    @Override public void onFocusChange(    View view,    boolean hasFocus){
      RelativeLayout formatBar=(RelativeLayout)findViewById(R.id.formatBar);
      if (hasFocus) {
        formatBar.setVisibility(View.VISIBLE);
        Animation fadeInAnimation=AnimationUtils.loadAnimation(EditContent.this,R.anim.show);
        formatBar.startAnimation(fadeInAnimation);
      }
 else {
        Animation fadeOutAnimation=AnimationUtils.loadAnimation(EditContent.this,R.anim.disappear);
        formatBar.startAnimation(fadeOutAnimation);
        formatBar.setVisibility(View.GONE);
      }
    }
  }
);
  contentEditor.setOnEditTextImeBackListener(new WPEditText.EditTextImeBackListener(){
    @Override public void onImeBack(    WPEditText view,    String text){
      finishEditing();
    }
  }
);
  contentEditor.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      RelativeLayout formatBar=(RelativeLayout)findViewById(R.id.formatBar);
      if (!(formatBar.getVisibility() == View.VISIBLE)) {
        formatBar.setVisibility(View.VISIBLE);
        Animation fadeInAnimation=AnimationUtils.loadAnimation(EditContent.this,R.anim.show);
        formatBar.startAnimation(fadeInAnimation);
      }
      final Spannable s=contentEditor.getText();
      styleStart=contentEditor.getSelectionStart();
      WPImageSpan[] click_spans=s.getSpans(contentEditor.getSelectionStart(),contentEditor.getSelectionStart(),WPImageSpan.class);
      if (click_spans.length != 0) {
        final WPImageSpan span=click_spans[0];
        if (!span.isVideo()) {
          LayoutInflater factory=LayoutInflater.from(EditContent.this);
          final View alertView=factory.inflate(R.layout.alert_image_options,null);
          final TextView imageWidthText=(TextView)alertView.findViewById(R.id.imageWidthText);
          final EditText titleText=(EditText)alertView.findViewById(R.id.title);
          final EditText caption=(EditText)alertView.findViewById(R.id.caption);
          final SeekBar seekBar=(SeekBar)alertView.findViewById(R.id.imageWidth);
          final Spinner alignmentSpinner=(Spinner)alertView.findViewById(R.id.alignment_spinner);
          ArrayAdapter<CharSequence> adapter=ArrayAdapter.createFromResource(EditContent.this,R.array.alignment_array,android.R.layout.simple_spinner_item);
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          alignmentSpinner.setAdapter(adapter);
          imageWidthText.setText(String.valueOf(span.getWidth()) + "String_Node_Str");
          seekBar.setProgress(span.getWidth());
          titleText.setText(span.getTitle());
          caption.setText(span.getCaption());
          alignmentSpinner.setSelection(span.getHorizontalAlignment(),true);
          seekBar.setMax(100);
          if (span.getWidth() != 0)           seekBar.setProgress(span.getWidth() / 10);
          seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){
            @Override public void onStopTrackingTouch(            SeekBar seekBar){
            }
            @Override public void onStartTrackingTouch(            SeekBar seekBar){
            }
            @Override public void onProgressChanged(            SeekBar seekBar,            int progress,            boolean fromUser){
              if (progress == 0)               progress=1;
              imageWidthText.setText(progress * 10 + "String_Node_Str");
            }
          }
);
          AlertDialog ad=new AlertDialog.Builder(EditContent.this).setTitle("String_Node_Str").setView(alertView).setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
            public void onClick(            DialogInterface dialog,            int whichButton){
              span.setTitle(titleText.getText().toString());
              span.setHorizontalAlignment(alignmentSpinner.getSelectedItemPosition());
              span.setWidth(seekBar.getProgress() * 10);
              span.setCaption(caption.getText().toString());
            }
          }
).setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
            public void onClick(            DialogInterface dialog,            int whichButton){
            }
          }
).create();
          ad.show();
        }
      }
 else {
        contentEditor.setMovementMethod(ArrowKeyMovementMethod.getInstance());
        contentEditor.setSelection(contentEditor.getSelectionStart());
      }
    }
  }
);
  final WPEditText contentEdit=(WPEditText)findViewById(R.id.postContent);
  contentEdit.addTextChangedListener(new TextWatcher(){
    public void afterTextChanged(    Editable s){
      try {
        int position=Selection.getSelectionStart(contentEdit.getText());
        if ((isBackspace && position != 1) || lastPosition == position || !localDraft)         return;
        ToggleButton boldButton=(ToggleButton)findViewById(R.id.bold);
        ToggleButton emButton=(ToggleButton)findViewById(R.id.em);
        ToggleButton bquoteButton=(ToggleButton)findViewById(R.id.bquote);
        ToggleButton underlineButton=(ToggleButton)findViewById(R.id.underline);
        ToggleButton strikeButton=(ToggleButton)findViewById(R.id.strike);
        if (position < 0) {
          position=0;
        }
        lastPosition=position;
        if (position > 0) {
          if (styleStart > position) {
            styleStart=position - 1;
          }
          boolean exists=false;
          if (boldButton.isChecked()) {
            StyleSpan[] ss=s.getSpans(styleStart,position,StyleSpan.class);
            exists=false;
            for (int i=0; i < ss.length; i++) {
              if (ss[i].getStyle() == android.graphics.Typeface.BOLD) {
                exists=true;
              }
            }
            if (!exists)             s.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),styleStart,position,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
          }
          if (emButton.isChecked()) {
            StyleSpan[] ss=s.getSpans(styleStart,position,StyleSpan.class);
            exists=false;
            for (int i=0; i < ss.length; i++) {
              if (ss[i].getStyle() == android.graphics.Typeface.ITALIC) {
                exists=true;
              }
            }
            if (!exists)             s.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC),styleStart,position,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
          }
          if (emButton.isChecked()) {
            StyleSpan[] ss=s.getSpans(styleStart,position,StyleSpan.class);
            exists=false;
            for (int i=0; i < ss.length; i++) {
              if (ss[i].getStyle() == android.graphics.Typeface.ITALIC) {
                exists=true;
              }
            }
            if (!exists)             s.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC),styleStart,position,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
          }
          if (underlineButton.isChecked()) {
            WPUnderlineSpan[] ss=s.getSpans(styleStart,position,WPUnderlineSpan.class);
            exists=false;
            for (int i=0; i < ss.length; i++) {
              exists=true;
            }
            if (!exists)             s.setSpan(new WPUnderlineSpan(),styleStart,position,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
          }
          if (strikeButton.isChecked()) {
            StrikethroughSpan[] ss=s.getSpans(styleStart,position,StrikethroughSpan.class);
            exists=false;
            for (int i=0; i < ss.length; i++) {
              exists=true;
            }
            if (!exists)             s.setSpan(new StrikethroughSpan(),styleStart,position,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
          }
          if (bquoteButton.isChecked()) {
            QuoteSpan[] ss=s.getSpans(styleStart,position,QuoteSpan.class);
            exists=false;
            for (int i=0; i < ss.length; i++) {
              exists=true;
            }
            if (!exists)             s.setSpan(new QuoteSpan(),styleStart,position,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
          }
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
      if ((count - after == 1) || (s.length() == 0))       isBackspace=true;
 else       isBackspace=false;
    }
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
  }
);
  final ToggleButton boldButton=(ToggleButton)findViewById(R.id.bold);
  boldButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      formatBtnClick(boldButton,"String_Node_Str");
    }
  }
);
  final Button linkButton=(Button)findViewById(R.id.link);
  linkButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      WPEditText contentText=(WPEditText)findViewById(R.id.postContent);
      selectionStart=contentText.getSelectionStart();
      styleStart=selectionStart;
      selectionEnd=contentText.getSelectionEnd();
      if (selectionStart > selectionEnd) {
        int temp=selectionEnd;
        selectionEnd=selectionStart;
        selectionStart=temp;
      }
      Intent i=new Intent(EditContent.this,Link.class);
      if (selectionEnd > selectionStart) {
        String selectedText=contentText.getText().subSequence(selectionStart,selectionEnd).toString();
        i.putExtra("String_Node_Str",selectedText);
      }
      startActivityForResult(i,4);
    }
  }
);
  final ToggleButton emButton=(ToggleButton)findViewById(R.id.em);
  emButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      formatBtnClick(emButton,"String_Node_Str");
    }
  }
);
  final ToggleButton underlineButton=(ToggleButton)findViewById(R.id.underline);
  underlineButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      formatBtnClick(underlineButton,"String_Node_Str");
    }
  }
);
  final ToggleButton strikeButton=(ToggleButton)findViewById(R.id.strike);
  strikeButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      formatBtnClick(strikeButton,"String_Node_Str");
    }
  }
);
  final ToggleButton bquoteButton=(ToggleButton)findViewById(R.id.bquote);
  bquoteButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      formatBtnClick(bquoteButton,"String_Node_Str");
    }
  }
);
  final Button moreButton=(Button)findViewById(R.id.more);
  moreButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      WPEditText contentText=(WPEditText)findViewById(R.id.postContent);
      selectionEnd=contentText.getSelectionEnd();
      Editable str=contentText.getText();
      str.insert(selectionEnd,"String_Node_Str");
    }
  }
);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.edit_content);
  if (WordPress.wpDB == null)   WordPress.wpDB=new WordPressDB(this);
  if (WordPress.currentBlog == null) {
    try {
      WordPress.currentBlog=new Blog(WordPress.wpDB.getLastBlogID(this),this);
    }
 catch (    Exception e) {
      Toast.makeText(this,getResources().getText(R.string.blog_not_found),Toast.LENGTH_SHORT).show();
      finish();
    }
  }
  final ImageButton addPictureButton=(ImageButton)findViewById(R.id.addPictureButton);
  registerForContextMenu(addPictureButton);
  addPictureButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      addPictureButton.performLongClick();
    }
  }
);
  Bundle extras=getIntent().getExtras();
  if (extras != null) {
    option=extras.getString("String_Node_Str");
    if (option != null) {
      if (option.equals("String_Node_Str")) {
        launchCamera();
      }
 else       if (option.equals("String_Node_Str")) {
        launchPictureLibrary();
      }
 else       if (option.equals("String_Node_Str")) {
        launchVideoCamera();
      }
 else       if (option.equals("String_Node_Str")) {
        launchVideoLibrary();
      }
    }
    localDraft=extras.getBoolean("String_Node_Str");
  }
  final WPEditText contentEditor=(WPEditText)findViewById(R.id.postContent);
  if (WordPress.richPostContent != null) {
    try {
      contentEditor.setText(WordPress.richPostContent);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  contentEditor.setOnSelectionChangedListener(new WPEditText.OnSelectionChangedListener(){
    @Override public void onSelectionChanged(){
      if (!localDraft)       return;
      final Spannable s=contentEditor.getText();
      styleStart=contentEditor.getSelectionStart();
      Object[] spans=s.getSpans(contentEditor.getSelectionStart(),contentEditor.getSelectionStart(),Object.class);
      ToggleButton boldButton=(ToggleButton)findViewById(R.id.bold);
      ToggleButton emButton=(ToggleButton)findViewById(R.id.em);
      ToggleButton bquoteButton=(ToggleButton)findViewById(R.id.bquote);
      ToggleButton underlineButton=(ToggleButton)findViewById(R.id.underline);
      ToggleButton strikeButton=(ToggleButton)findViewById(R.id.strike);
      boldButton.setChecked(false);
      emButton.setChecked(false);
      bquoteButton.setChecked(false);
      underlineButton.setChecked(false);
      strikeButton.setChecked(false);
      for (      Object span : spans) {
        if (span instanceof StyleSpan) {
          StyleSpan ss=(StyleSpan)span;
          if (ss.getStyle() == android.graphics.Typeface.BOLD) {
            boldButton.setChecked(true);
          }
          if (ss.getStyle() == android.graphics.Typeface.ITALIC) {
            emButton.setChecked(true);
          }
        }
        if (span instanceof QuoteSpan) {
          bquoteButton.setChecked(true);
        }
        if (span instanceof WPUnderlineSpan) {
          underlineButton.setChecked(true);
        }
        if (span instanceof StrikethroughSpan) {
          strikeButton.setChecked(true);
        }
      }
    }
  }
);
  contentEditor.setOnEditTextImeBackListener(new WPEditText.EditTextImeBackListener(){
    @Override public void onImeBack(    WPEditText view,    String text){
      finishEditing();
    }
  }
);
  contentEditor.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      RelativeLayout formatBar=(RelativeLayout)findViewById(R.id.formatBar);
      if (!(formatBar.getVisibility() == View.VISIBLE)) {
        formatBar.setVisibility(View.VISIBLE);
        Animation fadeInAnimation=AnimationUtils.loadAnimation(EditContent.this,R.anim.show);
        formatBar.startAnimation(fadeInAnimation);
      }
      final Spannable s=contentEditor.getText();
      styleStart=contentEditor.getSelectionStart();
      WPImageSpan[] click_spans=s.getSpans(contentEditor.getSelectionStart(),contentEditor.getSelectionStart(),WPImageSpan.class);
      if (click_spans.length != 0) {
        final WPImageSpan span=click_spans[0];
        if (!span.isVideo()) {
          LayoutInflater factory=LayoutInflater.from(EditContent.this);
          final View alertView=factory.inflate(R.layout.alert_image_options,null);
          final TextView imageWidthText=(TextView)alertView.findViewById(R.id.imageWidthText);
          final EditText titleText=(EditText)alertView.findViewById(R.id.title);
          final EditText caption=(EditText)alertView.findViewById(R.id.caption);
          final SeekBar seekBar=(SeekBar)alertView.findViewById(R.id.imageWidth);
          final Spinner alignmentSpinner=(Spinner)alertView.findViewById(R.id.alignment_spinner);
          ArrayAdapter<CharSequence> adapter=ArrayAdapter.createFromResource(EditContent.this,R.array.alignment_array,android.R.layout.simple_spinner_item);
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          alignmentSpinner.setAdapter(adapter);
          imageWidthText.setText(String.valueOf(span.getWidth()) + "String_Node_Str");
          seekBar.setProgress(span.getWidth());
          titleText.setText(span.getTitle());
          caption.setText(span.getCaption());
          alignmentSpinner.setSelection(span.getHorizontalAlignment(),true);
          seekBar.setMax(100);
          if (span.getWidth() != 0)           seekBar.setProgress(span.getWidth() / 10);
          seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){
            @Override public void onStopTrackingTouch(            SeekBar seekBar){
            }
            @Override public void onStartTrackingTouch(            SeekBar seekBar){
            }
            @Override public void onProgressChanged(            SeekBar seekBar,            int progress,            boolean fromUser){
              if (progress == 0)               progress=1;
              imageWidthText.setText(progress * 10 + "String_Node_Str");
            }
          }
);
          AlertDialog ad=new AlertDialog.Builder(EditContent.this).setTitle("String_Node_Str").setView(alertView).setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
            public void onClick(            DialogInterface dialog,            int whichButton){
              span.setTitle(titleText.getText().toString());
              span.setHorizontalAlignment(alignmentSpinner.getSelectedItemPosition());
              span.setWidth(seekBar.getProgress() * 10);
              span.setCaption(caption.getText().toString());
            }
          }
).setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
            public void onClick(            DialogInterface dialog,            int whichButton){
            }
          }
).create();
          ad.show();
        }
      }
 else {
        contentEditor.setMovementMethod(ArrowKeyMovementMethod.getInstance());
        contentEditor.setSelection(contentEditor.getSelectionStart());
      }
    }
  }
);
  final WPEditText contentEdit=(WPEditText)findViewById(R.id.postContent);
  contentEdit.addTextChangedListener(new TextWatcher(){
    public void afterTextChanged(    Editable s){
      try {
        int position=Selection.getSelectionStart(contentEdit.getText());
        if ((isBackspace && position != 1) || lastPosition == position || !localDraft)         return;
        ToggleButton boldButton=(ToggleButton)findViewById(R.id.bold);
        ToggleButton emButton=(ToggleButton)findViewById(R.id.em);
        ToggleButton bquoteButton=(ToggleButton)findViewById(R.id.bquote);
        ToggleButton underlineButton=(ToggleButton)findViewById(R.id.underline);
        ToggleButton strikeButton=(ToggleButton)findViewById(R.id.strike);
        if (position < 0) {
          position=0;
        }
        lastPosition=position;
        if (position > 0) {
          if (styleStart > position) {
            styleStart=position - 1;
          }
          boolean exists=false;
          if (boldButton.isChecked()) {
            StyleSpan[] ss=s.getSpans(styleStart,position,StyleSpan.class);
            exists=false;
            for (int i=0; i < ss.length; i++) {
              if (ss[i].getStyle() == android.graphics.Typeface.BOLD) {
                exists=true;
              }
            }
            if (!exists)             s.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),styleStart,position,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
          }
          if (emButton.isChecked()) {
            StyleSpan[] ss=s.getSpans(styleStart,position,StyleSpan.class);
            exists=false;
            for (int i=0; i < ss.length; i++) {
              if (ss[i].getStyle() == android.graphics.Typeface.ITALIC) {
                exists=true;
              }
            }
            if (!exists)             s.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC),styleStart,position,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
          }
          if (emButton.isChecked()) {
            StyleSpan[] ss=s.getSpans(styleStart,position,StyleSpan.class);
            exists=false;
            for (int i=0; i < ss.length; i++) {
              if (ss[i].getStyle() == android.graphics.Typeface.ITALIC) {
                exists=true;
              }
            }
            if (!exists)             s.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC),styleStart,position,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
          }
          if (underlineButton.isChecked()) {
            WPUnderlineSpan[] ss=s.getSpans(styleStart,position,WPUnderlineSpan.class);
            exists=false;
            for (int i=0; i < ss.length; i++) {
              exists=true;
            }
            if (!exists)             s.setSpan(new WPUnderlineSpan(),styleStart,position,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
          }
          if (strikeButton.isChecked()) {
            StrikethroughSpan[] ss=s.getSpans(styleStart,position,StrikethroughSpan.class);
            exists=false;
            for (int i=0; i < ss.length; i++) {
              exists=true;
            }
            if (!exists)             s.setSpan(new StrikethroughSpan(),styleStart,position,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
          }
          if (bquoteButton.isChecked()) {
            QuoteSpan[] ss=s.getSpans(styleStart,position,QuoteSpan.class);
            exists=false;
            for (int i=0; i < ss.length; i++) {
              exists=true;
            }
            if (!exists)             s.setSpan(new QuoteSpan(),styleStart,position,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
          }
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
      if ((count - after == 1) || (s.length() == 0))       isBackspace=true;
 else       isBackspace=false;
    }
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
  }
);
  final ToggleButton boldButton=(ToggleButton)findViewById(R.id.bold);
  boldButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      formatBtnClick(boldButton,"String_Node_Str");
    }
  }
);
  final Button linkButton=(Button)findViewById(R.id.link);
  linkButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      WPEditText contentText=(WPEditText)findViewById(R.id.postContent);
      selectionStart=contentText.getSelectionStart();
      styleStart=selectionStart;
      selectionEnd=contentText.getSelectionEnd();
      if (selectionStart > selectionEnd) {
        int temp=selectionEnd;
        selectionEnd=selectionStart;
        selectionStart=temp;
      }
      Intent i=new Intent(EditContent.this,Link.class);
      if (selectionEnd > selectionStart) {
        String selectedText=contentText.getText().subSequence(selectionStart,selectionEnd).toString();
        i.putExtra("String_Node_Str",selectedText);
      }
      startActivityForResult(i,4);
    }
  }
);
  final ToggleButton emButton=(ToggleButton)findViewById(R.id.em);
  emButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      formatBtnClick(emButton,"String_Node_Str");
    }
  }
);
  final ToggleButton underlineButton=(ToggleButton)findViewById(R.id.underline);
  underlineButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      formatBtnClick(underlineButton,"String_Node_Str");
    }
  }
);
  final ToggleButton strikeButton=(ToggleButton)findViewById(R.id.strike);
  strikeButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      formatBtnClick(strikeButton,"String_Node_Str");
    }
  }
);
  final ToggleButton bquoteButton=(ToggleButton)findViewById(R.id.bquote);
  bquoteButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      formatBtnClick(bquoteButton,"String_Node_Str");
    }
  }
);
  final Button moreButton=(Button)findViewById(R.id.more);
  moreButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      WPEditText contentText=(WPEditText)findViewById(R.id.postContent);
      selectionEnd=contentText.getSelectionEnd();
      Editable str=contentText.getText();
      str.insert(selectionEnd,"String_Node_Str");
    }
  }
);
}