mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
Naming for code review
This commit is contained in:
parent
f66fbef0ad
commit
5459b1eb1d
@ -1,11 +1,8 @@
|
||||
package org.thoughtcrime.securesms.onboarding
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.activity.viewModels
|
||||
import androidx.camera.core.ExperimentalGetImage
|
||||
import androidx.camera.core.ImageAnalysis.Analyzer
|
||||
import androidx.camera.core.ImageProxy
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@ -30,9 +27,6 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.google.mlkit.vision.barcode.BarcodeScanner
|
||||
import com.google.mlkit.vision.barcode.common.Barcode
|
||||
import com.google.mlkit.vision.common.InputImage
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
import network.loki.messenger.R
|
||||
@ -79,7 +73,7 @@ class LinkDeviceActivity : BaseActionBarActivity() {
|
||||
setContent {
|
||||
val state by viewModel.stateFlow.collectAsState()
|
||||
AppTheme {
|
||||
LoadAccountScreen(state, viewModel::onChange, viewModel::onContinue, viewModel::scan)
|
||||
LoadAccountScreen(state, viewModel::onChange, viewModel::onContinue, viewModel::onScanQrCode)
|
||||
}
|
||||
}
|
||||
}.let(::setContentView)
|
||||
|
@ -47,7 +47,7 @@ class LinkDeviceViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun scan(string: String) {
|
||||
fun onScanQrCode(string: String) {
|
||||
viewModelScope.launch {
|
||||
runDecodeCatching(string)
|
||||
.onSuccess(::onSuccess)
|
||||
|
@ -28,11 +28,10 @@ import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
data class State(val duration: Duration)
|
||||
|
||||
private val DONE_TIME = 1.seconds
|
||||
private val DONE_ANIMATE_TIME = 500.milliseconds
|
||||
|
||||
private val TOTAL_ANIMATE_TIME = 14.seconds
|
||||
private val TOTAL_TIME = 15.seconds
|
||||
private val ANIMATE_TO_DONE_TIME = 500.milliseconds
|
||||
private val IDLE_DONE_TIME = 1.seconds
|
||||
private val TIMEOUT_TIME = 15.seconds
|
||||
private val TOTAL_ANIMATION_TIME = TIMEOUT_TIME - IDLE_DONE_TIME
|
||||
|
||||
@HiltViewModel
|
||||
class LoadingViewModel @Inject constructor(
|
||||
@ -40,7 +39,7 @@ class LoadingViewModel @Inject constructor(
|
||||
private val prefs: TextSecurePreferences,
|
||||
) : ViewModel() {
|
||||
|
||||
private val state = MutableStateFlow(State(TOTAL_ANIMATE_TIME))
|
||||
private val state = MutableStateFlow(State(TOTAL_ANIMATION_TIME))
|
||||
val stateFlow = state.asStateFlow()
|
||||
|
||||
private val event = Channel<Event>()
|
||||
@ -77,7 +76,7 @@ class LoadingViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
val skipJob = launch(Dispatchers.IO) {
|
||||
delay(TOTAL_TIME)
|
||||
delay(TIMEOUT_TIME)
|
||||
event.send(Event.TIMEOUT)
|
||||
}
|
||||
|
||||
@ -87,8 +86,8 @@ class LoadingViewModel @Inject constructor(
|
||||
// handle we've synced
|
||||
skipJob.cancel()
|
||||
|
||||
state.value = State(DONE_ANIMATE_TIME)
|
||||
delay(DONE_TIME)
|
||||
state.value = State(ANIMATE_TO_DONE_TIME)
|
||||
delay(IDLE_DONE_TIME)
|
||||
event.send(Event.SUCCESS)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user