diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/adapter/LibraryListItem.kt b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/adapter/LibraryListItem.kt index ac8c47cf1..514452ecc 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/adapter/LibraryListItem.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/adapter/LibraryListItem.kt @@ -19,6 +19,7 @@ package org.kiwix.kiwixmobile.zim_manager.library_view.adapter import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity.Book +import org.kiwix.kiwixmobile.core.zim_manager.KiwixTag import org.kiwix.kiwixmobile.zim_manager.Fat32Checker import org.kiwix.kiwixmobile.zim_manager.Fat32Checker.FileSystemState import org.kiwix.kiwixmobile.zim_manager.Fat32Checker.FileSystemState.CanWrite4GbFile diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/adapter/LibraryViewHolder.kt b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/adapter/LibraryViewHolder.kt index 8e87b1577..6cad8282f 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/adapter/LibraryViewHolder.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/adapter/LibraryViewHolder.kt @@ -31,6 +31,7 @@ import kotlinx.android.synthetic.main.item_library.fileName import kotlinx.android.synthetic.main.item_library.language import kotlinx.android.synthetic.main.item_library.publisher import kotlinx.android.synthetic.main.item_library.size +import kotlinx.android.synthetic.main.item_library.tags import kotlinx.android.synthetic.main.item_library.title import kotlinx.android.synthetic.main.item_library.unableToDownload import kotlinx.android.synthetic.main.library_divider.divider_text @@ -70,6 +71,8 @@ sealed class LibraryViewHolder(containerView: View) : containerView.setOnClickListener { clickAction.invoke(item) } containerView.isClickable = item.canBeDownloaded + tags.render(item.tags) + unableToDownload.visibility = if (item.canBeDownloaded) View.GONE else View.VISIBLE unableToDownload.setOnLongClickListener { it.centreToast( diff --git a/app/src/main/res/layout/item_library.xml b/app/src/main/res/layout/item_library.xml index 97b2bb4c4..7f9c32a87 100644 --- a/app/src/main/res/layout/item_library.xml +++ b/app/src/main/res/layout/item_library.xml @@ -102,6 +102,16 @@ app:layout_constraintTop_toBottomOf="@+id/language" tools:text="File Name" /> + + + FtIndexTag(value!!) "_pictures" -> PicturesTag(value!!) - "_video" -> VideoTag(value!!) + "_videos" -> VideoTag(value!!) "_details" -> DetailsTag(value!!) "_category" -> CategoryTag(value!!) else -> value?.let { ArbitraryTag(tag, it) } ?: TagOnly(tag) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/zim_manager/TagsView.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/zim_manager/TagsView.kt new file mode 100644 index 000000000..b9012bb07 --- /dev/null +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/zim_manager/TagsView.kt @@ -0,0 +1,60 @@ +/* + * Kiwix Android + * Copyright (c) 2019 Kiwix + * 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 . + * + */ + +package org.kiwix.kiwixmobile.core.zim_manager + +import android.content.Context +import android.util.AttributeSet +import com.google.android.material.chip.Chip +import com.google.android.material.chip.ChipGroup +import kotlinx.android.synthetic.main.tag_content.view.tag_picture +import kotlinx.android.synthetic.main.tag_content.view.tag_short_text_only +import kotlinx.android.synthetic.main.tag_content.view.tag_text_only +import kotlinx.android.synthetic.main.tag_content.view.tag_video +import org.kiwix.kiwixmobile.core.R +import org.kiwix.kiwixmobile.core.extensions.ViewGroupExtensions.inflate +import org.kiwix.kiwixmobile.core.zim_manager.KiwixTag.Companion.YesNoValueTag +import org.kiwix.kiwixmobile.core.zim_manager.KiwixTag.Companion.YesNoValueTag.DetailsTag +import org.kiwix.kiwixmobile.core.zim_manager.KiwixTag.Companion.YesNoValueTag.PicturesTag +import org.kiwix.kiwixmobile.core.zim_manager.KiwixTag.Companion.YesNoValueTag.VideoTag +import org.kiwix.kiwixmobile.core.zim_manager.KiwixTag.TagValue.YES + +class TagsView(context: Context, attrs: AttributeSet) : ChipGroup(context, attrs) { + + init { + inflate(R.layout.tag_content, true) + } + + fun render(tags: List) { + val pictureTagIsSet = tags.isSet() + val videoTagIsSet = tags.isSet() + val detailsTagIsSet = tags.isSet() + tag_picture.selectBy(pictureTagIsSet) + tag_video.selectBy(videoTagIsSet) + tag_text_only.selectBy(!pictureTagIsSet && !videoTagIsSet && detailsTagIsSet) + tag_short_text_only.selectBy(!pictureTagIsSet && !videoTagIsSet && !detailsTagIsSet) + } + + private inline fun List.isSet() = + filterIsInstance().getOrNull(0)?.value == YES + + private fun Chip.selectBy(isTagSet: Boolean) { + isChecked = isTagSet + isEnabled = isTagSet + } +} diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/zim_manager/fileselect_view/adapter/BookOnDiskDelegate.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/zim_manager/fileselect_view/adapter/BookOnDiskDelegate.kt index e52c68f6e..882fe4353 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/zim_manager/fileselect_view/adapter/BookOnDiskDelegate.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/zim_manager/fileselect_view/adapter/BookOnDiskDelegate.kt @@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView.ViewHolder import org.kiwix.kiwixmobile.core.R +import org.kiwix.kiwixmobile.core.base.adapter.AbsDelegateAdapter import org.kiwix.kiwixmobile.core.extensions.ViewGroupExtensions.inflate import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode @@ -27,7 +28,6 @@ import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode.NORM import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BookOnDiskViewHolder.BookViewHolder import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.LanguageItem -import org.kiwix.kiwixmobile.core.base.adapter.AbsDelegateAdapter sealed class BookOnDiskDelegate> : AbsDelegateAdapter { @@ -53,7 +53,6 @@ sealed class BookOnDiskDelegate = KiwixTag.from(book.tags), override val id: Long = databaseId ) : BooksOnDiskListItem() { diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/zim_manager/fileselect_view/adapter/BooksOnDiskViewHolder.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/zim_manager/fileselect_view/adapter/BooksOnDiskViewHolder.kt index a80be58e4..75e60ec7b 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/zim_manager/fileselect_view/adapter/BooksOnDiskViewHolder.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/zim_manager/fileselect_view/adapter/BooksOnDiskViewHolder.kt @@ -26,14 +26,12 @@ import kotlinx.android.synthetic.main.item_book.item_book_clickable_area import kotlinx.android.synthetic.main.item_book.item_book_date import kotlinx.android.synthetic.main.item_book.item_book_description import kotlinx.android.synthetic.main.item_book.item_book_icon -import kotlinx.android.synthetic.main.item_book.item_book_label_picture -import kotlinx.android.synthetic.main.item_book.item_book_label_video import kotlinx.android.synthetic.main.item_book.item_book_size import kotlinx.android.synthetic.main.item_book.item_book_title +import kotlinx.android.synthetic.main.item_book.tags import org.kiwix.kiwixmobile.core.base.adapter.BaseViewHolder import org.kiwix.kiwixmobile.core.downloader.model.Base64String import org.kiwix.kiwixmobile.core.extensions.setBitmap -import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil import org.kiwix.kiwixmobile.core.zim_manager.KiloByte import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.ArticleCount import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode @@ -47,7 +45,6 @@ sealed class BookOnDiskViewHolder(containerView: Vie class BookViewHolder( containerView: View, - private val sharedPreferenceUtil: SharedPreferenceUtil, private val clickAction: ((BookOnDisk) -> Unit)?, private val longClickAction: ((BookOnDisk) -> Unit)?, private val multiSelectAction: ((BookOnDisk) -> Unit)? @@ -72,14 +69,7 @@ sealed class BookOnDiskViewHolder(containerView: Vie item_book_icon.setBitmap(Base64String(book.favicon)) - val path = item.file.path - if (path.contains("nopic")) { - item_book_label_picture.visibility = View.GONE - item_book_label_video.visibility = View.GONE - } - if (path.contains("novid")) { - item_book_label_video.visibility = View.GONE - } + tags.render(item.tags) itemBookCheckbox.isChecked = item.isSelected when (selectionMode) { diff --git a/core/src/main/res/drawable/border_label_picture.xml b/core/src/main/res/drawable/border_label_picture.xml deleted file mode 100644 index e668af0a0..000000000 --- a/core/src/main/res/drawable/border_label_picture.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/core/src/main/res/drawable/border_label_video.xml b/core/src/main/res/drawable/border_label_video.xml deleted file mode 100644 index 4d1815a83..000000000 --- a/core/src/main/res/drawable/border_label_video.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/core/src/main/res/layout/item_book.xml b/core/src/main/res/layout/item_book.xml index 00c4b4911..faaee0312 100644 --- a/core/src/main/res/layout/item_book.xml +++ b/core/src/main/res/layout/item_book.xml @@ -98,35 +98,14 @@ app:layout_constraintTop_toBottomOf="@id/item_book_date" tools:text="All wikipedia articles" /> - - - + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="@+id/item_book_description" + app:layout_constraintTop_toBottomOf="@id/item_book_description" + app:singleLine="true" /> + app:layout_constraintTop_toBottomOf="@id/tags" /> + + + + + + + + + + diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index 8a32a12b6..2dc973739 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -9,8 +9,6 @@ #5a5a5a #808080 #ECEFF1 - #fb8c00 - #651FFF #1565c0 #962e7ac4 #4285F4 diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 5a4ca38af..3272e36bf 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -285,6 +285,10 @@ Status Clears all notes on all articles Clear all notes + Pic + Vid + Text Only + Short Text Only On Off diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml index 25a7c5a9e..925310198 100644 --- a/core/src/main/res/values/styles.xml +++ b/core/src/main/res/values/styles.xml @@ -33,6 +33,10 @@ @color/white + +