mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-18 03:48:52 +01:00
attachment context menu for save, share, forward and open externally
remove share icons from audio and file attachment types add forward and open externally to gallery menu so it matches attachment context menu new icon/button for resend message
This commit is contained in:
@@ -39,7 +39,7 @@ import javax.inject.Inject
|
||||
|
||||
data class MenuItem(val title: String, val actionId: Int)
|
||||
|
||||
class MenuItemAdapter @Inject constructor(private val context: Context, private val colors: Colors) : QkAdapter<MenuItem>() {
|
||||
class MenuItemAdapter @Inject constructor(private val context: Context, private val colors: Colors) : QkAdapter<MenuItem, QkViewHolder>() {
|
||||
|
||||
val menuItemClicks: Subject<Int> = PublishSubject.create()
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import io.reactivex.disposables.Disposable
|
||||
* Base RecyclerView.Adapter that provides some convenience when creating a new Adapter, such as
|
||||
* data list handing and item animations
|
||||
*/
|
||||
abstract class FlowableAdapter<T> : QkAdapter<T>() {
|
||||
abstract class FlowableAdapter<T> : QkAdapter<T, QkViewHolder>() {
|
||||
|
||||
var flowable: Flowable<List<T>>? = null
|
||||
set(value) {
|
||||
|
||||
@@ -30,7 +30,7 @@ import io.reactivex.subjects.Subject
|
||||
* Base RecyclerView.Adapter that provides some convenience when creating a new Adapter, such as
|
||||
* data list handing and item animations
|
||||
*/
|
||||
abstract class QkAdapter<T> : RecyclerView.Adapter<QkViewHolder>() {
|
||||
abstract class QkAdapter<T, VHT : RecyclerView.ViewHolder> : RecyclerView.Adapter<VHT>() {
|
||||
|
||||
var data: List<T> = ArrayList()
|
||||
set(value) {
|
||||
|
||||
@@ -22,6 +22,6 @@ import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.android.extensions.LayoutContainer
|
||||
|
||||
class QkViewHolder(view: View) : RecyclerView.ViewHolder(view), LayoutContainer {
|
||||
open class QkViewHolder(view: View) : RecyclerView.ViewHolder(view), LayoutContainer {
|
||||
override val containerView: View = view
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package dev.octoshrimpy.quik.common.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.util.AttributeSet
|
||||
import android.view.ContextMenu
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import dev.octoshrimpy.quik.common.base.QkAdapter
|
||||
import dev.octoshrimpy.quik.common.base.QkViewHolder
|
||||
import dev.octoshrimpy.quik.model.MmsPart
|
||||
|
||||
open class QkContextMenuRecyclerView<ADAPTER_VALUE_TYPE, VIEW_HOLDER_VALUE_TYPE> : RecyclerView {
|
||||
class ViewHolder<VIEW_HOLDER_VALUE_TYPE>(view: View) : QkViewHolder(view) {
|
||||
init { itemView.isLongClickable = true }
|
||||
var contextMenuValue: VIEW_HOLDER_VALUE_TYPE? = null
|
||||
}
|
||||
|
||||
abstract class Adapter<
|
||||
ADAPTER_VALUE_TYPE,
|
||||
T,
|
||||
VHT : RecyclerView.ViewHolder
|
||||
> : QkAdapter<T, VHT>() {
|
||||
var contextMenuValue: ADAPTER_VALUE_TYPE? = null
|
||||
}
|
||||
|
||||
private var contextMenuInfo: ContextMenuInfo<
|
||||
ADAPTER_VALUE_TYPE,
|
||||
VIEW_HOLDER_VALUE_TYPE
|
||||
>? = null
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
|
||||
: super(context, attrs, defStyleAttr)
|
||||
|
||||
override fun getContextMenuInfo() = contextMenuInfo
|
||||
|
||||
override fun getChildViewHolder(child: View): ViewHolder<VIEW_HOLDER_VALUE_TYPE>? {
|
||||
return super.getChildViewHolder(child) as ViewHolder<VIEW_HOLDER_VALUE_TYPE>
|
||||
}
|
||||
|
||||
override fun showContextMenuForChild(originalView: View): Boolean {
|
||||
saveContextMenuInfo(originalView)
|
||||
return super.showContextMenuForChild(originalView)
|
||||
}
|
||||
|
||||
override fun showContextMenuForChild(originalView: View, x: Float, y: Float): Boolean {
|
||||
saveContextMenuInfo(originalView)
|
||||
return super.showContextMenuForChild(originalView, x, y)
|
||||
}
|
||||
|
||||
private fun saveContextMenuInfo(originalView: View) {
|
||||
contextMenuInfo = ContextMenuInfo(
|
||||
(adapter as Adapter<ADAPTER_VALUE_TYPE, *, *>)?.contextMenuValue,
|
||||
getChildViewHolder(originalView)?.contextMenuValue,
|
||||
this,
|
||||
originalView,
|
||||
getChildAdapterPosition(originalView),
|
||||
getChildItemId(originalView)
|
||||
)
|
||||
}
|
||||
|
||||
class ContextMenuInfo<ADAPTER_VALUE_TYPE, VIEW_HOLDER_VALUE_TYPE>(
|
||||
val adapterValue: ADAPTER_VALUE_TYPE?,
|
||||
val viewHolderValue: VIEW_HOLDER_VALUE_TYPE?,
|
||||
val recyclerView: QkContextMenuRecyclerView<ADAPTER_VALUE_TYPE, VIEW_HOLDER_VALUE_TYPE>,
|
||||
val itemView: View,
|
||||
val adapterPosition: Int,
|
||||
val childItemStableId: Long
|
||||
) : ContextMenu.ContextMenuInfo
|
||||
}
|
||||
|
||||
class QkContextMenuRecyclerViewLongMmsPart : QkContextMenuRecyclerView<Long, MmsPart> {
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
|
||||
: super(context, attrs, defStyleAttr)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ class QkDialog(private val context: Activity) : AlertDialog(context) {
|
||||
view.subtitle.isVisible = !value.isNullOrBlank()
|
||||
}
|
||||
|
||||
var adapter: QkAdapter<*>? = null
|
||||
var adapter: QkAdapter<*, *>? = null
|
||||
set(value) {
|
||||
field = value
|
||||
view.list.isVisible = value != null
|
||||
|
||||
Reference in New Issue
Block a user