commit
9b13381938
@ -28,9 +28,8 @@ import java.io.File
|
|||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class ImageCompressor @Inject constructor() {
|
internal class ImageCompressor @Inject constructor(private val context: Context) {
|
||||||
suspend fun compress(
|
suspend fun compress(
|
||||||
context: Context,
|
|
||||||
imageFile: File,
|
imageFile: File,
|
||||||
desiredWidth: Int,
|
desiredWidth: Int,
|
||||||
desiredHeight: Int,
|
desiredHeight: Int,
|
||||||
@ -46,7 +45,7 @@ internal class ImageCompressor @Inject constructor() {
|
|||||||
}
|
}
|
||||||
} ?: return@withContext imageFile
|
} ?: return@withContext imageFile
|
||||||
|
|
||||||
val destinationFile = createDestinationFile(context)
|
val destinationFile = createDestinationFile()
|
||||||
|
|
||||||
runCatching {
|
runCatching {
|
||||||
destinationFile.outputStream().use {
|
destinationFile.outputStream().use {
|
||||||
@ -118,7 +117,7 @@ internal class ImageCompressor @Inject constructor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createDestinationFile(context: Context): File {
|
private fun createDestinationFile(): File {
|
||||||
return File.createTempFile(UUID.randomUUID().toString(), null, context.cacheDir)
|
return File.createTempFile(UUID.randomUUID().toString(), null, context.cacheDir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
|
|||||||
// Do not compress gif
|
// Do not compress gif
|
||||||
&& attachment.mimeType != MimeTypes.Gif
|
&& attachment.mimeType != MimeTypes.Gif
|
||||||
&& params.compressBeforeSending) {
|
&& params.compressBeforeSending) {
|
||||||
fileToUpload = imageCompressor.compress(context, workingFile, MAX_IMAGE_SIZE, MAX_IMAGE_SIZE)
|
fileToUpload = imageCompressor.compress(workingFile, MAX_IMAGE_SIZE, MAX_IMAGE_SIZE)
|
||||||
.also { compressedFile ->
|
.also { compressedFile ->
|
||||||
// Get new Bitmap size
|
// Get new Bitmap size
|
||||||
compressedFile.inputStream().use {
|
compressedFile.inputStream().use {
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2021 New Vector Ltd
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package im.vector.app.core.platform
|
|
||||||
|
|
||||||
import com.airbnb.mvrx.MvRxState
|
|
||||||
|
|
||||||
data class EmptyState(
|
|
||||||
val dummy: Int = 0
|
|
||||||
) : MvRxState
|
|
@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2021 New Vector Ltd
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package im.vector.app.core.platform
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mainly used to get a viewModelScope
|
|
||||||
*/
|
|
||||||
class EmptyViewModel(initialState: EmptyState) : VectorViewModel<EmptyState, EmptyAction, EmptyViewEvents>(initialState) {
|
|
||||||
override fun handle(action: EmptyAction) {
|
|
||||||
// N/A
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,15 +22,13 @@ import android.os.Bundle
|
|||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.airbnb.mvrx.viewModel
|
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.di.ActiveSessionHolder
|
import im.vector.app.core.di.ActiveSessionHolder
|
||||||
import im.vector.app.core.di.ScreenComponent
|
import im.vector.app.core.di.ScreenComponent
|
||||||
import im.vector.app.core.error.ErrorFormatter
|
import im.vector.app.core.error.ErrorFormatter
|
||||||
import im.vector.app.core.extensions.startSyncing
|
import im.vector.app.core.extensions.startSyncing
|
||||||
import im.vector.app.core.platform.EmptyViewModel
|
|
||||||
import im.vector.app.core.platform.VectorBaseActivity
|
import im.vector.app.core.platform.VectorBaseActivity
|
||||||
import im.vector.app.core.utils.deleteAllFiles
|
import im.vector.app.core.utils.deleteAllFiles
|
||||||
import im.vector.app.databinding.FragmentLoadingBinding
|
import im.vector.app.databinding.FragmentLoadingBinding
|
||||||
@ -83,8 +81,6 @@ class MainActivity : VectorBaseActivity<FragmentLoadingBinding>(), UnlockedActiv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val emptyViewModel: EmptyViewModel by viewModel()
|
|
||||||
|
|
||||||
override fun getBinding() = FragmentLoadingBinding.inflate(layoutInflater)
|
override fun getBinding() = FragmentLoadingBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
private lateinit var args: MainActivityArgs
|
private lateinit var args: MainActivityArgs
|
||||||
@ -150,7 +146,7 @@ class MainActivity : VectorBaseActivity<FragmentLoadingBinding>(), UnlockedActiv
|
|||||||
}
|
}
|
||||||
when {
|
when {
|
||||||
args.isAccountDeactivated -> {
|
args.isAccountDeactivated -> {
|
||||||
emptyViewModel.viewModelScope.launch {
|
lifecycleScope.launch {
|
||||||
// Just do the local cleanup
|
// Just do the local cleanup
|
||||||
Timber.w("Account deactivated, start app")
|
Timber.w("Account deactivated, start app")
|
||||||
sessionHolder.clearActiveSession()
|
sessionHolder.clearActiveSession()
|
||||||
@ -159,7 +155,7 @@ class MainActivity : VectorBaseActivity<FragmentLoadingBinding>(), UnlockedActiv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
args.clearCredentials -> {
|
args.clearCredentials -> {
|
||||||
emptyViewModel.viewModelScope.launch {
|
lifecycleScope.launch {
|
||||||
try {
|
try {
|
||||||
session.signOut(!args.isUserLoggedOut)
|
session.signOut(!args.isUserLoggedOut)
|
||||||
Timber.w("SIGN_OUT: success, start app")
|
Timber.w("SIGN_OUT: success, start app")
|
||||||
@ -172,7 +168,7 @@ class MainActivity : VectorBaseActivity<FragmentLoadingBinding>(), UnlockedActiv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
args.clearCache -> {
|
args.clearCache -> {
|
||||||
emptyViewModel.viewModelScope.launch {
|
lifecycleScope.launch {
|
||||||
try {
|
try {
|
||||||
session.clearCache()
|
session.clearCache()
|
||||||
doLocalCleanup(clearPreferences = false)
|
doLocalCleanup(clearPreferences = false)
|
||||||
|
@ -19,13 +19,11 @@ package im.vector.app.features.link
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.airbnb.mvrx.viewModel
|
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.di.ActiveSessionHolder
|
import im.vector.app.core.di.ActiveSessionHolder
|
||||||
import im.vector.app.core.di.ScreenComponent
|
import im.vector.app.core.di.ScreenComponent
|
||||||
import im.vector.app.core.error.ErrorFormatter
|
import im.vector.app.core.error.ErrorFormatter
|
||||||
import im.vector.app.core.platform.EmptyViewModel
|
|
||||||
import im.vector.app.core.platform.VectorBaseActivity
|
import im.vector.app.core.platform.VectorBaseActivity
|
||||||
import im.vector.app.core.utils.toast
|
import im.vector.app.core.utils.toast
|
||||||
import im.vector.app.databinding.ActivityProgressBinding
|
import im.vector.app.databinding.ActivityProgressBinding
|
||||||
@ -48,8 +46,6 @@ class LinkHandlerActivity : VectorBaseActivity<ActivityProgressBinding>() {
|
|||||||
@Inject lateinit var errorFormatter: ErrorFormatter
|
@Inject lateinit var errorFormatter: ErrorFormatter
|
||||||
@Inject lateinit var permalinkHandler: PermalinkHandler
|
@Inject lateinit var permalinkHandler: PermalinkHandler
|
||||||
|
|
||||||
private val emptyViewModel: EmptyViewModel by viewModel()
|
|
||||||
|
|
||||||
override fun injectWith(injector: ScreenComponent) {
|
override fun injectWith(injector: ScreenComponent) {
|
||||||
injector.inject(this)
|
injector.inject(this)
|
||||||
}
|
}
|
||||||
@ -155,7 +151,7 @@ class LinkHandlerActivity : VectorBaseActivity<ActivityProgressBinding>() {
|
|||||||
// Should not happen
|
// Should not happen
|
||||||
startLoginActivity(uri)
|
startLoginActivity(uri)
|
||||||
} else {
|
} else {
|
||||||
emptyViewModel.viewModelScope.launch {
|
lifecycleScope.launch {
|
||||||
try {
|
try {
|
||||||
session.signOut(true)
|
session.signOut(true)
|
||||||
Timber.d("## displayAlreadyLoginPopup(): logout succeeded")
|
Timber.d("## displayAlreadyLoginPopup(): logout succeeded")
|
||||||
|
@ -80,8 +80,6 @@ class RoomMemberProfileController @Inject constructor(
|
|||||||
action = { callback?.onIgnoreClicked() }
|
action = { callback?.onIgnoreClicked() }
|
||||||
)
|
)
|
||||||
if (!state.isMine) {
|
if (!state.isMine) {
|
||||||
buildProfileSection(stringProvider.getString(R.string.room_profile_section_more))
|
|
||||||
|
|
||||||
buildProfileAction(
|
buildProfileAction(
|
||||||
id = "direct",
|
id = "direct",
|
||||||
editable = false,
|
editable = false,
|
||||||
|
Loading…
Reference in New Issue
Block a user