nus-yam/ex-repair huggingface dataset:
Program: 187773
Project: 187773
Buggy source:
/** 
 * Encrypt the current note.
 * @param text
 */
private void encryptNote(boolean encryptTags){
  String text=mText.getText().toString();
  String title=ExtractTitle.extractTitle(text);
  String tags=getTags();
  if (!encryptTags) {
    tags=null;
  }
  Intent i=new Intent(this,EncryptActivity.class);
  i.putExtra(PrivateNotePadIntents.EXTRA_ACTION,CryptoIntents.ACTION_ENCRYPT);
  i.putExtra(CryptoIntents.EXTRA_TEXT_ARRAY,EncryptActivity.getCryptoStringArray(text,title,tags));
  i.putExtra(PrivateNotePadIntents.EXTRA_URI,mUri.toString());
  startActivity(i);
  mDecryptedText=null;
  mText.setText(R.string.encrypted);
}

Fixed version (ground truth):
/** 
 * Encrypt the current note.
 * @param text
 */
private void encryptNote(boolean encryptTags){
  String text=mText.getText().toString();
  String title=ExtractTitle.extractTitle(text);
  String tags=getTags();
  if (!encryptTags) {
    tags=null;
  }
  if (debug)   Log.d(TAG,"String_Node_Str" + text);
  if (EncryptActivity.getPendingEncryptActivities() == 0) {
    Intent i=new Intent(this,EncryptActivity.class);
    i.putExtra(PrivateNotePadIntents.EXTRA_ACTION,CryptoIntents.ACTION_ENCRYPT);
    i.putExtra(CryptoIntents.EXTRA_TEXT_ARRAY,EncryptActivity.getCryptoStringArray(text,title,tags));
    i.putExtra(PrivateNotePadIntents.EXTRA_URI,mUri.toString());
    startActivity(i);
    if (debug)     Log.d(TAG,"String_Node_Str" + text);
    sDecryptedText=text;
    mDecryptedText=null;
    EncryptActivity.confirmEncryptActivityCalled();
    mText.setText(R.string.encrypted);
  }
 else {
  }
}
Program: 187774
Project: 187774
Buggy source:
protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (debug)   Log.d(TAG,"String_Node_Str" + requestCode + "String_Node_Str"+ resultCode);
switch (requestCode) {
case REQUEST_CODE_DECRYPT:
    if (resultCode == RESULT_OK && data != null) {
      String decryptedText=data.getStringExtra(CryptoIntents.EXTRA_TEXT);
      long id=data.getLongExtra(PrivateNotePadIntents.EXTRA_ID,-1);
      if (id == -1) {
        Log.e(TAG,"String_Node_Str");
        Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
        finish();
        return;
      }
      mDecryptedText=decryptedText;
    }
 else {
      Toast.makeText(this,R.string.decryption_failed,Toast.LENGTH_SHORT).show();
      Log.e(TAG,"String_Node_Str");
      finish();
    }
  break;
case REQUEST_CODE_TEXT_SELECTION_ALTERNATIVE:
if (resultCode == RESULT_OK && data != null) {
  mApplyText=data.getStringExtra(NotepadIntents.EXTRA_TEXT);
  mApplyTextBefore=data.getStringExtra(NotepadIntents.EXTRA_TEXT_BEFORE_SELECTION);
  mApplyTextAfter=data.getStringExtra(NotepadIntents.EXTRA_TEXT_AFTER_SELECTION);
}
break;
case REQUEST_CODE_SAVE_AS:
if (resultCode == RESULT_OK && data != null) {
mUri=data.getData();
if (debug) Log.d(TAG,"String_Node_Str" + mOriginalContent + "String_Node_Str"+ mFileContent);
mOriginalContent=mFileContent;
updateTitleSdCard();
}
}
}

Fixed version (ground truth):
protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (debug)   Log.d(TAG,"String_Node_Str" + requestCode + "String_Node_Str"+ resultCode);
switch (requestCode) {
case REQUEST_CODE_DECRYPT:
    if (resultCode == RESULT_OK && data != null) {
      String decryptedText=data.getStringExtra(CryptoIntents.EXTRA_TEXT);
      long id=data.getLongExtra(PrivateNotePadIntents.EXTRA_ID,-1);
      if (id == -1) {
        Log.e(TAG,"String_Node_Str");
        Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
        finish();
        return;
      }
      if (debug)       Log.d(TAG,"String_Node_Str" + decryptedText);
      mDecryptedText=decryptedText;
      mOriginalContent=decryptedText;
    }
 else {
      Toast.makeText(this,R.string.decryption_failed,Toast.LENGTH_SHORT).show();
      Log.e(TAG,"String_Node_Str");
      finish();
    }
  break;
case REQUEST_CODE_TEXT_SELECTION_ALTERNATIVE:
if (resultCode == RESULT_OK && data != null) {
  mApplyText=data.getStringExtra(NotepadIntents.EXTRA_TEXT);
  mApplyTextBefore=data.getStringExtra(NotepadIntents.EXTRA_TEXT_BEFORE_SELECTION);
  mApplyTextAfter=data.getStringExtra(NotepadIntents.EXTRA_TEXT_AFTER_SELECTION);
}
break;
case REQUEST_CODE_SAVE_AS:
if (resultCode == RESULT_OK && data != null) {
mUri=data.getData();
if (debug) Log.d(TAG,"String_Node_Str" + mOriginalContent + "String_Node_Str"+ mFileContent);
mOriginalContent=mFileContent;
updateTitleSdCard();
}
}
}
Program: 187776
Project: 187776
Buggy source:
@Override protected void onResume(){
  super.onResume();
  if (debug)   Log.d(TAG,"String_Node_Str");
  int autoLink=PreferenceActivity.getAutoLinkFromPreference(this);
  mText.setAutoLinkMask(autoLink);
  mEncrypted=0;
  if (mState == STATE_EDIT || mState == STATE_INSERT) {
    getNoteFromContentProvider();
  }
 else   if (mState == STATE_EDIT_NOTE_FROM_SDCARD) {
    getNoteFromFile();
  }
  if (mEncrypted == 0 || mDecryptedText != null) {
    applyInsertText();
  }
  mText.setMovementMethod(new ArrowKeyMovementMethod(){
    public boolean onTouchEvent(    TextView widget,    Spannable buffer,    MotionEvent event){
      int action=event.getAction();
      if (action == MotionEvent.ACTION_UP) {
        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);
        ClickableSpan[] link=buffer.getSpans(off,off,ClickableSpan.class);
        if (link.length != 0) {
          link[0].onClick(widget);
          return true;
        }
      }
      return super.onTouchEvent(widget,buffer,event);
    }
  }
);
  setTheme(loadTheme());
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  if (debug)   Log.d(TAG,"String_Node_Str");
  if (debug)   Log.d(TAG,"String_Node_Str" + mDecryptedText);
  int autoLink=PreferenceActivity.getAutoLinkFromPreference(this);
  mText.setAutoLinkMask(autoLink);
  mEncrypted=0;
  if (mState == STATE_EDIT || mState == STATE_INSERT) {
    getNoteFromContentProvider();
  }
 else   if (mState == STATE_EDIT_NOTE_FROM_SDCARD) {
    getNoteFromFile();
  }
  if (mEncrypted == 0 || mDecryptedText != null) {
    applyInsertText();
  }
  mText.setMovementMethod(new ArrowKeyMovementMethod(){
    public boolean onTouchEvent(    TextView widget,    Spannable buffer,    MotionEvent event){
      int action=event.getAction();
      if (action == MotionEvent.ACTION_UP) {
        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);
        ClickableSpan[] link=buffer.getSpans(off,off,ClickableSpan.class);
        if (link.length != 0) {
          link[0].onClick(widget);
          return true;
        }
      }
      return super.onTouchEvent(widget,buffer,event);
    }
  }
);
  setTheme(loadTheme());
}
Program: 187777
Project: 187777
Buggy source:
@Override protected void onSaveInstanceState(Bundle outState){
  if (debug)   Log.d(TAG,"String_Node_Str");
  if (debug)   Log.d(TAG,"String_Node_Str" + mFileContent);
  mSelectionStart=mText.getSelectionStart();
  mSelectionStop=mText.getSelectionEnd();
  mFileContent=mText.getText().toString();
  outState.putString(BUNDLE_ORIGINAL_CONTENT,mOriginalContent);
  outState.putInt(BUNDLE_STATE,mState);
  outState.putString(BUNDLE_URI,mUri.toString());
  outState.putInt(BUNDLE_SELECTION_START,mSelectionStart);
  outState.putInt(BUNDLE_SELECTION_STOP,mSelectionStop);
  outState.putString(BUNDLE_FILE_CONTENT,mFileContent);
  outState.putString(BUNDLE_APPLY_TEXT,mApplyText);
  outState.putString(BUNDLE_APPLY_TEXT_BEFORE,mApplyTextBefore);
  outState.putString(BUNDLE_APPLY_TEXT_AFTER,mApplyTextAfter);
}

Fixed version (ground truth):
@Override protected void onSaveInstanceState(Bundle outState){
  if (debug)   Log.d(TAG,"String_Node_Str");
  mSelectionStart=mText.getSelectionStart();
  mSelectionStop=mText.getSelectionEnd();
  mFileContent=mText.getText().toString();
  if (debug)   Log.d(TAG,"String_Node_Str" + mSelectionStart + "String_Node_Str"+ mSelectionStop+ "String_Node_Str"+ mFileContent);
  outState.putString(BUNDLE_ORIGINAL_CONTENT,mOriginalContent);
  outState.putInt(BUNDLE_STATE,mState);
  outState.putString(BUNDLE_URI,mUri.toString());
  outState.putInt(BUNDLE_SELECTION_START,mSelectionStart);
  outState.putInt(BUNDLE_SELECTION_STOP,mSelectionStop);
  outState.putString(BUNDLE_FILE_CONTENT,mFileContent);
  outState.putString(BUNDLE_APPLY_TEXT,mApplyText);
  outState.putString(BUNDLE_APPLY_TEXT_BEFORE,mApplyTextBefore);
  outState.putString(BUNDLE_APPLY_TEXT_AFTER,mApplyTextAfter);
}
Program: 187778
Project: 187778
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (debug)   Log.d(TAG,"String_Node_Str");
  Intent i=getIntent();
  i.setComponent(null);
  String action=i.getStringExtra(PrivateNotePadIntents.EXTRA_ACTION);
  setResult(RESULT_CANCELED);
  if (!action.equals(CryptoIntents.ACTION_ENCRYPT) && !action.equals(CryptoIntents.ACTION_DECRYPT)) {
    Log.e(TAG,"String_Node_Str" + action);
    finish();
    return;
  }
  i.setAction(action);
  if (IntentUtils.isIntentAvailable(this,i)) {
    try {
      if (debug)       Log.d(TAG,"String_Node_Str");
      startActivityForResult(i,REQUEST_CODE_ENCRYPT_OR_UNENCRYPT);
    }
 catch (    ActivityNotFoundException e) {
      Toast.makeText(this,R.string.encryption_failed,Toast.LENGTH_SHORT).show();
      Log.e(TAG,"String_Node_Str");
    }
  }
 else {
    showDialog(DIALOG_ID_GET_FROM_MARKET);
  }
  if (debug)   Log.d(TAG,"String_Node_Str");
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (debug)   Log.d(TAG,"String_Node_Str");
  sPendingEncryptActivities--;
  if (sCancelEncrypt) {
    if (debug)     Log.d(TAG,"String_Node_Str");
    sCancelEncrypt=false;
    setResult(RESULT_CANCELED);
    finish();
    return;
  }
  if (debug)   Log.d(TAG,"String_Node_Str");
  NoteEditor.deleteStaticDecryptedText();
  Intent i=getIntent();
  i.setComponent(null);
  String action=i.getStringExtra(PrivateNotePadIntents.EXTRA_ACTION);
  setResult(RESULT_CANCELED);
  if (!action.equals(CryptoIntents.ACTION_ENCRYPT) && !action.equals(CryptoIntents.ACTION_DECRYPT)) {
    Log.e(TAG,"String_Node_Str" + action);
    finish();
    return;
  }
  i.setAction(action);
  if (IntentUtils.isIntentAvailable(this,i)) {
    try {
      if (debug)       Log.d(TAG,"String_Node_Str");
      startActivityForResult(i,REQUEST_CODE_ENCRYPT_OR_UNENCRYPT);
    }
 catch (    ActivityNotFoundException e) {
      Toast.makeText(this,R.string.encryption_failed,Toast.LENGTH_SHORT).show();
      Log.e(TAG,"String_Node_Str");
    }
  }
 else {
    showDialog(DIALOG_ID_GET_FROM_MARKET);
  }
  if (debug)   Log.d(TAG,"String_Node_Str");
}
Program: 187780
Project: 187780
Buggy source:
/** 
 * Encrypt the current note.
 * @param text
 */
private void encryptNote(boolean encryptTags){
  String text=mText.getText().toString();
  String title=ExtractTitle.extractTitle(text);
  String tags=getTags();
  if (!encryptTags) {
    tags=null;
  }
  if (debug)   Log.d(TAG,"String_Node_Str" + text);
  if (EncryptActivity.getPendingEncryptActivities() == 0) {
    Intent i=new Intent(this,EncryptActivity.class);
    i.putExtra(PrivateNotePadIntents.EXTRA_ACTION,CryptoIntents.ACTION_ENCRYPT);
    i.putExtra(CryptoIntents.EXTRA_TEXT_ARRAY,EncryptActivity.getCryptoStringArray(text,title,tags));
    i.putExtra(PrivateNotePadIntents.EXTRA_URI,mUri.toString());
    if (text.equals(mOriginalContent)) {
      i.putExtra(PrivateNotePadIntents.EXTRA_CONTENT_UNCHANGED,true);
    }
    startActivity(i);
    if (debug)     Log.d(TAG,"String_Node_Str" + text);
    sDecryptedText=text;
    mDecryptedText=null;
    EncryptActivity.confirmEncryptActivityCalled();
    mText.setText(R.string.encrypted);
  }
 else {
  }
}

Fixed version (ground truth):
/** 
 * Encrypt the current note.
 * @param text
 */
private void encryptNote(boolean encryptTags){
  String text=mText.getText().toString();
  String title=ExtractTitle.extractTitle(text);
  String tags=getTags();
  boolean isNoteEncrypted=!isNoteUnencrypted();
  if (!encryptTags) {
    tags=null;
  }
  if (debug)   Log.d(TAG,"String_Node_Str" + text);
  if (EncryptActivity.getPendingEncryptActivities() == 0) {
    Intent i=new Intent(this,EncryptActivity.class);
    i.putExtra(PrivateNotePadIntents.EXTRA_ACTION,CryptoIntents.ACTION_ENCRYPT);
    i.putExtra(CryptoIntents.EXTRA_TEXT_ARRAY,EncryptActivity.getCryptoStringArray(text,title,tags));
    i.putExtra(PrivateNotePadIntents.EXTRA_URI,mUri.toString());
    if (text.equals(mOriginalContent) && isNoteEncrypted) {
      i.putExtra(PrivateNotePadIntents.EXTRA_CONTENT_UNCHANGED,true);
    }
    startActivity(i);
    if (debug)     Log.d(TAG,"String_Node_Str" + text);
    sDecryptedText=text;
    if (isNoteEncrypted) {
      mDecryptedText=null;
      mText.setText(R.string.encrypted);
    }
 else {
    }
    EncryptActivity.confirmEncryptActivityCalled();
  }
 else {
    if (debug)     Log.d(TAG,"String_Node_Str");
  }
}
Program: 187781
Project: 187781
Buggy source:
@Override public boolean onPrepareOptionsMenu(Menu menu){
  boolean contentChanged=!mOriginalContent.equals(mText.getText().toString());
  long encrypted=0;
  if (mCursor != null && mCursor.moveToFirst()) {
    encrypted=mCursor.getLong(COLUMN_INDEX_ENCRYPTED);
  }
  boolean isNoteUnencrypted=(encrypted == 0);
  menu.setGroupVisible(Menu.CATEGORY_ALTERNATIVE,isNoteUnencrypted);
  if (mState == STATE_EDIT_NOTE_FROM_SDCARD) {
    menu.setGroupVisible(0,false);
    menu.setGroupVisible(1,false);
    menu.setGroupVisible(2,true);
    menu.findItem(MENU_SAVE).setEnabled(contentChanged);
  }
 else {
    menu.setGroupVisible(0,contentChanged || mUndoRevert != null);
    menu.setGroupVisible(1,true);
    menu.setGroupVisible(2,false);
    menu.findItem(MENU_ENCRYPT).setVisible(isNoteUnencrypted);
    menu.findItem(MENU_UNENCRYPT).setVisible(!isNoteUnencrypted);
  }
  return super.onPrepareOptionsMenu(menu);
}

Fixed version (ground truth):
@Override public boolean onPrepareOptionsMenu(Menu menu){
  boolean contentChanged=!mOriginalContent.equals(mText.getText().toString());
  boolean isNoteUnencrypted=isNoteUnencrypted();
  menu.setGroupVisible(Menu.CATEGORY_ALTERNATIVE,isNoteUnencrypted);
  if (mState == STATE_EDIT_NOTE_FROM_SDCARD) {
    menu.setGroupVisible(0,false);
    menu.setGroupVisible(1,false);
    menu.setGroupVisible(2,true);
    menu.findItem(MENU_SAVE).setEnabled(contentChanged);
  }
 else {
    menu.setGroupVisible(0,contentChanged || mUndoRevert != null);
    menu.setGroupVisible(1,true);
    menu.setGroupVisible(2,false);
    menu.findItem(MENU_ENCRYPT).setVisible(isNoteUnencrypted);
    menu.findItem(MENU_UNENCRYPT).setVisible(!isNoteUnencrypted);
  }
  return super.onPrepareOptionsMenu(menu);
}
Program: 187783
Project: 187783
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (debug)   Log.d(TAG,"String_Node_Str");
  sPendingEncryptActivities--;
  if (sCancelEncrypt) {
    if (debug)     Log.d(TAG,"String_Node_Str");
    sCancelEncrypt=false;
    setResult(RESULT_CANCELED);
    finish();
    return;
  }
  if (debug)   Log.d(TAG,"String_Node_Str");
  NoteEditor.deleteStaticDecryptedText();
  Intent i=getIntent();
  i.setComponent(null);
  String action=i.getStringExtra(PrivateNotePadIntents.EXTRA_ACTION);
  setResult(RESULT_CANCELED);
  boolean contentUnchanged=i.getBooleanExtra(PrivateNotePadIntents.EXTRA_CONTENT_UNCHANGED,false);
  if (contentUnchanged) {
    finish();
    return;
  }
  if (!action.equals(CryptoIntents.ACTION_ENCRYPT) && !action.equals(CryptoIntents.ACTION_DECRYPT)) {
    Log.e(TAG,"String_Node_Str" + action);
    finish();
    return;
  }
  i.setAction(action);
  if (IntentUtils.isIntentAvailable(this,i)) {
    try {
      if (debug)       Log.d(TAG,"String_Node_Str");
      startActivityForResult(i,REQUEST_CODE_ENCRYPT_OR_UNENCRYPT);
    }
 catch (    ActivityNotFoundException e) {
      Toast.makeText(this,R.string.encryption_failed,Toast.LENGTH_SHORT).show();
      Log.e(TAG,"String_Node_Str");
    }
  }
 else {
    showDialog(DIALOG_ID_GET_FROM_MARKET);
  }
  if (debug)   Log.d(TAG,"String_Node_Str");
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (debug)   Log.d(TAG,"String_Node_Str");
  if (sPendingEncryptActivities > 0) {
    sPendingEncryptActivities--;
  }
  if (debug)   Log.d(TAG,"String_Node_Str" + sPendingEncryptActivities);
  if (sCancelEncrypt) {
    if (debug)     Log.d(TAG,"String_Node_Str");
    sCancelEncrypt=false;
    setResult(RESULT_CANCELED);
    finish();
    return;
  }
  if (debug)   Log.d(TAG,"String_Node_Str");
  NoteEditor.deleteStaticDecryptedText();
  Intent i=getIntent();
  i.setComponent(null);
  String action=i.getStringExtra(PrivateNotePadIntents.EXTRA_ACTION);
  setResult(RESULT_CANCELED);
  boolean contentUnchanged=i.getBooleanExtra(PrivateNotePadIntents.EXTRA_CONTENT_UNCHANGED,false);
  if (contentUnchanged) {
    finish();
    return;
  }
  if (!action.equals(CryptoIntents.ACTION_ENCRYPT) && !action.equals(CryptoIntents.ACTION_DECRYPT)) {
    Log.e(TAG,"String_Node_Str" + action);
    finish();
    return;
  }
  i.setAction(action);
  if (IntentUtils.isIntentAvailable(this,i)) {
    try {
      if (debug)       Log.d(TAG,"String_Node_Str");
      startActivityForResult(i,REQUEST_CODE_ENCRYPT_OR_UNENCRYPT);
    }
 catch (    ActivityNotFoundException e) {
      Toast.makeText(this,R.string.encryption_failed,Toast.LENGTH_SHORT).show();
      Log.e(TAG,"String_Node_Str");
    }
  }
 else {
    showDialog(DIALOG_ID_GET_FROM_MARKET);
  }
  if (debug)   Log.d(TAG,"String_Node_Str");
}
Program: 187784
Project: 187784
Buggy source:
public static int getPendingEncryptActivities(){
  return sPendingEncryptActivities;
}

Fixed version (ground truth):
public static int getPendingEncryptActivities(){
  if (debug)   Log.d(TAG,"String_Node_Str" + sPendingEncryptActivities);
  return sPendingEncryptActivities;
}
Program: 187785
Project: 187785
Buggy source:
public static void confirmEncryptActivityCalled(){
  sPendingEncryptActivities++;
}

Fixed version (ground truth):
public static void confirmEncryptActivityCalled(){
  sPendingEncryptActivities++;
  if (debug)   Log.d(TAG,"String_Node_Str" + sPendingEncryptActivities);
}
Program: 187787
Project: 187787
Buggy source:
protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (debug)   Log.d(TAG,"String_Node_Str" + requestCode + "String_Node_Str"+ resultCode);
switch (requestCode) {
case REQUEST_CODE_DECRYPT:
    if (resultCode == RESULT_OK && data != null) {
      String decryptedText=data.getStringExtra(CryptoIntents.EXTRA_TEXT);
      long id=data.getLongExtra(PrivateNotePadIntents.EXTRA_ID,-1);
      if (id == -1) {
        Log.e(TAG,"String_Node_Str");
        Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
        finish();
        return;
      }
      mDecryptedText=decryptedText;
    }
 else {
      Toast.makeText(this,R.string.decryption_failed,Toast.LENGTH_SHORT).show();
      Log.e(TAG,"String_Node_Str");
      finish();
    }
  break;
case REQUEST_CODE_TEXT_SELECTION_ALTERNATIVE:
if (resultCode == RESULT_OK && data != null) {
  String text=data.getStringExtra(NotepadIntents.EXTRA_TEXT);
  String textBefore=data.getStringExtra(NotepadIntents.EXTRA_TEXT_BEFORE_SELECTION);
  String textAfter=data.getStringExtra(NotepadIntents.EXTRA_TEXT_AFTER_SELECTION);
  insertAtPoint(textBefore,text,textAfter);
}
break;
case REQUEST_CODE_SAVE_AS:
if (resultCode == RESULT_OK && data != null) {
mUri=data.getData();
if (debug) Log.d(TAG,"String_Node_Str" + mOriginalContent + "String_Node_Str"+ mFileContent);
mOriginalContent=mFileContent;
updateTitleSdCard();
}
}
}

Fixed version (ground truth):
protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (debug)   Log.d(TAG,"String_Node_Str" + requestCode + "String_Node_Str"+ resultCode);
switch (requestCode) {
case REQUEST_CODE_DECRYPT:
    if (resultCode == RESULT_OK && data != null) {
      String decryptedText=data.getStringExtra(CryptoIntents.EXTRA_TEXT);
      long id=data.getLongExtra(PrivateNotePadIntents.EXTRA_ID,-1);
      if (id == -1) {
        Log.e(TAG,"String_Node_Str");
        Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
        finish();
        return;
      }
      mDecryptedText=decryptedText;
    }
 else {
      Toast.makeText(this,R.string.decryption_failed,Toast.LENGTH_SHORT).show();
      Log.e(TAG,"String_Node_Str");
      finish();
    }
  break;
case REQUEST_CODE_TEXT_SELECTION_ALTERNATIVE:
if (resultCode == RESULT_OK && data != null) {
  mApplyText=data.getStringExtra(NotepadIntents.EXTRA_TEXT);
  mApplyTextBefore=data.getStringExtra(NotepadIntents.EXTRA_TEXT_BEFORE_SELECTION);
  mApplyTextAfter=data.getStringExtra(NotepadIntents.EXTRA_TEXT_AFTER_SELECTION);
}
break;
case REQUEST_CODE_SAVE_AS:
if (resultCode == RESULT_OK && data != null) {
mUri=data.getData();
if (debug) Log.d(TAG,"String_Node_Str" + mOriginalContent + "String_Node_Str"+ mFileContent);
mOriginalContent=mFileContent;
updateTitleSdCard();
}
}
}
Program: 187790
Project: 187790
Buggy source:
@Override protected void onResume(){
  super.onResume();
  if (debug)   Log.d(TAG,"String_Node_Str");
  int autoLink=PreferenceActivity.getAutoLinkFromPreference(this);
  mText.setAutoLinkMask(autoLink);
  if (mState == STATE_EDIT || mState == STATE_INSERT) {
    getNoteFromContentProvider();
  }
 else   if (mState == STATE_EDIT_NOTE_FROM_SDCARD) {
    getNoteFromFile();
  }
  mText.setMovementMethod(new ArrowKeyMovementMethod(){
    public boolean onTouchEvent(    TextView widget,    Spannable buffer,    MotionEvent event){
      int action=event.getAction();
      if (action == MotionEvent.ACTION_UP) {
        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);
        ClickableSpan[] link=buffer.getSpans(off,off,ClickableSpan.class);
        if (link.length != 0) {
          link[0].onClick(widget);
          return true;
        }
      }
      return super.onTouchEvent(widget,buffer,event);
    }
  }
);
  setTheme(loadTheme());
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  if (debug)   Log.d(TAG,"String_Node_Str");
  int autoLink=PreferenceActivity.getAutoLinkFromPreference(this);
  mText.setAutoLinkMask(autoLink);
  mEncrypted=0;
  if (mState == STATE_EDIT || mState == STATE_INSERT) {
    getNoteFromContentProvider();
  }
 else   if (mState == STATE_EDIT_NOTE_FROM_SDCARD) {
    getNoteFromFile();
  }
  if (mEncrypted == 0 || mDecryptedText != null) {
    applyInsertText();
  }
  mText.setMovementMethod(new ArrowKeyMovementMethod(){
    public boolean onTouchEvent(    TextView widget,    Spannable buffer,    MotionEvent event){
      int action=event.getAction();
      if (action == MotionEvent.ACTION_UP) {
        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);
        ClickableSpan[] link=buffer.getSpans(off,off,ClickableSpan.class);
        if (link.length != 0) {
          link[0].onClick(widget);
          return true;
        }
      }
      return super.onTouchEvent(widget,buffer,event);
    }
  }
);
  setTheme(loadTheme());
}
Program: 187791
Project: 187791
Buggy source:
@Override protected void onSaveInstanceState(Bundle outState){
  if (debug)   Log.d(TAG,"String_Node_Str");
  if (debug)   Log.d(TAG,"String_Node_Str" + mFileContent);
  mSelectionStart=mText.getSelectionStart();
  mSelectionStop=mText.getSelectionEnd();
  mFileContent=mText.getText().toString();
  outState.putString(BUNDLE_ORIGINAL_CONTENT,mOriginalContent);
  outState.putInt(BUNDLE_STATE,mState);
  outState.putString(BUNDLE_URI,mUri.toString());
  outState.putInt(BUNDLE_SELECTION_START,mSelectionStart);
  outState.putInt(BUNDLE_SELECTION_STOP,mSelectionStop);
  outState.putString(BUNDLE_FILE_CONTENT,mFileContent);
}

Fixed version (ground truth):
@Override protected void onSaveInstanceState(Bundle outState){
  if (debug)   Log.d(TAG,"String_Node_Str");
  if (debug)   Log.d(TAG,"String_Node_Str" + mFileContent);
  mSelectionStart=mText.getSelectionStart();
  mSelectionStop=mText.getSelectionEnd();
  mFileContent=mText.getText().toString();
  outState.putString(BUNDLE_ORIGINAL_CONTENT,mOriginalContent);
  outState.putInt(BUNDLE_STATE,mState);
  outState.putString(BUNDLE_URI,mUri.toString());
  outState.putInt(BUNDLE_SELECTION_START,mSelectionStart);
  outState.putInt(BUNDLE_SELECTION_STOP,mSelectionStop);
  outState.putString(BUNDLE_FILE_CONTENT,mFileContent);
  outState.putString(BUNDLE_APPLY_TEXT,mApplyText);
  outState.putString(BUNDLE_APPLY_TEXT_BEFORE,mApplyTextBefore);
  outState.putString(BUNDLE_APPLY_TEXT_AFTER,mApplyTextAfter);
}
Program: 187792
Project: 187792
Buggy source:
private void onModeChanged(){
  Log.d(TAG,"String_Node_Str");
  fillItems();
  if (mMode == MODE_IN_SHOP) {
    setTitle(getString(R.string.shopping_title,getCurrentListName()));
    registerSensor();
  }
 else {
    setTitle(getString(R.string.pick_items_titel,getCurrentListName()));
    unregisterSensor();
  }
}

Fixed version (ground truth):
private void onModeChanged(){
  Log.d(TAG,"String_Node_Str");
  fillItems();
  if (mMode == MODE_IN_SHOP) {
    registerSensor();
  }
 else {
    unregisterSensor();
  }
}
Program: 187793
Project: 187793
Buggy source:
public NewListDialog(Context context,DialogActionListener listener){
  super(context);
  setDialogActionListener(listener);
}

Fixed version (ground truth):
public NewListDialog(Context context,DialogActionListener listener){
  super(context);
  setTitle(R.string.ask_new_list);
  setDialogActionListener(listener);
}
Program: 187794
Project: 187794
Buggy source:
protected void onActivityResult(int requestCode,int resultCode,Intent intent){
  Log.i(TAG,"String_Node_Str" + requestCode + "String_Node_Str"+ resultCode);
switch (requestCode) {
case REQUEST_CODE_DECRYPT_TITLE:
    if (resultCode == RESULT_OK && intent != null) {
      String decryptedText=intent.getStringExtra(CryptoIntents.EXTRA_TEXT);
      String encryptedText=intent.getStringExtra(PrivateNotePadIntents.EXTRA_ENCRYPTED_TEXT);
      if (encryptedText != null) {
        NotesListCursor.mEncryptedStringHashMap.put(encryptedText,decryptedText);
        Log.i(TAG,"String_Node_Str" + encryptedText + "String_Node_Str"+ decryptedText);
      }
      mDecryptionSucceeded=true;
      NotesListCursor.mLoggedIn=true;
      decryptDelayed();
    }
 else {
      mDecryptionFailed=true;
      setProgressBarIndeterminateVisibility(false);
    }
  break;
case REQUEST_CODE_OPEN:
if (resultCode == RESULT_OK && intent != null) {
  File filename=FileUriUtils.getFile(intent.getData());
  if (filename.exists() && !filename.isDirectory()) {
    Intent i=new Intent(this,NoteEditor.class);
    i.setAction(Intent.ACTION_VIEW);
    i.setData(intent.getData());
    startActivity(i);
  }
 else {
    Toast.makeText(this,R.string.file_not_found,Toast.LENGTH_SHORT).show();
  }
}
break;
}
}

Fixed version (ground truth):
protected void onActivityResult(int requestCode,int resultCode,Intent intent){
  if (debug)   Log.i(TAG,"String_Node_Str" + requestCode + "String_Node_Str"+ resultCode);
switch (requestCode) {
case REQUEST_CODE_DECRYPT_TITLE:
    if (resultCode == RESULT_OK && intent != null) {
      String decryptedText=intent.getStringExtra(CryptoIntents.EXTRA_TEXT);
      String encryptedText=intent.getStringExtra(PrivateNotePadIntents.EXTRA_ENCRYPTED_TEXT);
      if (encryptedText != null) {
        NotesListCursor.mEncryptedStringHashMap.put(encryptedText,decryptedText);
        if (debug)         Log.i(TAG,"String_Node_Str" + encryptedText + "String_Node_Str"+ decryptedText);
      }
      mDecryptionSucceeded=true;
      NotesListCursor.mLoggedIn=true;
      decryptDelayed();
    }
 else {
      mDecryptionFailed=true;
      setProgressBarIndeterminateVisibility(false);
    }
  break;
case REQUEST_CODE_OPEN:
if (resultCode == RESULT_OK && intent != null) {
  File filename=FileUriUtils.getFile(intent.getData());
  if (filename.exists() && !filename.isDirectory()) {
    Intent i=new Intent(this,NoteEditor.class);
    i.setAction(Intent.ACTION_VIEW);
    i.setData(intent.getData());
    startActivity(i);
  }
 else {
    Toast.makeText(this,R.string.file_not_found,Toast.LENGTH_SHORT).show();
  }
}
break;
}
}
Program: 187795
Project: 187795
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (!EulaActivity.checkEula(this)) {
    return;
  }
  setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
  Intent intent=getIntent();
  if (intent.getData() == null) {
    intent.setData(Notes.CONTENT_URI);
  }
  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  setContentView(R.layout.noteslist);
  getListView().setOnCreateContextMenuListener(this);
  getListView().setEmptyView(findViewById(R.id.empty));
  getListView().setTextFilterEnabled(true);
  getListView().setOnScrollListener(this);
  mLastFilter=null;
  if (savedInstanceState != null) {
    mLastFilter=savedInstanceState.getString(BUNDLE_LAST_FILTER);
  }
  mCursorUtils=new NotesListCursor(this,getIntent());
  if (Intent.ACTION_CREATE_SHORTCUT.equals(intent.getAction())) {
    setTitle(R.string.title_pick_note_for_shortcut);
  }
  mDecryptionFailed=false;
  mDecryptionSucceeded=false;
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (debug)   Log.d(TAG,"String_Node_Str" + (savedInstanceState == null ? "String_Node_Str" : "String_Node_Str"));
  if (!EulaActivity.checkEula(this)) {
    return;
  }
  setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
  Intent intent=getIntent();
  if (intent.getData() == null) {
    intent.setData(Notes.CONTENT_URI);
  }
  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  setContentView(R.layout.noteslist);
  getListView().setOnCreateContextMenuListener(this);
  getListView().setEmptyView(findViewById(R.id.empty));
  getListView().setTextFilterEnabled(true);
  getListView().setOnScrollListener(this);
  mLastFilter=null;
  if (savedInstanceState != null) {
    mLastFilter=savedInstanceState.getString(BUNDLE_LAST_FILTER);
    if (savedInstanceState.containsKey(BUNDLE_CONTEXTMENUINFO_ID)) {
      long id=savedInstanceState.getLong(BUNDLE_CONTEXTMENUINFO_ID);
      int position=savedInstanceState.getInt(BUNDLE_CONTEXTMENUINFO_POSITION);
      mContextMenuInfo=new AdapterView.AdapterContextMenuInfo(null,position,id);
    }
  }
  mCursorUtils=new NotesListCursor(this,getIntent());
  checkAdapter();
  if (Intent.ACTION_CREATE_SHORTCUT.equals(intent.getAction())) {
    setTitle(R.string.title_pick_note_for_shortcut);
  }
  mDecryptionFailed=false;
  mDecryptionSucceeded=false;
}
Program: 187796
Project: 187796
Buggy source:
private void saveFile(Uri uri,File file){
  Log.i(TAG,"String_Node_Str" + uri + "String_Node_Str"+ file);
  Cursor c=getContentResolver().query(uri,new String[]{Notes.ENCRYPTED,Notes.NOTE},null,null,null);
  if (c != null && c.getCount() > 0) {
    c.moveToFirst();
    long encrypted=c.getLong(0);
    String note=c.getString(1);
    if (encrypted == 0) {
      Log.d(TAG,"String_Node_Str");
      writeToFile(file,note);
    }
 else {
      Log.d(TAG,"String_Node_Str");
    }
  }
 else {
    Log.e(TAG,"String_Node_Str" + uri);
  }
}

Fixed version (ground truth):
private void saveFile(Uri uri,File file){
  if (debug)   Log.i(TAG,"String_Node_Str" + uri + "String_Node_Str"+ file);
  Cursor c=getContentResolver().query(uri,new String[]{Notes.ENCRYPTED,Notes.NOTE},null,null,null);
  if (c != null && c.getCount() > 0) {
    c.moveToFirst();
    long encrypted=c.getLong(0);
    String note=c.getString(1);
    if (encrypted == 0) {
      if (debug)       Log.d(TAG,"String_Node_Str");
      writeToFile(file,note);
    }
 else {
      if (debug)       Log.d(TAG,"String_Node_Str");
    }
  }
 else {
    Log.e(TAG,"String_Node_Str" + uri);
  }
}
Program: 187797
Project: 187797
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  Log.i(TAG,"String_Node_Str");
  NotesListCursor.flushDecryptedStringHashMap();
  mAdapter.getCursor().requery();
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  if (debug)   Log.i(TAG,"String_Node_Str");
  NotesListCursor.flushDecryptedStringHashMap();
  mAdapter.getCursor().requery();
}
Program: 187798
Project: 187798
Buggy source:
@Override protected void onResume(){
  super.onResume();
  NotesListCursor.mSuspendQueries=false;
  if (mAdapter == null) {
    Cursor cursor=mCursorUtils.query(null);
    mAdapter=new NotesListCursorAdapter(this,cursor,mCursorUtils);
    setListAdapter(mAdapter);
    Log.i(TAG,"String_Node_Str" + mLastFilter);
    if (mLastFilter != null) {
      cursor=mAdapter.runQueryOnBackgroundThread(mLastFilter);
      mAdapter.changeCursor(cursor);
    }
  }
 else {
    mAdapter.getCursor().requery();
  }
  if (!mDecryptionFailed) {
    decryptDelayed();
  }
 else {
    mDecryptionFailed=false;
  }
  if (mDecryptionSucceeded) {
    NotesListCursor.mLoggedIn=true;
  }
  IntentFilter filter=new IntentFilter();
  filter.addAction(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
  registerReceiver(mBroadcastReceiver,filter);
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  if (debug)   Log.d(TAG,"String_Node_Str");
  NotesListCursor.mSuspendQueries=false;
  checkAdapter();
  if (!mDecryptionFailed) {
    decryptDelayed();
  }
 else {
    mDecryptionFailed=false;
  }
  if (mDecryptionSucceeded) {
    NotesListCursor.mLoggedIn=true;
  }
  IntentFilter filter=new IntentFilter();
  filter.addAction(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
  registerReceiver(mBroadcastReceiver,filter);
}
Program: 187799
Project: 187799
Buggy source:
@Override protected void onPrepareDialog(int id,Dialog dialog){
  FilenameDialog fd;
switch (id) {
case DIALOG_TAGS:
    TagsDialog d=(TagsDialog)dialog;
  Uri uri=ContentUris.withAppendedId(getIntent().getData(),mContextMenuInfo.id);
Cursor c=mAdapter.getCursor();
c.moveToPosition(mContextMenuInfo.position);
String tags=c.getString(NotesListCursor.COLUMN_INDEX_TAGS);
long encrypted=c.getLong(NotesListCursor.COLUMN_INDEX_ENCRYPTED);
d.setUri(uri);
d.setTags(tags);
d.setEncrypted(encrypted);
String[] taglist=getTaglist(c);
d.setTagList(taglist);
break;
case DIALOG_ABOUT:
break;
}
}

Fixed version (ground truth):
@Override protected void onPrepareDialog(int id,Dialog dialog){
  if (debug)   Log.d(TAG,"String_Node_Str");
switch (id) {
case DIALOG_TAGS:
    TagsDialog d=(TagsDialog)dialog;
  Uri uri=ContentUris.withAppendedId(getIntent().getData(),mContextMenuInfo.id);
Cursor c=mAdapter.getCursor();
c.moveToPosition(mContextMenuInfo.position);
String tags=c.getString(NotesListCursor.COLUMN_INDEX_TAGS);
long encrypted=c.getLong(NotesListCursor.COLUMN_INDEX_ENCRYPTED);
d.setUri(uri);
d.setTags(tags);
d.setEncrypted(encrypted);
String[] taglist=getTaglist(c);
d.setTagList(taglist);
break;
case DIALOG_ABOUT:
break;
}
}
Program: 187800
Project: 187800
Buggy source:
@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  outState.putString(BUNDLE_LAST_FILTER,mCursorUtils.mCurrentFilter);
}

Fixed version (ground truth):
@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  outState.putString(BUNDLE_LAST_FILTER,mCursorUtils.mCurrentFilter);
  if (mContextMenuInfo != null) {
    outState.putLong(BUNDLE_CONTEXTMENUINFO_ID,mContextMenuInfo.id);
    outState.putInt(BUNDLE_CONTEXTMENUINFO_POSITION,mContextMenuInfo.position);
  }
}
Program: 187801
Project: 187801
Buggy source:
private void sendNoteByEmail(long id){
  Uri noteUri=ContentUris.withAppendedId(getIntent().getData(),id);
  Cursor c=getContentResolver().query(noteUri,new String[]{NotePad.Notes.TITLE,NotePad.Notes.NOTE},null,null,PreferenceActivity.getSortOrderFromPrefs(this));
  String title="String_Node_Str";
  String content=getString(R.string.empty_note);
  if (c != null) {
    c.moveToFirst();
    title=c.getString(0);
    content=c.getString(1);
  }
  Log.i(TAG,"String_Node_Str" + title);
  Log.i(TAG,"String_Node_Str" + content);
  Intent i=new Intent();
  i.setAction(Intent.ACTION_SEND);
  i.setType("String_Node_Str");
  i.putExtra(Intent.EXTRA_SUBJECT,title);
  i.putExtra(Intent.EXTRA_TEXT,content);
  try {
    startActivity(i);
  }
 catch (  ActivityNotFoundException e) {
    Toast.makeText(this,R.string.email_not_available,Toast.LENGTH_SHORT).show();
    Log.e(TAG,"String_Node_Str");
  }
}

Fixed version (ground truth):
private void sendNoteByEmail(long id){
  Uri noteUri=ContentUris.withAppendedId(getIntent().getData(),id);
  Cursor c=getContentResolver().query(noteUri,new String[]{NotePad.Notes.TITLE,NotePad.Notes.NOTE},null,null,PreferenceActivity.getSortOrderFromPrefs(this));
  String title="String_Node_Str";
  String content=getString(R.string.empty_note);
  if (c != null) {
    c.moveToFirst();
    title=c.getString(0);
    content=c.getString(1);
  }
  if (debug)   Log.i(TAG,"String_Node_Str" + title);
  if (debug)   Log.i(TAG,"String_Node_Str" + content);
  Intent i=new Intent();
  i.setAction(Intent.ACTION_SEND);
  i.setType("String_Node_Str");
  i.putExtra(Intent.EXTRA_SUBJECT,title);
  i.putExtra(Intent.EXTRA_TEXT,content);
  try {
    startActivity(i);
  }
 catch (  ActivityNotFoundException e) {
    Toast.makeText(this,R.string.email_not_available,Toast.LENGTH_SHORT).show();
    Log.e(TAG,"String_Node_Str");
  }
}
Program: 187802
Project: 187802
Buggy source:
@Override public boolean onCreateOptionsMenu(Menu menu){
  super.onCreateOptionsMenu(menu);
  menu.add(0,MENU_ITEM_INSERT,0,R.string.menu_insert).setShortcut('3','a').setIcon(android.R.drawable.ic_menu_add);
  menu.add(0,MENU_OPEN,0,R.string.menu_open_from_sdcard).setShortcut('4','o').setIcon(R.drawable.ic_menu_folder);
  UpdateMenu.addUpdateMenu(this,menu,0,MENU_UPDATE,0,R.string.update);
  menu.add(0,MENU_SETTINGS,0,R.string.settings).setIcon(android.R.drawable.ic_menu_preferences).setShortcut('9','s');
  menu.add(0,MENU_ABOUT,0,R.string.about).setIcon(android.R.drawable.ic_menu_info_details).setShortcut('0','a');
  Intent intent=new Intent(null,getIntent().getData());
  Log.i(TAG,"String_Node_Str" + intent.getDataString());
  intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
  MenuIntentOptionsWithIcons menu2=new MenuIntentOptionsWithIcons(this,menu);
  menu2.addIntentOptions(CATEGORY_ALTERNATIVE_GLOBAL,0,0,new ComponentName(this,NotesList.class),null,intent,0,null);
  return true;
}

Fixed version (ground truth):
@Override public boolean onCreateOptionsMenu(Menu menu){
  super.onCreateOptionsMenu(menu);
  menu.add(0,MENU_ITEM_INSERT,0,R.string.menu_insert).setShortcut('3','a').setIcon(android.R.drawable.ic_menu_add);
  menu.add(0,MENU_OPEN,0,R.string.menu_open_from_sdcard).setShortcut('4','o').setIcon(R.drawable.ic_menu_folder);
  UpdateMenu.addUpdateMenu(this,menu,0,MENU_UPDATE,0,R.string.update);
  menu.add(0,MENU_SETTINGS,0,R.string.settings).setIcon(android.R.drawable.ic_menu_preferences).setShortcut('9','s');
  menu.add(0,MENU_ABOUT,0,R.string.about).setIcon(android.R.drawable.ic_menu_info_details).setShortcut('0','a');
  Intent intent=new Intent(null,getIntent().getData());
  if (debug)   Log.i(TAG,"String_Node_Str" + intent.getDataString());
  intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
  MenuIntentOptionsWithIcons menu2=new MenuIntentOptionsWithIcons(this,menu);
  menu2.addIntentOptions(CATEGORY_ALTERNATIVE_GLOBAL,0,0,new ComponentName(this,NotesList.class),null,intent,0,null);
  return true;
}
Program: 187803
Project: 187803
Buggy source:
@Override public void onDestroy(){
  super.onDestroy();
  unregisterReceiver(mIntentReceiver);
  if (debug)   Log.d(TAG,"String_Node_Str");
}

Fixed version (ground truth):
@Override public void onDestroy(){
  super.onDestroy();
  if (mIntentReceiver != null) {
    unregisterReceiver(mIntentReceiver);
    mIntentReceiver=null;
  }
  if (debug)   Log.d(TAG,"String_Node_Str");
}
Program: 187804
Project: 187804
Buggy source:
@Override public void onRestoreInstanceState(Bundle savedInstanceState){
  super.onRestoreInstanceState(savedInstanceState);
  mUri=Uri.parse(savedInstanceState.getString(BUNDLE_URI));
  mEncrypted=savedInstanceState.getLong(BUNDLE_ENCRYPTED);
  mTagList=savedInstanceState.getStringArray(BUNDLE_TAGLIST);
}

Fixed version (ground truth):
@Override public void onRestoreInstanceState(Bundle savedInstanceState){
  super.onRestoreInstanceState(savedInstanceState);
  mUri=Uri.parse(savedInstanceState.getString(BUNDLE_URI));
  mEncrypted=savedInstanceState.getLong(BUNDLE_ENCRYPTED);
  mTagList=savedInstanceState.getStringArray(BUNDLE_TAGLIST);
  setTagList(mTagList);
}
Program: 187805
Project: 187805
Buggy source:
/** 
 * Modifies an activity to pass along the currently selected text.
 * @param intent
 */
private void startTextSelectionActivity(Intent intent){
  Intent newIntent=new Intent(intent);
  String text=mText.getText().toString();
  int start=mText.getSelectionStart();
  int end=mText.getSelectionEnd();
  newIntent.putExtra(NotepadIntents.EXTRA_TEXT,text.substring(start,end));
  newIntent.putExtra(NotepadIntents.EXTRA_TEXT_BEFORE_SELECTION,text.substring(0,start));
  newIntent.putExtra(NotepadIntents.EXTRA_TEXT_AFTER_SELECTION,text.substring(end));
  startActivityForResult(newIntent,REQUEST_CODE_TEXT_SELECTION_ALTERNATIVE);
}

Fixed version (ground truth):
/** 
 * Modifies an activity to pass along the currently selected text.
 * @param intent
 */
private void startTextSelectionActivity(Intent intent){
  Intent newIntent=new Intent(intent);
  String text=mText.getText().toString();
  int start=mText.getSelectionStart();
  int end=mText.getSelectionEnd();
  if (end < start) {
    int swap=end;
    end=start;
    start=swap;
  }
  newIntent.putExtra(NotepadIntents.EXTRA_TEXT,text.substring(start,end));
  newIntent.putExtra(NotepadIntents.EXTRA_TEXT_BEFORE_SELECTION,text.substring(0,start));
  newIntent.putExtra(NotepadIntents.EXTRA_TEXT_AFTER_SELECTION,text.substring(end));
  startActivityForResult(newIntent,REQUEST_CODE_TEXT_SELECTION_ALTERNATIVE);
}
Program: 187806
Project: 187806
Buggy source:
protected void onActivityResult(int requestCode,int resultCode,Intent data){
  Log.i(TAG,"String_Node_Str" + requestCode + "String_Node_Str"+ resultCode);
switch (requestCode) {
case REQUEST_CODE_DECRYPT:
    if (resultCode == RESULT_OK && data != null) {
      String decryptedText=data.getStringExtra(CryptoIntents.EXTRA_TEXT);
      long id=data.getLongExtra(PrivateNotePadIntents.EXTRA_ID,-1);
      if (id == -1) {
        Log.i(TAG,"String_Node_Str");
        Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
        finish();
        return;
      }
      mDecryptedText=decryptedText;
    }
 else {
      Toast.makeText(this,R.string.decryption_failed,Toast.LENGTH_SHORT).show();
      Log.e(TAG,"String_Node_Str");
      finish();
    }
  break;
case REQUEST_CODE_TEXT_SELECTION_ALTERNATIVE:
if (resultCode == RESULT_OK && data != null) {
  String text=data.getStringExtra(NotepadIntents.EXTRA_TEXT);
  String textBefore=data.getStringExtra(NotepadIntents.EXTRA_TEXT_BEFORE_SELECTION);
  String textAfter=data.getStringExtra(NotepadIntents.EXTRA_TEXT_AFTER_SELECTION);
  insertAtPoint(textBefore,text,textAfter);
}
break;
case REQUEST_CODE_SAVE_AS:
if (resultCode == RESULT_OK && data != null) {
mUri=data.getData();
mOriginalContent=mFileContent;
updateTitleSdCard();
}
}
}

Fixed version (ground truth):
protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (debug)   Log.i(TAG,"String_Node_Str" + requestCode + "String_Node_Str"+ resultCode);
switch (requestCode) {
case REQUEST_CODE_DECRYPT:
    if (resultCode == RESULT_OK && data != null) {
      String decryptedText=data.getStringExtra(CryptoIntents.EXTRA_TEXT);
      long id=data.getLongExtra(PrivateNotePadIntents.EXTRA_ID,-1);
      if (id == -1) {
        Log.i(TAG,"String_Node_Str");
        Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
        finish();
        return;
      }
      mDecryptedText=decryptedText;
    }
 else {
      Toast.makeText(this,R.string.decryption_failed,Toast.LENGTH_SHORT).show();
      Log.e(TAG,"String_Node_Str");
      finish();
    }
  break;
case REQUEST_CODE_TEXT_SELECTION_ALTERNATIVE:
if (resultCode == RESULT_OK && data != null) {
  String text=data.getStringExtra(NotepadIntents.EXTRA_TEXT);
  String textBefore=data.getStringExtra(NotepadIntents.EXTRA_TEXT_BEFORE_SELECTION);
  String textAfter=data.getStringExtra(NotepadIntents.EXTRA_TEXT_AFTER_SELECTION);
  insertAtPoint(textBefore,text,textAfter);
}
break;
case REQUEST_CODE_SAVE_AS:
if (resultCode == RESULT_OK && data != null) {
mUri=data.getData();
if (debug) Log.i(TAG,"String_Node_Str" + mOriginalContent + "String_Node_Str"+ mFileContent);
mOriginalContent=mFileContent;
updateTitleSdCard();
}
}
}
Program: 187807
Project: 187807
Buggy source:
private void getNoteFromFile(){
  mText.setTextKeepState(mFileContent);
  mText.setSelection(mSelectionStart,mSelectionStop);
  if (mOriginalContent == null) {
    mOriginalContent=mFileContent;
  }
  updateTitleSdCard();
}

Fixed version (ground truth):
private void getNoteFromFile(){
  if (debug)   Log.i(TAG,"String_Node_Str" + mFileContent);
  mText.setTextKeepState(mFileContent);
  try {
    mText.setSelection(mSelectionStart,mSelectionStop);
  }
 catch (  IndexOutOfBoundsException e) {
  }
  if (mOriginalContent == null) {
    mOriginalContent=mFileContent;
  }
  updateTitleSdCard();
}
Program: 187808
Project: 187808
Buggy source:
private void updateTitleSdCard(){
  mFileContent=mText.getText().toString();
  String modified="String_Node_Str";
  if (!mOriginalContent.equals(mFileContent)) {
    modified="String_Node_Str";
  }
  String filename=FileUriUtils.getFilename(mUri);
  setTitle(modified + filename);
}

Fixed version (ground truth):
private void updateTitleSdCard(){
  String modified="String_Node_Str";
  if (!mOriginalContent.equals(mFileContent)) {
    modified="String_Node_Str";
  }
  String filename=FileUriUtils.getFilename(mUri);
  setTitle(modified + filename);
}
Program: 187810
Project: 187810
Buggy source:
@Override public void afterTextChanged(Editable s){
  Log.i(TAG,"String_Node_Str");
  updateTitleSdCard();
}

Fixed version (ground truth):
@Override public void afterTextChanged(Editable s){
  Log.i(TAG,"String_Node_Str");
  mFileContent=s.toString();
  updateTitleSdCard();
}