mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-14 09:57:31 -04:00
#3668 Added setToolTip function
This commit is contained in:
parent
4b9a309fb1
commit
a907fa3f42
@ -19,8 +19,10 @@
|
||||
package org.kiwix.kiwixmobile.core.extensions
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Build
|
||||
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
|
||||
|
||||
@ -69,3 +71,11 @@ fun View.snack(
|
||||
})
|
||||
}.show()
|
||||
}
|
||||
|
||||
fun View.setToolTip(description: String) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
TooltipCompat.setTooltipText(this, description)
|
||||
} else {
|
||||
contentDescription = description
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
@ -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.setToolTip
|
||||
import org.kiwix.kiwixmobile.core.extensions.snack
|
||||
import org.kiwix.kiwixmobile.core.extensions.toast
|
||||
import org.kiwix.kiwixmobile.core.main.DocumentParser.SectionsListener
|
||||
@ -694,6 +694,7 @@ abstract class CoreReaderFragment :
|
||||
)
|
||||
setDisplayShowTitleEnabled(false)
|
||||
}
|
||||
closeAllTabsButton?.setToolTip(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())
|
||||
@ -770,11 +771,6 @@ abstract class CoreReaderFragment :
|
||||
setImageDrawable(
|
||||
ContextCompat.getDrawable(requireActivity(), R.drawable.ic_close_black_24dp)
|
||||
)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
TooltipCompat.setTooltipText(this, resources.getString(R.string.close_all_tabs))
|
||||
} else {
|
||||
contentDescription = resources.getString(R.string.close_all_tabs)
|
||||
}
|
||||
}
|
||||
tabSwitcherRoot?.let {
|
||||
if (it.visibility == View.VISIBLE) {
|
||||
@ -938,22 +934,27 @@ abstract class CoreReaderFragment :
|
||||
hideTabSwitcher()
|
||||
return FragmentActivityExtensions.Super.ShouldNotCall
|
||||
}
|
||||
|
||||
isInFullScreenMode() -> {
|
||||
closeFullScreen()
|
||||
return FragmentActivityExtensions.Super.ShouldNotCall
|
||||
}
|
||||
|
||||
compatCallback?.isActive == true -> {
|
||||
compatCallback?.finish()
|
||||
return FragmentActivityExtensions.Super.ShouldNotCall
|
||||
}
|
||||
|
||||
drawerLayout?.isDrawerOpen(GravityCompat.END) == true -> {
|
||||
drawerLayout?.closeDrawers()
|
||||
return FragmentActivityExtensions.Super.ShouldNotCall
|
||||
}
|
||||
|
||||
getCurrentWebView()?.canGoBack() == true -> {
|
||||
getCurrentWebView()?.goBack()
|
||||
return FragmentActivityExtensions.Super.ShouldNotCall
|
||||
}
|
||||
|
||||
else -> return FragmentActivityExtensions.Super.ShouldCall
|
||||
}
|
||||
}
|
||||
@ -1025,6 +1026,7 @@ abstract class CoreReaderFragment :
|
||||
pauseTTSButton?.setText(R.string.tts_resume)
|
||||
setActionAndStartTTSService(ACTION_PAUSE_OR_RESUME_TTS, true)
|
||||
}
|
||||
|
||||
AudioManager.AUDIOFOCUS_GAIN -> {
|
||||
pauseTTSButton?.setText(R.string.tts_pause)
|
||||
setActionAndStartTTSService(ACTION_PAUSE_OR_RESUME_TTS, false)
|
||||
@ -1310,12 +1312,14 @@ abstract class CoreReaderFragment :
|
||||
startReadAloud()
|
||||
}
|
||||
}
|
||||
|
||||
View.VISIBLE -> {
|
||||
if (isBackToTopEnabled) {
|
||||
backToTopButton?.show()
|
||||
}
|
||||
tts?.stop()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@ -1586,6 +1590,7 @@ abstract class CoreReaderFragment :
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REQUEST_POST_NOTIFICATION_PERMISSION -> {
|
||||
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
onReadAloudMenuClicked()
|
||||
@ -1740,18 +1745,22 @@ abstract class CoreReaderFragment :
|
||||
// see https://github.com/kiwix/kiwix-android/issues/2607
|
||||
intent.action = null
|
||||
}
|
||||
|
||||
CoreSearchWidget.TEXT_CLICKED -> {
|
||||
goToSearch(false)
|
||||
intent.action = null
|
||||
}
|
||||
|
||||
CoreSearchWidget.STAR_CLICKED -> {
|
||||
goToBookmarks()
|
||||
intent.action = null
|
||||
}
|
||||
|
||||
CoreSearchWidget.MIC_CLICKED -> {
|
||||
goToSearch(true)
|
||||
intent.action = null
|
||||
}
|
||||
|
||||
Intent.ACTION_VIEW -> if (intent.type == null ||
|
||||
intent.type != "application/octet-stream"
|
||||
) {
|
||||
@ -2059,10 +2068,12 @@ abstract class CoreReaderFragment :
|
||||
// This is my web site, so do not override; let my WebView load the page
|
||||
handleEvent = true
|
||||
}
|
||||
|
||||
url.startsWith("file://") -> {
|
||||
// To handle help page (loaded from resources)
|
||||
handleEvent = true
|
||||
}
|
||||
|
||||
url.startsWith(ZimFileReader.UI_URI.toString()) -> {
|
||||
handleEvent = true
|
||||
}
|
||||
|
@ -19,13 +19,12 @@ package org.kiwix.kiwixmobile.core.main
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.res.Configuration
|
||||
import android.os.Build
|
||||
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
|
||||
@ -102,11 +101,7 @@ class MainMenu(
|
||||
)
|
||||
tabSwitcher?.actionView?.apply {
|
||||
setOnClickListener { menuClickListener.onTabMenuClicked() }
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
TooltipCompat.setTooltipText(this, resources.getText(R.string.switch_tabs))
|
||||
} else {
|
||||
contentDescription = resources.getText(R.string.switch_tabs)
|
||||
}
|
||||
setToolTip(resources.getString(R.string.switch_tabs))
|
||||
}
|
||||
addNote.menuItemClickListener { menuClickListener.onAddNoteMenuClicked() }
|
||||
randomArticle.menuItemClickListener { menuClickListener.onRandomArticleMenuClicked() }
|
||||
@ -126,6 +121,7 @@ class MainMenu(
|
||||
menuClickListener.onHomeMenuClicked()
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
package org.kiwix.kiwixmobile.core.main
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Build
|
||||
import android.text.TextUtils
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
@ -27,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
|
||||
@ -40,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.setToolTip
|
||||
import org.kiwix.kiwixmobile.core.extensions.tint
|
||||
import org.kiwix.kiwixmobile.core.utils.DimenUtils.getToolbarHeight
|
||||
import org.kiwix.kiwixmobile.core.utils.DimenUtils.getWindowHeight
|
||||
@ -68,11 +67,7 @@ class TabsAdapter internal constructor(
|
||||
.apply {
|
||||
id = R.id.tabsAdapterCloseImageView
|
||||
setImageDrawableCompat(R.drawable.ic_clear_white_24dp)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
TooltipCompat.setTooltipText(this, "Close Tab")
|
||||
} else {
|
||||
contentDescription = "Close Tab"
|
||||
}
|
||||
setToolTip(resources.getString(R.string.close_tab))
|
||||
val outValue = TypedValue()
|
||||
context.theme.resolveAttribute(android.R.attr.actionBarItemBackground, outValue, true)
|
||||
setBackgroundResource(outValue.resourceId)
|
||||
|
@ -214,6 +214,7 @@
|
||||
<string name="search_bookmarks">Search bookmarks</string>
|
||||
<string name="switch_tabs">Switch tabs</string>
|
||||
<string name="close_all_tabs">Close all tabs</string>
|
||||
<string name="close_tab">Close tab</string>
|
||||
<string name="pending_state">Pending</string>
|
||||
<string name="running_state">In Progress</string>
|
||||
<string name="complete">Complete</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user