Permissions fix
This commit is contained in:
parent
be17e5687d
commit
afda604805
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="sushi.hardcore.droidfs">
|
package="sushi.hardcore.droidfs">
|
||||||
|
|
||||||
<permission
|
<permission
|
||||||
@ -10,7 +11,8 @@
|
|||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
||||||
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" tools:node="remove"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".ColoredApplication"
|
android:name=".ColoredApplication"
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package sushi.hardcore.droidfs
|
package sushi.hardcore.droidfs
|
||||||
|
|
||||||
import android.content.Intent
|
import android.Manifest
|
||||||
import android.graphics.Color
|
import android.content.pm.PackageManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.InputType
|
import android.text.InputType
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import com.otaliastudios.cameraview.CameraListener
|
import com.otaliastudios.cameraview.CameraListener
|
||||||
import com.otaliastudios.cameraview.PictureResult
|
import com.otaliastudios.cameraview.PictureResult
|
||||||
import com.otaliastudios.cameraview.controls.Facing
|
import com.otaliastudios.cameraview.controls.Facing
|
||||||
@ -216,9 +217,18 @@ class CameraActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onStop() {
|
||||||
|
super.onStop()
|
||||||
|
if (!isFinishing){
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
finish()
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED){ //if not asking for permission
|
||||||
|
finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
|
@ -27,46 +27,62 @@ class MainActivity : BaseActivity() {
|
|||||||
ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
requestPermissions(arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_PERMISSIONS_REQUEST)
|
requestPermissions(arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_PERMISSIONS_REQUEST)
|
||||||
|
} else {
|
||||||
|
if (checkStorageAvailability()){
|
||||||
|
checkFirstOpening()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val state = Environment.getExternalStorageState()
|
|
||||||
val storageAvailable = Environment.MEDIA_MOUNTED == state || Environment.MEDIA_MOUNTED_READ_ONLY == state
|
|
||||||
if (!storageAvailable) {
|
|
||||||
ColoredAlertDialogBuilder(this)
|
|
||||||
.setTitle(R.string.storage_unavailable)
|
|
||||||
.setMessage(R.string.storage_unavailable_msg)
|
|
||||||
.setPositiveButton(R.string.ok
|
|
||||||
) { _, _ -> finish() }.show()
|
|
||||||
}
|
|
||||||
if (!sharedPrefs.getBoolean("alreadyLaunched", false)){
|
|
||||||
ColoredAlertDialogBuilder(this)
|
|
||||||
.setTitle(R.string.warning)
|
|
||||||
.setMessage(R.string.usf_home_warning_msg)
|
|
||||||
.setCancelable(false)
|
|
||||||
.setPositiveButton(R.string.see_unsafe_features){ _, _ ->
|
|
||||||
val intent = Intent(this, SettingsActivity::class.java)
|
|
||||||
intent.putExtra("screen", "UnsafeFeaturesSettingsFragment")
|
|
||||||
startActivity(intent)
|
|
||||||
}
|
|
||||||
.setNegativeButton(R.string.ok, null)
|
|
||||||
.setOnDismissListener { sharedPrefs.edit().putBoolean("alreadyLaunched", true).apply() }
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
val metrics = DisplayMetrics()
|
val metrics = DisplayMetrics()
|
||||||
windowManager.defaultDisplay.getMetrics(metrics)
|
windowManager.defaultDisplay.getMetrics(metrics)
|
||||||
image_logo.layoutParams.height = (metrics.heightPixels/2.2).toInt()
|
image_logo.layoutParams.height = (metrics.heightPixels/2.2).toInt()
|
||||||
Glide.with(this).load(R.drawable.logo).into(image_logo)
|
Glide.with(this).load(R.drawable.logo).into(image_logo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkStorageAvailability(): Boolean {
|
||||||
|
val state = Environment.getExternalStorageState()
|
||||||
|
val storageAvailable = Environment.MEDIA_MOUNTED == state || Environment.MEDIA_MOUNTED_READ_ONLY == state
|
||||||
|
return if (!storageAvailable) {
|
||||||
|
ColoredAlertDialogBuilder(this)
|
||||||
|
.setTitle(R.string.storage_unavailable)
|
||||||
|
.setMessage(R.string.storage_unavailable_msg)
|
||||||
|
.setCancelable(false)
|
||||||
|
.setPositiveButton(R.string.ok) { _, _ -> finish() }.show()
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkFirstOpening() {
|
||||||
|
if (sharedPrefs.getBoolean("applicationFirstOpening", true)){
|
||||||
|
ColoredAlertDialogBuilder(this)
|
||||||
|
.setTitle(R.string.warning)
|
||||||
|
.setMessage(R.string.usf_home_warning_msg)
|
||||||
|
.setCancelable(false)
|
||||||
|
.setPositiveButton(R.string.see_unsafe_features){ _, _ ->
|
||||||
|
val intent = Intent(this, SettingsActivity::class.java)
|
||||||
|
intent.putExtra("screen", "UnsafeFeaturesSettingsFragment")
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
.setNegativeButton(R.string.ok, null)
|
||||||
|
.setOnDismissListener { sharedPrefs.edit().putBoolean("applicationFirstOpening", false).apply() }
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
||||||
when (requestCode) {
|
when (requestCode) {
|
||||||
STORAGE_PERMISSIONS_REQUEST -> if (grantResults.size == 2) {
|
STORAGE_PERMISSIONS_REQUEST -> if (grantResults.size == 2) {
|
||||||
if (grantResults[0] != PackageManager.PERMISSION_GRANTED || grantResults[1] != PackageManager.PERMISSION_GRANTED) {
|
if (grantResults[0] != PackageManager.PERMISSION_GRANTED || grantResults[1] != PackageManager.PERMISSION_GRANTED) {
|
||||||
ColoredAlertDialogBuilder(this)
|
ColoredAlertDialogBuilder(this)
|
||||||
.setTitle(R.string.storage_perm_denied)
|
.setTitle(R.string.storage_perm_denied)
|
||||||
.setMessage(R.string.storage_perm_denied_msg)
|
.setMessage(R.string.storage_perm_denied_msg)
|
||||||
.setPositiveButton(R.string.ok
|
.setCancelable(false)
|
||||||
) { _, _ -> finish() }.show()
|
.setPositiveButton(R.string.ok) { _, _ -> finish() }.show()
|
||||||
|
} else {
|
||||||
|
checkStorageAvailability()
|
||||||
|
checkFirstOpening()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user