Skip to content

Commit

Permalink
fix sync tooltip text
Browse files Browse the repository at this point in the history
  • Loading branch information
RobozinhoD authored and david-allison committed May 5, 2024
1 parent 9a81b50 commit d983b81
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
18 changes: 10 additions & 8 deletions AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -995,14 +995,16 @@ open class DeckPicker :
}
menuItem.isVisible = true

menuItem.setTitle(
when (state.syncIcon) {
SyncIconState.Normal, SyncIconState.PendingChanges -> R.string.button_sync
SyncIconState.OneWay -> R.string.sync_menu_title_one_way_sync
SyncIconState.NotLoggedIn -> R.string.sync_menu_title_no_account
}
)
val provider = MenuItemCompat.getActionProvider(menuItem) as? SyncActionProvider ?: return
val provider = MenuItemCompat.getActionProvider(menuItem) as? SyncActionProvider
?: return
val tooltipText = when (state.syncIcon) {
SyncIconState.Normal, SyncIconState.PendingChanges -> R.string.button_sync
SyncIconState.OneWay -> R.string.sync_menu_title_one_way_sync
SyncIconState.NotLoggedIn -> R.string.sync_menu_title_no_account
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
provider.setTooltipText(getString(tooltipText))
}
when (state.syncIcon) {
SyncIconState.Normal -> {
BadgeDrawableBuilder.removeBadge(provider)
Expand Down
7 changes: 7 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/anki/SyncActionProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ package com.ichi2.anki
import android.app.Activity
import android.content.Context
import android.graphics.drawable.Drawable
import android.os.Build
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import androidx.annotation.RequiresApi
import androidx.appcompat.widget.AppCompatImageButton
import androidx.core.view.isVisible
import com.google.android.material.progressindicator.LinearProgressIndicator
Expand Down Expand Up @@ -57,4 +59,9 @@ class SyncActionProvider(context: Context) : ActionProviderCompat(context) {

return view
}

@RequiresApi(Build.VERSION_CODES.O)
fun setTooltipText(value: CharSequence) {
syncButton?.tooltipText = value
}
}
1 change: 1 addition & 0 deletions AnkiDroid/src/main/res/layout/sync_progress_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
android:layout_height="@dimen/touch_target"
app:srcCompat="@drawable/ic_sync"
style="@android:style/Widget.ActionButton"
android:tooltipText="@string/button_sync"
android:tint="@color/white"
tools:tint="?attr/colorControlNormal"
/>
Expand Down

0 comments on commit d983b81

Please sign in to comment.