<commit_before>package org.wordpress.aztec.toolbar

import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import androidx.core.content.ContextCompat
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import android.view.View.OnLongClickListener
import android.widget.Toast
import android.widget.ToggleButton
import org.wordpress.aztec.R

class RippleToggleButton : ToggleButton, OnLongClickListener {
    private var mHalfWidth: Float = 0.toFloat()
    private var mAnimationIsRunning = false
    private var mTimer = 0
    private var mFillPaint: Paint? = null
    private var mStrokePaint: Paint? = null

    constructor(context: Context) : super(context) {
        init()
    }

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
        init()
    }

    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
        init()
    }

    private fun init() {
        if (isInEditMode) {
            return
        }

        setOnLongClickListener(this)

        val rippleColor = ContextCompat.getColor(context, R.color.format_bar_ripple_animation)

        mFillPaint = Paint()
        mFillPaint!!.isAntiAlias = true
        mFillPaint!!.color = rippleColor
        mFillPaint!!.style = Paint.Style.FILL
        mFillPaint!!.alpha = FILL_INITIAL_OPACITY

        mStrokePaint = Paint()
        mStrokePaint!!.isAntiAlias = true
        mStrokePaint!!.color = rippleColor
        mStrokePaint!!.style = Paint.Style.STROKE
        mStrokePaint!!.strokeWidth = 2f
        mStrokePaint!!.alpha = STROKE_INITIAL_OPACITY

        setWillNotDraw(false)
    }

    override fun draw(canvas: Canvas) {
        super.draw(canvas)
        if (mAnimationIsRunning) {
            if (DURATION <= mTimer * FRAME_RATE) {
                mAnimationIsRunning = false
                mTimer = 0
            } else {
                val progressFraction = mTimer.toFloat() * FRAME_RATE / DURATION

                mFillPaint!!.alpha = (FILL_INITIAL_OPACITY * (1 - progressFraction)).toInt()
                mStrokePaint!!.alpha = (STROKE_INITIAL_OPACITY * (1 - progressFraction)).toInt()

                canvas.drawCircle(mHalfWidth, mHalfWidth, mHalfWidth * progressFraction, mFillPaint!!)
                canvas.drawCircle(mHalfWidth, mHalfWidth, mHalfWidth * progressFraction, mStrokePaint!!)

                mTimer++
            }

            invalidate()
        }
    }

    override fun onLongClick(view: View?): Boolean {
        if (contentDescription == null ||
            contentDescription.toString().equals("", ignoreCase = true)) {
            return false
        } else {
            Toast.makeText(context, contentDescription, Toast.LENGTH_SHORT).show()
            return true
        }
    }

    override fun onTouchEvent(event: MotionEvent): Boolean {
        startRippleAnimation()
        return super.onTouchEvent(event)
    }

    private fun startRippleAnimation() {
        if (this.isEnabled && !mAnimationIsRunning) {
            mHalfWidth = (measuredWidth / 2).toFloat()
            mAnimationIsRunning = true
            invalidate()
        }
    }

    companion object {
        private val FRAME_RATE = 10
        private val DURATION = 250
        private val FILL_INITIAL_OPACITY = 200
        private val STROKE_INITIAL_OPACITY = 255
    }
}
<commit_msg>Fix lint<commit_after>package org.wordpress.aztec.toolbar

import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import androidx.core.content.ContextCompat
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import android.view.View.OnLongClickListener
import android.widget.Toast
import androidx.appcompat.widget.AppCompatToggleButton
import org.wordpress.aztec.R

class RippleToggleButton : AppCompatToggleButton, OnLongClickListener {
    private var mHalfWidth: Float = 0.toFloat()
    private var mAnimationIsRunning = false
    private var mTimer = 0
    private var mFillPaint: Paint? = null
    private var mStrokePaint: Paint? = null

    constructor(context: Context) : super(context) {
        init()
    }

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
        init()
    }

    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
        init()
    }

    private fun init() {
        if (isInEditMode) {
            return
        }

        setOnLongClickListener(this)

        val rippleColor = ContextCompat.getColor(context, R.color.format_bar_ripple_animation)

        mFillPaint = Paint()
        mFillPaint!!.isAntiAlias = true
        mFillPaint!!.color = rippleColor
        mFillPaint!!.style = Paint.Style.FILL
        mFillPaint!!.alpha = FILL_INITIAL_OPACITY

        mStrokePaint = Paint()
        mStrokePaint!!.isAntiAlias = true
        mStrokePaint!!.color = rippleColor
        mStrokePaint!!.style = Paint.Style.STROKE
        mStrokePaint!!.strokeWidth = 2f
        mStrokePaint!!.alpha = STROKE_INITIAL_OPACITY

        setWillNotDraw(false)
    }

    override fun draw(canvas: Canvas) {
        super.draw(canvas)
        if (mAnimationIsRunning) {
            if (DURATION <= mTimer * FRAME_RATE) {
                mAnimationIsRunning = false
                mTimer = 0
            } else {
                val progressFraction = mTimer.toFloat() * FRAME_RATE / DURATION

                mFillPaint!!.alpha = (FILL_INITIAL_OPACITY * (1 - progressFraction)).toInt()
                mStrokePaint!!.alpha = (STROKE_INITIAL_OPACITY * (1 - progressFraction)).toInt()

                canvas.drawCircle(mHalfWidth, mHalfWidth, mHalfWidth * progressFraction, mFillPaint!!)
                canvas.drawCircle(mHalfWidth, mHalfWidth, mHalfWidth * progressFraction, mStrokePaint!!)

                mTimer++
            }

            invalidate()
        }
    }

    override fun onLongClick(view: View?): Boolean {
        if (contentDescription == null ||
            contentDescription.toString().equals("", ignoreCase = true)) {
            return false
        } else {
            Toast.makeText(context, contentDescription, Toast.LENGTH_SHORT).show()
            return true
        }
    }

    override fun onTouchEvent(event: MotionEvent): Boolean {
        startRippleAnimation()
        return super.onTouchEvent(event)
    }

    private fun startRippleAnimation() {
        if (this.isEnabled && !mAnimationIsRunning) {
            mHalfWidth = (measuredWidth / 2).toFloat()
            mAnimationIsRunning = true
            invalidate()
        }
    }

    companion object {
        private val FRAME_RATE = 10
        private val DURATION = 250
        private val FILL_INITIAL_OPACITY = 200
        private val STROKE_INITIAL_OPACITY = 255
    }
}

{'fraction_non_alphanumeric': 0.08808215215504774, 'fraction_numerical': 0.005206826728377205, 'mean_word_length': 2.4592296148074038, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '17865', 'n_tokens_mistral': 2081, 'n_tokens_neox': 1935, 'n_words': 409}