Use swipe right both to enable and disable codec
This commit is contained in:
@@ -68,16 +68,6 @@ class CodecsActivity : AppCompatActivity() {
|
|||||||
codecList.layoutManager = LinearLayoutManager(this)
|
codecList.layoutManager = LinearLayoutManager(this)
|
||||||
codecList.adapter = codecsAdapter
|
codecList.adapter = codecsAdapter
|
||||||
|
|
||||||
codecsAdapter.setOnItemClickListener(object : CodecsAdapter.OnItemClickListener {
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
|
||||||
override fun onItemClick(position: Int) {
|
|
||||||
if (!newCodecs[position].enabled) {
|
|
||||||
codecsAdapter.enableItem(position)
|
|
||||||
codecsAdapter.notifyDataSetChanged()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
itemTouchHelper.attachToRecyclerView(binding.CodecList)
|
itemTouchHelper.attachToRecyclerView(binding.CodecList)
|
||||||
|
|
||||||
codecsTitle.setOnClickListener {
|
codecsTitle.setOnClickListener {
|
||||||
@@ -93,9 +83,8 @@ class CodecsActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private val itemTouchHelper by lazy {
|
private val itemTouchHelper by lazy {
|
||||||
val simpleItemTouchCallback = object : ItemTouchHelper.SimpleCallback(
|
val simpleItemTouchCallback = object : ItemTouchHelper.SimpleCallback(
|
||||||
UP or DOWN or START or END,
|
UP or DOWN or START or END, RIGHT) {
|
||||||
RIGHT
|
|
||||||
) {
|
|
||||||
override fun onMove(
|
override fun onMove(
|
||||||
recyclerView: RecyclerView,
|
recyclerView: RecyclerView,
|
||||||
viewHolder: RecyclerView.ViewHolder,
|
viewHolder: RecyclerView.ViewHolder,
|
||||||
@@ -108,9 +97,16 @@ class CodecsActivity : AppCompatActivity() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
|
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
|
||||||
codecsAdapter.removeItem(viewHolder.adapterPosition)
|
val position = viewHolder.adapterPosition
|
||||||
codecsAdapter.notifyItemRemoved(viewHolder.adapterPosition)
|
if (newCodecs[position].enabled) {
|
||||||
|
codecsAdapter.disableItem(position)
|
||||||
|
codecsAdapter.notifyItemRemoved(position)
|
||||||
|
} else {
|
||||||
|
codecsAdapter.enableItem(position)
|
||||||
|
codecsAdapter.notifyDataSetChanged()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
|||||||
@@ -11,19 +11,9 @@ import java.util.*
|
|||||||
class CodecsAdapter(private val codecs: ArrayList<Codec>):
|
class CodecsAdapter(private val codecs: ArrayList<Codec>):
|
||||||
RecyclerView.Adapter<CodecsAdapter.CodecViewHolder>() {
|
RecyclerView.Adapter<CodecsAdapter.CodecViewHolder>() {
|
||||||
|
|
||||||
private var codecListener: OnItemClickListener? = null
|
|
||||||
|
|
||||||
interface OnItemClickListener {
|
|
||||||
fun onItemClick(position: Int)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setOnItemClickListener(listener: OnItemClickListener) {
|
|
||||||
codecListener = listener
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CodecViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CodecViewHolder {
|
||||||
val v = LayoutInflater.from(parent.context).inflate(R.layout.codec, parent, false)
|
val v = LayoutInflater.from(parent.context).inflate(R.layout.codec, parent, false)
|
||||||
return CodecViewHolder(v, codecListener!!)
|
return CodecViewHolder(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
@@ -37,7 +27,14 @@ class CodecsAdapter(private val codecs: ArrayList<Codec>):
|
|||||||
codecs.add(toPosition, codec)
|
codecs.add(toPosition, codec)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun removeItem(position: Int) {
|
fun enableItem(position: Int) {
|
||||||
|
val codec: Codec = codecs[position]
|
||||||
|
codec.enabled = true
|
||||||
|
codecs.removeAt(position)
|
||||||
|
codecs.add(0, codec)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun disableItem(position: Int) {
|
||||||
val codec: Codec = codecs[position]
|
val codec: Codec = codecs[position]
|
||||||
if (codec.enabled) {
|
if (codec.enabled) {
|
||||||
codec.enabled = false
|
codec.enabled = false
|
||||||
@@ -46,33 +43,17 @@ class CodecsAdapter(private val codecs: ArrayList<Codec>):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun enableItem(position: Int) {
|
|
||||||
val codec: Codec = codecs[position]
|
|
||||||
codec.enabled = true
|
|
||||||
codecs.removeAt(position)
|
|
||||||
codecs.add(0, codec)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: CodecViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: CodecViewHolder, position: Int) {
|
||||||
val codec = codecs[position]
|
val codec = codecs[position]
|
||||||
holder.codecName.text = codec.name
|
holder.codecName.text = codec.name
|
||||||
holder.codecName.alpha = if (codec.enabled) 1.0f else 0.5f
|
holder.codecName.alpha = if (codec.enabled) 1.0f else 0.5f
|
||||||
holder.actionImage.setImageResource(
|
holder.reorderImage.setImageResource(
|
||||||
if (codec.enabled) R.drawable.reorder else R.drawable.add
|
if (codec.enabled) R.drawable.reorder else android.R.color.transparent
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
class CodecViewHolder(itemView: View, listener: OnItemClickListener):
|
class CodecViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) {
|
||||||
RecyclerView.ViewHolder(itemView) {
|
|
||||||
var codecName: TextView = itemView.findViewById(R.id.codecName)
|
var codecName: TextView = itemView.findViewById(R.id.codecName)
|
||||||
var actionImage: ImageView = itemView.findViewById(R.id.actionImage)
|
var reorderImage: ImageView = itemView.findViewById(R.id.reorderImage)
|
||||||
init {
|
|
||||||
itemView.setOnClickListener {
|
|
||||||
val position = adapterPosition
|
|
||||||
if (position != RecyclerView.NO_POSITION) {
|
|
||||||
listener.onItemClick(position)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -240,6 +240,7 @@
|
|||||||
android:hint="@string/dtmf"
|
android:hint="@string/dtmf"
|
||||||
android:importantForAutofill="no"
|
android:importantForAutofill="no"
|
||||||
android:inputType="phone"
|
android:inputType="phone"
|
||||||
|
android:digits="0123456789#*"
|
||||||
android:textSize="20sp" >
|
android:textSize="20sp" >
|
||||||
</EditText>
|
</EditText>
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/actionImage"
|
android:id="@+id/reorderImage"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
|||||||
@@ -287,15 +287,14 @@
|
|||||||
<string name="delete_chats_alert">Haluatko tyhjentää tilin \'%1$s\' viestihistorian\?</string>
|
<string name="delete_chats_alert">Haluatko tyhjentää tilin \'%1$s\' viestihistorian\?</string>
|
||||||
<!-- Codecs Activity -->
|
<!-- Codecs Activity -->
|
||||||
<string name="audio_codecs">Audion koodausmenetelmät</string>
|
<string name="audio_codecs">Audion koodausmenetelmät</string>
|
||||||
<string name="audio_codecs_help">Luettelo käytössä olevista audion
|
<string name="audio_codecs_help">Luettelo audion koodausmenetelmistä prioriteettijärjestyksessä.
|
||||||
koodausmenetelmistä prioriteettijärjestyksessä. Ota käyttöön koskettamalla,
|
Järjestä raahaamalla ja pudottamalla, ota käyttöön tai poista käytöstä pyyhkäisemällä oikealle.
|
||||||
järjestä vetämällä ja pudottamalla, poista käytöstä pyyhkäisemällä oikealle.</string>
|
</string>
|
||||||
<string name="video_codecs">Videon koodausmenetelmät</string>
|
<string name="video_codecs">Videon koodausmenetelmät</string>
|
||||||
<string name="video_codecs_help">Luettelo käytössä olevista videon
|
<string name="video_codecs_help">Luettelo videon koodausmenetelmistä prioriteettijärjestyksessä.
|
||||||
koodausmenetelmistä prioriteettijärjestyksessä. Ota käyttöön koskettamalla,
|
Järjestä raahaamalla ja pudottamalla, ota käyttöön tai poista käytöstä pyyhkäisemällä oikealle.
|
||||||
järjestä vetämällä ja pudottamalla, poista käytöstä pyyhkäisemällä oikealle.</string>
|
</string>
|
||||||
<string name="codec_action">Koodausmenetelmä toiminto (ota käyttöön, järjestä, poista
|
<string name="codec_action">Järjestä</string>
|
||||||
käytöstä)</string>
|
|
||||||
<!-- Config Activity -->
|
<!-- Config Activity -->
|
||||||
<string name="configuration">Asetukset</string>
|
<string name="configuration">Asetukset</string>
|
||||||
<string name="start_automatically">Käynnistä automaattisesti</string>
|
<string name="start_automatically">Käynnistä automaattisesti</string>
|
||||||
|
|||||||
@@ -279,12 +279,12 @@
|
|||||||
<string name="delete_chats_alert">Do you want to delete chat history of account \'%1$s\'\?</string>
|
<string name="delete_chats_alert">Do you want to delete chat history of account \'%1$s\'\?</string>
|
||||||
<!-- Codecs Activity -->
|
<!-- Codecs Activity -->
|
||||||
<string name="audio_codecs">Audio Codecs</string>
|
<string name="audio_codecs">Audio Codecs</string>
|
||||||
<string name="audio_codecs_help">List of enabled audio codecs in priority order. Click to enable,
|
<string name="audio_codecs_help">List of audio codecs in priority order. Drag to reorder,
|
||||||
drag to reorder, swipe right to disable.</string>
|
swipe right to enable or disable.</string>
|
||||||
<string name="video_codecs">Video Codecs</string>
|
<string name="video_codecs">Video Codecs</string>
|
||||||
<string name="video_codecs_help">List of enabled video codecs in priority order. Click to enable,
|
<string name="video_codecs_help">List of video codecs in priority order. Drag to reorder,
|
||||||
drag to reorder, swipe right to disable.</string>
|
swipe right to enable or disable.</string>
|
||||||
<string name="codec_action">Codec action (enable, reorder, disable)</string>
|
<string name="codec_action">Reorder</string>
|
||||||
<!-- Config Activity -->
|
<!-- Config Activity -->
|
||||||
<string name="configuration">Settings</string>
|
<string name="configuration">Settings</string>
|
||||||
<string name="start_automatically">Start Automatically</string>
|
<string name="start_automatically">Start Automatically</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user