mirror of
https://github.com/oxen-io/session-android.git
synced 2023-12-14 02:53:01 +01:00
* feat: Menu redesign * Add bottomsheet * Handle default peek height * Smooth out setting peek height * Move contacts prep to util * Dialog layout tweaks * Contact grouping tweaks * Add new message dialog * Add public key input delegate * Add create group dialog * Add join community dialog * Handle dialog back navigation * Enter community url tab tweaks * Scan QR code tab refactor * Scan qr code refactor * Direct and community tabs refactor * Add session id copy context menu item * Set dialog background colours * Set full dialog background colour * Minor tweaks * Add closed group contact search * Cleanup * Add content descriptions * Resize community chips * Fix new conversation screen paddings * Fix fade in/out of join community screen * Prevent creating conversation with empty public key * Resize and position create group loader * Fix back nav after creating direct message conversation * Fix inter-screen transitions * Fix new conversation background colours * Fix background colours * Rename contact list header for clarity * Bug fixes * Enable scrolling of Enter Session ID tab of the new message dialog * Minor refactor * Switch to child fragment manager * Fix member search on create group screen Co-authored-by: charles <charles@oxen.io>
62 lines
2 KiB
Kotlin
62 lines
2 KiB
Kotlin
package org.thoughtcrime.securesms.util
|
|
|
|
import android.animation.Animator
|
|
import android.animation.AnimatorListenerAdapter
|
|
import android.animation.FloatEvaluator
|
|
import android.animation.ValueAnimator
|
|
import android.content.Context
|
|
import android.graphics.PointF
|
|
import android.graphics.Rect
|
|
import androidx.annotation.DimenRes
|
|
import android.view.View
|
|
import android.view.inputmethod.InputMethodManager
|
|
|
|
fun View.contains(point: PointF): Boolean {
|
|
return hitRect.contains(point.x.toInt(), point.y.toInt())
|
|
}
|
|
|
|
val View.hitRect: Rect
|
|
get() {
|
|
val rect = Rect()
|
|
getHitRect(rect)
|
|
return rect
|
|
}
|
|
|
|
fun View.animateSizeChange(@DimenRes startSizeID: Int, @DimenRes endSizeID: Int, animationDuration: Long = 250) {
|
|
val startSize = resources.getDimension(startSizeID)
|
|
val endSize = resources.getDimension(endSizeID)
|
|
animateSizeChange(startSize, endSize)
|
|
}
|
|
|
|
fun View.animateSizeChange(startSize: Float, endSize: Float, animationDuration: Long = 250) {
|
|
val layoutParams = this.layoutParams
|
|
val animation = ValueAnimator.ofObject(FloatEvaluator(), startSize, endSize)
|
|
animation.duration = animationDuration
|
|
animation.addUpdateListener { animator ->
|
|
val size = animator.animatedValue as Float
|
|
layoutParams.width = size.toInt()
|
|
layoutParams.height = size.toInt()
|
|
this.layoutParams = layoutParams
|
|
}
|
|
animation.start()
|
|
}
|
|
|
|
fun View.fadeIn(duration: Long = 150) {
|
|
visibility = View.VISIBLE
|
|
animate().setDuration(duration).alpha(1.0f).start()
|
|
}
|
|
|
|
fun View.fadeOut(duration: Long = 150) {
|
|
animate().setDuration(duration).alpha(0.0f).setListener(object : AnimatorListenerAdapter() {
|
|
override fun onAnimationEnd(animation: Animator?) {
|
|
super.onAnimationEnd(animation)
|
|
visibility = View.GONE
|
|
}
|
|
})
|
|
}
|
|
|
|
fun View.hideKeyboard() {
|
|
val imm = this.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
|
imm.hideSoftInputFromWindow(this.windowToken, 0)
|
|
}
|