Skip to content

Commit

Permalink
Utilize the toolTip extension function instead of employing TooltipCo…
Browse files Browse the repository at this point in the history
…mpat.setTooltipText throughout the code to eliminate redundancy. Additionally, removed comments related to the usage of this method, as the information is already provided in our extension function's comment.
  • Loading branch information
MohitMaliDeveloper committed Feb 15, 2024
1 parent 767aec5 commit 03f4a07
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ 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
Expand Down Expand Up @@ -115,6 +114,7 @@ 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.setToolTipWithContentDescription
import org.kiwix.kiwixmobile.core.extensions.snack
import org.kiwix.kiwixmobile.core.extensions.toast
import org.kiwix.kiwixmobile.core.main.DocumentParser.SectionsListener
Expand Down Expand Up @@ -694,13 +694,8 @@ abstract class CoreReaderFragment :
)
setDisplayShowTitleEnabled(false)
}
// 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)
)
it.setToolTipWithContentDescription(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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.setToolTipWithContentDescription
import org.kiwix.kiwixmobile.core.reader.ZimFileReader

const val REQUEST_FILE_SEARCH = 1236
Expand Down Expand Up @@ -101,12 +101,7 @@ class MainMenu(
)
tabSwitcher?.actionView?.apply {
setOnClickListener { menuClickListener.onTabMenuClicked() }
// 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)
)
setToolTipWithContentDescription(resources.getString(R.string.switch_tabs))
}
addNote.menuItemClickListener { menuClickListener.onAddNoteMenuClicked() }
randomArticle.menuItemClickListener { menuClickListener.onRandomArticleMenuClicked() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ 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
Expand All @@ -39,6 +38,7 @@ 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.setToolTipWithContentDescription
import org.kiwix.kiwixmobile.core.extensions.tint
import org.kiwix.kiwixmobile.core.utils.DimenUtils.getToolbarHeight
import org.kiwix.kiwixmobile.core.utils.DimenUtils.getWindowHeight
Expand Down Expand Up @@ -67,12 +67,7 @@ class TabsAdapter internal constructor(
.apply {
id = R.id.tabsAdapterCloseImageView
setImageDrawableCompat(R.drawable.ic_clear_white_24dp)
// 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)
)
setToolTipWithContentDescription(resources.getString(R.string.close_tab))
val outValue = TypedValue()
context.theme.resolveAttribute(android.R.attr.actionBarItemBackground, outValue, true)
setBackgroundResource(outValue.resourceId)
Expand Down

0 comments on commit 03f4a07

Please sign in to comment.