Skip to content

Commit

Permalink
Merge pull request #456 from jorgeblacio/release_0_18_6
Browse files Browse the repository at this point in the history
Various fixes.
  • Loading branch information
danieltigse authored Apr 17, 2019
2 parents d538dbc + 967aa1c commit cb5de1e
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 26 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 60
versionName "0.18.5"
versionCode 61
versionName "0.18.6"
applicationId "com.criptext.mail"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
Expand Down
12 changes: 8 additions & 4 deletions src/main/kotlin/com/criptext/mail/BaseActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,17 @@ abstract class BaseActivity: PinCompatActivity(), IHostActivity {
Intent.ACTION_SEND_MULTIPLE -> {
val data = intent
if(data != null) {
val account = intent.extras.getString("account")
val account = intent.extras.getString("account") ?: ActiveAccount.loadFromStorage(this)!!.recipientId
val clipData = data.clipData
if(clipData == null) {
data.data?.also { uri ->
val attachment = FileUtils.getPathAndSizeFromUri(uri, contentResolver, this)
if (attachment != null)
return IntentExtrasData.IntentExtrasSend(intent.action, listOf(attachment), account)
return IntentExtrasData.IntentExtrasSend(intent.action, listOf(attachment), listOf(), account)
}
}else{
val attachmentList = mutableListOf<Pair<String, Long>>()
val urlList = mutableListOf<String>()
for (i in 0 until clipData.itemCount) {
clipData.getItemAt(i).also { item ->
if (item.uri != null) {
Expand All @@ -485,10 +486,13 @@ abstract class BaseActivity: PinCompatActivity(), IHostActivity {
if (attachment != null)
attachmentList.add(attachment)
}
if(item.text != null){
urlList.add("<a href=\"${item.text}\">${item.text}</a>")
}
}
}
if (attachmentList.isNotEmpty())
return IntentExtrasData.IntentExtrasSend(intent.action, attachmentList, account)
if (attachmentList.isNotEmpty() || urlList.isNotEmpty())
return IntentExtrasData.IntentExtrasSend(intent.action, attachmentList, urlList, account)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sealed class IntentExtrasData(open val action: String, open val account: String)
val deviceType: DeviceUtils.DeviceType, val syncFileVersion: Int, override val account: String) : IntentExtrasData(action, account)
data class IntentExtrasReply(override val action: String, val threadId: String, val metadataKey: Long, override val account: String) : IntentExtrasData(action, account)
data class IntentExtrasMailTo(override val action: String, val mailTo: String, override val account: String) : IntentExtrasData(action, account)
data class IntentExtrasSend(override val action: String, val files: List<Pair<String, Long>>, override val account: String) : IntentExtrasData(action, account)
data class IntentExtrasSend(override val action: String, val files: List<Pair<String, Long>>, val urls: List<String>, override val account: String) : IntentExtrasData(action, account)
data class IntentErrorMessage(override val action: String, val uiMessage: UIMessage, override val account: String) : IntentExtrasData(action, account)

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ sealed class ActivityMessage {
val composerInputData: ComposerInputData,
val attachments: List<ComposerAttachment>, val fileKey: String?): ActivityMessage()
data class AddAttachments(val filesMetadata: List<Pair<String, Long>>): ActivityMessage()
data class AddUrls(val urls: List<String>): ActivityMessage()
data class ProfilePictureFile(val filesMetadata: Pair<String, Long>): ActivityMessage()
data class UpdateUnreadStatusThread(val threadId: String, val unread: Boolean): ActivityMessage()
data class UpdateLabelsThread(val threadId: String, val selectedLabelIds: List<Long>): ActivityMessage()
Expand Down
16 changes: 9 additions & 7 deletions src/main/kotlin/com/criptext/mail/scenes/WebViewActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ class WebViewActivity : AppCompatActivity() {
override fun onCreateOptionsMenu(menu: Menu): Boolean {
val inflater = menuInflater
inflater.inflate(R.menu.menu_webview, menu)
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(mUrl))
val resolveInfo = packageManager.resolveActivity(browserIntent, PackageManager.MATCH_DEFAULT_ONLY)
browserName = resolveInfo.activityInfo.packageName

menu.findItem(R.id.ac_open).title = this.getLocalizedUIMessage(UIMessage(
R.string.web_view_open_in_chrome, arrayOf(resolveInfo.loadLabel(packageManager).toString())
))
if(!mUrl.isNullOrEmpty()) {
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(mUrl))
val resolveInfo = packageManager.resolveActivity(browserIntent, PackageManager.MATCH_DEFAULT_ONLY)
browserName = resolveInfo.activityInfo.packageName

menu.findItem(R.id.ac_open)?.title = this.getLocalizedUIMessage(UIMessage(
R.string.web_view_open_in_chrome, arrayOf(resolveInfo.loadLabel(packageManager).toString())
))
}
return super.onCreateOptionsMenu(menu)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package com.criptext.mail.scenes.composer

import android.content.Intent
import android.net.Uri
import android.provider.OpenableColumns
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import com.criptext.mail.BaseActivity
import com.criptext.mail.R
Expand All @@ -21,12 +23,9 @@ import com.criptext.mail.signal.SignalClient
import com.criptext.mail.signal.SignalStoreCriptext
import com.criptext.mail.utils.KeyboardManager
import com.criptext.mail.utils.PhotoUtil
import com.criptext.mail.utils.UIMessage
import com.criptext.mail.utils.file.FileUtils
import com.criptext.mail.utils.file.PathUtil
import com.criptext.mail.utils.generaldatasource.data.GeneralDataSource
import droidninja.filepicker.FilePickerConst
import java.io.File


class ComposerActivity : BaseActivity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,19 @@ class ComposerController(private val storage: KeyValueStorage,
PinLockUtils.resetLastMillisPin()
PinLockUtils.setPinLockTimeoutPosition(storage.getInt(KeyValueStorage.StringKey.PINTimeout, 1))
if (activityMessage is ActivityMessage.AddAttachments) {
generateEmailFileKey()
addNewAttachments(activityMessage.filesMetadata)
if(activityMessage.filesMetadata.isNotEmpty()){
generateEmailFileKey()
addNewAttachments(activityMessage.filesMetadata)
}
return true
}else if(activityMessage is ActivityMessage.ShowUIMessage){
} else if (activityMessage is ActivityMessage.AddUrls){
if(activityMessage.urls.isNotEmpty()){
activityMessage.urls.forEach {
model.body = model.body.plus(it.plus("\n"))
}
bindWithModel(ComposerInputData.fromModel(model), activeAccount.signature)
}
} else if(activityMessage is ActivityMessage.ShowUIMessage){
scene.showError(activityMessage.message)
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import android.view.View
import com.criptext.mail.*
import com.criptext.mail.api.models.DeviceInfo
import com.criptext.mail.api.models.SyncStatusData
import com.criptext.mail.bgworker.BackgroundWorkManager
import com.criptext.mail.db.KeyValueStorage
import com.criptext.mail.db.models.Account
import com.criptext.mail.db.models.ActiveAccount
Expand Down Expand Up @@ -551,7 +550,8 @@ class MailboxSceneController(private val scene: MailboxScene,
Intent.ACTION_SEND_MULTIPLE,
Intent.ACTION_SEND -> {
val extrasMail = extras as IntentExtrasData.IntentExtrasSend
val composerMessage = ActivityMessage.AddAttachments(extrasMail.files)
val composerMessage = if(extrasMail.files.isNotEmpty()) ActivityMessage.AddAttachments(extrasMail.files)
else ActivityMessage.AddUrls(extrasMail.urls)
host.exitToScene(ComposerParams(type = ComposerType.Empty()), composerMessage, false, true)
}
}
Expand Down Expand Up @@ -1085,6 +1085,7 @@ class MailboxSceneController(private val scene: MailboxScene,
is GeneralResult.TotalUnreadEmails.Success -> {
scene.setToolbarNumberOfEmails(resultData.activeAccountTotal)
scene.setMenuAccounts(model.extraAccounts, resultData.extraAccountsData.map { it.second })
resultData.extraAccountsData.forEach { if(it.second > 0) scene.showExtraAccountsBadge(true) }
scene.updateBadges(resultData.extraAccountsData)

}
Expand Down Expand Up @@ -1134,7 +1135,6 @@ class MailboxSceneController(private val scene: MailboxScene,
if(resultData.isActiveAccount)
handleSuccessfulMailboxUpdate(resultData)
else {
scene.showExtraAccountsBadge(true)
generalDataSource.submitRequest(GeneralRequest.TotalUnreadEmails(model.selectedLabel.text))
dataSource.submitRequest(MailboxRequest.GetMenuInformation())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class RegisterUserWorker(
}

override fun work(reporter: ProgressReporter<RegisterUser>): RegisterUser? {
db.clearAllTables()
val registrationBundle = signalKeyGenerator.register(
recipientId = incompleteAccount.username,
deviceId = 1)
Expand Down
2 changes: 1 addition & 1 deletion src/main/res/menu/menu_webview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
tools:context=".login.GruposActivity">

<item android:id="@+id/ac_open"
android:title="@string/web_view_open_in_chrome"
android:title="@string/web_view_open_in_browser"
android:orderInCategory="100"
app:showAsAction="collapseActionView"/>

Expand Down
1 change: 1 addition & 0 deletions src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<string name="mk_label_today">Hoy</string>
<string name="error_no_app_for_file">Puede que no tengas una aplicación que pueda abrir este tipo de archivo.</string>
<string name="web_view_open_in_chrome">Abrir en %1$s</string>
<string name="web_view_open_in_browser">Abrir en Navegador</string>
<string name="attachment_limit_reached">Solo se permite %1$d archivos por correo.</string>
<string name="attachment_history_opened">abierto:</string>
<string name="title_sync">Sincronización de Buzón</string>
Expand Down
1 change: 1 addition & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<string name="mk_label_today">Today </string>
<string name="error_no_app_for_file">You may not have a proper app for viewing this content</string>
<string name="web_view_open_in_chrome">Open in %1$s</string>
<string name="web_view_open_in_browser">Open in browser</string>
<string name="attachment_limit_reached">Only %1$d attachments per email allowed.</string>
<string name="attachment_history_opened">opened:</string>
<string name="title_sync">Mailbox Sync</string>
Expand Down

0 comments on commit cb5de1e

Please sign in to comment.