solved synatax issues

This commit is contained in:
ritvik 2020-08-17 15:33:33 +05:30
parent cfe99fc760
commit d2f2cd0de1

View File

@ -88,7 +88,6 @@ class LocalFileTransferActivity : BaseActivity(),
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_local_file_transfer) setContentView(R.layout.activity_local_file_transfer)
/* /*
* Presence of file Uris decides whether the device with the activity open is a sender or receiver: * Presence of file Uris decides whether the device with the activity open is a sender or receiver:
* - On the sender device, this activity is started from the app chooser post selection * - On the sender device, this activity is started from the app chooser post selection
@ -131,12 +130,10 @@ class LocalFileTransferActivity : BaseActivity(),
if (item.itemId == R.id.menu_item_search_devices) { if (item.itemId == R.id.menu_item_search_devices) {
/* Permissions essential for this module */ /* Permissions essential for this module */
return when { return when {
!checkCoarseLocationAccessPermission() -> { !checkCoarseLocationAccessPermission() ->
true true
} !checkExternalStorageWritePermission() ->
!checkExternalStorageWritePermission() -> {
true true
}
/* Initiate discovery */ /* Initiate discovery */
!wifiDirectManager.isWifiP2pEnabled -> { !wifiDirectManager.isWifiP2pEnabled -> {
requestEnableWifiP2pServices() requestEnableWifiP2pServices()
@ -168,8 +165,7 @@ class LocalFileTransferActivity : BaseActivity(),
if (userDevice != null) { if (userDevice != null) {
text_view_device_name.text = userDevice.deviceName text_view_device_name.text = userDevice.deviceName
Log.d( Log.d(
TAG, TAG, getDeviceStatus(userDevice.status)
getDeviceStatus(userDevice.status)
) )
} }
} }
@ -216,23 +212,25 @@ class LocalFileTransferActivity : BaseActivity(),
) )
== PackageManager.PERMISSION_DENIED == PackageManager.PERMISSION_DENIED
) { ) {
if (ActivityCompat.shouldShowRequestPermissionRationale( when {
ActivityCompat.shouldShowRequestPermissionRationale(
this, this,
Manifest.permission.ACCESS_COARSE_LOCATION Manifest.permission.ACCESS_COARSE_LOCATION
) ) -> {
) { alertDialogShower.show(KiwixDialog.LocationPermissionRationale,
alertDialogShower.show(KiwixDialog.LocationPermissionRationale, {
{ ActivityCompat.requestPermissions(
ActivityCompat.requestPermissions( this, arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION),
this, arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION), PERMISSION_REQUEST_CODE_COARSE_LOCATION
PERMISSION_REQUEST_CODE_COARSE_LOCATION )
) })
}) }
} else { else -> {
ActivityCompat.requestPermissions( ActivityCompat.requestPermissions(
this, arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION), this, arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION),
PERMISSION_REQUEST_CODE_COARSE_LOCATION PERMISSION_REQUEST_CODE_COARSE_LOCATION
) )
}
} }
false false
} else { } else {
@ -281,31 +279,23 @@ class LocalFileTransferActivity : BaseActivity(),
if (grantResults[0] == PackageManager.PERMISSION_DENIED) { if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
when (requestCode) { when (requestCode) {
PERMISSION_REQUEST_CODE_COARSE_LOCATION -> { PERMISSION_REQUEST_CODE_COARSE_LOCATION -> {
Log.e( Log.e(TAG, "Location permission not granted")
TAG,
"Location permission not granted"
)
this.toast( this.toast(
R.string.permission_refused_location, R.string.permission_refused_location,
Toast.LENGTH_SHORT Toast.LENGTH_SHORT
) )
finish() finish()
} }
PERMISSION_REQUEST_CODE_STORAGE_WRITE_ACCESS -> { PERMISSION_REQUEST_CODE_STORAGE_WRITE_ACCESS -> {
Log.e( Log.e(TAG, "Storage write permission not granted")
TAG,
"Storage write permission not granted"
)
this.toast( this.toast(
R.string.permission_refused_storage, R.string.permission_refused_storage,
Toast.LENGTH_SHORT Toast.LENGTH_SHORT
) )
finish() finish()
} }
else -> { else ->
super.onRequestPermissionsResult(requestCode, permissions, grantResults) super.onRequestPermissionsResult(requestCode, permissions, grantResults)
}
} }
} }
} }
@ -370,9 +360,8 @@ class LocalFileTransferActivity : BaseActivity(),
) )
} }
} }
else -> { else ->
super.onActivityResult(requestCode, resultCode, data) super.onActivityResult(requestCode, resultCode, data)
}
} }
} }