Move session restore prompt from message level to conversation level.
parent
0caeb3a109
commit
97ffea040f
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/session_restore_banner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/core_grey_60"
|
||||
android:focusable="true"
|
||||
android:nextFocusDown="@+id/cancel"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingTop="24dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/restoreTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp"
|
||||
tools:text="@string/session_restore_banner_title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/restoreText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
tools:text="@string/session_restore_banner_message" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:gravity="right"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/dismissButton"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
android:text="@string/session_restore_banner_dismiss_button_title" />
|
||||
|
||||
<android.support.v4.widget.Space
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/restoreButton"
|
||||
style="@style/Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
android:text="@string/session_restore_banner_restore_button_title" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -1,7 +0,0 @@
|
||||
package org.thoughtcrime.securesms.loki
|
||||
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
|
||||
interface ConversationUpdateItemViewDelegate {
|
||||
fun updateItemButtonPressed(message: MessageRecord)
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package org.thoughtcrime.securesms.loki
|
||||
|
||||
import org.thoughtcrime.securesms.components.reminder.Reminder
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.content.Context
|
||||
import android.os.Build.VERSION_CODES
|
||||
import android.text.TextUtils
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageButton
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import kotlinx.android.synthetic.main.session_restore_banner.view.*
|
||||
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.ViewUtil
|
||||
|
||||
/**
|
||||
* View to display actionable reminders to the user
|
||||
*/
|
||||
class SessionRestoreBannerView private constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : LinearLayout(context, attrs, defStyleAttr) {
|
||||
private var container: ViewGroup? = null
|
||||
private var closeButton: ImageButton? = null
|
||||
private var title: TextView? = null
|
||||
private var text: TextView? = null
|
||||
lateinit var recipient: Recipient
|
||||
var onDismiss: (() -> Unit)? = null
|
||||
var onRestore: (() -> Unit)? = null
|
||||
|
||||
constructor(context: Context) : this(context, null)
|
||||
private constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.session_restore_banner, this, true)
|
||||
restoreButton.setOnClickListener { onRestore?.invoke() }
|
||||
dismissButton.setOnClickListener { onDismiss?.invoke() }
|
||||
}
|
||||
|
||||
fun update(recipient: Recipient) {
|
||||
this.recipient = recipient
|
||||
restoreText.text = context.getString(R.string.session_restore_banner_message, recipient.toShortString())
|
||||
}
|
||||
|
||||
fun show() {
|
||||
container!!.visibility = View.VISIBLE;
|
||||
}
|
||||
|
||||
fun hide() {
|
||||
container!!.visibility = View.GONE
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue