Skip to content

Commit

Permalink
#3668 Comments added for ToolTip uses
Browse files Browse the repository at this point in the history
  • Loading branch information
Sagar0-0 committed Feb 15, 2024
1 parent 0411a98 commit b924daa
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -70,7 +69,3 @@ fun View.snack(
})
}.show()
}

fun View.setToolTip(description: String) {
TooltipCompat.setTooltipText(this, description)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
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.setToolTip
import org.kiwix.kiwixmobile.core.reader.ZimFileReader

const val REQUEST_FILE_SEARCH = 1236
Expand Down Expand Up @@ -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() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b924daa

Please sign in to comment.