mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
commit
9b13381938
7 changed files with 10 additions and 70 deletions
|
@ -28,9 +28,8 @@ import java.io.File
|
|||
import java.util.UUID
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class ImageCompressor @Inject constructor() {
|
||||
internal class ImageCompressor @Inject constructor(private val context: Context) {
|
||||
suspend fun compress(
|
||||
context: Context,
|
||||
imageFile: File,
|
||||
desiredWidth: Int,
|
||||
desiredHeight: Int,
|
||||
|
@ -46,7 +45,7 @@ internal class ImageCompressor @Inject constructor() {
|
|||
}
|
||||
} ?: return@withContext imageFile
|
||||
|
||||
val destinationFile = createDestinationFile(context)
|
||||
val destinationFile = createDestinationFile()
|
||||
|
||||
runCatching {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
|
|||
// Do not compress gif
|
||||
&& attachment.mimeType != MimeTypes.Gif
|
||||
&& 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 ->
|
||||
// Get new Bitmap size
|
||||
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 androidx.appcompat.app.AlertDialog
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.airbnb.mvrx.viewModel
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.bumptech.glide.Glide
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.di.ScreenComponent
|
||||
import im.vector.app.core.error.ErrorFormatter
|
||||
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.utils.deleteAllFiles
|
||||
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)
|
||||
|
||||
private lateinit var args: MainActivityArgs
|
||||
|
@ -150,7 +146,7 @@ class MainActivity : VectorBaseActivity<FragmentLoadingBinding>(), UnlockedActiv
|
|||
}
|
||||
when {
|
||||
args.isAccountDeactivated -> {
|
||||
emptyViewModel.viewModelScope.launch {
|
||||
lifecycleScope.launch {
|
||||
// Just do the local cleanup
|
||||
Timber.w("Account deactivated, start app")
|
||||
sessionHolder.clearActiveSession()
|
||||
|
@ -159,7 +155,7 @@ class MainActivity : VectorBaseActivity<FragmentLoadingBinding>(), UnlockedActiv
|
|||
}
|
||||
}
|
||||
args.clearCredentials -> {
|
||||
emptyViewModel.viewModelScope.launch {
|
||||
lifecycleScope.launch {
|
||||
try {
|
||||
session.signOut(!args.isUserLoggedOut)
|
||||
Timber.w("SIGN_OUT: success, start app")
|
||||
|
@ -172,7 +168,7 @@ class MainActivity : VectorBaseActivity<FragmentLoadingBinding>(), UnlockedActiv
|
|||
}
|
||||
}
|
||||
args.clearCache -> {
|
||||
emptyViewModel.viewModelScope.launch {
|
||||
lifecycleScope.launch {
|
||||
try {
|
||||
session.clearCache()
|
||||
doLocalCleanup(clearPreferences = false)
|
||||
|
|
|
@ -19,13 +19,11 @@ package im.vector.app.features.link
|
|||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.airbnb.mvrx.viewModel
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.di.ScreenComponent
|
||||
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.utils.toast
|
||||
import im.vector.app.databinding.ActivityProgressBinding
|
||||
|
@ -48,8 +46,6 @@ class LinkHandlerActivity : VectorBaseActivity<ActivityProgressBinding>() {
|
|||
@Inject lateinit var errorFormatter: ErrorFormatter
|
||||
@Inject lateinit var permalinkHandler: PermalinkHandler
|
||||
|
||||
private val emptyViewModel: EmptyViewModel by viewModel()
|
||||
|
||||
override fun injectWith(injector: ScreenComponent) {
|
||||
injector.inject(this)
|
||||
}
|
||||
|
@ -155,7 +151,7 @@ class LinkHandlerActivity : VectorBaseActivity<ActivityProgressBinding>() {
|
|||
// Should not happen
|
||||
startLoginActivity(uri)
|
||||
} else {
|
||||
emptyViewModel.viewModelScope.launch {
|
||||
lifecycleScope.launch {
|
||||
try {
|
||||
session.signOut(true)
|
||||
Timber.d("## displayAlreadyLoginPopup(): logout succeeded")
|
||||
|
|
|
@ -80,8 +80,6 @@ class RoomMemberProfileController @Inject constructor(
|
|||
action = { callback?.onIgnoreClicked() }
|
||||
)
|
||||
if (!state.isMine) {
|
||||
buildProfileSection(stringProvider.getString(R.string.room_profile_section_more))
|
||||
|
||||
buildProfileAction(
|
||||
id = "direct",
|
||||
editable = false,
|
||||
|
|
Loading…
Reference in a new issue