diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 81d0586..0f7bfcd 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,8 +11,6 @@ - - - - - - - - - - - - - - - - - - - @@ -182,7 +150,7 @@ 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..ff1b37b 100644 --- a/app/src/main/java/ch/dissem/apps/abit/ComposeMessageFragment.kt +++ b/app/src/main/java/ch/dissem/apps/abit/ComposeMessageFragment.kt @@ -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) { 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..646579e 100644 --- a/app/src/main/java/ch/dissem/apps/abit/MainActivity.kt +++ b/app/src/main/java/ch/dissem/apps/abit/MainActivity.kt @@ -31,7 +31,6 @@ 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 @@ -145,11 +144,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 +173,6 @@ class MainActivity : AppCompatActivity(), ListSelectionListener { .setDelay(1000) .show() } - - SyncAdapter.startSync(this) } private fun changeList(listFragment: F) where F : Fragment, F : ListHolder<*> { @@ -259,14 +251,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.isOnline(this)) .withOnCheckedChangeListener { _, _, isChecked -> + Preferences.setOnline(this, isChecked) if (isChecked) { - NetworkUtils.enableNode(this@MainActivity) - } else { - NetworkUtils.disableNode(this@MainActivity) + NetworkUtils.enableNode(this, true) } } @@ -369,10 +360,8 @@ class MainActivity : AppCompatActivity(), ListSelectionListener { } override fun onResume() { + NetworkUtils.enableNode(this, 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 +567,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