Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: Content labeling issue reported by the playstore. #3707

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.SearchView
import androidx.appcompat.widget.Toolbar
import androidx.core.view.MenuHost
import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle
Expand All @@ -35,10 +36,13 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import io.reactivex.disposables.CompositeDisposable
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.R.string
import org.kiwix.kiwixmobile.cachedComponent
import org.kiwix.kiwixmobile.core.base.BaseActivity
import org.kiwix.kiwixmobile.core.base.BaseFragment
import org.kiwix.kiwixmobile.core.extensions.closeKeyboard
import org.kiwix.kiwixmobile.core.extensions.getToolbarNavigationIcon
import org.kiwix.kiwixmobile.core.extensions.setToolTipWithContentDescription
import org.kiwix.kiwixmobile.core.extensions.viewModel
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
import org.kiwix.kiwixmobile.core.utils.SimpleTextListener
Expand Down Expand Up @@ -78,13 +82,18 @@ class LanguageFragment : BaseFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val activity = requireActivity() as CoreMainActivity
activity.setSupportActionBar(view.findViewById(R.id.toolbar))
val toolbar: Toolbar = view.findViewById(R.id.toolbar)
activity.setSupportActionBar(toolbar)

activity.supportActionBar?.let {
it.setDisplayHomeAsUpEnabled(true)
it.setHomeAsUpIndicator(R.drawable.ic_clear_white_24dp)
it.setTitle(R.string.select_languages)
}
// set the contentDescription to navigation back button
toolbar.getToolbarNavigationIcon()?.setToolTipWithContentDescription(
getString(string.toolbar_back_button_content_description)
)
activityLanguageBinding?.languageRecyclerView?.run {
adapter = languageAdapter
layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package org.kiwix.kiwixmobile.language.adapter
import android.view.View
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.base.adapter.BaseViewHolder
import org.kiwix.kiwixmobile.core.extensions.setToolTipWithContentDescription
import org.kiwix.kiwixmobile.databinding.HeaderDateBinding
import org.kiwix.kiwixmobile.databinding.ItemLanguageBinding
import org.kiwix.kiwixmobile.language.adapter.LanguageListItem.HeaderItem
Expand Down Expand Up @@ -48,8 +49,18 @@ sealed class LanguageListViewHolder<in T : LanguageListItem>(override val contai
itemLanguageBinding.itemLanguageLocalizedName.text = language.languageLocalized
itemLanguageBinding.itemLanguageBooksCount.text = containerView.context
.getString(R.string.books_count, language.occurencesOfLanguage)
itemLanguageBinding.itemLanguageCheckbox.isChecked = language.active
itemLanguageBinding.itemLanguageClickableArea.setOnClickListener { clickAction(item) }
itemLanguageBinding.itemLanguageCheckbox.apply {
setToolTipWithContentDescription(
containerView.context.getString(R.string.select_language_content_description)
)
isChecked = language.active
}
itemLanguageBinding.itemLanguageClickableArea.apply {
setToolTipWithContentDescription(
containerView.context.getString(R.string.select_language_content_description)
)
setOnClickListener { clickAction(item) }
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.R.string
import org.kiwix.kiwixmobile.cachedComponent
import org.kiwix.kiwixmobile.core.base.BaseActivity
import org.kiwix.kiwixmobile.core.base.BaseFragment
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.popNavigationBackstack
import org.kiwix.kiwixmobile.core.extensions.getToolbarNavigationIcon
import org.kiwix.kiwixmobile.core.extensions.setToolTipWithContentDescription
import org.kiwix.kiwixmobile.core.extensions.toast
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
Expand Down Expand Up @@ -139,6 +142,9 @@ class LocalFileTransferFragment :
wifiDirectManager.callbacks = this
wifiDirectManager.lifecycleCoroutineScope = lifecycleScope
wifiDirectManager.startWifiDirectManager(filesForTransfer)
fragmentLocalFileTransferBinding
?.textViewDeviceName
?.setToolTipWithContentDescription(getString(R.string.your_device))
}

private fun setupMenu() {
Expand Down Expand Up @@ -241,12 +247,18 @@ class LocalFileTransferFragment :

private fun setupToolbar(view: View, activity: CoreMainActivity, isReceiver: Boolean) {
val toolbar: Toolbar = view.findViewById(R.id.toolbar)
activity.setSupportActionBar(toolbar)
toolbar.title =
if (isReceiver) getString(R.string.receive_files_title)
else getString(R.string.send_files_title)
toolbar.setNavigationIcon(R.drawable.ic_close_white_24dp)
toolbar.setNavigationOnClickListener { activity.popNavigationBackstack() }
toolbar.apply {
activity.setSupportActionBar(this)
title =
if (isReceiver) getString(R.string.receive_files_title)
else getString(R.string.send_files_title)
setNavigationIcon(R.drawable.ic_close_white_24dp)
// set the contentDescription to navigation back button
getToolbarNavigationIcon()?.setToolTipWithContentDescription(
getString(string.toolbar_back_button_content_description)
)
setNavigationOnClickListener { activity.popNavigationBackstack() }
}
}

private fun getFilesForTransfer() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.kiwix.kiwixmobile.core.downloader.model.Base64String
import org.kiwix.kiwixmobile.core.extensions.setBitmap
import org.kiwix.kiwixmobile.core.extensions.setImageDrawableCompat
import org.kiwix.kiwixmobile.core.extensions.setTextAndVisibility
import org.kiwix.kiwixmobile.core.extensions.setToolTipWithContentDescription
import org.kiwix.kiwixmobile.core.extensions.toast
import org.kiwix.kiwixmobile.core.utils.BookUtils
import org.kiwix.kiwixmobile.core.zim_manager.KiloByte
Expand Down Expand Up @@ -101,9 +102,18 @@ sealed class LibraryViewHolder<in T : LibraryListItem>(containerView: View) :
itemDownloadBinding.libraryDownloadTitle.text = item.title
itemDownloadBinding.libraryDownloadDescription.text = item.description
itemDownloadBinding.downloadProgress.progress = item.progress
itemDownloadBinding.stop.setOnClickListener { clickAction.invoke(item) }
itemDownloadBinding.pauseResume.setOnClickListener {
pauseResumeClickAction.invoke(item)
itemDownloadBinding.stop.apply {
setToolTipWithContentDescription(itemDownloadBinding.root.context.getString(R.string.stop))
setOnClickListener { clickAction.invoke(item) }
}
itemDownloadBinding.pauseResume.apply {
val context = itemDownloadBinding.root.context
val description =
"${context.getString(R.string.tts_pause)}/${context.getString(R.string.tts_resume)}"
setToolTipWithContentDescription(description)
setOnClickListener {
pauseResumeClickAction.invoke(item)
}
}
itemDownloadBinding.downloadState.text =
item.downloadState.toReadableState(containerView.context).also {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_language.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
android:layout_width="0dp"
android:layout_height="0dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:contentDescription="@string/pref_language_title"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_destination_download.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:contentDescription="@string/library"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:listitem="@layout/item_download" />

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_destination_library.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
android:id="@+id/zimfilelist"
android:layout_width="0dp"
android:layout_height="match_parent"
android:contentDescription="@string/crash_checkbox_zimfiles"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_library.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:alpha=".5"
android:contentDescription="@string/detecting_file_system"
android:background="@color/pure_gray"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import eu.mhutti1.utils.storage.StorageDevice
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.base.adapter.BaseViewHolder
import org.kiwix.kiwixmobile.core.databinding.DeviceItemBinding
import org.kiwix.kiwixmobile.core.extensions.setToolTipWithContentDescription
import org.kiwix.kiwixmobile.core.settings.StorageCalculator
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil

Expand All @@ -45,8 +46,15 @@ internal class StorageViewHolder(
}
deviceItemBinding.fileSize.text = storageCalculator.calculateAvailableSpace(item.file) + " / " +
storageCalculator.calculateTotalSpace(item.file) + " "
deviceItemBinding.clickOverlay.setOnClickListener {
onClickAction.invoke(item)
deviceItemBinding.clickOverlay.apply {
setToolTipWithContentDescription(
deviceItemBinding.root.context.getString(
R.string.storage_selection_dialog_accessibility_description
)
)
setOnClickListener {
onClickAction.invoke(item)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.extensions.getToolbarNavigationIcon
import org.kiwix.kiwixmobile.core.extensions.setToolTipWithContentDescription

/**
* All fragments should inherit from this fragment.
Expand Down Expand Up @@ -55,6 +58,10 @@ abstract class BaseFragment : Fragment() {
it.supportActionBar?.let { actionBar ->
actionBar.setDisplayHomeAsUpEnabled(true)
title = fragmentTitle
// set the navigation back button contentDescription
getToolbarNavigationIcon()?.setToolTipWithContentDescription(
getString(R.string.toolbar_back_button_content_description)
)
}
}
setNavigationOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Kiwix Android
* Copyright (c) 2024 Kiwix <android.kiwix.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package org.kiwix.kiwixmobile.core.extensions

import android.text.TextUtils
import android.view.View
import androidx.appcompat.widget.Toolbar

fun Toolbar.getToolbarNavigationIcon(): View? {
// check if contentDescription previously was set
val hadContentDescription = !TextUtils.isEmpty(navigationContentDescription)
val contentDescription =
if (hadContentDescription) navigationContentDescription else "navigationIcon"
// set the contentDescription on toolbar's navigationIcon
navigationContentDescription = contentDescription
val potentialViews = arrayListOf<View>()
// find the view based on it's content description,
// set programmatically or with android:contentDescription
findViewsWithText(potentialViews, contentDescription, View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION)
// Clear content description if not previously present
if (!hadContentDescription) {
navigationContentDescription = null
}
// Nav icon is always instantiated at this point because calling
// setNavigationContentDescription ensures its existence
return potentialViews.firstOrNull()
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ 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 @@ -69,3 +70,14 @@ fun View.snack(
})
}.show()
}

/**
* Sets the content description to address an accessibility issue reported by the Play Store.
* Additionally, sets a tooltip for displaying hints to the user when they long-click on the view.
*
* @param description The content description and tooltip text to be set.
*/
fun View.setToolTipWithContentDescription(description: String) {
contentDescription = description
TooltipCompat.setTooltipText(this, description)
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import org.kiwix.kiwixmobile.core.data.remote.ObjectBoxToLibkiwixMigrator
import org.kiwix.kiwixmobile.core.di.components.CoreActivityComponent
import org.kiwix.kiwixmobile.core.error.ErrorActivity
import org.kiwix.kiwixmobile.core.extensions.browserIntent
import org.kiwix.kiwixmobile.core.extensions.getToolbarNavigationIcon
import org.kiwix.kiwixmobile.core.extensions.setToolTipWithContentDescription
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer
import org.kiwix.kiwixmobile.core.search.NAV_ARG_SEARCH_STRING
import org.kiwix.kiwixmobile.core.utils.EXTRA_IS_WIDGET_VOICE
Expand Down Expand Up @@ -197,6 +199,14 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
navController.navigateUp() || super.onSupportNavigateUp()

open fun setupDrawerToggle(toolbar: Toolbar) {
// Set the initial contentDescription to the hamburger icon.
// This method is called from various locations after modifying the navigationIcon.
// For example, we previously changed this icon/contentDescription to the "+" button
// when opening the tabSwitcher. After closing the tabSwitcher, we reset the
// contentDescription to the default hamburger icon.
toolbar.getToolbarNavigationIcon()?.setToolTipWithContentDescription(
getString(R.string.open_drawer)
)
drawerToggle =
ActionBarDrawerToggle(
this,
Expand Down
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 @@ -114,7 +113,9 @@ import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.hasNotificationP
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.observeNavigationResult
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.requestNotificationPermission
import org.kiwix.kiwixmobile.core.extensions.ViewGroupExtensions.findFirstTextView
import org.kiwix.kiwixmobile.core.extensions.getToolbarNavigationIcon
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 @@ -692,16 +693,15 @@ abstract class CoreReaderFragment :
setHomeAsUpIndicator(
ContextCompat.getDrawable(requireActivity(), R.drawable.ic_round_add_white_36dp)
)
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)
// set the contentDescription to UpIndicator icon.
toolbar?.getToolbarNavigationIcon()?.setToolTipWithContentDescription(
getString(R.string.search_open_in_new_tab)
)
setDisplayShowTitleEnabled(false)
}
closeAllTabsButton?.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.
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.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
Loading
Loading