Skip to content

Commit

Permalink
Automatic merge branch 'current-stable' into 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Auto CI committed Jan 11, 2025
2 parents a3794be + 842701e commit 9e96a1b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
android:versionCode="845"
android:versionName="5.0.845">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" android:minSdkVersion="24"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import android.content.pm.PackageManager
import android.content.res.Configuration
import android.graphics.Color
import android.media.AudioManager
import android.net.ConnectivityManager
import android.net.Network
import android.net.Uri
import android.os.Build
import android.os.Bundle
Expand Down Expand Up @@ -311,11 +313,21 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
}
initialized = true
}
syncScope.launch { startSync() }
if(intent.hasExtra("openLink")) {
val uri = Uri.parse(intent.getStringExtra("openLink"))
openLink(uri)
}
val connManager = getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
connManager.registerDefaultNetworkCallback(networkCallback)
}
}

var networkCallback = object: ConnectivityManager.NetworkCallback() {
override fun onAvailable(network: Network) {
super.onAvailable(network)
syncScope.launch { startSync() }
}
}

override fun fixNightMode() {} // handle this manually here
Expand Down Expand Up @@ -1396,7 +1408,6 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
windowRepository.saveIntoDb(false)
if (force || (now - max(lastSynchronized, lastTouched) > syncInterval && CloudSync.hasChanges())) {
Log.i(TAG, "Performing periodic sync")
CommonUtils.settings.setLong("globalLastSynchronized", now)
if(!CloudSync.signedIn) {
CloudSync.signIn(this@MainBibleActivity)
}
Expand All @@ -1406,6 +1417,12 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
}
}

fun onEvent(event: CloudSyncEvent) {
if (!event.running) {
CommonUtils.settings.setLong("globalLastSynchronized", now)
}
}

private fun stopPeriodicSync() {
syncJob?.cancel()
syncJob = null
Expand All @@ -1418,10 +1435,7 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
syncScope.launch { synchronize(true) }
} else {
updateActions()
syncScope.launch {
delay(5000) // Wait a little bit as wifi might be auto-turned on after returning from sleep
startSync()
}
syncScope.launch { startSync() }
}
}

Expand Down

0 comments on commit 9e96a1b

Please sign in to comment.