From 3a98cc115a0916239729c21a005ec5dc68236843 Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Fri, 11 Aug 2017 17:24:36 +0200 Subject: [PATCH] Option to turn off acknowledgements --- .../ch/dissem/apps/abit/ComposeMessageFragment.java | 4 ++++ .../java/ch/dissem/apps/abit/util/Constants.java | 1 + .../java/ch/dissem/apps/abit/util/Preferences.kt | 12 ++++++++++++ app/src/main/res/xml/preferences.xml | 5 +++++ 4 files changed, 22 insertions(+) diff --git a/app/src/main/java/ch/dissem/apps/abit/ComposeMessageFragment.java b/app/src/main/java/ch/dissem/apps/abit/ComposeMessageFragment.java index aeea76c..7a57892 100644 --- a/app/src/main/java/ch/dissem/apps/abit/ComposeMessageFragment.java +++ b/app/src/main/java/ch/dissem/apps/abit/ComposeMessageFragment.java @@ -36,6 +36,7 @@ import java.util.List; import ch.dissem.apps.abit.adapter.ContactAdapter; import ch.dissem.apps.abit.dialog.SelectEncodingDialogFragment; import ch.dissem.apps.abit.service.Singleton; +import ch.dissem.apps.abit.util.Preferences; import ch.dissem.bitmessage.BitmessageContext; import ch.dissem.bitmessage.entity.BitmessageAddress; import ch.dissem.bitmessage.entity.Plaintext; @@ -227,6 +228,9 @@ public class ComposeMessageFragment extends Fragment { .from(identity) .to(recipient); } + if (!Preferences.requestAcknowledgements(getContext())){ + builder.preventAck(); + } switch (encoding) { case SIMPLE: builder.message( diff --git a/app/src/main/java/ch/dissem/apps/abit/util/Constants.java b/app/src/main/java/ch/dissem/apps/abit/util/Constants.java index 5180a4d..0ce5bd6 100644 --- a/app/src/main/java/ch/dissem/apps/abit/util/Constants.java +++ b/app/src/main/java/ch/dissem/apps/abit/util/Constants.java @@ -27,6 +27,7 @@ public class Constants { public static final String PREFERENCE_SYNC_TIMEOUT = "sync_timeout"; public static final String PREFERENCE_SERVER_POW = "server_pow"; public static final String PREFERENCE_FULL_NODE = "full_node"; + public static final String PREFERENCE_REQUEST_ACK = "request_acknowledgments"; public static final String PREFERENCE_POW_AVERAGE = "average_pow_time_ms"; public static final String PREFERENCE_POW_COUNT = "pow_count"; diff --git a/app/src/main/java/ch/dissem/apps/abit/util/Preferences.kt b/app/src/main/java/ch/dissem/apps/abit/util/Preferences.kt index a37a79e..cb93e6b 100644 --- a/app/src/main/java/ch/dissem/apps/abit/util/Preferences.kt +++ b/app/src/main/java/ch/dissem/apps/abit/util/Preferences.kt @@ -122,6 +122,18 @@ object Preferences { return File(ctx.filesDir, "exports") } + @JvmStatic + fun requestAcknowledgements(ctx: Context): Boolean { + val preferences = PreferenceManager.getDefaultSharedPreferences(ctx) + return preferences.getBoolean(PREFERENCE_REQUEST_ACK, true) + } + + @JvmStatic + fun setRequestAcknowledgements(ctx: Context, status: Boolean) { + val preferences = PreferenceManager.getDefaultSharedPreferences(ctx) + preferences.edit().putBoolean(PREFERENCE_REQUEST_ACK, status).apply() + } + @JvmStatic fun cleanupExportDirectory(ctx: Context) { val exportDirectory = getExportDirectory(ctx) diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index c86a5fa..8c56a4c 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -5,6 +5,11 @@ android:key="wifi_only" android:summary="@string/wifi_only_summary" android:title="@string/wifi_only"/> +