Closes #1803: remove text for swipe delete
parent
cef6c11fb5
commit
d1c2ed2052
|
@ -4,17 +4,15 @@
|
||||||
|
|
||||||
package org.mozilla.fenix.home.sessioncontrol
|
package org.mozilla.fenix.home.sessioncontrol
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
import android.graphics.Paint
|
import android.graphics.drawable.Drawable
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import io.reactivex.Observer
|
import io.reactivex.Observer
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.TabViewHolder
|
import org.mozilla.fenix.home.sessioncontrol.viewholders.TabViewHolder
|
||||||
import android.graphics.drawable.Drawable
|
|
||||||
|
|
||||||
class SwipeToDeleteCallback(
|
class SwipeToDeleteCallback(
|
||||||
val actionEmitter: Observer<SessionControlAction>
|
val actionEmitter: Observer<SessionControlAction>
|
||||||
|
@ -72,7 +70,7 @@ class SwipeToDeleteCallback(
|
||||||
itemView.bottom
|
itemView.bottom
|
||||||
)
|
)
|
||||||
icon.setBounds(iconLeft, iconTop, iconRight, iconBottom)
|
icon.setBounds(iconLeft, iconTop, iconRight, iconBottom)
|
||||||
draw(background, icon, c, recyclerView.context, iconLeft, iconBottom)
|
draw(background, icon, c)
|
||||||
}
|
}
|
||||||
dX < 0 -> { // Swiping to the left
|
dX < 0 -> { // Swiping to the left
|
||||||
iconLeft = itemView.right - margin - iconWidth
|
iconLeft = itemView.right - margin - iconWidth
|
||||||
|
@ -82,7 +80,7 @@ class SwipeToDeleteCallback(
|
||||||
itemView.top, itemView.right, itemView.bottom
|
itemView.top, itemView.right, itemView.bottom
|
||||||
)
|
)
|
||||||
icon.setBounds(iconLeft, iconTop, iconRight, iconBottom)
|
icon.setBounds(iconLeft, iconTop, iconRight, iconBottom)
|
||||||
draw(background, icon, c, recyclerView.context, iconLeft, iconBottom)
|
draw(background, icon, c)
|
||||||
}
|
}
|
||||||
else -> { // View not swiped
|
else -> { // View not swiped
|
||||||
background.setBounds(0, 0, 0, 0)
|
background.setBounds(0, 0, 0, 0)
|
||||||
|
@ -105,36 +103,16 @@ class SwipeToDeleteCallback(
|
||||||
companion object {
|
companion object {
|
||||||
const val BACKGROUND_CORNER_OFFSET = 40
|
const val BACKGROUND_CORNER_OFFSET = 40
|
||||||
const val MARGIN = 32
|
const val MARGIN = 32
|
||||||
const val TEXT_MARGIN = 12
|
|
||||||
const val TEXT_SIZE = 36f
|
|
||||||
const val TEXT_MARGIN_X = 14
|
|
||||||
const val DENSITY_CONVERSION = 160f
|
const val DENSITY_CONVERSION = 160f
|
||||||
|
|
||||||
@Suppress("LongParameterList")
|
@Suppress("LongParameterList")
|
||||||
private fun draw(
|
private fun draw(
|
||||||
background: Drawable,
|
background: Drawable,
|
||||||
icon: Drawable,
|
icon: Drawable,
|
||||||
c: Canvas,
|
c: Canvas
|
||||||
context: Context,
|
|
||||||
iconLeft: Int,
|
|
||||||
iconBottom: Int
|
|
||||||
) {
|
) {
|
||||||
background.draw(c)
|
background.draw(c)
|
||||||
icon.draw(c)
|
icon.draw(c)
|
||||||
val textPaint = Paint()
|
|
||||||
textPaint.color = ContextCompat.getColor(
|
|
||||||
context,
|
|
||||||
R.color.delete_color
|
|
||||||
)
|
|
||||||
textPaint.textSize = TEXT_SIZE
|
|
||||||
val textX = iconLeft - TEXT_MARGIN_X
|
|
||||||
val textY = iconBottom + convertDpToPixel(TEXT_MARGIN.toFloat())
|
|
||||||
c.drawText(
|
|
||||||
context.getString(R.string.current_session_delete),
|
|
||||||
textX.toFloat(),
|
|
||||||
textY.toFloat(),
|
|
||||||
textPaint
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun convertDpToPixel(dp: Float): Int {
|
private fun convertDpToPixel(dp: Float): Int {
|
||||||
|
|
Loading…
Reference in New Issue