adding compatToolTipText helper + using unused strings

This commit is contained in:
Jays2Kings 2021-04-10 19:10:42 -04:00
parent 074f41ca7e
commit 0a3d6bd8f5
6 changed files with 24 additions and 6 deletions

View File

@ -112,6 +112,13 @@ class EditMangaDialog : DialogController {
infoController.changeCover()
}
binding.resetTags.setOnClickListener { resetTags() }
binding.resetTags.text = resources?.getString(
if (manga.genre.isNullOrBlank() || manga.source == LocalSource.ID) {
R.string.clear_tags
} else {
R.string.reset_tags
}
)
binding.resetCover.visibleIf(!isLocal)
binding.resetCover.setOnClickListener {
binding.mangaCover.loadAny(

View File

@ -43,10 +43,6 @@ class ThemePreference @JvmOverloads constructor(context: Context, attrs: Attribu
layoutResource = R.layout.themes_preference
fastAdapter = FastAdapter.with(itemAdapter)
fastAdapter.setHasStableIds(true)
val enumConstants = ThemeUtil.Themes::class.java.enumConstants
val currentLightTheme = preferences.lightTheme().get()
val currentDarkTheme = preferences.darkTheme().get()
val nightMode = preferences.nightMode().get()
selectExtension = fastAdapter.getSelectExtension().apply {
isSelectable = true
multiSelect = true
@ -78,6 +74,7 @@ class ThemePreference @JvmOverloads constructor(context: Context, attrs: Attribu
}
}
val enumConstants = ThemeUtil.Themes::class.java.enumConstants
itemAdapter.set(enumConstants?.map(::ThemeItem).orEmpty())
isSelectable = false
}

View File

@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.source.LocalSource
import eu.kanade.tachiyomi.source.icon
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.view.compatToolTipText
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
@ -40,6 +41,7 @@ class SourceHolder(view: View, val adapter: SourceAdapter) :
else android.R.attr.textColorSecondary
)
)
compatToolTipText = context.getString(if (isPinned) R.string.unpin else R.string.pin)
setImageResource(
if (isPinned) R.drawable.ic_pin_24dp
else R.drawable.ic_pin_outline_24dp

View File

@ -20,6 +20,7 @@ import androidx.annotation.IdRes
import androidx.annotation.Px
import androidx.appcompat.view.menu.MenuBuilder
import androidx.core.graphics.ColorUtils
import androidx.core.view.ViewCompat
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearSmoothScroller
import androidx.recyclerview.widget.RecyclerView
@ -336,3 +337,13 @@ fun RecyclerView.smoothScrollToTop() {
scrollToPosition(0)
}
}
var View.compatToolTipText: CharSequence?
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
tooltipText
} else {
""
}
set(value) {
ViewCompat.setTooltipText(this, value)
}

View File

@ -102,7 +102,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:contentDescription="@string/pin" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>

View File

@ -9,7 +9,7 @@
<item
android:id="@+id/action_migration_guide"
android:title="@string/help"
android:title="@string/source_migration_guide"
android:icon="@drawable/ic_help_24dp"
app:showAsAction="ifRoom"/>
</menu>