Skip to content

Commit

Permalink
Add force sync button to toolbar if there is space
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomas2 committed Dec 28, 2024
1 parent 1608222 commit eb236d5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,9 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
}
prefOptions.openDialog(this@MainBibleActivity, onChanged = {apply()}, onReset = {apply()})
}
forceSyncButton.setOnClickListener {
syncScope.launch { synchronize(true) }
}

speakButton.setOnClickListener {
if(transportBarVisible) {
Expand Down Expand Up @@ -980,6 +983,7 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
val maxButtons: Int = (maxWidth / approximateSize).toInt()
val showSearch = documentControl.currentPage.currentPage.isSearchable
val showSpeak = documentControl.currentPage.currentPage.isSpeakable
val showForceSync = CommonUtils.isCloudSyncEnabled

fun shouldShowBibleButton(): Boolean =
toolbarButtonSetting?.let {
Expand Down Expand Up @@ -1059,7 +1063,13 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
View.VISIBLE
} else View.GONE
}

fun addForceSync() {
forceSyncButton.visibility = if (visibleButtonCount < maxButtons && showForceSync)
{
visibleButtonCount += 1
View.VISIBLE
} else View.GONE
}
val speakLastUsed = preferences.getLong("speak-last-used", 0)
val searchLastUsed = preferences.getLong("search-last-used", 0)

Expand All @@ -1083,6 +1093,8 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
View.VISIBLE
} else View.GONE

addForceSync()

if(!showSpeak && transportBarVisible && speakControl.isStopped) {
transportBarVisible = false
updateBottomBars()
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/main_bible_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@
android:contentDescription="@string/help_workspaces_title"
app:srcCompat="@drawable/ic_workspace_solid_24dp"
/>
<ImageButton
android:id="@+id/forceSyncButton"
style="@style/MyActionButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:contentDescription="@string/windowSynchronise"
app:srcCompat="@drawable/ic_syncdb_24dp" />
<ImageButton
android:id="@+id/optionsMenu"
style="@style/MyActionButton"
Expand Down

0 comments on commit eb236d5

Please sign in to comment.