Skip to content

Commit

Permalink
Hide sync feature from lollipop users
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomas2 committed Jun 22, 2023
1 parent c342060 commit 994669c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
6 changes: 5 additions & 1 deletion app/src/main/java/net/bible/android/BibleApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ open class BibleApplication : Application() {

val intent = Intent(this, ErrorActivity::class.java)
val pendingIntent = PendingIntent.getActivity(this, 0, intent, if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) PendingIntent.FLAG_IMMUTABLE else 0)
val action = NotificationCompat.Action.Builder(android.R.drawable.ic_dialog_alert, getString(R.string.report), pendingIntent).build()
val action = NotificationCompat.Action.Builder(
android.R.drawable.ic_dialog_alert,
getString(R.string.report),
pendingIntent
).build()

val builder = NotificationCompat.Builder(this, ERROR_NOTIFICATION_CHANNEL)
builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ class MainBibleActivity : CustomTitlebarActivityBase() {

updateToolbar()
updateBottomBars()

if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
binding.navigationView.menu.findItem(R.id.googleDriveSync).isVisible = false
}
binding.navigationView.setNavigationItemSelectedListener { menuItem ->
binding.drawerLayout.closeDrawers()
mainMenuCommandHandler.handleMenuRequest(menuItem)
Expand Down Expand Up @@ -1276,7 +1278,7 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
var syncJob: Job? = null

private suspend fun startSync(signIn: Boolean = true) {
if(CommonUtils.isGoogleDriveSyncEnabled) {
if(CommonUtils.isCloudSyncEnabled) {
if(signIn && !CloudSync.signedIn) {
CloudSync.signIn(this@MainBibleActivity)
}
Expand All @@ -1296,7 +1298,7 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
private suspend fun periodicSync() {
Log.i(TAG, "Periodic sync starting")
try {
while (CommonUtils.isGoogleDriveSyncEnabled && CloudSync.signedIn) {
while (CommonUtils.isCloudSyncEnabled && CloudSync.signedIn) {
delay(60*1000) // 1 minute
synchronize()
}
Expand All @@ -1317,7 +1319,7 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
private val now get() = System.currentTimeMillis()

private suspend fun synchronize(force: Boolean = false) {
if(CommonUtils.isGoogleDriveSyncEnabled && CloudSync.signedIn) {
if(CommonUtils.isCloudSyncEnabled && CloudSync.signedIn) {
windowRepository.saveIntoDb(false)
if (force || (now - max(lastSynchronized, lastTouched) > syncInterval && CloudSync.hasChanges())) {
Log.i(TAG, "Performing periodic sync")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class SyncSettingsFragment: PreferenceFragmentCompat() {
preferenceScreen.findPreference<SwitchPreferenceCompat>("gdrive_readingplans").run { setupDrivePref(this!!) }
preferenceScreen.findPreference<SwitchPreferenceCompat>("gdrive_workspaces").run { setupDrivePref(this!!) }
preferenceScreen.findPreference<Preference>("gdrive_reset_sync")!!.run {
if(!CommonUtils.isGoogleDriveSyncEnabled || !CloudSync.signedIn) {
if(!CommonUtils.isCloudSyncEnabled || !CloudSync.signedIn) {
isVisible = false
}
setOnPreferenceClickListener {
Expand All @@ -100,7 +100,7 @@ class SyncSettingsFragment: PreferenceFragmentCompat() {
}
}
preferenceScreen.findPreference<Preference>("gdrive_info")!!.run {
if(!CommonUtils.isGoogleDriveSyncEnabled || !CloudSync.signedIn) {
if(!CommonUtils.isCloudSyncEnabled || !CloudSync.signedIn) {
isVisible = false
} else {
lifecycleScope.launch {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/net/bible/service/common/CommonUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1376,11 +1376,11 @@ object CommonUtils : CommonUtilsBase() {
}
}

val isGoogleDriveSyncEnabled: Boolean get () =
if(BuildVariant.Appearance.isDiscrete)
val isCloudSyncEnabled: Boolean get () =
if(BuildVariant.Appearance.isDiscrete || Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1)
false
else
SyncableDatabaseDefinition.ALL.filter { it.enabled }.any()
SyncableDatabaseDefinition.ALL.any { it.enabled }
val isDiscrete get() = settings.getBoolean("discrete_mode", false) || BuildVariant.Appearance.isDiscrete
val showCalculator get() = settings.getBoolean("show_calculator", false) || BuildVariant.Appearance.isDiscrete

Expand Down

0 comments on commit 994669c

Please sign in to comment.