mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 10:35:19 +00:00
Add path status indicator glow
This commit is contained in:
parent
b57e94b943
commit
b3e672a9ed
@ -101,6 +101,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
||||
profileButton.publicKey = publicKey
|
||||
profileButton.update()
|
||||
profileButton.setOnClickListener { openSettings() }
|
||||
pathStatusViewContainer.disableClipping()
|
||||
pathStatusViewContainer.setOnClickListener { showPath() }
|
||||
// Set up seed reminder view
|
||||
val isMasterDevice = (TextSecurePreferences.getMasterHexEncodedPublicKey(this) == null)
|
||||
|
@ -4,14 +4,30 @@ import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Paint
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.annotation.ColorInt
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.loki.utilities.getColorWithID
|
||||
import org.thoughtcrime.securesms.loki.utilities.toPx
|
||||
import org.whispersystems.signalservice.loki.api.onionrequests.OnionRequestAPI
|
||||
|
||||
class PathStatusView : View {
|
||||
private val broadcastReceivers = mutableListOf<BroadcastReceiver>()
|
||||
@ColorInt var mainColor: Int = 0
|
||||
set(newValue) { field = newValue; paint.color = newValue }
|
||||
@ColorInt var sessionShadowColor: Int = 0
|
||||
set(newValue) { field = newValue; paint.setShadowLayer(toPx(8, 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
|
||||
}
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
initialize()
|
||||
@ -31,6 +47,7 @@ class PathStatusView : View {
|
||||
|
||||
private fun initialize() {
|
||||
update()
|
||||
setWillNotDraw(false)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
@ -70,8 +87,19 @@ class PathStatusView : View {
|
||||
private fun update() {
|
||||
if (OnionRequestAPI.paths.count() >= OnionRequestAPI.pathCount) {
|
||||
setBackgroundResource(R.drawable.accent_dot)
|
||||
mainColor = resources.getColorWithID(R.color.accent, context.theme)
|
||||
sessionShadowColor = resources.getColorWithID(R.color.accent, context.theme)
|
||||
} else {
|
||||
setBackgroundResource(R.drawable.paths_building_dot)
|
||||
mainColor = resources.getColorWithID(R.color.paths_building, context.theme)
|
||||
sessionShadowColor = resources.getColorWithID(R.color.paths_building, context.theme)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user