Implement new private chat screen redesign

This commit is contained in:
Niels Andriesse 2019-12-18 11:36:09 +01:00
parent f8737c3f81
commit bb976a4bff
18 changed files with 320 additions and 15 deletions

View File

@ -142,6 +142,9 @@
<activity
android:name="org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity"
android:launchMode="singleTask" />
<activity
android:name="org.thoughtcrime.securesms.loki.redesign.activities.NewPrivateChatActivity"
android:launchMode="singleTask" />
<!-- Session -->
<activity android:name="org.thoughtcrime.securesms.loki.LinkedDevicesActivity" />
<activity

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/unimportant_button_background" />
<corners android:radius="24dp" />
<stroke android:width="@dimen/border_thickness" android:color="@color/unimportant_button_background" />
</shape>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.design.widget.TabLayout
style="@style/Session.DarkTabLayout"
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="@dimen/tab_bar_height" />
</android.support.v4.view.ViewPager>

View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contentView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/default_session_background"
android:orientation="vertical">
<EditText
style="@style/SessionEditText"
android:id="@+id/publicKeyEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/very_large_spacing"
android:layout_marginTop="@dimen/medium_spacing"
android:layout_marginRight="@dimen/very_large_spacing"
android:hint="Enter Session ID of recipient" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/very_large_spacing"
android:layout_marginTop="@dimen/medium_spacing"
android:layout_marginRight="@dimen/very_large_spacing"
android:textSize="@dimen/small_font_size"
android:textColor="@color/text"
android:alpha="0.6"
android:textAlignment="center"
android:text="Users can share their Session ID by going into their account settings and tapping &quot;Share Session ID&quot;, or by sharing their QR code." />
<org.thoughtcrime.securesms.loki.redesign.views.SeparatorView
android:id="@+id/separatorView"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_marginLeft="@dimen/very_large_spacing"
android:layout_marginTop="@dimen/large_spacing"
android:layout_marginRight="@dimen/very_large_spacing" />
<TextView
android:id="@+id/publicKeyTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/very_large_spacing"
android:layout_marginTop="@dimen/large_spacing"
android:layout_marginRight="@dimen/very_large_spacing"
android:textSize="@dimen/medium_font_size"
android:textColor="@color/text"
android:fontFamily="@font/space_mono_regular"
android:textAlignment="center"
android:text="05987d601943c267879be41830888066c6a024cbdc9a548d06813924bf3372ea78" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/very_large_spacing"
android:layout_marginTop="@dimen/large_spacing"
android:layout_marginRight="@dimen/very_large_spacing"
android:orientation="horizontal">
<Button
style="@style/MediumUnimportantFilledButton"
android:id="@+id/copyButton"
android:layout_width="0dp"
android:layout_height="@dimen/medium_button_height"
android:layout_weight="1"
android:text="Copy" />
<Button
style="@style/MediumUnimportantFilledButton"
android:id="@+id/shareButton"
android:layout_width="0dp"
android:layout_height="@dimen/medium_button_height"
android:layout_weight="1"
android:layout_marginLeft="@dimen/medium_spacing"
android:text="Share" />
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
style="@style/MediumProminentOutlineButton"
android:id="@+id/createPrivateChatButton"
android:layout_width="match_parent"
android:layout_height="@dimen/medium_button_height"
android:layout_marginLeft="90dp"
android:layout_marginRight="90dp"
android:layout_marginBottom="@dimen/medium_spacing"
android:text="Next" />
</LinearLayout>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/titleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:textColor="@color/text"
android:alpha="0.6"
android:textSize="@dimen/small_font_size"
android:text="Your Public Key" />
</RelativeLayout>

View File

@ -10,6 +10,8 @@
<color name="cell_selected">#0C0C0C</color>
<color name="action_bar_background">#171717</color>
<color name="navigation_bar_background">#121212</color>
<color name="separator">#36383C</color>
<color name="unimportant_button_background">#323232</color>
<color name="fake_chat_bubble_background">#3F4146</color>
<color name="fake_chat_bubble_text">#000000</color>
<!-- Session -->

View File

@ -20,6 +20,7 @@
<dimen name="border_thickness">2dp</dimen>
<dimen name="profile_picture_border_thickness">1dp</dimen>
<dimen name="new_conversation_button_size">56dp</dimen>
<dimen name="tab_bar_height">48dp</dimen>
<dimen name="text_view_corner_radius">8dp</dimen>
<dimen name="fake_chat_view_bubble_width">224dp</dimen>
<dimen name="fake_chat_view_bubble_corner_radius">10dp</dimen>
@ -31,7 +32,7 @@
<dimen name="large_spacing">24dp</dimen>
<dimen name="very_large_spacing">35dp</dimen>
<dimen name="massive_spacing">64dp</dimen>
<dimen name="new_conversation_button_bottom_offset">60dp</dimen>
<dimen name="new_conversation_button_bottom_offset">48dp</dimen>
<dimen name="onboarding_button_bottom_offset">48dp</dimen>
<!-- Session -->

View File

@ -5,22 +5,38 @@
<style name="Session.DarkActionBar" parent="@style/Widget.AppCompat.ActionBar">
<item name="background">@color/action_bar_background</item>
<item name="android:background">@color/action_bar_background</item>
<item name="titleTextStyle">@style/Session.TitleTextStyle</item>
<item name="android:titleTextStyle">@style/Session.TitleTextStyle</item>
<item name="titleTextStyle">@style/Session.DarkActionBar.TitleTextStyle</item>
<item name="android:titleTextStyle">@style/Session.DarkActionBar.TitleTextStyle</item>
<item name="elevation">0dp</item>
<item name="android:elevation">0dp</item>
</style>
<style name="Session.TitleTextStyle" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<style name="Session.DarkActionBar.TitleTextStyle" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/text</item>
<item name="android:textSize">@dimen/very_large_font_size</item>
</style>
<style name="Session.DarkTabLayout" parent="Widget.Design.TabLayout">
<item name="tabIndicatorColor">@color/accent</item>
<item name="tabIndicatorHeight">@dimen/accent_line_thickness</item>
<item name="tabBackground">@color/action_bar_background</item>
<item name="tabRippleColor">@color/cell_selected</item>
<item name="tabTextAppearance">@style/Session.DarkTabLayout.TextAppearance</item>
<item name="tabSelectedTextColor">@color/text</item>
</style>
<style name="Session.DarkTabLayout.TextAppearance" parent="TextAppearance.Design.Tab">
<item name="android:textSize">@dimen/medium_font_size</item>
<item name="android:textColor">@color/unimportant</item>"
<item name="textAllCaps">false</item>
</style>
<style name="MediumProminentFilledButton">
<item name="android:background">@drawable/prominent_filled_button_medium_background</item>
<item name="android:textAllCaps">false</item>
<item name="android:textSize">@dimen/medium_font_size</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/text</item>
</style>
<style name="MediumProminentOutlineButton">
@ -31,6 +47,14 @@
<item name="android:textColor">@color/accent</item>
</style>
<style name="MediumUnimportantFilledButton">
<item name="android:background">@drawable/unimportant_filled_button_medium_background</item>
<item name="android:textAllCaps">false</item>
<item name="android:textSize">@dimen/medium_font_size</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/text</item>
</style>
<style name="SessionIDTextView">
<item name="android:background">@drawable/session_id_text_view_background</item>
<item name="android:padding">@dimen/medium_spacing</item>

View File

@ -10,13 +10,13 @@ import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
import org.thoughtcrime.securesms.conversation.ConversationActivity
import org.thoughtcrime.securesms.database.DatabaseFactory
import org.thoughtcrime.securesms.database.model.ThreadRecord
import org.thoughtcrime.securesms.loki.NewConversationActivity
import org.thoughtcrime.securesms.loki.redesign.utilities.push
import org.thoughtcrime.securesms.loki.redesign.views.ConversationView
import org.thoughtcrime.securesms.util.TextSecurePreferences
class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListener {
// region Lifecycle
constructor() : super()
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
@ -27,7 +27,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
supportActionBar!!.title = "Messages"
// Set up recycler view
val cursor = DatabaseFactory.getThreadDatabase(this).conversationList
val conversationAdapter = ConversationAdapter(this, cursor)
val conversationAdapter = HomeAdapter(this, cursor)
conversationAdapter.conversationClickListener = this
recyclerView.adapter = conversationAdapter
recyclerView.layoutManager = LinearLayoutManager(this)
@ -42,6 +42,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
application.startRSSFeedPollersIfNeeded()
}
}
// endregion
override fun onConversationClick(view: ConversationView) {
val thread = view.thread ?: return
@ -64,7 +65,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
}
private fun createPrivateChat() {
val intent = Intent(this, NewConversationActivity::class.java)
val intent = Intent(this, NewPrivateChatActivity::class.java)
startActivity(intent)
}
}

View File

@ -9,7 +9,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory
import org.thoughtcrime.securesms.database.model.ThreadRecord
import org.thoughtcrime.securesms.loki.redesign.views.ConversationView
class ConversationAdapter(context: Context, cursor: Cursor) : CursorRecyclerViewAdapter<ConversationAdapter.ViewHolder>(context, cursor) {
class HomeAdapter(context: Context, cursor: Cursor) : CursorRecyclerViewAdapter<HomeAdapter.ViewHolder>(context, cursor) {
private val threadDatabase = DatabaseFactory.getThreadDatabase(context)
var conversationClickListener: ConversationClickListener? = null
@ -30,7 +30,7 @@ class ConversationAdapter(context: Context, cursor: Cursor) : CursorRecyclerView
}
private fun getThread(cursor: Cursor): ThreadRecord? {
return threadDatabase.readerFor(cursor).getCurrent()
return threadDatabase.readerFor(cursor).current
}
}

View File

@ -0,0 +1,63 @@
package org.thoughtcrime.securesms.loki.redesign.activities
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import kotlinx.android.synthetic.main.activity_new_private_chat.*
import kotlinx.android.synthetic.main.fragment_enter_public_key.*
import network.loki.messenger.R
import org.thoughtcrime.securesms.BaseActionBarActivity
class NewPrivateChatActivity : BaseActionBarActivity() {
private val adapter = Adapter(supportFragmentManager)
// region Lifecycle
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Set content view
setContentView(R.layout.activity_new_private_chat)
// Set title
supportActionBar!!.title = "New Conversation"
// Set up view pager
viewPager.adapter = adapter
tabLayout.setupWithViewPager(viewPager)
}
// endregion
}
// region Adapter
private class Adapter(manager: FragmentManager) : FragmentPagerAdapter(manager) {
override fun getCount(): Int {
return 2
}
override fun getItem(index: Int): Fragment {
return EnterPublicKeyFragment()
}
override fun getPageTitle(index: Int): CharSequence? {
return when (index) {
0 -> "Enter Public Key"
1 -> "Scan QR Code"
else -> throw IllegalStateException()
}
}
}
// endregion
class EnterPublicKeyFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
return inflater.inflate(R.layout.fragment_enter_public_key, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
separatorView.title = "Test"
}
}

View File

@ -6,7 +6,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import kotlinx.android.synthetic.main.conversation_view.view.*
import kotlinx.android.synthetic.main.view_conversation.view.*
import network.loki.messenger.R
import org.thoughtcrime.securesms.database.model.ThreadRecord
import org.thoughtcrime.securesms.loki.LokiAPIUtilities.populateUserHexEncodedPublicKeyCacheIfNeeded
@ -37,7 +37,7 @@ class ConversationView : LinearLayout {
private fun setUpViewHierarchy() {
val inflater = context.applicationContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val contentView = inflater.inflate(R.layout.conversation_view, null)
val contentView = inflater.inflate(R.layout.view_conversation, null)
addView(contentView)
}
// endregion

View File

@ -7,7 +7,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.ScrollView
import kotlinx.android.synthetic.main.fake_chat_view.view.*
import kotlinx.android.synthetic.main.view_fake_chat.view.*
import network.loki.messenger.R
class FakeChatView : ScrollView {
@ -38,7 +38,7 @@ class FakeChatView : ScrollView {
private fun setUpViewHierarchy() {
val inflater = context.applicationContext.getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater
val contentView = inflater.inflate(R.layout.fake_chat_view, null)
val contentView = inflater.inflate(R.layout.view_fake_chat, null)
addView(contentView)
isVerticalScrollBarEnabled = false
}

View File

@ -5,7 +5,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.RelativeLayout
import kotlinx.android.synthetic.main.profile_picture_view.view.*
import kotlinx.android.synthetic.main.view_profile_picture.view.*
import network.loki.messenger.R
class ProfilePictureView : RelativeLayout {
@ -32,10 +32,12 @@ class ProfilePictureView : RelativeLayout {
private fun setUpViewHierarchy() {
val inflater = context.applicationContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val contentView = inflater.inflate(R.layout.profile_picture_view, null)
val contentView = inflater.inflate(R.layout.view_profile_picture, null)
addView(contentView)
}
// endregion
// region Updating
fun update() {
val hexEncodedPublicKey = hexEncodedPublicKey ?: return
val additionalHexEncodedPublicKey = additionalHexEncodedPublicKey

View File

@ -0,0 +1,71 @@
package org.thoughtcrime.securesms.loki.redesign.views
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Path
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.RelativeLayout
import kotlinx.android.synthetic.main.view_separator.view.*
import network.loki.messenger.R
import org.thoughtcrime.securesms.loki.getColorWithID
import org.thoughtcrime.securesms.loki.toPx
class SeparatorView : RelativeLayout {
lateinit var title: CharSequence
private val path = Path()
private val paint: Paint = {
val result = Paint()
result.style = Paint.Style.STROKE
result.color = resources.getColorWithID(R.color.separator, context.theme)
result.strokeWidth = 2.0f
result.isAntiAlias = true
result
}()
// 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(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val contentView = inflater.inflate(R.layout.view_separator, null)
val layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
addView(contentView, layoutParams)
setWillNotDraw(false)
}
// endregion
// region Updating
override fun onDraw(c: Canvas) {
super.onDraw(c)
val w = width.toFloat()
val h = height.toFloat()
val hMargin = toPx(10, resources).toFloat()
path.reset()
path.moveTo(0.0f, h / 2)
path.lineTo(titleTextView.left - hMargin, h / 2)
path.addRoundRect(titleTextView.left - hMargin, 0.0f, titleTextView.right + hMargin, h, h / 2, h / 2, Path.Direction.CCW)
path.moveTo(titleTextView.right + hMargin, h / 2)
path.lineTo(w, h / 2)
path.close()
c.drawPath(path, paint)
}
// endregion
}