diff --git a/app/src/main/java/ch/dissem/apps/abit/dialog/FullNodeDialogActivity.kt b/app/src/main/java/ch/dissem/apps/abit/dialog/FullNodeDialogActivity.kt index 9f86455..6aed933 100644 --- a/app/src/main/java/ch/dissem/apps/abit/dialog/FullNodeDialogActivity.kt +++ b/app/src/main/java/ch/dissem/apps/abit/dialog/FullNodeDialogActivity.kt @@ -32,7 +32,7 @@ class FullNodeDialogActivity : Activity() { setContentView(R.layout.dialog_full_node) ok.setOnClickListener { preferences.wifiOnly = false - network.enableNode() + network.scheduleNodeStart() finish() } dismiss.setOnClickListener { diff --git a/app/src/main/java/ch/dissem/apps/abit/drawer/ProfileSelectionListener.kt b/app/src/main/java/ch/dissem/apps/abit/drawer/ProfileSelectionListener.kt index eb1bff4..00626f5 100644 --- a/app/src/main/java/ch/dissem/apps/abit/drawer/ProfileSelectionListener.kt +++ b/app/src/main/java/ch/dissem/apps/abit/drawer/ProfileSelectionListener.kt @@ -5,20 +5,14 @@ import android.content.Intent import android.support.v4.app.FragmentManager import android.view.View import android.widget.Toast - -import com.mikepenz.materialdrawer.AccountHeader -import com.mikepenz.materialdrawer.model.ProfileDrawerItem -import com.mikepenz.materialdrawer.model.interfaces.IProfile - -import ch.dissem.apps.abit.AddressDetailActivity -import ch.dissem.apps.abit.AddressDetailFragment -import ch.dissem.apps.abit.MainActivity -import ch.dissem.apps.abit.R +import android.widget.Toast.LENGTH_LONG +import ch.dissem.apps.abit.* import ch.dissem.apps.abit.dialog.AddIdentityDialogFragment import ch.dissem.apps.abit.service.Singleton import ch.dissem.bitmessage.entity.BitmessageAddress - -import android.widget.Toast.LENGTH_LONG +import com.mikepenz.materialdrawer.AccountHeader +import com.mikepenz.materialdrawer.model.ProfileDrawerItem +import com.mikepenz.materialdrawer.model.interfaces.IProfile class ProfileSelectionListener( private val ctx: Context, diff --git a/app/src/main/java/ch/dissem/apps/abit/service/NodeStartupService.kt b/app/src/main/java/ch/dissem/apps/abit/service/NodeStartupService.kt index 9a2b8e2..5432d28 100644 --- a/app/src/main/java/ch/dissem/apps/abit/service/NodeStartupService.kt +++ b/app/src/main/java/ch/dissem/apps/abit/service/NodeStartupService.kt @@ -34,6 +34,11 @@ class NodeStartupService : JobService() { } } + override fun onCreate() { + super.onCreate() + notification = NetworkNotification(this) + } + override fun onStartJob(params: JobParameters?): Boolean { if (preferences.online) { registerReceiver( @@ -43,7 +48,6 @@ class NodeStartupService : JobService() { addAction(Intent.ACTION_BATTERY_CHANGED) } ) - notification = NetworkNotification(this) NodeStartupService.running = false if (!isRunning) { @@ -67,7 +71,12 @@ class NodeStartupService : JobService() { doAsync { bmc.cleanup() } - unregisterReceiver(connectivityReceiver) + try { + unregisterReceiver(connectivityReceiver) + } catch (_: IllegalArgumentException) { + // For some reason, onStartJob wasn't called so the receiver isn't registered. + // Let's just ignore this. + } stopSelf() } diff --git a/app/src/main/java/ch/dissem/apps/abit/service/Singleton.kt b/app/src/main/java/ch/dissem/apps/abit/service/Singleton.kt index a9d044b..d08bf58 100644 --- a/app/src/main/java/ch/dissem/apps/abit/service/Singleton.kt +++ b/app/src/main/java/ch/dissem/apps/abit/service/Singleton.kt @@ -24,6 +24,7 @@ import ch.dissem.apps.abit.adapter.SwipeableMessageAdapter import ch.dissem.apps.abit.listener.MessageListener import ch.dissem.apps.abit.repository.* import ch.dissem.apps.abit.util.Observable +import ch.dissem.apps.abit.util.preferences import ch.dissem.bitmessage.BitmessageContext import ch.dissem.bitmessage.cryptography.sc.SpongyCryptography import ch.dissem.bitmessage.entity.BitmessageAddress