Implement fake chat view
parent
e46e1b2dd9
commit
3a91280b40
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="@color/accent" />
|
||||
|
||||
<corners android:radius="@dimen/fake_chat_view_bubble_corner_radius" />
|
||||
</shape>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="@color/fake_chat_bubble_background" />
|
||||
|
||||
<corners android:radius="@dimen/fake_chat_view_bubble_corner_radius" />
|
||||
</shape>
|
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/very_large_spacing"
|
||||
android:paddingRight="@dimen/very_large_spacing"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
style="@style/FakeChatViewOutgoingMessageBubble"
|
||||
android:id="@+id/bubble1"
|
||||
android:layout_width="@dimen/fake_chat_view_bubble_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_spacing"
|
||||
android:text="What's Session?"
|
||||
android:layout_gravity="right" />
|
||||
|
||||
<TextView
|
||||
style="@style/FakeChatViewIncomingMessageBubble"
|
||||
android:id="@+id/bubble2"
|
||||
android:layout_width="@dimen/fake_chat_view_bubble_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_spacing"
|
||||
android:text="It's a secure, decentralized cross-platform private messaging app"
|
||||
android:layout_gravity="left" />
|
||||
|
||||
<TextView
|
||||
style="@style/FakeChatViewOutgoingMessageBubble"
|
||||
android:id="@+id/bubble3"
|
||||
android:layout_width="@dimen/fake_chat_view_bubble_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_spacing"
|
||||
android:text="So it doesn't collect my personal information or my conversation metadata? How's it work?"
|
||||
android:layout_gravity="right" />
|
||||
|
||||
<TextView
|
||||
style="@style/FakeChatViewIncomingMessageBubble"
|
||||
android:id="@+id/bubble4"
|
||||
android:layout_width="@dimen/fake_chat_view_bubble_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_spacing"
|
||||
android:text="Using a combination of advanced anonymous routing and end-to-end encryption technologies."
|
||||
android:layout_gravity="left" />
|
||||
|
||||
<TextView
|
||||
style="@style/FakeChatViewIncomingMessageBubble"
|
||||
android:id="@+id/bubble5"
|
||||
android:layout_width="@dimen/fake_chat_view_bubble_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_spacing"
|
||||
android:text="Friends don't let friends use compromised messengers. You're welcome."
|
||||
android:layout_gravity="left" />
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,74 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Context.LAYOUT_INFLATER_SERVICE
|
||||
import android.os.Handler
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.ScrollView
|
||||
import kotlinx.android.synthetic.main.fake_chat_content_view.view.*
|
||||
import network.loki.messenger.R
|
||||
|
||||
|
||||
class FakeChatView : ScrollView {
|
||||
|
||||
// region Settings
|
||||
private val spacing = context.resources.getDimension(R.dimen.medium_spacing)
|
||||
private val startDelay: Long = 2000
|
||||
private val delayBetweenMessages: Long = 3000
|
||||
private val animationDuration: Long = 400
|
||||
// endregion
|
||||
|
||||
// region Lifecycle
|
||||
constructor(context: Context) : super(context) {
|
||||
setUpViewHierarchy()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
setUpViewHierarchy()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
setUpViewHierarchy()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
setUpViewHierarchy()
|
||||
}
|
||||
|
||||
private fun setUpViewHierarchy() {
|
||||
val inflater = context.applicationContext.getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
||||
val contentView = inflater.inflate(R.layout.fake_chat_content_view, null)
|
||||
addView(contentView)
|
||||
isVerticalScrollBarEnabled = false
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region Animation
|
||||
fun startAnimating() {
|
||||
listOf( bubble1, bubble2, bubble3, bubble4, bubble5 ).forEach { it.alpha = 0.0f }
|
||||
fun show(view: View) {
|
||||
view.animate().alpha(1.0f).setDuration(animationDuration).start()
|
||||
}
|
||||
Handler().postDelayed({
|
||||
show(bubble1)
|
||||
Handler().postDelayed({
|
||||
show(bubble2)
|
||||
Handler().postDelayed({
|
||||
show(bubble3)
|
||||
smoothScrollTo(0, (bubble1.height + spacing).toInt())
|
||||
Handler().postDelayed({
|
||||
show(bubble4)
|
||||
smoothScrollTo(0, (bubble1.height + spacing).toInt() + (bubble2.height + spacing).toInt())
|
||||
Handler().postDelayed({
|
||||
show(bubble5)
|
||||
smoothScrollTo(0, (bubble1.height + spacing).toInt() + (bubble2.height + spacing).toInt() + (bubble3.height + spacing).toInt())
|
||||
}, delayBetweenMessages)
|
||||
}, delayBetweenMessages)
|
||||
}, delayBetweenMessages)
|
||||
}, delayBetweenMessages)
|
||||
}, startDelay)
|
||||
}
|
||||
// endregion
|
||||
}
|
Loading…
Reference in New Issue