mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-23 23:21:11 +01:00
Popup to show long pressing a category name can edit it
This commit is contained in:
parent
cdf2a16731
commit
8f63243d9f
@ -269,4 +269,6 @@ class PreferencesHelper(val context: Context) {
|
|||||||
fun shownChapterSwipeTutorial() = flowPrefs.getBoolean("shown_swipe_tutorial", false)
|
fun shownChapterSwipeTutorial() = flowPrefs.getBoolean("shown_swipe_tutorial", false)
|
||||||
|
|
||||||
fun shownDownloadQueueTutorial() = flowPrefs.getBoolean("shown_download_queue", false)
|
fun shownDownloadQueueTutorial() = flowPrefs.getBoolean("shown_download_queue", false)
|
||||||
|
|
||||||
|
fun shownLongPressCategoryTutorial() = flowPrefs.getBoolean("shown_long_press_category", false)
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package eu.kanade.tachiyomi.ui.library
|
package eu.kanade.tachiyomi.ui.library
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.Activity
|
||||||
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
import android.text.style.ForegroundColorSpan
|
import android.text.style.ForegroundColorSpan
|
||||||
|
import android.util.TypedValue
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
@ -15,6 +18,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.f2prateek.rx.preferences.Preference
|
import com.f2prateek.rx.preferences.Preference
|
||||||
|
import com.github.florent37.viewtooltip.ViewTooltip
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.flexibleadapter.SelectableAdapter
|
import eu.davidea.flexibleadapter.SelectableAdapter
|
||||||
import eu.davidea.flexibleadapter.items.AbstractHeaderItem
|
import eu.davidea.flexibleadapter.items.AbstractHeaderItem
|
||||||
@ -22,6 +26,7 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Category
|
import eu.kanade.tachiyomi.data.database.models.Category
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
@ -32,6 +37,8 @@ import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
|||||||
import eu.kanade.tachiyomi.util.view.visInvisIf
|
import eu.kanade.tachiyomi.util.view.visInvisIf
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
import kotlinx.android.synthetic.main.library_category_header_item.*
|
import kotlinx.android.synthetic.main.library_category_header_item.*
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
class LibraryHeaderItem(
|
class LibraryHeaderItem(
|
||||||
private val categoryF: (Int) -> Category,
|
private val categoryF: (Int) -> Category,
|
||||||
@ -97,22 +104,33 @@ class LibraryHeaderItem(
|
|||||||
sortText.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
sortText.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
marginEnd = (if (padEnd && adapter.recyclerView.paddingEnd == 0) 12 else 2).dpToPx
|
marginEnd = (if (padEnd && adapter.recyclerView.paddingEnd == 0) 12 else 2).dpToPx
|
||||||
}
|
}
|
||||||
category_header_layout.setOnClickListener {
|
category_header_layout.setOnClickListener { toggleCategory() }
|
||||||
adapter.libraryListener.toggleCategoryVisibility(adapterPosition)
|
|
||||||
}
|
|
||||||
updateButton.setOnClickListener { addCategoryToUpdate() }
|
updateButton.setOnClickListener { addCategoryToUpdate() }
|
||||||
sectionText.setOnLongClickListener {
|
sectionText.setOnLongClickListener {
|
||||||
adapter.libraryListener.manageCategory(adapterPosition)
|
adapter.libraryListener.manageCategory(adapterPosition)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
sectionText.setOnClickListener {
|
sectionText.setOnClickListener { toggleCategory() }
|
||||||
adapter.libraryListener.toggleCategoryVisibility(adapterPosition)
|
|
||||||
}
|
|
||||||
sortText.setOnClickListener { it.post { showCatSortOptions() } }
|
sortText.setOnClickListener { it.post { showCatSortOptions() } }
|
||||||
checkboxImage.setOnClickListener { selectAll() }
|
checkboxImage.setOnClickListener { selectAll() }
|
||||||
updateButton.drawable.mutate()
|
updateButton.drawable.mutate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun toggleCategory() {
|
||||||
|
adapter.libraryListener.toggleCategoryVisibility(adapterPosition)
|
||||||
|
val tutorial = Injekt.get<PreferencesHelper>().shownLongPressCategoryTutorial()
|
||||||
|
if (!tutorial.get()) {
|
||||||
|
ViewTooltip.on(itemView.context as? Activity, sectionText).autoHide(true, 5000L)
|
||||||
|
.align(ViewTooltip.ALIGN.START).position(ViewTooltip.Position.TOP)
|
||||||
|
.text(R.string.long_press_category)
|
||||||
|
.color(itemView.context.getResourceColor(R.attr.colorAccent))
|
||||||
|
.textSize(TypedValue.COMPLEX_UNIT_SP, 15f).textColor(Color.WHITE)
|
||||||
|
.withShadow(false).corner(30).arrowWidth(15).arrowHeight(15).distanceWithView(0)
|
||||||
|
.show()
|
||||||
|
tutorial.set(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun bind(item: LibraryHeaderItem) {
|
fun bind(item: LibraryHeaderItem) {
|
||||||
val index = adapter.headerItems.indexOf(item)
|
val index = adapter.headerItems.indexOf(item)
|
||||||
val previousIsCollapsed =
|
val previousIsCollapsed =
|
||||||
|
@ -36,15 +36,4 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="@style/Theme.Widget.Button.TextButton"
|
style="@style/Theme.Widget.Button.TextButton"
|
||||||
android:text="@string/edit_categories"/>
|
android:text="@string/edit_categories"/>
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:layout_marginTop="6dp"
|
|
||||||
android:layout_marginStart="12dp"
|
|
||||||
android:layout_marginEnd="12dp"
|
|
||||||
android:textColor="?android:attr/textColorHint"
|
|
||||||
android:text="@string/tip_long_press_category"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -91,8 +91,7 @@
|
|||||||
</plurals>
|
</plurals>
|
||||||
<string name="category_with_name_exists">A category with that name already exists!</string>
|
<string name="category_with_name_exists">A category with that name already exists!</string>
|
||||||
<string name="category_deleted">Category deleted</string>
|
<string name="category_deleted">Category deleted</string>
|
||||||
<string name="tip_long_press_category">Tip: Press and hold a category\'s name to collapse
|
<string name="long_press_category">Press and hold to edit a category</string>
|
||||||
section</string>
|
|
||||||
|
|
||||||
<!-- Updates -->
|
<!-- Updates -->
|
||||||
<string name="update">Update</string>
|
<string name="update">Update</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user