Improve app Signature.

Instead of having to manually check the checkbox to get a preview, now
it checks whether it is checked at when required, only shows the
signature during preview, and adds it once you've sent the message
rather than putting it in the EditText field.
This commit is contained in:
Jedi Burrell 2017-05-10 04:24:29 -04:00
parent 2ab30aa924
commit b216f275d3
2 changed files with 19 additions and 16 deletions

View File

@ -83,7 +83,8 @@ public class EditorActivity extends BaseActivity<EditorMvp.View, EditorPresenter
if (editText.isEnabled() && !InputHelper.isEmpty(editText)) {
editText.setEnabled(false);
sentVia.setEnabled(false);
MarkDownProvider.setMdText(editText, InputHelper.toString(editText));
MarkDownProvider.setMdText(editText, InputHelper.toString(editText) +
(sentVia.isChecked() ? "\n\n_"+sentVia.getText().toString()+"_" : ""));
ViewHelper.hideKeyboard(editText);
AnimHelper.animateVisibility(editorIconsHolder, false);
} else {
@ -112,19 +113,6 @@ public class EditorActivity extends BaseActivity<EditorMvp.View, EditorPresenter
}
}
@OnCheckedChanged(R.id.sentVia) void onChecked(boolean isChecked) {
if (editText.isEnabled() && !InputHelper.isEmpty(editText)) {
if (isChecked) {
savedText = savedText + "\n> " + sentVia.getText();
editText.setText(savedText);
} else {
String text = InputHelper.toString(editText);
text = text.replace("\n> " + sentVia.getText().toString(), "");
editText.setText(text);
}
}
}
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sentVia.setChecked(PrefGetter.isSentViaEnabled());
@ -166,6 +154,9 @@ public class EditorActivity extends BaseActivity<EditorMvp.View, EditorPresenter
@Override public void onSendResultAndFinish(@NonNull Comment commentModel, boolean isNew) {
hideProgress();
Intent intent = new Intent();
if(sentVia.isChecked())
commentModel.setBodyHtml(commentModel.getBodyHtml()+"<br /><br /><i>"+sentVia.getText().toString()+"</i>");
commentModel.save(commentModel);
intent.putExtras(Bundler.start()
.put(BundleConstant.ITEM, commentModel)
.put(BundleConstant.EXTRA, isNew)
@ -176,7 +167,8 @@ public class EditorActivity extends BaseActivity<EditorMvp.View, EditorPresenter
@Override public void onSendMarkDownResult() {
Intent intent = new Intent();
intent.putExtras(Bundler.start().put(BundleConstant.EXTRA, savedText).end());
intent.putExtras(Bundler.start().put(BundleConstant.EXTRA, savedText +
(sentVia.isChecked() ? "\n\n_"+sentVia.getText().toString()+"_" : "")).end());
setResult(RESULT_OK, intent);
finish();
}
@ -189,7 +181,9 @@ public class EditorActivity extends BaseActivity<EditorMvp.View, EditorPresenter
@Override public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.submit) {
item.setEnabled(false);
getPresenter().onHandleSubmission(savedText, extraType, itemId, commentId, login, issueNumber, sha);
getPresenter().onHandleSubmission(savedText +
(sentVia.isChecked() ? "\n\n_" + sentVia.getText() + "_" : ""),
extraType, itemId, commentId, login, issueNumber, sha);
return true;
}
return super.onOptionsItemSelected(item);

View File

@ -222,11 +222,20 @@
android:src="@drawable/ic_eye"/>
</FrameLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dividerColor"/>
<com.fastaccess.ui.widgets.FontCheckbox
android:id="@+id/sentVia"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:background="?attr/selectableItemBackground"
android:button="@null"
android:layout_gravity="end"
android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
android:paddingStart="@dimen/spacing_xs_large"
android:paddingEnd="@dimen/spacing_xs_large"
android:paddingBottom="@dimen/spacing_normal"