mirror of
https://github.com/element-hq/element-android
synced 2024-11-25 02:45:37 +03:00
code review and lint fixes
This commit is contained in:
parent
b6eb27f8a1
commit
f56991f077
8 changed files with 29 additions and 23 deletions
|
@ -46,9 +46,9 @@ import im.vector.app.core.utils.registerForPermissionsResult
|
|||
import im.vector.app.features.analytics.plan.Screen
|
||||
import im.vector.app.features.contactsbook.ContactsBookFragment
|
||||
import im.vector.app.features.qrcode.QrCodeScannerEvents
|
||||
import im.vector.app.features.qrcode.QrCodeScannerFragment
|
||||
import im.vector.app.features.qrcode.QrCodeScannerViewModel
|
||||
import im.vector.app.features.qrcode.QrScannerArgs
|
||||
import im.vector.app.features.qrcode.QrCodeScannerFragment
|
||||
import im.vector.app.features.userdirectory.UserListFragment
|
||||
import im.vector.app.features.userdirectory.UserListFragmentArgs
|
||||
import im.vector.app.features.userdirectory.UserListSharedAction
|
||||
|
@ -107,11 +107,11 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() {
|
|||
Toast.makeText(this, R.string.invalid_qr_code_uri, Toast.LENGTH_SHORT).show()
|
||||
finish()
|
||||
}
|
||||
CreateDirectRoomViewEvents.DmSelf -> {
|
||||
CreateDirectRoomViewEvents.DmSelf -> {
|
||||
Toast.makeText(this, R.string.cannot_dm_self, Toast.LENGTH_SHORT).show()
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}.exhaustive
|
||||
}
|
||||
|
||||
qrViewModel.observeViewEvents {
|
||||
|
@ -123,7 +123,8 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() {
|
|||
Toast.makeText(this, R.string.qr_code_not_scanned, Toast.LENGTH_SHORT).show()
|
||||
finish()
|
||||
}
|
||||
}
|
||||
else -> Unit
|
||||
}.exhaustive
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,9 @@
|
|||
|
||||
package im.vector.app.features.createdirect
|
||||
|
||||
import com.airbnb.mvrx.Async
|
||||
import im.vector.app.core.platform.VectorViewEvents
|
||||
|
||||
sealed class CreateDirectRoomViewEvents : VectorViewEvents {
|
||||
object InvalidCode: CreateDirectRoomViewEvents()
|
||||
object DmSelf: CreateDirectRoomViewEvents()
|
||||
object InvalidCode : CreateDirectRoomViewEvents()
|
||||
object DmSelf : CreateDirectRoomViewEvents()
|
||||
}
|
||||
|
|
|
@ -24,12 +24,13 @@ import androidx.activity.result.ActivityResultLauncher
|
|||
import com.airbnb.mvrx.viewModel
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.extensions.exhaustive
|
||||
import im.vector.app.core.extensions.replaceFragment
|
||||
import im.vector.app.core.platform.VectorBaseActivity
|
||||
import im.vector.app.databinding.ActivitySimpleBinding
|
||||
|
||||
@AndroidEntryPoint
|
||||
class QrCodeScannerActivity(): VectorBaseActivity<ActivitySimpleBinding>() {
|
||||
class QrCodeScannerActivity() : VectorBaseActivity<ActivitySimpleBinding>() {
|
||||
|
||||
override fun getBinding() = ActivitySimpleBinding.inflate(layoutInflater)
|
||||
|
||||
|
@ -49,7 +50,8 @@ class QrCodeScannerActivity(): VectorBaseActivity<ActivitySimpleBinding>() {
|
|||
Toast.makeText(this, R.string.qr_code_not_scanned, Toast.LENGTH_SHORT).show()
|
||||
finish()
|
||||
}
|
||||
}
|
||||
else -> Unit
|
||||
}.exhaustive
|
||||
}
|
||||
|
||||
if (isFirstCreation()) {
|
||||
|
@ -66,7 +68,6 @@ class QrCodeScannerActivity(): VectorBaseActivity<ActivitySimpleBinding>() {
|
|||
finish()
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
private const val EXTRA_OUT_TEXT = "EXTRA_OUT_TEXT"
|
||||
private const val EXTRA_OUT_IS_QR_CODE = "EXTRA_OUT_IS_QR_CODE"
|
||||
|
|
|
@ -19,7 +19,7 @@ package im.vector.app.features.qrcode
|
|||
import im.vector.app.core.platform.VectorViewEvents
|
||||
|
||||
sealed class QrCodeScannerEvents : VectorViewEvents {
|
||||
data class CodeParsed(val result: String, val isQrCode: Boolean): QrCodeScannerEvents()
|
||||
object ParseFailed: QrCodeScannerEvents()
|
||||
object SwitchMode: QrCodeScannerEvents()
|
||||
data class CodeParsed(val result: String, val isQrCode: Boolean) : QrCodeScannerEvents()
|
||||
object ParseFailed : QrCodeScannerEvents()
|
||||
object SwitchMode : QrCodeScannerEvents()
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ data class QrScannerArgs(
|
|||
@StringRes val titleRes: Int
|
||||
) : Parcelable
|
||||
|
||||
open class QrCodeScannerFragment @Inject constructor(): VectorBaseFragment<FragmentQrCodeScannerBinding>(), ZXingScannerView.ResultHandler {
|
||||
open class QrCodeScannerFragment @Inject constructor() : VectorBaseFragment<FragmentQrCodeScannerBinding>(), ZXingScannerView.ResultHandler {
|
||||
|
||||
private val qrViewModel: QrCodeScannerViewModel by activityViewModel()
|
||||
private val scannerArgs: QrScannerArgs? by args()
|
||||
|
|
|
@ -40,11 +40,12 @@ class QrCodeScannerViewModel @AssistedInject constructor(
|
|||
companion object : MavericksViewModelFactory<QrCodeScannerViewModel, VectorDummyViewState> by hiltMavericksViewModelFactory()
|
||||
|
||||
override fun handle(action: QrCodeScannerAction) {
|
||||
when (action) {
|
||||
is QrCodeScannerAction.CodeDecoded -> _viewEvents.post(QrCodeScannerEvents.CodeParsed(action.result, action.isQrCode))
|
||||
is QrCodeScannerAction.SwitchMode -> _viewEvents.post(QrCodeScannerEvents.SwitchMode)
|
||||
is QrCodeScannerAction.ScanFailed -> _viewEvents.post(QrCodeScannerEvents.ParseFailed)
|
||||
}.exhaustive
|
||||
_viewEvents.post(
|
||||
when (action) {
|
||||
is QrCodeScannerAction.CodeDecoded -> QrCodeScannerEvents.CodeParsed(action.result, action.isQrCode)
|
||||
is QrCodeScannerAction.SwitchMode -> QrCodeScannerEvents.SwitchMode
|
||||
is QrCodeScannerAction.ScanFailed -> QrCodeScannerEvents.ParseFailed
|
||||
}.exhaustive
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ class UserCodeActivity : VectorBaseActivity<ActivitySimpleBinding>(),
|
|||
Toast.makeText(this, R.string.qr_code_not_scanned, Toast.LENGTH_SHORT).show()
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}.exhaustive
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
@ -29,6 +30,7 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/appBarLayout" />
|
||||
|
||||
<!-- TODO In the future we could add a toggle to switch the flash, and other possible settings -->
|
||||
<Button
|
||||
android:id="@+id/userCodeMyCodeButton"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -39,7 +41,8 @@
|
|||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/userCodeOpenGalleryButton"
|
||||
|
@ -65,6 +68,7 @@
|
|||
app:layout_constraintBottom_toBottomOf="@id/userCodeMyCodeButton"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/userCodeMyCodeButton"
|
||||
app:layout_constraintTop_toTopOf="@id/userCodeMyCodeButton" />
|
||||
app:layout_constraintTop_toTopOf="@id/userCodeMyCodeButton"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in a new issue