mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-12 17:53:39 +00:00
Add path dot glow
This commit is contained in:
parent
b3e672a9ed
commit
8a8fdb4c54
@ -23,7 +23,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_margin="@dimen/large_spacing">
|
android:layout_margin="@dimen/large_spacing"
|
||||||
|
android:clipChildren="false">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/pathRowsContainer"
|
android:id="@+id/pathRowsContainer"
|
||||||
|
@ -16,10 +16,13 @@ import android.widget.LinearLayout
|
|||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.annotation.ColorRes
|
||||||
import kotlinx.android.synthetic.main.activity_path.*
|
import kotlinx.android.synthetic.main.activity_path.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||||
import org.thoughtcrime.securesms.loki.utilities.*
|
import org.thoughtcrime.securesms.loki.utilities.*
|
||||||
|
import org.thoughtcrime.securesms.loki.views.GlowViewUtilities
|
||||||
|
import org.thoughtcrime.securesms.loki.views.PathDotView
|
||||||
import org.whispersystems.signalservice.loki.api.Snode
|
import org.whispersystems.signalservice.loki.api.Snode
|
||||||
import org.whispersystems.signalservice.loki.api.onionrequests.OnionRequestAPI
|
import org.whispersystems.signalservice.loki.api.onionrequests.OnionRequestAPI
|
||||||
|
|
||||||
@ -31,6 +34,7 @@ class PathActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
super.onCreate(savedInstanceState, isReady)
|
super.onCreate(savedInstanceState, isReady)
|
||||||
setContentView(R.layout.activity_path)
|
setContentView(R.layout.activity_path)
|
||||||
supportActionBar!!.title = resources.getString(R.string.activity_path_title)
|
supportActionBar!!.title = resources.getString(R.string.activity_path_title)
|
||||||
|
pathRowsContainer.disableClipping()
|
||||||
learnMoreButton.setOnClickListener { learnMore() }
|
learnMoreButton.setOnClickListener { learnMore() }
|
||||||
update(false)
|
update(false)
|
||||||
registerObservers()
|
registerObservers()
|
||||||
@ -111,6 +115,7 @@ class PathActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
val mainContainer = LinearLayout(this)
|
val mainContainer = LinearLayout(this)
|
||||||
mainContainer.orientation = LinearLayout.HORIZONTAL
|
mainContainer.orientation = LinearLayout.HORIZONTAL
|
||||||
mainContainer.gravity = Gravity.CENTER_VERTICAL
|
mainContainer.gravity = Gravity.CENTER_VERTICAL
|
||||||
|
mainContainer.disableClipping()
|
||||||
val mainContainerLayoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)
|
val mainContainerLayoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)
|
||||||
mainContainer.layoutParams = mainContainerLayoutParams
|
mainContainer.layoutParams = mainContainerLayoutParams
|
||||||
val lineView = LineView(this, location, dotAnimationStartDelay, dotAnimationRepeatInterval)
|
val lineView = LineView(this, location, dotAnimationStartDelay, dotAnimationRepeatInterval)
|
||||||
@ -170,8 +175,9 @@ class PathActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
private var dotAnimationRepeatInterval: Long = 0
|
private var dotAnimationRepeatInterval: Long = 0
|
||||||
|
|
||||||
private val dotView by lazy {
|
private val dotView by lazy {
|
||||||
val result = View(context)
|
val result = PathDotView(context)
|
||||||
result.setBackgroundResource(R.drawable.accent_dot)
|
result.setBackgroundResource(R.drawable.accent_dot)
|
||||||
|
result.mainColor = resources.getColorWithID(R.color.accent, context.theme)
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,6 +209,7 @@ class PathActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpViewHierarchy() {
|
private fun setUpViewHierarchy() {
|
||||||
|
disableClipping()
|
||||||
val lineView = View(context)
|
val lineView = View(context)
|
||||||
lineView.setBackgroundColor(resources.getColorWithID(R.color.text, context.theme))
|
lineView.setBackgroundColor(resources.getColorWithID(R.color.text, context.theme))
|
||||||
val lineViewHeight = when (location) {
|
val lineViewHeight = when (location) {
|
||||||
@ -239,10 +246,14 @@ class PathActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
|
|
||||||
private fun expand() {
|
private fun expand() {
|
||||||
dotView.animateSizeChange(R.dimen.path_row_dot_size, R.dimen.path_row_expanded_dot_size)
|
dotView.animateSizeChange(R.dimen.path_row_dot_size, R.dimen.path_row_expanded_dot_size)
|
||||||
|
@ColorRes val startColorID = if (UiModeUtilities.isDayUiMode(context)) R.color.transparent_black_30 else R.color.black
|
||||||
|
GlowViewUtilities.animateShadowColorChange(context, dotView, startColorID, R.color.accent)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun collapse() {
|
private fun collapse() {
|
||||||
dotView.animateSizeChange(R.dimen.path_row_expanded_dot_size, R.dimen.path_row_dot_size)
|
dotView.animateSizeChange(R.dimen.path_row_expanded_dot_size, R.dimen.path_row_dot_size)
|
||||||
|
@ColorRes val endColorID = if (UiModeUtilities.isDayUiMode(context)) R.color.transparent_black_30 else R.color.black
|
||||||
|
GlowViewUtilities.animateShadowColorChange(context, dotView, R.color.accent, endColorID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
@ -92,10 +92,43 @@ class PNModeView : LinearLayout, GlowView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class NewConversationButtonImageView : androidx.appcompat.widget.AppCompatImageView, GlowView {
|
class NewConversationButtonImageView : androidx.appcompat.widget.AppCompatImageView, GlowView {
|
||||||
|
@ColorInt override var mainColor: Int = 0
|
||||||
|
set(newValue) { field = newValue; paint.color = newValue }
|
||||||
|
@ColorInt override var sessionShadowColor: Int = 0
|
||||||
|
set(newValue) { field = newValue; paint.setShadowLayer(toPx(6, resources).toFloat(), 0.0f, 0.0f, newValue) }
|
||||||
|
|
||||||
|
private val paint: Paint by lazy {
|
||||||
|
val result = Paint()
|
||||||
|
result.style = Paint.Style.FILL
|
||||||
|
result.isAntiAlias = true
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
// region Lifecycle
|
||||||
|
constructor(context: Context) : super(context) { }
|
||||||
|
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { }
|
||||||
|
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { }
|
||||||
|
|
||||||
|
init {
|
||||||
|
setWillNotDraw(false)
|
||||||
|
}
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
// region Updating
|
||||||
|
override fun onDraw(c: Canvas) {
|
||||||
|
val w = width.toFloat()
|
||||||
|
val h = height.toFloat()
|
||||||
|
c.drawCircle(w / 2, h / 2, w / 2, paint)
|
||||||
|
super.onDraw(c)
|
||||||
|
}
|
||||||
|
// endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
class PathDotView : View, GlowView {
|
||||||
@ColorInt override var mainColor: Int = 0
|
@ColorInt override var mainColor: Int = 0
|
||||||
set(newValue) { field = newValue; paint.color = newValue }
|
set(newValue) { field = newValue; paint.color = newValue }
|
||||||
@ColorInt override var sessionShadowColor: Int = 0
|
@ColorInt override var sessionShadowColor: Int = 0
|
||||||
set(newValue) { field = newValue; paint.setShadowLayer(toPx(6, resources).toFloat(), 0.0f, 0.0f, newValue) }
|
set(newValue) { field = newValue; paint.setShadowLayer(toPx(4, resources).toFloat(), 0.0f, 0.0f, newValue) }
|
||||||
|
|
||||||
private val paint: Paint by lazy {
|
private val paint: Paint by lazy {
|
||||||
val result = Paint()
|
val result = Paint()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user