diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 81d0586..e8ed1be 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -11,8 +11,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -182,7 +146,12 @@
+
+
diff --git a/app/src/main/java/ch/dissem/apps/abit/ComposeMessageFragment.kt b/app/src/main/java/ch/dissem/apps/abit/ComposeMessageFragment.kt
index 10cb977..bca4f5f 100644
--- a/app/src/main/java/ch/dissem/apps/abit/ComposeMessageFragment.kt
+++ b/app/src/main/java/ch/dissem/apps/abit/ComposeMessageFragment.kt
@@ -35,7 +35,7 @@ import ch.dissem.apps.abit.ComposeMessageActivity.Companion.EXTRA_SUBJECT
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.apps.abit.util.preferences
import ch.dissem.bitmessage.entity.BitmessageAddress
import ch.dissem.bitmessage.entity.Plaintext
import ch.dissem.bitmessage.entity.Plaintext.Type.BROADCAST
@@ -76,7 +76,7 @@ class ComposeMessageFragment : Fragment() {
parents.addAll(draft.parents)
} else {
var id = getSerializable(EXTRA_IDENTITY) as? BitmessageAddress
- if (context != null && (id == null || id.privateKey == null)) {
+ if (context != null && id?.privateKey == null) {
id = Singleton.getIdentity(context!!)
}
if (id?.privateKey != null) {
@@ -94,8 +94,7 @@ class ComposeMessageFragment : Fragment() {
if (containsKey(EXTRA_CONTENT)) {
content = getString(EXTRA_CONTENT)
}
- encoding = getSerializable(EXTRA_ENCODING) as? Plaintext.Encoding ?:
- Plaintext.Encoding.SIMPLE
+ encoding = getSerializable(EXTRA_ENCODING) as? Plaintext.Encoding ?: Plaintext.Encoding.SIMPLE
if (containsKey(EXTRA_PARENT)) {
val parent = getSerializable(EXTRA_PARENT) as Plaintext
@@ -221,7 +220,7 @@ class ComposeMessageFragment : Fragment() {
}
val sender = sender_input.selectedItem as? ch.dissem.bitmessage.entity.BitmessageAddress
sender?.let { builder.from(it) }
- if (!Preferences.requestAcknowledgements(ctx)) {
+ if (!ctx.preferences.requestAcknowledgements) {
builder.preventAck()
}
when (encoding) {
diff --git a/app/src/main/java/ch/dissem/apps/abit/MainActivity.kt b/app/src/main/java/ch/dissem/apps/abit/MainActivity.kt
index ade79e1..516e7bb 100644
--- a/app/src/main/java/ch/dissem/apps/abit/MainActivity.kt
+++ b/app/src/main/java/ch/dissem/apps/abit/MainActivity.kt
@@ -31,11 +31,7 @@ import ch.dissem.apps.abit.listener.ListSelectionListener
import ch.dissem.apps.abit.repository.AndroidLabelRepository.Companion.LABEL_ARCHIVE
import ch.dissem.apps.abit.service.Singleton
import ch.dissem.apps.abit.service.Singleton.currentLabel
-import ch.dissem.apps.abit.synchronization.SyncAdapter
-import ch.dissem.apps.abit.util.NetworkUtils
-import ch.dissem.apps.abit.util.Preferences
-import ch.dissem.apps.abit.util.getColor
-import ch.dissem.apps.abit.util.getIcon
+import ch.dissem.apps.abit.util.*
import ch.dissem.bitmessage.BitmessageContext
import ch.dissem.bitmessage.entity.BitmessageAddress
import ch.dissem.bitmessage.entity.Conversation
@@ -145,11 +141,6 @@ class MainActivity : AppCompatActivity(), ListSelectionListener {
ComposeMessageActivity.launchReplyTo(this, item)
}
- if (Preferences.useTrustedNode(this)) {
- SyncAdapter.startSync(this)
- } else {
- SyncAdapter.stopSync(this)
- }
if (drawer.isDrawerOpen) {
MaterialShowcaseView.Builder(this)
.setMaskColour(R.color.colorPrimary)
@@ -179,8 +170,6 @@ class MainActivity : AppCompatActivity(), ListSelectionListener {
.setDelay(1000)
.show()
}
-
- SyncAdapter.startSync(this)
}
private fun changeList(listFragment: F) where F : Fragment, F : ListHolder<*> {
@@ -259,14 +248,13 @@ class MainActivity : AppCompatActivity(), ListSelectionListener {
nodeSwitch = SwitchDrawerItem()
.withIdentifier(ID_NODE_SWITCH)
- .withName(R.string.full_node)
+ .withName(R.string.online)
.withIcon(CommunityMaterial.Icon.cmd_cloud_outline)
- .withChecked(Preferences.isFullNodeActive(this))
+ .withChecked(preferences.online)
.withOnCheckedChangeListener { _, _, isChecked ->
+ preferences.online = isChecked
if (isChecked) {
- NetworkUtils.enableNode(this@MainActivity)
- } else {
- NetworkUtils.disableNode(this@MainActivity)
+ network.enableNode(true)
}
}
@@ -369,10 +357,8 @@ class MainActivity : AppCompatActivity(), ListSelectionListener {
}
override fun onResume() {
+ network.enableNode(false)
updateUnread()
- if (Preferences.isFullNodeActive(this) && Preferences.isConnectionAllowed(this@MainActivity)) {
- NetworkUtils.enableNode(this, false)
- }
Singleton.getMessageListener(this).resetNotification()
currentLabel.addObserver(this) { label ->
if (label != null && label.id is Long) {
@@ -578,15 +564,6 @@ class MainActivity : AppCompatActivity(), ListSelectionListener {
private var instance: WeakReference? = null
- fun updateNodeSwitch() {
- apply {
- runOnUiThread {
- nodeSwitch.withChecked(Preferences.isFullNodeActive(this))
- drawer.updateStickyFooterItem(nodeSwitch)
- }
- }
- }
-
/**
* Runs the given code in the main activity context, if it currently exists. Otherwise,
* it's ignored.
diff --git a/app/src/main/java/ch/dissem/apps/abit/MessageListFragment.kt b/app/src/main/java/ch/dissem/apps/abit/MessageListFragment.kt
index 6597810..dc0b30f 100644
--- a/app/src/main/java/ch/dissem/apps/abit/MessageListFragment.kt
+++ b/app/src/main/java/ch/dissem/apps/abit/MessageListFragment.kt
@@ -134,23 +134,27 @@ class MessageListFragment : Fragment(), ListHolder