diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/ViewExtensions.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/ViewExtensions.kt index 3a82331239..e8e2a7ed8f 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/ViewExtensions.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/ViewExtensions.kt @@ -21,7 +21,6 @@ package org.kiwix.kiwixmobile.core.extensions import android.annotation.SuppressLint import android.view.View import androidx.annotation.ColorInt -import androidx.appcompat.widget.TooltipCompat import com.google.android.material.snackbar.BaseTransientBottomBar import com.google.android.material.snackbar.Snackbar @@ -70,7 +69,3 @@ fun View.snack( }) }.show() } - -fun View.setToolTip(description: String) { - TooltipCompat.setTooltipText(this, description) -} diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt index c31d217c5d..4cff759cdb 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt @@ -65,6 +65,7 @@ import androidx.annotation.AnimRes import androidx.appcompat.app.ActionBar import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar +import androidx.appcompat.widget.TooltipCompat import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.Group import androidx.coordinatorlayout.widget.CoordinatorLayout @@ -114,7 +115,6 @@ import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.observeNavigatio import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.requestNotificationPermission import org.kiwix.kiwixmobile.core.extensions.ViewGroupExtensions.findFirstTextView import org.kiwix.kiwixmobile.core.extensions.isFileExist -import org.kiwix.kiwixmobile.core.extensions.setToolTip import org.kiwix.kiwixmobile.core.extensions.snack import org.kiwix.kiwixmobile.core.extensions.toast import org.kiwix.kiwixmobile.core.main.DocumentParser.SectionsListener @@ -694,7 +694,14 @@ abstract class CoreReaderFragment : ) setDisplayShowTitleEnabled(false) } - closeAllTabsButton?.setToolTip(resources.getString(R.string.close_all_tabs)) + // contentDescription is not working as expected, so use TooltipCompat.setTooltipText + // method instead of toolTipText, for backward compatibility + closeAllTabsButton?.let { + TooltipCompat.setTooltipText( + it, + resources.getString(R.string.close_all_tabs) + ) + } // Set a negative top margin to the web views to remove // the unwanted blank space caused by the toolbar. setTopMarginToWebViews(-requireActivity().getToolbarHeight()) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/MainMenu.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/MainMenu.kt index 2c0a06eea2..625fc4ac5a 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/MainMenu.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/MainMenu.kt @@ -22,9 +22,9 @@ import android.content.res.Configuration import android.view.Menu import android.view.MenuItem import android.widget.TextView +import androidx.appcompat.widget.TooltipCompat import androidx.core.view.isVisible import org.kiwix.kiwixmobile.core.R -import org.kiwix.kiwixmobile.core.extensions.setToolTip import org.kiwix.kiwixmobile.core.reader.ZimFileReader const val REQUEST_FILE_SEARCH = 1236 @@ -101,7 +101,12 @@ class MainMenu( ) tabSwitcher?.actionView?.apply { setOnClickListener { menuClickListener.onTabMenuClicked() } - setToolTip(resources.getString(R.string.switch_tabs)) + // contentDescription is not working as expected, so use TooltipCompat.setTooltipText + // method instead of toolTipText, for backward compatibility + TooltipCompat.setTooltipText( + this, + resources.getString(R.string.switch_tabs) + ) } addNote.menuItemClickListener { menuClickListener.onAddNoteMenuClicked() } randomArticle.menuItemClickListener { menuClickListener.onRandomArticleMenuClicked() } diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/TabsAdapter.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/TabsAdapter.kt index 1cf87f57fd..9a8290ec42 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/TabsAdapter.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/TabsAdapter.kt @@ -26,6 +26,7 @@ import android.widget.FrameLayout import android.widget.ImageView import android.widget.TextView import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.widget.TooltipCompat import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet import androidx.constraintlayout.widget.ConstraintSet.BOTTOM @@ -38,7 +39,6 @@ import com.google.android.material.card.MaterialCardView import org.kiwix.kiwixmobile.core.R import org.kiwix.kiwixmobile.core.extensions.getAttribute import org.kiwix.kiwixmobile.core.extensions.setImageDrawableCompat -import org.kiwix.kiwixmobile.core.extensions.setToolTip import org.kiwix.kiwixmobile.core.extensions.tint import org.kiwix.kiwixmobile.core.utils.DimenUtils.getToolbarHeight import org.kiwix.kiwixmobile.core.utils.DimenUtils.getWindowHeight @@ -67,7 +67,12 @@ class TabsAdapter internal constructor( .apply { id = R.id.tabsAdapterCloseImageView setImageDrawableCompat(R.drawable.ic_clear_white_24dp) - setToolTip(resources.getString(R.string.close_tab)) + // contentDescription is not working as expected, so use TooltipCompat.setTooltipText + // method instead of toolTipText, for backward compatibility + TooltipCompat.setTooltipText( + this, + resources.getString(R.string.close_tab) + ) val outValue = TypedValue() context.theme.resolveAttribute(android.R.attr.actionBarItemBackground, outValue, true) setBackgroundResource(outValue.resourceId)