🐛 Fix connectivity issues
This commit is contained in:
parent
c6e29c056b
commit
a01f116065
@ -179,6 +179,8 @@ class MainActivity : AppCompatActivity(), ListSelectionListener<Serializable> {
|
||||
.setDelay(1000)
|
||||
.show()
|
||||
}
|
||||
|
||||
SyncAdapter.startSync(this)
|
||||
}
|
||||
|
||||
private fun <F> changeList(listFragment: F) where F : Fragment, F : ListHolder<*> {
|
||||
|
@ -189,21 +189,10 @@ class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedP
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
when (key) {
|
||||
PREFERENCE_TRUSTED_NODE -> toggleSyncTrustedNode(sharedPreferences)
|
||||
PREFERENCE_SERVER_POW -> toggleSyncServerPOW(sharedPreferences)
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleSyncTrustedNode(sharedPreferences: SharedPreferences) {
|
||||
val node = sharedPreferences.getString(PREFERENCE_TRUSTED_NODE, null)
|
||||
val ctx = context ?: throw IllegalStateException("No context available")
|
||||
if (node != null) {
|
||||
SyncAdapter.startSync(ctx)
|
||||
} else {
|
||||
SyncAdapter.stopSync(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleSyncServerPOW(sharedPreferences: SharedPreferences) {
|
||||
val node = sharedPreferences.getString(PREFERENCE_TRUSTED_NODE, null)
|
||||
if (node != null) {
|
||||
|
@ -15,6 +15,7 @@ import ch.dissem.apps.abit.util.Preferences
|
||||
* And stops it when the preconditions for the job (unmetered network) aren't met anymore.
|
||||
*/
|
||||
class StartupNodeOnWifiService : JobService() {
|
||||
|
||||
override fun onStartJob(params: JobParameters?): Boolean {
|
||||
val bmc = Singleton.getBitmessageContext(this)
|
||||
if (Preferences.isFullNodeActive(this) && !bmc.isRunning()) {
|
||||
@ -28,4 +29,5 @@ class StartupNodeOnWifiService : JobService() {
|
||||
* depending on Android version.
|
||||
*/
|
||||
override fun onStopJob(params: JobParameters?) = Preferences.isFullNodeActive(this)
|
||||
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ class SyncAdapter(context: Context, autoInitialize: Boolean) : AbstractThreadedS
|
||||
}
|
||||
val trustedNode = Preferences.getTrustedNode(context)
|
||||
if (trustedNode == null) {
|
||||
// As Abit tends to get killed by the system, let's leverage the sync mechanism to start it again:
|
||||
NetworkUtils.scheduleNodeStart(context)
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user