Merge pull request #57 from vector-im/feature/fga/gradle_perf
Feature/fga/gradle perf
This commit is contained in:
commit
701e6ce4aa
59 changed files with 217 additions and 209 deletions
|
|
@ -51,10 +51,10 @@ import androidx.compose.ui.unit.sp
|
|||
import coil.compose.AsyncImage
|
||||
import coil.request.ImageRequest
|
||||
import io.element.android.libraries.architecture.Async
|
||||
import io.element.android.libraries.core.compose.LogCompositions
|
||||
import io.element.android.libraries.core.compose.textFieldState
|
||||
import io.element.android.libraries.designsystem.components.form.textFieldState
|
||||
import io.element.android.libraries.designsystem.components.LabelledCheckbox
|
||||
import io.element.android.libraries.designsystem.components.dialogs.ErrorDialog
|
||||
import io.element.android.libraries.designsystem.utils.LogCompositions
|
||||
import io.element.android.libraries.ui.strings.R as StringR
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
|
|
@ -111,7 +111,9 @@ fun BugReportView(
|
|||
.padding(horizontal = 16.dp, vertical = 16.dp),
|
||||
fontSize = 16.sp,
|
||||
)
|
||||
var descriptionFieldState by textFieldState(stateValue = state.formState.description)
|
||||
var descriptionFieldState by textFieldState(
|
||||
stateValue = state.formState.description
|
||||
)
|
||||
Column(
|
||||
// modifier = Modifier.weight(1f),
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ package io.element.android.features.rageshake.crash.ui
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import io.element.android.libraries.core.compose.LogCompositions
|
||||
import io.element.android.libraries.designsystem.components.dialogs.ConfirmationDialog
|
||||
import io.element.android.libraries.designsystem.utils.LogCompositions
|
||||
import io.element.android.libraries.ui.strings.R as StringR
|
||||
|
||||
@Composable
|
||||
|
|
@ -28,7 +28,10 @@ fun CrashDetectionView(
|
|||
state: CrashDetectionState,
|
||||
onOpenBugReport: () -> Unit = { },
|
||||
) {
|
||||
LogCompositions(tag = "Crash", msg = "CrashDetectionScreen")
|
||||
LogCompositions(
|
||||
tag = "Crash",
|
||||
msg = "CrashDetectionScreen"
|
||||
)
|
||||
|
||||
fun onPopupDismissed() {
|
||||
state.eventSink(CrashDetectionEvents.ResetAllCrashData)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package io.element.android.features.rageshake.detection
|
||||
|
||||
import io.element.android.libraries.core.screenshot.ImageResult
|
||||
import io.element.android.features.rageshake.screenshot.ImageResult
|
||||
|
||||
sealed interface RageshakeDetectionEvents {
|
||||
object Dismiss : RageshakeDetectionEvents
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ import androidx.compose.runtime.mutableStateOf
|
|||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.core.screenshot.ImageResult
|
||||
import io.element.android.features.rageshake.preferences.RageshakePreferencesEvents
|
||||
import io.element.android.features.rageshake.preferences.RageshakePreferencesPresenter
|
||||
import io.element.android.features.rageshake.rageshake.RageShake
|
||||
import io.element.android.features.rageshake.screenshot.ImageResult
|
||||
import io.element.android.features.rageshake.screenshot.ScreenshotHolder
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ import androidx.compose.ui.platform.LocalView
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import io.element.android.libraries.core.compose.LogCompositions
|
||||
import io.element.android.libraries.core.compose.OnLifecycleEvent
|
||||
import io.element.android.libraries.core.hardware.vibrate
|
||||
import io.element.android.libraries.core.screenshot.ImageResult
|
||||
import io.element.android.libraries.core.screenshot.screenshot
|
||||
import io.element.android.features.rageshake.screenshot.ImageResult
|
||||
import io.element.android.features.rageshake.screenshot.screenshot
|
||||
import io.element.android.libraries.androidutils.hardware.vibrate
|
||||
import io.element.android.libraries.designsystem.utils.OnLifecycleEvent
|
||||
import io.element.android.libraries.designsystem.components.dialogs.ConfirmationDialog
|
||||
import io.element.android.libraries.designsystem.utils.LogCompositions
|
||||
import io.element.android.libraries.ui.strings.R as StringR
|
||||
|
||||
@Composable
|
||||
|
|
@ -36,7 +36,10 @@ fun RageshakeDetectionView(
|
|||
state: RageshakeDetectionState,
|
||||
onOpenBugReport: () -> Unit = { },
|
||||
) {
|
||||
LogCompositions(tag = "Rageshake", msg = "RageshakeDetectionScreen")
|
||||
LogCompositions(
|
||||
tag = "Rageshake",
|
||||
msg = "RageshakeDetectionScreen"
|
||||
)
|
||||
val eventSink = state.eventSink
|
||||
val context = LocalContext.current
|
||||
OnLifecycleEvent { _, event ->
|
||||
|
|
|
|||
|
|
@ -19,17 +19,17 @@ package io.element.android.features.rageshake.logs
|
|||
import android.content.Context
|
||||
import android.util.Log
|
||||
import io.element.android.libraries.core.data.tryOrNull
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
import java.util.logging.FileHandler
|
||||
import java.util.logging.Level
|
||||
import java.util.logging.Logger
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* Will be planted in Timber.
|
||||
|
|
@ -85,7 +85,9 @@ class VectorFileLogger(
|
|||
tryOrNull { file.delete() }
|
||||
}
|
||||
|
||||
fileHandler = tryOrNull("Failed to initialize FileLogger") {
|
||||
fileHandler = tryOrNull(
|
||||
onError = { Timber.e(it, "Failed to initialize FileLogger") }
|
||||
) {
|
||||
FileHandler(
|
||||
cacheDirectory.absolutePath + "/" + fileNamePrefix + ".%g.txt",
|
||||
maxLogSizeByte,
|
||||
|
|
@ -134,7 +136,9 @@ class VectorFileLogger(
|
|||
* @return The list of files with logs.
|
||||
*/
|
||||
fun getLogFiles(): List<File> {
|
||||
return tryOrNull("## getLogFiles() failed") {
|
||||
return tryOrNull(
|
||||
onError = { Timber.e(it, "## getLogFiles() failed") }
|
||||
) {
|
||||
fileHandler
|
||||
?.flush()
|
||||
?.let { 0 until logRotationCount }
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package io.element.android.features.rageshake.reporter
|
|||
import android.content.Context
|
||||
import android.os.Build
|
||||
import io.element.android.libraries.core.extensions.toOnOff
|
||||
import io.element.android.libraries.core.file.compressFile
|
||||
import io.element.android.libraries.androidutils.file.compressFile
|
||||
import io.element.android.libraries.core.mimetype.MimeTypes
|
||||
import io.element.android.libraries.di.ApplicationContext
|
||||
import io.element.android.features.rageshake.R
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (c) 2023 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 io.element.android.features.rageshake.screenshot
|
||||
|
||||
import android.app.Activity
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.PixelCopy
|
||||
import android.view.View
|
||||
|
||||
fun View.screenshot(bitmapCallback: (ImageResult) -> Unit) {
|
||||
try {
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
val bitmap = Bitmap.createBitmap(
|
||||
width,
|
||||
height,
|
||||
Bitmap.Config.ARGB_8888,
|
||||
)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
PixelCopy.request(
|
||||
(this.context as Activity).window,
|
||||
clipBounds,
|
||||
bitmap,
|
||||
{
|
||||
when (it) {
|
||||
PixelCopy.SUCCESS -> {
|
||||
bitmapCallback.invoke(ImageResult.Success(bitmap))
|
||||
}
|
||||
else -> {
|
||||
bitmapCallback.invoke(ImageResult.Error(Exception(it.toString())))
|
||||
}
|
||||
}
|
||||
},
|
||||
handler
|
||||
)
|
||||
} else {
|
||||
handler.post {
|
||||
val canvas = Canvas(bitmap)
|
||||
.apply {
|
||||
translate(-clipBounds.left.toFloat(), -clipBounds.top.toFloat())
|
||||
}
|
||||
this.draw(canvas)
|
||||
canvas.setBitmap(null)
|
||||
bitmapCallback.invoke(ImageResult.Success(bitmap))
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
bitmapCallback.invoke(ImageResult.Error(e))
|
||||
}
|
||||
}
|
||||
|
||||
sealed interface ImageResult {
|
||||
data class Error(val exception: Exception) : ImageResult
|
||||
data class Success(val data: Bitmap) : ImageResult
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ package io.element.android.features.rageshake.screenshot
|
|||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import io.element.android.libraries.core.bitmap.writeBitmap
|
||||
import io.element.android.libraries.androidutils.bitmap.writeBitmap
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.libraries.di.ApplicationContext
|
||||
import io.element.android.libraries.di.SingleIn
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue