Option to turn off acknowledgements

This commit is contained in:
Christian Basler 2017-08-11 17:24:36 +02:00
parent e2aa0e8b1d
commit 3a98cc115a
4 changed files with 22 additions and 0 deletions

View File

@ -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(

View File

@ -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";

View File

@ -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)

View File

@ -5,6 +5,11 @@
android:key="wifi_only"
android:summary="@string/wifi_only_summary"
android:title="@string/wifi_only"/>
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="request_acknowledgements"
android:summary="@string/request_acknowledgements_summary"
android:title="@string/request_acknowledgements"/>
<EditTextPreference
android:inputType="textUri"
android:key="trusted_node"