Commit b711badf authored by narinder Rana's avatar narinder Rana
Browse files

investigation test 2

parent e95472e4
Pipeline #183192 failed with stage
in 6 minutes and 28 seconds
......@@ -19,7 +19,6 @@
package com.moez.QKSMS.feature.compose
import android.content.Context
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.view.isVisible
......@@ -56,7 +55,7 @@ class AttachmentAdapter @Inject constructor(
val inflater = LayoutInflater.from(parent.context)
val view = when (viewType) {
VIEW_TYPE_IMAGE -> inflater.inflate(R.layout.attachment_image_list_item, parent, false)
.apply { thumbnailBounds.clipToOutline = true }
.apply { thumbnailBounds.clipToOutline = true }
VIEW_TYPE_CONTACT -> inflater.inflate(R.layout.attachment_contact_list_item, parent, false)
......@@ -73,22 +72,21 @@ class AttachmentAdapter @Inject constructor(
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
val attachment = getItem(position)
val view = holder.containerView
when (attachment) {
is Attachment.Image -> Glide.with(context)
.load(attachment.getUri())
.into(holder.thumbnail)
.load(attachment.getUri())
.into(holder.thumbnail)
is Attachment.Contact -> Observable.just(attachment.vCard)
.mapNotNull { vCard -> Ezvcard.parse(vCard).first() }
.map { vcard -> vcard.getDisplayName() ?: "" }
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { displayName ->
holder.name?.text = displayName
holder.name?.isVisible = displayName.isNotEmpty()
}
.mapNotNull { vCard -> Ezvcard.parse(vCard).first() }
.map { vcard -> vcard.getDisplayName() ?: "" }
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { displayName ->
holder.name?.text = displayName
holder.name?.isVisible = displayName.isNotEmpty()
}
}
}
......
......@@ -35,7 +35,6 @@ import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AlertDialog
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelProviders
......@@ -148,11 +147,12 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
message.supportsInputContent = true
theme
.doOnNext { loading.setTint(it.theme) }
.doOnNext { attach.setTint(ContextCompat.getColor(this, R.color.colorPrimaryDark)) }
.doOnNext { messageAdapter.theme = it }
.autoDisposable(scope())
.subscribe()
.doOnNext { loading.setTint(it.theme) }
.doOnNext { attach.setBackgroundTint(it.theme) }
.doOnNext { attach.setTint(it.textPrimary) }
.doOnNext { messageAdapter.theme = it }
.autoDisposable(scope())
.subscribe()
window.callback = ComposeWindowCallback(window.callback, this)
......@@ -188,7 +188,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
toolbarSubtitle.setVisible(state.query.isNotEmpty())
toolbarSubtitle.text = getString(R.string.compose_subtitle_results, state.searchSelectionPosition,
state.searchResults)
state.searchResults)
toolbarTitle.setVisible(!state.editingMode)
chips.setVisible(state.editingMode)
......@@ -238,17 +238,17 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
simIndex.text = state.subscription?.simSlotIndex?.plus(1)?.toString()
send.isEnabled = state.canSend
send.imageAlpha = if (state.canSend) 255 else 128
}
override fun clearSelection() = messageAdapter.clearSelection()
override fun showDetails(details: String) {
AlertDialog.Builder(this, R.style.customAlertDialog)
.setTitle(R.string.compose_details_title)
.setMessage(details)
.setCancelable(true)
.show()
AlertDialog.Builder(this)
.setTitle(R.string.compose_details_title)
.setMessage(details)
.setCancelable(true)
.show()
}
override fun requestDefaultSms() {
......@@ -261,14 +261,14 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
override fun requestSmsPermission() {
ActivityCompat.requestPermissions(this, arrayOf(
Manifest.permission.READ_SMS,
Manifest.permission.SEND_SMS), 0)
Manifest.permission.READ_SMS,
Manifest.permission.SEND_SMS), 0)
}
override fun requestDatePicker() {
val calendar = Calendar.getInstance()
DatePickerDialog(this, R.style.customAlertDialog, DatePickerDialog.OnDateSetListener { _, year, month, day ->
TimePickerDialog(this, R.style.customAlertDialog, TimePickerDialog.OnTimeSetListener { _, hour, minute ->
DatePickerDialog(this, DatePickerDialog.OnDateSetListener { _, year, month, day ->
TimePickerDialog(this, TimePickerDialog.OnTimeSetListener { _, hour, minute ->
calendar.set(Calendar.YEAR, year)
calendar.set(Calendar.MONTH, month)
calendar.set(Calendar.DAY_OF_MONTH, day)
......@@ -276,7 +276,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
calendar.set(Calendar.MINUTE, minute)
scheduleSelectedIntent.onNext(calendar.timeInMillis)
}, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), DateFormat.is24HourFormat(this))
.show()
.show()
}, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)).show()
// On some devices, the keyboard can cover the date picker
......@@ -285,7 +285,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
override fun requestContact() {
val intent = Intent(Intent.ACTION_PICK)
.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE)
.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE)
startActivityForResult(Intent.createChooser(intent, null), AttachContactRequestCode)
}
......@@ -294,8 +294,8 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
message.hideKeyboard()
val serialized = HashMap(chips.associate { chip -> chip.address to chip.contact?.lookupKey })
val intent = Intent(this, ContactsActivity::class.java)
.putExtra(ContactsActivity.SharingKey, sharing)
.putExtra(ContactsActivity.ChipsKey, serialized)
.putExtra(ContactsActivity.SharingKey, sharing)
.putExtra(ContactsActivity.ChipsKey, serialized)
startActivityForResult(intent, SelectContactRequestCode)
}
......@@ -311,21 +311,21 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
override fun requestCamera() {
cameraDestination = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())
.let { timestamp -> ContentValues().apply { put(MediaStore.Images.Media.TITLE, timestamp) } }
.let { cv -> contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, cv) }
.let { timestamp -> ContentValues().apply { put(MediaStore.Images.Media.TITLE, timestamp) } }
.let { cv -> contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, cv) }
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
.putExtra(MediaStore.EXTRA_OUTPUT, cameraDestination)
.putExtra(MediaStore.EXTRA_OUTPUT, cameraDestination)
startActivityForResult(Intent.createChooser(intent, null), TakePhotoRequestCode)
}
override fun requestGallery() {
val intent = Intent(Intent.ACTION_PICK)
.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION)
.putExtra(Intent.EXTRA_LOCAL_ONLY, false)
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
.setType("image/*")
.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION)
.putExtra(Intent.EXTRA_LOCAL_ONLY, false)
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
.setType("image/*")
startActivityForResult(Intent.createChooser(intent, null), AttachPhotoRequestCode)
}
......@@ -336,9 +336,9 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
override fun scrollToMessage(id: Long) {
messageAdapter.data?.second
?.indexOfLast { message -> message.id == id }
?.takeIf { position -> position != -1 }
?.let(messageList::scrollToPosition)
?.indexOfLast { message -> message.id == id }
?.takeIf { position -> position != -1 }
?.let(messageList::scrollToPosition)
}
override fun showQksmsPlusSnackbar(message: Int) {
......@@ -367,18 +367,18 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
when {
requestCode == SelectContactRequestCode -> {
chipsSelectedIntent.onNext(data?.getSerializableExtra(ContactsActivity.ChipsKey)
?.let { serializable -> serializable as? HashMap<String, String?> }
?: hashMapOf())
?.let { serializable -> serializable as? HashMap<String, String?> }
?: hashMapOf())
}
requestCode == TakePhotoRequestCode && resultCode == Activity.RESULT_OK -> {
cameraDestination?.let(attachmentSelectedIntent::onNext)
}
requestCode == AttachPhotoRequestCode && resultCode == Activity.RESULT_OK -> {
data?.clipData?.itemCount
?.let { count -> 0 until count }
?.mapNotNull { i -> data.clipData?.getItemAt(i)?.uri }
?.forEach(attachmentSelectedIntent::onNext)
?: data?.data?.let(attachmentSelectedIntent::onNext)
?.let { count -> 0 until count }
?.mapNotNull { i -> data.clipData?.getItemAt(i)?.uri }
?.forEach(attachmentSelectedIntent::onNext)
?: data?.data?.let(attachmentSelectedIntent::onNext)
}
requestCode == AttachContactRequestCode && resultCode == Activity.RESULT_OK -> {
data?.data?.let(contactSelectedIntent::onNext)
......@@ -392,6 +392,11 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
super.onSaveInstanceState(outState)
}
override fun onRestoreInstanceState(savedInstanceState: Bundle?) {
cameraDestination = savedInstanceState?.getParcelable(CameraDestinationKey)
super.onRestoreInstanceState(savedInstanceState)
}
override fun onBackPressed() = backPressedIntent.onNext(Unit)
}
\ No newline at end of file
......@@ -47,12 +47,12 @@ class ComposeActivityModule {
@Named("addresses")
fun provideAddresses(activity: ComposeActivity): List<String> {
return activity.intent
?.decodedDataString()
?.substringAfter(':') // Remove scheme
?.substringBefore("?") // Remove query
?.split(",", ";")
?.filter { number -> number.isNotEmpty() }
?: listOf()
?.decodedDataString()
?.substringAfter(':') // Remove scheme
?.substringBefore("?") // Remove query
?.split(",", ";")
?.filter { number -> number.isNotEmpty() }
?: listOf()
}
@Provides
......@@ -64,12 +64,12 @@ class ComposeActivityModule {
}
return subject + (activity.intent.extras?.getString(Intent.EXTRA_TEXT)
?: activity.intent.extras?.getString("sms_body")
?: activity.intent?.decodedDataString()
?.substringAfter('?') // Query string
?.takeIf { it.startsWith("body") }
?.substringAfter('=')
?: "")
?: activity.intent.extras?.getString("sms_body")
?: activity.intent?.decodedDataString()
?.substringAfter('?') // Query string
?.takeIf { it.startsWith("body") }
?.substringAfter('=')
?: "")
}
@Provides
......@@ -110,4 +110,4 @@ class ComposeActivityModule {
return data
}
}
}
\ No newline at end of file
......@@ -74,14 +74,14 @@ import javax.inject.Inject
import javax.inject.Provider
class MessagesAdapter @Inject constructor(
subscriptionManager: SubscriptionManagerCompat,
private val context: Context,
private val colors: Colors,
private val dateFormatter: DateFormatter,
private val partsAdapterProvider: Provider<PartsAdapter>,
private val phoneNumberUtils: PhoneNumberUtils,
private val prefs: Preferences,
private val textViewStyler: TextViewStyler
subscriptionManager: SubscriptionManagerCompat,
private val context: Context,
private val colors: Colors,
private val dateFormatter: DateFormatter,
private val partsAdapterProvider: Provider<PartsAdapter>,
private val phoneNumberUtils: PhoneNumberUtils,
private val prefs: Preferences,
private val textViewStyler: TextViewStyler
) : QkRealmAdapter<Message>() {
companion object {
......@@ -91,7 +91,7 @@ class MessagesAdapter @Inject constructor(
// Thanks to Cory Kilger for this regex
// https://gist.github.com/cmkilger/b8f7dba3e76244a84e7e
private val EMOJI_REGEX = Regex(
"^[\\s\n\r]*(?:(?:[\u00a9\u00ae\u203c\u2049\u2122\u2139\u2194-\u2199\u21a9-\u21aa\u231a-\u231b\u2328\u23cf\u23e9-\u23f3\u23f8-\u23fa\u24c2\u25aa-\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614-\u2615\u2618\u261d\u2620\u2622-\u2623\u2626\u262a\u262e-\u262f\u2638-\u263a\u2648-\u2653\u2660\u2663\u2665-\u2666\u2668\u267b\u267f\u2692-\u2694\u2696-\u2697\u2699\u269b-\u269c\u26a0-\u26a1\u26aa-\u26ab\u26b0-\u26b1\u26bd-\u26be\u26c4-\u26c5\u26c8\u26ce-\u26cf\u26d1\u26d3-\u26d4\u26e9-\u26ea\u26f0-\u26f5\u26f7-\u26fa\u26fd\u2702\u2705\u2708-\u270d\u270f\u2712\u2714\u2716\u271d\u2721\u2728\u2733-\u2734\u2744\u2747\u274c\u274e\u2753-\u2755\u2757\u2763-\u2764\u2795-\u2797\u27a1\u27b0\u27bf\u2934-\u2935\u2b05-\u2b07\u2b1b-\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299\ud83c\udc04\ud83c\udccf\ud83c\udd70-\ud83c\udd71\ud83c\udd7e-\ud83c\udd7f\ud83c\udd8e\ud83c\udd91-\ud83c\udd9a\ud83c\ude01-\ud83c\ude02\ud83c\ude1a\ud83c\ude2f\ud83c\ude32-\ud83c\ude3a\ud83c\ude50-\ud83c\ude51\u200d\ud83c\udf00-\ud83d\uddff\ud83d\ude00-\ud83d\ude4f\ud83d\ude80-\ud83d\udeff\ud83e\udd00-\ud83e\uddff\udb40\udc20-\udb40\udc7f]|\u200d[\u2640\u2642]|[\ud83c\udde6-\ud83c\uddff]{2}|.[\u20e0\u20e3\ufe0f]+)+[\\s\n\r]*)+$")
"^[\\s\n\r]*(?:(?:[\u00a9\u00ae\u203c\u2049\u2122\u2139\u2194-\u2199\u21a9-\u21aa\u231a-\u231b\u2328\u23cf\u23e9-\u23f3\u23f8-\u23fa\u24c2\u25aa-\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614-\u2615\u2618\u261d\u2620\u2622-\u2623\u2626\u262a\u262e-\u262f\u2638-\u263a\u2648-\u2653\u2660\u2663\u2665-\u2666\u2668\u267b\u267f\u2692-\u2694\u2696-\u2697\u2699\u269b-\u269c\u26a0-\u26a1\u26aa-\u26ab\u26b0-\u26b1\u26bd-\u26be\u26c4-\u26c5\u26c8\u26ce-\u26cf\u26d1\u26d3-\u26d4\u26e9-\u26ea\u26f0-\u26f5\u26f7-\u26fa\u26fd\u2702\u2705\u2708-\u270d\u270f\u2712\u2714\u2716\u271d\u2721\u2728\u2733-\u2734\u2744\u2747\u274c\u274e\u2753-\u2755\u2757\u2763-\u2764\u2795-\u2797\u27a1\u27b0\u27bf\u2934-\u2935\u2b05-\u2b07\u2b1b-\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299\ud83c\udc04\ud83c\udccf\ud83c\udd70-\ud83c\udd71\ud83c\udd7e-\ud83c\udd7f\ud83c\udd8e\ud83c\udd91-\ud83c\udd9a\ud83c\ude01-\ud83c\ude02\ud83c\ude1a\ud83c\ude2f\ud83c\ude32-\ud83c\ude3a\ud83c\ude50-\ud83c\ude51\u200d\ud83c\udf00-\ud83d\uddff\ud83d\ude00-\ud83d\ude4f\ud83d\ude80-\ud83d\udeff\ud83e\udd00-\ud83e\uddff\udb40\udc20-\udb40\udc7f]|\u200d[\u2640\u2642]|[\ud83c\udde6-\ud83c\uddff]{2}|.[\u20e0\u20e3\ufe0f]+)+[\\s\n\r]*)+$")
}
......@@ -213,8 +213,8 @@ class MessagesAdapter @Inject constructor(
val progress = (1 - (message.date - System.currentTimeMillis()) / delay.toFloat()) * 100
ObjectAnimator.ofInt(cancel, "progress", progress.toInt(), 100)
.setDuration(message.date - System.currentTimeMillis())
.start()
.setDuration(message.date - System.currentTimeMillis())
.start()
}
}
......@@ -253,16 +253,16 @@ class MessagesAdapter @Inject constructor(
false -> {
val subject = message.getCleansedSubject()
val body = message.parts
.filter { part -> part.isText() }
.mapNotNull { part -> part.text }
.filter { text -> text.isNotBlank() }
.joinToString("\n")
.filter { part -> part.isText() }
.mapNotNull { part -> part.text }
.filter { text -> text.isNotBlank() }
.joinToString("\n")
when {
subject.isNotBlank() -> {
val spannable = SpannableString(if (body.isNotBlank()) "$subject\n$body" else subject)
spannable.setSpan(StyleSpan(Typeface.BOLD), 0, subject.length,
Spannable.SPAN_INCLUSIVE_EXCLUSIVE)
Spannable.SPAN_INCLUSIVE_EXCLUSIVE)
spannable
}
else -> body
......@@ -278,10 +278,10 @@ class MessagesAdapter @Inject constructor(
holder.body.text = messageText
holder.body.setVisible(message.isSms() || messageText.isNotBlank())
holder.body.setBackgroundResource(getBubble(
emojiOnly = emojiOnly,
canGroupWithPrevious = canGroup(message, previous) || media.isNotEmpty(),
canGroupWithNext = canGroup(message, next),
isMe = message.isMe()))
emojiOnly = emojiOnly,
canGroupWithPrevious = canGroup(message, previous) || media.isNotEmpty(),
canGroupWithNext = canGroup(message, next),
isMe = message.isMe()))
// Bind the attachments
val partsAdapter = holder.attachments.adapter as PartsAdapter
......@@ -295,7 +295,7 @@ class MessagesAdapter @Inject constructor(
holder.status.text = when {
message.isSending() -> context.getString(R.string.message_status_sending)
message.isDelivered() -> context.getString(R.string.message_status_delivered,
dateFormatter.getTimestamp(message.dateSent))
dateFormatter.getTimestamp(message.dateSent))
message.isFailedMessage() -> context.getString(R.string.message_status_failed)
// Incoming group message
......
......@@ -40,21 +40,21 @@ class MediaBinder @Inject constructor(colors: Colors, private val context: Conte
override fun canBindPart(part: MmsPart) = part.isImage() || part.isVideo()
override fun bindPart(
holder: QkViewHolder,
part: MmsPart,
message: Message,
canGroupWithPrevious: Boolean,
canGroupWithNext: Boolean
holder: QkViewHolder,
part: MmsPart,
message: Message,
canGroupWithPrevious: Boolean,
canGroupWithNext: Boolean
) {
holder.video.setVisible(part.isVideo())
holder.containerView.setOnClickListener { clicks.onNext(part.id) }
// holder.thumbnail.bubbleStyle = when {
// !canGroupWithPrevious && canGroupWithNext -> if (message.isMe()) BubbleImageView.Style.OUT_FIRST else BubbleImageView.Style.IN_FIRST
// canGroupWithPrevious && canGroupWithNext -> if (message.isMe()) BubbleImageView.Style.OUT_MIDDLE else BubbleImageView.Style.IN_MIDDLE
// canGroupWithPrevious && !canGroupWithNext -> if (message.isMe()) BubbleImageView.Style.OUT_LAST else BubbleImageView.Style.IN_LAST
// else -> BubbleImageView.Style.ONLY
// }
holder.thumbnail.bubbleStyle = when {
!canGroupWithPrevious && canGroupWithNext -> if (message.isMe()) BubbleImageView.Style.OUT_FIRST else BubbleImageView.Style.IN_FIRST
canGroupWithPrevious && canGroupWithNext -> if (message.isMe()) BubbleImageView.Style.OUT_MIDDLE else BubbleImageView.Style.IN_MIDDLE
canGroupWithPrevious && !canGroupWithNext -> if (message.isMe()) BubbleImageView.Style.OUT_LAST else BubbleImageView.Style.IN_LAST
else -> BubbleImageView.Style.ONLY
}
GlideApp.with(context).load(part.getUri()).fitCenter().into(holder.thumbnail)
}
......
......@@ -36,11 +36,11 @@ abstract class PartBinder {
abstract fun canBindPart(part: MmsPart): Boolean
abstract fun bindPart(
holder: QkViewHolder,
part: MmsPart,
message: Message,
canGroupWithPrevious: Boolean,
canGroupWithNext: Boolean
holder: QkViewHolder,
part: MmsPart,
message: Message,
canGroupWithPrevious: Boolean,
canGroupWithNext: Boolean
)
}
}
\ No newline at end of file
......@@ -35,10 +35,10 @@ import kotlinx.android.synthetic.main.message_list_item_in.*
import javax.inject.Inject
class PartsAdapter @Inject constructor(
colors: Colors,
fileBinder: FileBinder,
mediaBinder: MediaBinder,
vCardBinder: VCardBinder
colors: Colors,
fileBinder: FileBinder,
mediaBinder: MediaBinder,
vCardBinder: VCardBinder
) : QkAdapter<MmsPart>() {
private val partBinders = listOf(mediaBinder, vCardBinder, fileBinder)
......@@ -80,8 +80,8 @@ class PartsAdapter @Inject constructor(
val canGroupWithNext = canGroup(message, next) || position < itemCount - 1 || bodyVisible
partBinders
.firstOrNull { it.canBindPart(part) }
?.bindPart(holder, part, message, canGroupWithPrevious, canGroupWithNext)
.firstOrNull { it.canBindPart(part) }
?.bindPart(holder, part, message, canGroupWithPrevious, canGroupWithNext)
}
override fun getItemViewType(position: Int): Int {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment