diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java index 9b1bcede..b46d401a 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java @@ -1,7 +1,9 @@ package gr.thmmy.mthmmy.activities; import android.content.Intent; +import android.content.SharedPreferences; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.design.widget.TextInputLayout; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; @@ -11,8 +13,11 @@ import android.widget.TextView; import android.widget.Toast; import gr.thmmy.mthmmy.R; +import gr.thmmy.mthmmy.activities.settings.SettingsActivity; +import gr.thmmy.mthmmy.base.BaseActivity; import gr.thmmy.mthmmy.editorview.EditorView; import gr.thmmy.mthmmy.editorview.EmojiKeyboard; +import gr.thmmy.mthmmy.session.SessionManager; import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import timber.log.Timber; @@ -55,7 +60,14 @@ public class CreateContentActivity extends AppCompatActivity implements EmojiKey contentEditor.setEmojiKeyboardOwner(this); contentEditor.setOnSubmitListener(v -> { if (newTopicUrl != null) { - new NewTopicTask(this).execute(newTopicUrl, subjectInput.getEditText().getText().toString(), + boolean includeAppSignature = true; + SessionManager sessionManager = BaseActivity.getSessionManager(); + if (sessionManager.isLoggedIn()) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + includeAppSignature = prefs.getBoolean(SettingsActivity.POSTING_APP_SIGNATURE_ENABLE_KEY, true); + } + + new NewTopicTask(this, includeAppSignature).execute(newTopicUrl, subjectInput.getEditText().getText().toString(), contentEditor.getText().toString()); } }); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java index 322cac43..c8dc34d5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java @@ -20,9 +20,11 @@ import static gr.thmmy.mthmmy.activities.topic.Posting.replyStatus; public class NewTopicTask extends AsyncTask { private NewTopicTaskCallbacks listener; + private boolean includeAppSignature; - public NewTopicTask(NewTopicTaskCallbacks listener){ + public NewTopicTask(NewTopicTaskCallbacks listener, boolean includeAppSignature){ this.listener = listener; + this.includeAppSignature = includeAppSignature; } @Override @@ -49,9 +51,12 @@ public class NewTopicTask extends AsyncTask { topic = document.select("input[name=topic]").first().attr("value"); createTopicUrl = document.select("form").first().attr("action"); + final String appSignature = "\n[right][size=7pt][i]sent from [url=https://play.google.com/store/apps/" + + "details?id=gr.thmmy.mthmmy]mTHMMY[/url][/i][/size][/right]"; + RequestBody postBody = new MultipartBody.Builder() .setType(MultipartBody.FORM) - .addFormDataPart("message", strings[2]) + .addFormDataPart("message", strings[2] + (includeAppSignature ? appSignature : "")) .addFormDataPart("seqnum", seqnum) .addFormDataPart("sc", sc) .addFormDataPart("subject", strings[1]) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java index 63c2955b..033316d2 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java @@ -31,7 +31,7 @@ public class ReplyTask extends AsyncTask { @Override protected Boolean doInBackground(String... args) { final String sentFrommTHMMY = includeAppSignature - ? "\n[right][size=7pt][i]sent from [url=https://play.google.com/store/apps/details?id=gr.thmmy.mthmmy]mTHMMY[/url][/i] [/size][/right]" + ? "\n[right][size=7pt][i]sent from [url=https://play.google.com/store/apps/details?id=gr.thmmy.mthmmy]mTHMMY[/url][/i][/size][/right]" : ""; RequestBody postBody = new MultipartBody.Builder() .setType(MultipartBody.FORM)