Merge pull request #6 from moezbhatti/v3.10

V3.10
This commit is contained in:
octoshrimpy
2023-07-17 14:44:01 -06:00
committed by GitHub
120 changed files with 3187 additions and 2790 deletions
@@ -156,11 +156,6 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
.subscribe()
window.callback = ComposeWindowCallback(window.callback, this)
// These theme attributes don't apply themselves on API 21
if (Build.VERSION.SDK_INT <= 22) {
messageBackground.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
}
}
override fun onStart() {
@@ -403,8 +398,8 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
super.onSaveInstanceState(outState)
}
override fun onRestoreInstanceState(savedInstanceState: Bundle?) {
cameraDestination = savedInstanceState?.getParcelable(CameraDestinationKey)
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
cameraDestination = savedInstanceState.getParcelable(CameraDestinationKey)
super.onRestoreInstanceState(savedInstanceState)
}
@@ -433,7 +433,7 @@ class ComposeViewModel @Inject constructor(
.autoDisposable(view.scope())
.subscribe { part ->
if (permissionManager.hasStorage()) {
messageRepo.savePart(part.id)?.let(navigator::viewFile)
messageRepo.savePart(part.id)?.let { navigator.viewFile(it, part.type) }
} else {
view.requestStoragePermission()
}
@@ -634,23 +634,36 @@ class ComposeViewModel @Inject constructor(
// Send a message when the send button is clicked, and disable editing mode if it's enabled
view.sendIntent
.filter { permissionManager.isDefaultSms().also { if (!it) view.requestDefaultSms() } }
.filter { permissionManager.hasSendSms().also { if (!it) view.requestSmsPermission() } }
.withLatestFrom(view.textChangedIntent) { _, body -> body }
.map { body -> body.toString() }
.withLatestFrom(view.textChangedIntent) { _, body -> body.toString() }
.withLatestFrom(state, attachments, conversation, selectedChips) { body, state, attachments,
conversation, chips ->
val subId = state.subscription?.subscriptionId ?: -1
val addresses = when (conversation.recipients.isNotEmpty()) {
true -> conversation.recipients.map { it.address }
false -> chips.map { chip -> chip.address }
if (!permissionManager.isDefaultSms()) {
view.requestDefaultSms()
return@withLatestFrom
}
if (!permissionManager.hasSendSms()) {
view.requestSmsPermission()
return@withLatestFrom
}
val delay = when (prefs.sendDelay.get()) {
Preferences.SEND_DELAY_SHORT -> 3000
Preferences.SEND_DELAY_MEDIUM -> 5000
Preferences.SEND_DELAY_LONG -> 10000
else -> 0
}
if ((delay != 0 || state.scheduled != 0L) && !permissionManager.hasExactAlarms()) {
navigator.showExactAlarmsSettings()
return@withLatestFrom
}
val subId = state.subscription?.subscriptionId ?: -1
val addresses = when (conversation.recipients.isNotEmpty()) {
true -> conversation.recipients.map { it.address }
false -> chips.map { chip -> chip.address }
}
val sendAsGroup = !state.editingMode || state.sendAsGroup
when {
@@ -83,7 +83,7 @@ class ComposeWindowCallback(
return localCallback.onCreatePanelMenu(i, menu)
}
override fun onPreparePanel(i: Int, view: View, menu: Menu): Boolean {
override fun onPreparePanel(i: Int, view: View?, menu: Menu): Boolean {
return localCallback.onPreparePanel(i, view, menu)
}
@@ -123,7 +123,6 @@ class ComposeWindowCallback(
return localCallback.onSearchRequested()
}
@RequiresApi(api = Build.VERSION_CODES.M)
override fun onSearchRequested(searchEvent: SearchEvent): Boolean {
return localCallback.onSearchRequested(searchEvent)
}
@@ -132,7 +131,6 @@ class ComposeWindowCallback(
return localCallback.onWindowStartingActionMode(callback)
}
@RequiresApi(api = Build.VERSION_CODES.M)
override fun onWindowStartingActionMode(callback: ActionMode.Callback, i: Int): ActionMode? {
return localCallback.onWindowStartingActionMode(callback, i)
}
@@ -152,9 +152,7 @@ class MessagesAdapter @Inject constructor(
view = layoutInflater.inflate(R.layout.message_list_item_in, parent, false)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
view.body.hyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NONE
}
view.body.hyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NONE
val partsAdapter = partsAdapterProvider.get()
partsAdapter.clicks.subscribe(partClicks)
@@ -44,11 +44,6 @@ class ChipsAdapter @Inject constructor() : QkAdapter<Recipient>() {
val inflater = LayoutInflater.from(parent.context)
val view = inflater.inflate(R.layout.contact_chip, parent, false)
return QkViewHolder(view).apply {
// These theme attributes don't apply themselves on API 21
if (Build.VERSION.SDK_INT <= 22) {
content.setBackgroundTint(view.context.resolveThemeColor(R.attr.bubbleColor))
}
view.setOnClickListener {
val chip = getItem(adapterPosition)
showDetailedChip(view.context, chip)