I'm trying to create a small strikethrough application for myself. The idea is simple: select the text, select the MStrike option in the floating menu that appears and then continue typing.
Except that after I press MStrike the still remains selected. Yet, while pressing other options (such as 'Copy') the text doesn't remain selected. I've tried searching Google, StackOverlow and Reddit but I didn't get any answer.
Here are some parts of my code if it's of any help:
public class MainActivity extends Activity {
public String editedText;
public boolean readOnly;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
if (intent.getAction() != null && intent.getAction().equals(Intent.ACTION_PROCESS_TEXT)){
String selectedText = intent.getStringExtra(Intent.EXTRA_PROCESS_TEXT);
readOnly = intent.getBooleanExtra(
Intent.EXTRA_PROCESS_TEXT_READONLY,
false);
//function to Strikethrough the text
editedText = editText(selectedText);
}
finish();
}
@Override
public void finish(){
if (readOnly){
ClipboardManager clipboardManager =
(ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText(
"StyleText",
editedText
);
clipboardManager.setPrimaryClip(clip);
}
else {
Intent back = new Intent();
back.putExtra(Intent.EXTRA_PROCESS_TEXT, editedText);
setResult(RESULT_OK, back);
}
super.finish();
}
}
p.s. I'm still a beginner so my code might be not well-written. I'm open to any suggestions you have.