forked from upstream-mirrors/quik
changes to add a new setting that allows user to choose to allow all message links, block all message links (including in notifications), or ask via a dialog box whether the user wishes to proceed
This commit is contained in:
@@ -80,6 +80,10 @@ class Preferences @Inject constructor(
|
|||||||
const val BLOCKING_MANAGER_CC = 1
|
const val BLOCKING_MANAGER_CC = 1
|
||||||
const val BLOCKING_MANAGER_SIA = 2
|
const val BLOCKING_MANAGER_SIA = 2
|
||||||
const val BLOCKING_MANAGER_CB = 3
|
const val BLOCKING_MANAGER_CB = 3
|
||||||
|
|
||||||
|
const val MESSAGE_LINK_HANDLING_BLOCK = 0
|
||||||
|
const val MESSAGE_LINK_HANDLING_ALLOW = 1
|
||||||
|
const val MESSAGE_LINK_HANDLING_ASK = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal
|
// Internal
|
||||||
@@ -124,6 +128,7 @@ class Preferences @Inject constructor(
|
|||||||
val autoDelete = rxPrefs.getInteger("autoDelete", 0)
|
val autoDelete = rxPrefs.getInteger("autoDelete", 0)
|
||||||
val longAsMms = rxPrefs.getBoolean("longAsMms", false)
|
val longAsMms = rxPrefs.getBoolean("longAsMms", false)
|
||||||
val mmsSize = rxPrefs.getInteger("mmsSize", 300)
|
val mmsSize = rxPrefs.getInteger("mmsSize", 300)
|
||||||
|
val messageLinkHandling = rxPrefs.getInteger("messageLinkHandling", MESSAGE_LINK_HANDLING_ASK)
|
||||||
val logging = rxPrefs.getBoolean("logging", false)
|
val logging = rxPrefs.getBoolean("logging", false)
|
||||||
val unreadAtTop = rxPrefs.getBoolean("unreadAtTop", false)
|
val unreadAtTop = rxPrefs.getBoolean("unreadAtTop", false)
|
||||||
|
|
||||||
|
|||||||
@@ -206,6 +206,12 @@ class NotificationManagerImpl @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove system generated contextual actions (they're generated from message links) unless
|
||||||
|
// the user has explicitly set to allow message links
|
||||||
|
notification.setAllowSystemGeneratedContextualActions(
|
||||||
|
(prefs.messageLinkHandling.get() == Preferences.MESSAGE_LINK_HANDLING_ALLOW)
|
||||||
|
)
|
||||||
|
|
||||||
// Set the large icon
|
// Set the large icon
|
||||||
val avatar = conversation.recipients.takeIf { it.size == 1 }
|
val avatar = conversation.recipients.takeIf { it.size == 1 }
|
||||||
?.first()?.contact?.photoUri
|
?.first()?.contact?.photoUri
|
||||||
|
|||||||
+54
-42
@@ -92,55 +92,67 @@ fun View.setVisible(visible: Boolean, invisible: Int = View.GONE) {
|
|||||||
* the view no longer work. Also problematic when we try to long press on an image in the message
|
* the view no longer work. Also problematic when we try to long press on an image in the message
|
||||||
* view
|
* view
|
||||||
*/
|
*/
|
||||||
fun View.forwardTouches(parent: View) {
|
|
||||||
var isLongClick = false
|
class CancelableSimpleOnGestureListener(view: View, parentView: View) : SimpleOnGestureListener() {
|
||||||
var textInitiallySelectable = false
|
private var lastUpEvent: MotionEvent? = null
|
||||||
if (this@forwardTouches is TextView)
|
private val parent = parentView
|
||||||
textInitiallySelectable = this@forwardTouches.isTextSelectable
|
private val thisView = view
|
||||||
|
private var textInitiallySelectable = false
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (thisView is TextView)
|
||||||
|
textInitiallySelectable = thisView.isTextSelectable
|
||||||
|
}
|
||||||
|
|
||||||
|
fun cancelCurrentClick() {
|
||||||
|
lastUpEvent?.recycle()
|
||||||
|
lastUpEvent = null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
|
||||||
|
if (lastUpEvent !== null) {
|
||||||
|
parent.onTouchEvent(e)
|
||||||
|
parent.onTouchEvent(lastUpEvent)
|
||||||
|
lastUpEvent?.recycle()
|
||||||
|
lastUpEvent = null
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSingleTapUp(e: MotionEvent): Boolean {
|
||||||
|
lastUpEvent = MotionEvent.obtain(e)
|
||||||
|
thisView.onTouchEvent(e)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDown(e: MotionEvent): Boolean {
|
||||||
|
thisView.onTouchEvent(e)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLongPress(e: MotionEvent) {
|
||||||
|
parent.onTouchEvent(e)
|
||||||
|
// this is kinda odd but we have to 'bounce' the text selectable value so it doesn't
|
||||||
|
// start selecting text on a long press, but will start selecting it on the next double-tap
|
||||||
|
if (thisView is TextView) {
|
||||||
|
thisView.setTextIsSelectable(false)
|
||||||
|
thisView.setTextIsSelectable(textInitiallySelectable)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun View.forwardTouches(parent: View): CancelableSimpleOnGestureListener {
|
||||||
|
val gestureListener = CancelableSimpleOnGestureListener(this, parent)
|
||||||
|
|
||||||
setOnTouchListener(object : OnTouchListener {
|
setOnTouchListener(object : OnTouchListener {
|
||||||
private val gestureDetector =
|
val gestureDetector = GestureDetector(parent.context, gestureListener)
|
||||||
GestureDetector(parent.context, object : SimpleOnGestureListener() {
|
|
||||||
private var lastUpEvent: MotionEvent? = null
|
|
||||||
|
|
||||||
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
|
|
||||||
parent.onTouchEvent(e)
|
|
||||||
if (lastUpEvent !== null) {
|
|
||||||
parent.onTouchEvent(lastUpEvent)
|
|
||||||
lastUpEvent?.recycle()
|
|
||||||
lastUpEvent = null
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSingleTapUp(e: MotionEvent): Boolean {
|
|
||||||
onTouchEvent(e)
|
|
||||||
lastUpEvent = MotionEvent.obtain(e)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDown(e: MotionEvent): Boolean {
|
|
||||||
isLongClick = false
|
|
||||||
onTouchEvent(e)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onLongPress(e: MotionEvent) {
|
|
||||||
parent.onTouchEvent(e)
|
|
||||||
isLongClick = true
|
|
||||||
// this is kinda odd but we have to 'bounce' the text selectable value so it doesn't
|
|
||||||
// start selecting text on a long press, but will start selecting it on the next double-tap
|
|
||||||
if (this@forwardTouches is TextView) {
|
|
||||||
(this@forwardTouches as TextView).setTextIsSelectable(false)
|
|
||||||
(this@forwardTouches as TextView).setTextIsSelectable(textInitiallySelectable)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
override fun onTouch(v: View, e: MotionEvent): Boolean {
|
override fun onTouch(v: View, e: MotionEvent): Boolean {
|
||||||
return gestureDetector.onTouchEvent(e)
|
return gestureDetector.onTouchEvent(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return gestureListener
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ViewPager.addOnPageChangeListener(listener: (Int) -> Unit) {
|
fun ViewPager.addOnPageChangeListener(listener: (Int) -> Unit) {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import androidx.appcompat.app.AlertDialog
|
|||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.constraintlayout.widget.ConstraintSet
|
import androidx.constraintlayout.widget.ConstraintSet
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.lifecycle.ViewModelProviders
|
import androidx.lifecycle.ViewModelProviders
|
||||||
@@ -121,6 +122,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
|||||||
override val viewQksmsPlusIntent: Subject<Unit> = PublishSubject.create()
|
override val viewQksmsPlusIntent: Subject<Unit> = PublishSubject.create()
|
||||||
override val backPressedIntent: Subject<Unit> = PublishSubject.create()
|
override val backPressedIntent: Subject<Unit> = PublishSubject.create()
|
||||||
override val confirmDeleteIntent: Subject<List<Long>> = PublishSubject.create()
|
override val confirmDeleteIntent: Subject<List<Long>> = PublishSubject.create()
|
||||||
|
override val messageLinkAskIntent: Subject<Uri> by lazy { messageAdapter.messageLinkClicks }
|
||||||
|
|
||||||
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[ComposeViewModel::class.java] }
|
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[ComposeViewModel::class.java] }
|
||||||
|
|
||||||
@@ -350,6 +352,23 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun showMessageLinkAskDialog(uri: Uri) {
|
||||||
|
AlertDialog.Builder(this)
|
||||||
|
.setTitle(R.string.messageLinkHandling_dialog_title)
|
||||||
|
.setMessage(getString(R.string.messageLinkHandling_dialog_body, uri.toString()))
|
||||||
|
.setPositiveButton(
|
||||||
|
R.string.messageLinkHandling_dialog_positive
|
||||||
|
) { _, _ ->
|
||||||
|
ContextCompat.startActivity(
|
||||||
|
this,
|
||||||
|
Intent(Intent.ACTION_VIEW).setData(uri),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.setNegativeButton(R.string.messageLinkHandling_dialog_negative) { _, _ -> { } }
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
override fun requestDefaultSms() {
|
override fun requestDefaultSms() {
|
||||||
navigator.showDefaultSmsDialog(this)
|
navigator.showDefaultSmsDialog(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,11 +68,13 @@ interface ComposeView : QkView<ComposeState> {
|
|||||||
val viewQksmsPlusIntent: Subject<Unit>
|
val viewQksmsPlusIntent: Subject<Unit>
|
||||||
val backPressedIntent: Observable<Unit>
|
val backPressedIntent: Observable<Unit>
|
||||||
val confirmDeleteIntent: Observable<List<Long>>
|
val confirmDeleteIntent: Observable<List<Long>>
|
||||||
|
val messageLinkAskIntent: Observable<Uri>
|
||||||
|
|
||||||
fun clearSelection()
|
fun clearSelection()
|
||||||
fun toggleSelectAll()
|
fun toggleSelectAll()
|
||||||
fun expandMessages(messageIds: List<Long>, expand: Boolean)
|
fun expandMessages(messageIds: List<Long>, expand: Boolean)
|
||||||
fun showDetails(details: String)
|
fun showDetails(details: String)
|
||||||
|
fun showMessageLinkAskDialog(uri: Uri)
|
||||||
fun requestDefaultSms()
|
fun requestDefaultSms()
|
||||||
fun requestStoragePermission()
|
fun requestStoragePermission()
|
||||||
fun requestSmsPermission()
|
fun requestSmsPermission()
|
||||||
|
|||||||
@@ -513,6 +513,11 @@ class ComposeViewModel @Inject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show the message details
|
||||||
|
view.messageLinkAskIntent
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe { view.showMessageLinkAskDialog(it) }
|
||||||
|
|
||||||
// Set the current conversation
|
// Set the current conversation
|
||||||
Observables
|
Observables
|
||||||
.combineLatest(
|
.combineLatest(
|
||||||
|
|||||||
@@ -21,17 +21,21 @@ package dev.octoshrimpy.quik.feature.compose
|
|||||||
import android.animation.ObjectAnimator
|
import android.animation.ObjectAnimator
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.os.Build
|
import android.net.Uri
|
||||||
import android.text.Layout
|
import android.text.Layout
|
||||||
import android.text.Spannable
|
import android.text.Spannable
|
||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
|
import android.text.SpannableStringBuilder
|
||||||
|
import android.text.method.LinkMovementMethod
|
||||||
|
import android.text.style.ClickableSpan
|
||||||
import android.text.style.StyleSpan
|
import android.text.style.StyleSpan
|
||||||
|
import android.text.style.URLSpan
|
||||||
|
import android.text.util.Linkify
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.ProgressBar
|
import android.widget.ProgressBar
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import com.jakewharton.rxbinding2.view.clicks
|
import com.jakewharton.rxbinding2.view.clicks
|
||||||
import com.moez.QKSMS.common.QkMediaPlayer
|
import com.moez.QKSMS.common.QkMediaPlayer
|
||||||
import dev.octoshrimpy.quik.R
|
import dev.octoshrimpy.quik.R
|
||||||
@@ -107,6 +111,7 @@ class MessagesAdapter @Inject constructor(
|
|||||||
|
|
||||||
val clicks: Subject<Long> = PublishSubject.create()
|
val clicks: Subject<Long> = PublishSubject.create()
|
||||||
val partClicks: Subject<Long> = PublishSubject.create()
|
val partClicks: Subject<Long> = PublishSubject.create()
|
||||||
|
val messageLinkClicks: Subject<Uri> = PublishSubject.create()
|
||||||
val cancelSending: Subject<Long> = PublishSubject.create()
|
val cancelSending: Subject<Long> = PublishSubject.create()
|
||||||
val sendNow: Subject<Long> = PublishSubject.create()
|
val sendNow: Subject<Long> = PublishSubject.create()
|
||||||
|
|
||||||
@@ -170,7 +175,6 @@ class MessagesAdapter @Inject constructor(
|
|||||||
val partsAdapter = partsAdapterProvider.get()
|
val partsAdapter = partsAdapterProvider.get()
|
||||||
partsAdapter.clicks.subscribe(partClicks)
|
partsAdapter.clicks.subscribe(partClicks)
|
||||||
view.attachments.adapter = partsAdapter
|
view.attachments.adapter = partsAdapter
|
||||||
view.body.forwardTouches(view)
|
|
||||||
|
|
||||||
return QkViewHolder(view).apply {
|
return QkViewHolder(view).apply {
|
||||||
view.setOnClickListener {
|
view.setOnClickListener {
|
||||||
@@ -240,6 +244,8 @@ class MessagesAdapter @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val cancelableSimpleOnGestureListener = holder.body.forwardTouches(holder.containerView)
|
||||||
|
|
||||||
// Bind the message status
|
// Bind the message status
|
||||||
bindStatus(holder, message, next)
|
bindStatus(holder, message, next)
|
||||||
|
|
||||||
@@ -297,8 +303,47 @@ class MessagesAdapter @Inject constructor(
|
|||||||
false -> TextViewStyler.SIZE_PRIMARY
|
false -> TextViewStyler.SIZE_PRIMARY
|
||||||
})
|
})
|
||||||
|
|
||||||
holder.body.text = messageText
|
val spanString = SpannableStringBuilder(messageText)
|
||||||
holder.body.setVisible(message.isSms() || messageText.isNotBlank())
|
|
||||||
|
when (prefs.messageLinkHandling.get()) {
|
||||||
|
Preferences.MESSAGE_LINK_HANDLING_BLOCK -> holder.body.autoLinkMask = 0
|
||||||
|
Preferences.MESSAGE_LINK_HANDLING_ASK -> {
|
||||||
|
// manually handle link clicks if user has set to ask before opening links
|
||||||
|
holder.body.isClickable = false
|
||||||
|
holder.body.linksClickable = false
|
||||||
|
holder.body.movementMethod = LinkMovementMethod.getInstance()
|
||||||
|
|
||||||
|
Linkify.addLinks(spanString, holder.body.autoLinkMask)
|
||||||
|
|
||||||
|
for (span in spanString.getSpans(
|
||||||
|
0,
|
||||||
|
spanString.length,
|
||||||
|
URLSpan::class.java)
|
||||||
|
) {
|
||||||
|
// set handler for when user touches a link into new span
|
||||||
|
spanString.setSpan(
|
||||||
|
object : ClickableSpan() {
|
||||||
|
override fun onClick(widget: View) {
|
||||||
|
messageLinkClicks.onNext(Uri.parse(span.url))
|
||||||
|
|
||||||
|
// interrupt the upcoming click event on the body view
|
||||||
|
cancelableSimpleOnGestureListener.cancelCurrentClick()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
spanString.getSpanStart(span),
|
||||||
|
spanString.getSpanEnd(span),
|
||||||
|
spanString.getSpanFlags(span)
|
||||||
|
)
|
||||||
|
|
||||||
|
// remove original span
|
||||||
|
spanString.removeSpan(span)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.body.text = spanString
|
||||||
|
holder.body.setVisible(message.isSms() || spanString.isNotBlank())
|
||||||
|
|
||||||
holder.body.setBackgroundResource(getBubble(
|
holder.body.setBackgroundResource(getBubble(
|
||||||
emojiOnly = emojiOnly,
|
emojiOnly = emojiOnly,
|
||||||
canGroupWithPrevious = canGroup(message, previous) || media.isNotEmpty(),
|
canGroupWithPrevious = canGroup(message, previous) || media.isNotEmpty(),
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import dev.octoshrimpy.quik.common.util.extensions.animateLayoutChanges
|
|||||||
import dev.octoshrimpy.quik.common.util.extensions.setBackgroundTint
|
import dev.octoshrimpy.quik.common.util.extensions.setBackgroundTint
|
||||||
import dev.octoshrimpy.quik.common.util.extensions.setVisible
|
import dev.octoshrimpy.quik.common.util.extensions.setVisible
|
||||||
import dev.octoshrimpy.quik.common.widget.PreferenceView
|
import dev.octoshrimpy.quik.common.widget.PreferenceView
|
||||||
import dev.octoshrimpy.quik.common.widget.QkSwitch
|
|
||||||
import dev.octoshrimpy.quik.common.widget.TextInputDialog
|
import dev.octoshrimpy.quik.common.widget.TextInputDialog
|
||||||
import dev.octoshrimpy.quik.feature.settings.about.AboutController
|
import dev.octoshrimpy.quik.feature.settings.about.AboutController
|
||||||
import dev.octoshrimpy.quik.feature.settings.autodelete.AutoDeleteDialog
|
import dev.octoshrimpy.quik.feature.settings.autodelete.AutoDeleteDialog
|
||||||
@@ -73,6 +72,7 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
|||||||
@Inject lateinit var textSizeDialog: QkDialog
|
@Inject lateinit var textSizeDialog: QkDialog
|
||||||
@Inject lateinit var sendDelayDialog: QkDialog
|
@Inject lateinit var sendDelayDialog: QkDialog
|
||||||
@Inject lateinit var mmsSizeDialog: QkDialog
|
@Inject lateinit var mmsSizeDialog: QkDialog
|
||||||
|
@Inject lateinit var messageLinkHandlingDialog: QkDialog
|
||||||
|
|
||||||
@Inject override lateinit var presenter: SettingsPresenter
|
@Inject override lateinit var presenter: SettingsPresenter
|
||||||
|
|
||||||
@@ -113,6 +113,7 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
|||||||
textSizeDialog.adapter.setData(R.array.text_sizes)
|
textSizeDialog.adapter.setData(R.array.text_sizes)
|
||||||
sendDelayDialog.adapter.setData(R.array.delayed_sending_labels)
|
sendDelayDialog.adapter.setData(R.array.delayed_sending_labels)
|
||||||
mmsSizeDialog.adapter.setData(R.array.mms_sizes, R.array.mms_sizes_ids)
|
mmsSizeDialog.adapter.setData(R.array.mms_sizes, R.array.mms_sizes_ids)
|
||||||
|
messageLinkHandlingDialog.adapter.setData(R.array.messageLinkHandlings, R.array.messageLinkHandling_ids)
|
||||||
|
|
||||||
about.summary = context.getString(R.string.settings_version, BuildConfig.VERSION_NAME)
|
about.summary = context.getString(R.string.settings_version, BuildConfig.VERSION_NAME)
|
||||||
}
|
}
|
||||||
@@ -150,6 +151,8 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
|||||||
|
|
||||||
override fun mmsSizeSelected(): Observable<Int> = mmsSizeDialog.adapter.menuItemClicks
|
override fun mmsSizeSelected(): Observable<Int> = mmsSizeDialog.adapter.menuItemClicks
|
||||||
|
|
||||||
|
override fun messageLinkHandlingSelected(): Observable<Int> = messageLinkHandlingDialog.adapter.menuItemClicks
|
||||||
|
|
||||||
override fun render(state: SettingsState) {
|
override fun render(state: SettingsState) {
|
||||||
themePreview.setBackgroundTint(state.theme)
|
themePreview.setBackgroundTint(state.theme)
|
||||||
night.summary = state.nightModeSummary
|
night.summary = state.nightModeSummary
|
||||||
@@ -195,6 +198,9 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
|||||||
mmsSize.summary = state.maxMmsSizeSummary
|
mmsSize.summary = state.maxMmsSizeSummary
|
||||||
mmsSizeDialog.adapter.selectedItem = state.maxMmsSizeId
|
mmsSizeDialog.adapter.selectedItem = state.maxMmsSizeId
|
||||||
|
|
||||||
|
messsageLinkHandling.summary = state.messageLinkHandlingSummary
|
||||||
|
messageLinkHandlingDialog.adapter.selectedItem = state.messageLinkHandlingId
|
||||||
|
|
||||||
when (state.syncProgress) {
|
when (state.syncProgress) {
|
||||||
is SyncRepository.SyncProgress.Idle -> syncingProgress.isVisible = false
|
is SyncRepository.SyncProgress.Idle -> syncingProgress.isVisible = false
|
||||||
|
|
||||||
@@ -254,6 +260,8 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
|||||||
|
|
||||||
override fun showMmsSizePicker() = mmsSizeDialog.show(activity!!)
|
override fun showMmsSizePicker() = mmsSizeDialog.show(activity!!)
|
||||||
|
|
||||||
|
override fun showMessageLinkHandlingDialogPicker() = messageLinkHandlingDialog.show(activity!!)
|
||||||
|
|
||||||
override fun showSwipeActions() {
|
override fun showSwipeActions() {
|
||||||
router.pushController(RouterTransaction.with(SwipeActionsController())
|
router.pushController(RouterTransaction.with(SwipeActionsController())
|
||||||
.pushChangeHandler(QkChangeHandler())
|
.pushChangeHandler(QkChangeHandler())
|
||||||
|
|||||||
@@ -138,6 +138,19 @@ class SettingsPresenter @Inject constructor(
|
|||||||
newState { copy(maxMmsSizeSummary = mmsSizeLabels[index], maxMmsSizeId = maxMmsSize) }
|
newState { copy(maxMmsSizeSummary = mmsSizeLabels[index], maxMmsSizeId = maxMmsSize) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val messageLinkHandlingLabels = context.resources.getStringArray(R.array.messageLinkHandlings)
|
||||||
|
val messageLinkHandlingIds = context.resources.getIntArray(R.array.messageLinkHandling_ids)
|
||||||
|
disposables += prefs.messageLinkHandling.asObservable()
|
||||||
|
.subscribe { messageLinkHandlingId ->
|
||||||
|
val index = messageLinkHandlingIds.indexOf(messageLinkHandlingId)
|
||||||
|
newState {
|
||||||
|
copy(
|
||||||
|
messageLinkHandlingSummary = messageLinkHandlingLabels[index],
|
||||||
|
messageLinkHandlingId = messageLinkHandlingId
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
disposables += syncRepo.syncProgress
|
disposables += syncRepo.syncProgress
|
||||||
.sample(16, TimeUnit.MILLISECONDS)
|
.sample(16, TimeUnit.MILLISECONDS)
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
@@ -204,6 +217,8 @@ class SettingsPresenter @Inject constructor(
|
|||||||
|
|
||||||
R.id.mmsSize -> view.showMmsSizePicker()
|
R.id.mmsSize -> view.showMmsSizePicker()
|
||||||
|
|
||||||
|
R.id.messsageLinkHandling -> view.showMessageLinkHandlingDialogPicker()
|
||||||
|
|
||||||
R.id.sync -> syncMessages.execute(Unit)
|
R.id.sync -> syncMessages.execute(Unit)
|
||||||
|
|
||||||
R.id.about -> view.showAbout()
|
R.id.about -> view.showAbout()
|
||||||
@@ -294,6 +309,10 @@ class SettingsPresenter @Inject constructor(
|
|||||||
view.mmsSizeSelected()
|
view.mmsSizeSelected()
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe(prefs.mmsSize::set)
|
.subscribe(prefs.mmsSize::set)
|
||||||
|
|
||||||
|
view.messageLinkHandlingSelected()
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe(prefs.messageLinkHandling::set)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -46,5 +46,7 @@ data class SettingsState(
|
|||||||
val longAsMms: Boolean = false,
|
val longAsMms: Boolean = false,
|
||||||
val maxMmsSizeSummary: String = "100KB",
|
val maxMmsSizeSummary: String = "100KB",
|
||||||
val maxMmsSizeId: Int = 100,
|
val maxMmsSizeId: Int = 100,
|
||||||
|
val messageLinkHandlingSummary: String = "Ask before opening",
|
||||||
|
val messageLinkHandlingId: Int = 2,
|
||||||
val syncProgress: SyncRepository.SyncProgress = SyncRepository.SyncProgress.Idle
|
val syncProgress: SyncRepository.SyncProgress = SyncRepository.SyncProgress.Idle
|
||||||
)
|
)
|
||||||
@@ -34,6 +34,7 @@ interface SettingsView : QkViewContract<SettingsState> {
|
|||||||
fun signatureChanged(): Observable<String>
|
fun signatureChanged(): Observable<String>
|
||||||
fun autoDeleteChanged(): Observable<Int>
|
fun autoDeleteChanged(): Observable<Int>
|
||||||
fun mmsSizeSelected(): Observable<Int>
|
fun mmsSizeSelected(): Observable<Int>
|
||||||
|
fun messageLinkHandlingSelected(): Observable<Int>
|
||||||
|
|
||||||
fun showQksmsPlusSnackbar()
|
fun showQksmsPlusSnackbar()
|
||||||
fun showNightModeDialog()
|
fun showNightModeDialog()
|
||||||
@@ -45,6 +46,7 @@ interface SettingsView : QkViewContract<SettingsState> {
|
|||||||
fun showAutoDeleteDialog(days: Int)
|
fun showAutoDeleteDialog(days: Int)
|
||||||
suspend fun showAutoDeleteWarningDialog(messages: Int): Boolean
|
suspend fun showAutoDeleteWarningDialog(messages: Int): Boolean
|
||||||
fun showMmsSizePicker()
|
fun showMmsSizePicker()
|
||||||
|
fun showMessageLinkHandlingDialogPicker()
|
||||||
fun showSwipeActions()
|
fun showSwipeActions()
|
||||||
fun showThemePicker()
|
fun showThemePicker()
|
||||||
fun showAbout()
|
fun showAbout()
|
||||||
|
|||||||
@@ -212,6 +212,15 @@
|
|||||||
app:title="@string/settings_mms_size_title"
|
app:title="@string/settings_mms_size_title"
|
||||||
tools:summary="100KB" />
|
tools:summary="100KB" />
|
||||||
|
|
||||||
|
<dev.octoshrimpy.quik.common.widget.PreferenceView
|
||||||
|
android:id="@+id/messsageLinkHandling"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:icon="@android:drawable/stat_sys_warning"
|
||||||
|
app:title="@string/settings_mms_weblink_title"
|
||||||
|
tools:summary="100KB" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
|
|||||||
@@ -296,6 +296,7 @@
|
|||||||
<string name="settings_long_as_mms_title">Send long messages as MMS</string>
|
<string name="settings_long_as_mms_title">Send long messages as MMS</string>
|
||||||
<string name="settings_long_as_mms_summary">If your longer text messages are failing to send, or sending in the wrong order, you can send them as MMS messages instead. Additional charges may apply</string>
|
<string name="settings_long_as_mms_summary">If your longer text messages are failing to send, or sending in the wrong order, you can send them as MMS messages instead. Additional charges may apply</string>
|
||||||
<string name="settings_mms_size_title">Auto-compress MMS image attachments</string>
|
<string name="settings_mms_size_title">Auto-compress MMS image attachments</string>
|
||||||
|
<string name="settings_mms_weblink_title">Link handling in messages</string>
|
||||||
<string name="settings_sync_title">Sync messages</string>
|
<string name="settings_sync_title">Sync messages</string>
|
||||||
<string name="settings_sync_summary">Re-sync your messages with the native Android SMS database</string>
|
<string name="settings_sync_summary">Re-sync your messages with the native Android SMS database</string>
|
||||||
<string name="settings_about_title">About QUIK</string>
|
<string name="settings_about_title">About QUIK</string>
|
||||||
@@ -505,6 +506,18 @@
|
|||||||
<item>0</item>
|
<item>0</item>
|
||||||
</integer-array>
|
</integer-array>
|
||||||
|
|
||||||
|
<string-array name="messageLinkHandlings">
|
||||||
|
<item>Block</item>
|
||||||
|
<item>Allow</item>
|
||||||
|
<item>Ask before opening</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<integer-array name="messageLinkHandling_ids">
|
||||||
|
<item>0</item>
|
||||||
|
<item>1</item>
|
||||||
|
<item>2</item>
|
||||||
|
</integer-array>
|
||||||
|
|
||||||
<string-array name="qk_responses">
|
<string-array name="qk_responses">
|
||||||
<item>Okay</item>
|
<item>Okay</item>
|
||||||
<item>Give me a moment</item>
|
<item>Give me a moment</item>
|
||||||
@@ -521,4 +534,8 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
<string name="speak_no_messages">No Messages</string>
|
<string name="speak_no_messages">No Messages</string>
|
||||||
<string name="speak_unseen_messages">Speak unseen messages</string>
|
<string name="speak_unseen_messages">Speak unseen messages</string>
|
||||||
|
<string name="messageLinkHandling_dialog_title">External Link Warning</string>
|
||||||
|
<string name="messageLinkHandling_dialog_body">Some links may be unsafe or redirect you unexpectedly. Review the link below before proceeding:\n\n%1$s\n\nDo you want to continue?</string>
|
||||||
|
<string name="messageLinkHandling_dialog_positive">Yes, open the link</string>
|
||||||
|
<string name="messageLinkHandling_dialog_negative">No</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user