mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-23 20:55:02 +01:00
linter
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
parent
e643039488
commit
1918349c93
@ -150,28 +150,29 @@ class BrowserLoginActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private val qrScanResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
if (result.resultCode == RESULT_OK) {
|
||||
val data = result.data
|
||||
private val qrScanResultLauncher =
|
||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
if (result.resultCode == RESULT_OK) {
|
||||
val data = result.data
|
||||
|
||||
if (data == null) {
|
||||
return@registerForActivityResult
|
||||
}
|
||||
if (data == null) {
|
||||
return@registerForActivityResult
|
||||
}
|
||||
|
||||
val resultData = data.getStringExtra("com.blikoon.qrcodescanner.got_qr_scan_relult")
|
||||
val resultData = data.getStringExtra("com.blikoon.qrcodescanner.got_qr_scan_relult")
|
||||
|
||||
if (resultData == null || !resultData.startsWith("nc")) {
|
||||
Snackbar.make(binding.root, getString(R.string.qr_code_error), Snackbar.LENGTH_SHORT).show()
|
||||
return@registerForActivityResult
|
||||
}
|
||||
if (resultData == null || !resultData.startsWith("nc")) {
|
||||
Snackbar.make(binding.root, getString(R.string.qr_code_error), Snackbar.LENGTH_SHORT).show()
|
||||
return@registerForActivityResult
|
||||
}
|
||||
|
||||
try {
|
||||
parseLoginDataUrl(resultData)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Log.e(TAG, "Error in scanning QR Code: $e")
|
||||
try {
|
||||
parseLoginDataUrl(resultData)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Log.e(TAG, "Error in scanning QR Code: $e")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun anonymouslyPostLoginRequest() {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
@ -276,13 +277,13 @@ class BrowserLoginActivity : BaseActivity() {
|
||||
*/
|
||||
fun parseLoginDataUrl(dataString: String) {
|
||||
if (!dataString.startsWith(PREFIX)) {
|
||||
throw IllegalArgumentException("Invalid login URL detected" )
|
||||
throw IllegalArgumentException("Invalid login URL detected")
|
||||
}
|
||||
|
||||
val data = dataString.removePrefix(PREFIX)
|
||||
val values = data.split('&')
|
||||
|
||||
if(values.size !in 1..3) {
|
||||
if (values.size !in 1..MAX_ARGS) {
|
||||
throw IllegalArgumentException("Illegal number of login URL elements detected: ${values.size}")
|
||||
}
|
||||
|
||||
@ -293,9 +294,11 @@ class BrowserLoginActivity : BaseActivity() {
|
||||
value.startsWith(USER_KEY) -> {
|
||||
loginData.username = URLDecoder.decode(value.removePrefix(USER_KEY), "UTF-8")
|
||||
}
|
||||
|
||||
value.startsWith(PASS_KEY) -> {
|
||||
loginData.token = URLDecoder.decode(value.removePrefix(PASS_KEY), "UTF-8")
|
||||
}
|
||||
|
||||
value.startsWith(SERVER_KEY) -> {
|
||||
loginData.serverUrl = URLDecoder.decode(value.removePrefix(SERVER_KEY), "UTF-8")
|
||||
baseUrl = loginData.serverUrl
|
||||
@ -431,5 +434,6 @@ class BrowserLoginActivity : BaseActivity() {
|
||||
private const val SERVER_KEY = "server:"
|
||||
private const val PASS_KEY = "password:"
|
||||
private const val PREFIX = "nc://login/"
|
||||
private const val MAX_ARGS = 3
|
||||
}
|
||||
}
|
||||
|
@ -396,12 +396,13 @@ class ServerSelectionActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private val requestCameraPermissionLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted: Boolean ->
|
||||
if (isGranted) {
|
||||
// Permission was granted
|
||||
startQRScanner()
|
||||
private val requestCameraPermissionLauncher =
|
||||
registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted: Boolean ->
|
||||
if (isGranted) {
|
||||
// Permission was granted
|
||||
startQRScanner()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onScan() {
|
||||
if (PermissionUtil.isPermissionGranted(this, Manifest.permission.CAMERA)) {
|
||||
|
Loading…
Reference in New Issue
Block a user