Unverified Commit 9bc1a4bf authored by Lucio Maciel's avatar Lucio Maciel Committed by GitHub

Merge branch 'beta' into emoji-picker-layout-adjustments

parents 421106c4 cf0b6d7c
app/src/main/ic_launcher-web.png

39.1 KB | W: | H:

app/src/main/ic_launcher-web.png

63.8 KB | W: | H:

app/src/main/ic_launcher-web.png
app/src/main/ic_launcher-web.png
app/src/main/ic_launcher-web.png
app/src/main/ic_launcher-web.png
  • 2-up
  • Swipe
  • Onion skin
package chat.rocket.android.chatroom.presentation package chat.rocket.android.chatroom.presentation
import android.graphics.Bitmap
import android.net.Uri import android.net.Uri
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.analytics.AnalyticsManager import chat.rocket.android.analytics.AnalyticsManager
...@@ -80,6 +81,7 @@ import org.threeten.bp.Instant ...@@ -80,6 +81,7 @@ import org.threeten.bp.Instant
import timber.log.Timber import timber.log.Timber
import java.io.InputStream import java.io.InputStream
import java.util.* import java.util.*
import java.util.zip.DeflaterInputStream
import javax.inject.Inject import javax.inject.Inject
class ChatRoomPresenter @Inject constructor( class ChatRoomPresenter @Inject constructor(
...@@ -331,7 +333,7 @@ class ChatRoomPresenter @Inject constructor( ...@@ -331,7 +333,7 @@ class ChatRoomPresenter @Inject constructor(
view.showFileSelection(settings.uploadMimeTypeFilter()) view.showFileSelection(settings.uploadMimeTypeFilter())
} }
fun uploadFile(roomId: String, uri: Uri, msg: String) { fun uploadFile(roomId: String, uri: Uri, msg: String, bitmap: Bitmap? = null) {
launchUI(strategy) { launchUI(strategy) {
view.showLoading() view.showLoading()
try { try {
...@@ -348,12 +350,8 @@ class ChatRoomPresenter @Inject constructor( ...@@ -348,12 +350,8 @@ class ChatRoomPresenter @Inject constructor(
else -> { else -> {
var inputStream: InputStream? = uriInteractor.getInputStream(uri) var inputStream: InputStream? = uriInteractor.getInputStream(uri)
if (mimeType.contains("image")) { bitmap?.compressImageAndGetInputStream(mimeType)?.let {
uriInteractor.getBitmap(uri)?.let { inputStream = it
it.compressImageAndGetInputStream(mimeType)?.let {
inputStream = it
}
}
} }
retryIO("uploadFile($roomId, $fileName, $mimeType") { retryIO("uploadFile($roomId, $fileName, $mimeType") {
......
package chat.rocket.android.chatroom.ui package chat.rocket.android.chatroom.ui
import android.graphics.Bitmap
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.net.Uri import android.net.Uri
import androidx.core.view.isVisible import androidx.core.view.isVisible
import chat.rocket.android.emoji.internal.GlideApp
import chat.rocket.android.util.extensions.getFileName import chat.rocket.android.util.extensions.getFileName
import chat.rocket.android.util.extensions.getMimeType import chat.rocket.android.util.extensions.getMimeType
import com.bumptech.glide.request.target.SimpleTarget
import com.bumptech.glide.request.transition.Transition
fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) { fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) {
activity?.let { fragmentActivity -> var bitmap: Bitmap? = null
uri.getMimeType(fragmentActivity).let { mimeType ->
activity?.let { context ->
uri.getMimeType(context).let { mimeType ->
description.text.clear() description.text.clear()
when { when {
mimeType.startsWith("image") -> { mimeType.startsWith("image") -> {
imagePreview.isVisible = true GlideApp
imagePreview.setImageURI(uri) .with(context)
} .asBitmap()
mimeType.startsWith("video") -> { .load(uri)
audioVideoAttachment.isVisible = true .override(500, 500)
.centerCrop()
.into(object : SimpleTarget<Bitmap>() {
override fun onResourceReady(
resource: Bitmap,
transition: Transition<in Bitmap>?
) {
bitmap = resource
imagePreview.isVisible = true
imagePreview.setImageBitmap(resource)
}
})
} }
mimeType.startsWith("video") -> audioVideoAttachment.isVisible = true
else -> { else -> {
textFile.isVisible = true textFile.isVisible = true
textFile.text = uri.getFileName(fragmentActivity) textFile.text = uri.getFileName(context)
} }
} }
} }
} }
sendButton.setOnClickListener { sendButton.setOnClickListener {
presenter.uploadFile(chatRoomId, uri, (citation ?: "") + description.text.toString()) presenter.uploadFile(
chatRoomId,
uri,
(citation ?: "") + description.text.toString(),
bitmap
)
alertDialog.dismiss() alertDialog.dismiss()
} }
cancelButton.setOnClickListener { alertDialog.dismiss() } cancelButton.setOnClickListener { alertDialog.dismiss() }
......
...@@ -34,8 +34,8 @@ class FileUiModel( ...@@ -34,8 +34,8 @@ class FileUiModel(
} }
private fun getUserDisplayName(): String { private fun getUserDisplayName(): String {
val username = "@${genericAttachment.user?.username}" val username = "@${genericAttachment.user.username}"
val realName = genericAttachment.user?.name val realName = genericAttachment.user.name
val uploaderName = if (settings.useRealName()) realName else username val uploaderName = if (settings.useRealName()) realName else username
return uploaderName ?: username return uploaderName ?: username
} }
......
...@@ -14,12 +14,12 @@ class SharedPreferencesAccountsRepository( ...@@ -14,12 +14,12 @@ class SharedPreferencesAccountsRepository(
private val moshi: Moshi private val moshi: Moshi
) : AccountsRepository { ) : AccountsRepository {
override fun save(newAccount: Account) { override fun save(account: Account) {
val accounts = load() val accounts = load()
val newList = accounts.filter { account -> newAccount.serverUrl != account.serverUrl } val newList = accounts.filter { it.serverUrl != it.serverUrl }
.toMutableList() .toMutableList()
newList.add(0, newAccount) newList.add(0, account)
save(newList) save(newList)
} }
......
...@@ -27,7 +27,7 @@ class PasswordPresenter @Inject constructor( ...@@ -27,7 +27,7 @@ class PasswordPresenter @Inject constructor(
val me = retryIO("me") { client.me() } val me = retryIO("me") { client.me() }
retryIO("updateProfile(${me.id})") { retryIO("updateProfile(${me.id})") {
client.updateProfile(me.id!!, null, null, password, null) client.updateProfile(me.id, null, null, password, null)
} }
view.showPasswordSuccessfullyUpdatedMessage() view.showPasswordSuccessfullyUpdatedMessage()
......
...@@ -10,15 +10,19 @@ import android.provider.DocumentsContract ...@@ -10,15 +10,19 @@ import android.provider.DocumentsContract
import android.provider.MediaStore import android.provider.MediaStore
import android.provider.OpenableColumns import android.provider.OpenableColumns
import android.webkit.MimeTypeMap import android.webkit.MimeTypeMap
import java.io.* import java.io.File
import java.io.FileInputStream
import java.io.FileNotFoundException
import java.io.IOException
import java.io.InputStream
fun Uri.getFileName(context: Context): String? { fun Uri.getFileName(context: Context): String? {
val cursor = context.contentResolver.query(this, null, null, null, null, null) val cursor = context.contentResolver.query(this, null, null, null, null, null)
var fileName: String? = null var fileName: String? = null
cursor.use { cursor -> cursor?.use {
if (cursor != null && cursor.moveToFirst()) { if (it.moveToFirst()) {
fileName = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)) fileName = it.getString(it.getColumnIndex(OpenableColumns.DISPLAY_NAME))
} }
} }
return fileName return fileName
...@@ -29,7 +33,7 @@ fun Uri.getFileSize(context: Context): Int { ...@@ -29,7 +33,7 @@ fun Uri.getFileSize(context: Context): Int {
if (scheme == ContentResolver.SCHEME_CONTENT) { if (scheme == ContentResolver.SCHEME_CONTENT) {
try { try {
val fileInputStream = context.contentResolver.openInputStream(this) val fileInputStream = context.contentResolver.openInputStream(this)
fileSize = fileInputStream.available().toString() fileSize = fileInputStream?.available().toString()
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }
...@@ -67,14 +71,17 @@ fun Uri.isVirtualFile(context: Context): Boolean { ...@@ -67,14 +71,17 @@ fun Uri.isVirtualFile(context: Context): Boolean {
val cursor = context.contentResolver.query( val cursor = context.contentResolver.query(
this, this,
arrayOf(DocumentsContract.Document.COLUMN_FLAGS), arrayOf(DocumentsContract.Document.COLUMN_FLAGS),
null, null, null null,
null,
null
) )
var flags = 0 var flags = 0
if (cursor.moveToFirst()) { cursor?.use {
flags = cursor.getInt(0) if (it.moveToFirst()) {
flags = it.getInt(0)
}
} }
cursor.close()
return flags and DocumentsContract.Document.FLAG_VIRTUAL_DOCUMENT != 0 return flags and DocumentsContract.Document.FLAG_VIRTUAL_DOCUMENT != 0
} }
...@@ -104,4 +111,4 @@ fun Uri.getInputStream(context: Context): InputStream? { ...@@ -104,4 +111,4 @@ fun Uri.getInputStream(context: Context): InputStream? {
fun Uri.getBitmpap(context: Context): Bitmap? { fun Uri.getBitmpap(context: Context): Bitmap? {
return MediaStore.Images.Media.getBitmap(context.contentResolver, this) return MediaStore.Images.Media.getBitmap(context.contentResolver, this)
} }
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp" android:width="108dp"
android:height="108dp" android:height="108dp"
android:viewportWidth="1055.0303" android:viewportHeight="1055.0303"
android:viewportHeight="1055.0303"> android:viewportWidth="1055.0303">
<path
android:fillType="nonZero" <group
android:pathData="M398.607,219.474L398.612,219.482C398.611,219.48 398.61,219.479 398.609,219.478C398.608,219.477 398.608,219.475 398.607,219.474ZM182.24,104.988C193.825,111.43 204.777,119.58 214.13,128.64C229.206,125.906 244.752,124.527 260.522,124.527C307.733,124.527 352.493,136.926 386.549,159.432C404.185,171.093 418.203,184.928 428.208,200.558C439.352,217.973 445,236.701 445,256.769C445,276.297 439.352,295.032 428.208,312.444C418.203,328.081 404.185,341.913 386.549,353.573C352.493,376.08 307.737,388.47 260.522,388.47C244.752,388.47 229.21,387.092 214.13,384.362C204.773,393.417 193.825,401.572 182.24,408.014C120.335,439.051 69,408.744 69,408.744C69,408.744 116.729,368.178 108.967,332.617C87.612,310.704 76.041,284.276 76.041,256.237C76.041,228.725 87.616,202.297 108.967,180.381C116.727,144.83 69.016,104.271 69,104.258C69.015,104.249 120.345,73.951 182.24,104.988Z" android:translateX="281.28394"
android:strokeWidth="1" android:translateY="271.51514">
android:strokeColor="#00000000"> <path
<aapt:attr name="android:fillColor"> android:fillColor="#FFDB2323"
<gradient android:pathData="M491.3,255.3c0,-24.1 -7.2,-47.2 -21.4,-68.7c-12.8,-19.3 -30.7,-36.4 -53.2,-50.7c-43.5,-27.8 -100.6,-43.1 -160.9,-43.1c-20.1,0 -40,1.7 -59.2,5.1c-11.9,-11.2 -25.9,-21.2 -40.7,-29.2c-79,-38.3 -144.6,-0.9 -144.6,-0.9s60.9,50.1 51,93.9c-27.3,27 -42,59.6 -42,93.6c0,0.1 0,0.2 0,0.3c0,0.1 0,0.2 0,0.3c0,33.9 14.8,66.6 42,93.6c9.9,43.9 -51,93.9 -51,93.9s65.5,37.4 144.6,-0.9c14.8,-8 28.8,-18 40.7,-29.2c19.2,3.4 39.1,5.1 59.2,5.1c60.3,0 117.4,-15.3 160.9,-43.1c22.5,-14.4 40.4,-31.5 53.2,-50.7c14.2,-21.5 21.4,-44.6 21.4,-68.7c0,-0.1 0,-0.2 0,-0.3C491.3,255.6 491.3,255.4 491.3,255.3z" />
android:endX="257" <path
android:endY="383.12793" android:fillColor="#FFFFFF"
android:startX="257" android:pathData="M255.9,124.2c113.9,0 206.3,59 206.3,131.8c0,72.8 -92.4,131.8 -206.3,131.8c-25.4,0 -49.7,-2.9 -72.1,-8.3c-22.8,27.4 -73,65.6 -121.7,53.3c15.9,-17 39.4,-45.8 34.3,-93.2c-29.2,-22.7 -46.8,-51.8 -46.8,-83.5C49.6,183.2 142,124.2 255.9,124.2" />
android:startY="49.942783" <path
android:type="linear"> android:fillColor="#FFDB2323"
<item android:pathData="M255.9,256m-27.4,0a27.4,27.4 0,1 1,54.8 0a27.4,27.4 0,1 1,-54.8 0" />
android:color="#FFDB2323" <path
android:offset="0" /> android:fillColor="#FFDB2323"
<item android:pathData="M351.2,256m-27.4,0a27.4,27.4 0,1 1,54.8 0a27.4,27.4 0,1 1,-54.8 0" />
android:color="#FFDB2323" <path
android:offset="1" /> android:fillColor="#FFDB2323"
</gradient> android:pathData="M160.6,256m-27.4,0a27.4,27.4 0,1 1,54.8 0a27.4,27.4 0,1 1,-54.8 0" />
</aapt:attr> </group>
</path> </vector>
<path \ No newline at end of file
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M144.889,317.876C123.712,301.098 111,279.628 111,256.227C111,202.53 177.933,159 260.5,159C343.067,159 410,202.53 410,256.227C410,309.925 343.067,353.455 260.5,353.455C240.151,353.455 220.751,350.811 203.069,346.022L190.142,358.556C183.117,365.366 174.884,371.529 166.303,376.385C154.928,382.001 143.695,385.065 132.582,386C133.209,384.854 133.787,383.693 134.406,382.546C147.359,358.559 150.854,337.002 144.889,317.876Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
<path
android:fillType="nonZero"
android:pathData="M167,256a22.04,22 0,1 0,44.081 0a22.04,22 0,1 0,-44.081 0z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="189.0405"
android:endY="271.55902"
android:startX="189.0405"
android:startY="230.61958"
android:type="linear">
<item
android:color="#FFDB2323"
android:offset="0" />
<item
android:color="#FFDB2323"
android:offset="1" />
</gradient>
</aapt:attr>
</path>
<path
android:fillType="nonZero"
android:pathData="M237.96,256a22.04,22 0,1 0,44.081 0a22.04,22 0,1 0,-44.081 0z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="260.00052"
android:endY="271.55902"
android:startX="260.00052"
android:startY="230.61958"
android:type="linear">
<item
android:color="#FFDB2323"
android:offset="0" />
<item
android:color="#FFDB2323"
android:offset="1" />
</gradient>
</aapt:attr>
</path>
<path
android:fillType="nonZero"
android:pathData="M308.919,256a22.04,22 0,1 0,44.081 0a22.04,22 0,1 0,-44.081 0z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="330.9595"
android:endY="271.55902"
android:startX="330.9595"
android:startY="230.61958"
android:type="linear">
<item
android:color="#FFDB2323"
android:offset="0" />
<item
android:color="#FFDB2323"
android:offset="1" />
</gradient>
</aapt:attr>
</path>
</vector>
...@@ -44,8 +44,9 @@ ...@@ -44,8 +44,9 @@
<!-- Settings List --> <!-- Settings List -->
<string-array name="settings_actions"> <string-array name="settings_actions">
<item name="item_password">パスワードの変更</item> <item name="item_preferences">Preferences</item> <!-- TODO Add translation -->
<item name="item_password">このアプリケーションについて</item> <item name="item_password">Change Password</item> <!-- TODO Add translation -->
<item name="item_password">About</item> <!-- TODO Add translation -->
</string-array> </string-array>
<!-- Regular information messages --> <!-- Regular information messages -->
......
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
<!-- Preferences messages --> <!-- Preferences messages -->
<string name="msg_analytics_tracking">Отслеживание Analytics</string> <string name="msg_analytics_tracking">Отслеживание Analytics</string>
<string name="msg_send_analytics_tracking">Отправлять анонимную статистику для улучшения приложения.</string> <string name="msg_send_analytics_tracking">Отправлять анонимную статистику для улучшения приложения.</string>
<string name="msg_do_not_send_analytics_tracking">Не отправлять анонимную статистику для улучшения приложения</string> <string name="msg_do_not_send_analytics_tracking">Не отправлять анонимную статистику для улучшения приложения</string>
<string name="msg_not_applicable_since_it_is_a_foss_version">Не применимо, так как это FOSS версия</string> <string name="msg_not_applicable_since_it_is_a_foss_version">Не применимо, так как это FOSS версия</string>
......
...@@ -25,7 +25,7 @@ ext { ...@@ -25,7 +25,7 @@ ext {
playServices : '16.0.0', playServices : '16.0.0',
exoPlayer : '2.8.2', exoPlayer : '2.8.2',
flexbox : '1.0.0', flexbox : '1.0.0',
material : '1.0.0-rc01', material : '1.0.0-beta01',
room : '2.0.0-rc01', room : '2.0.0-rc01',
lifecycle : '2.0.0-rc01', lifecycle : '2.0.0-rc01',
......
Markdown is supported
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