aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-20 01:39:43 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-20 01:39:43 -0600
commit0c93d08effd1bcc1c41aa839ed31e2cb8b5a6961 (patch)
tree4753e754d20f4a6f7c389620be367715a92f7be7
parent5b49e2eb2db829b2b386a707d79a52f72a2ef0e3 (diff)
downloadetbsa-trackermap-mobile-0c93d08effd1bcc1c41aa839ed31e2cb8b5a6961.tar.gz
etbsa-trackermap-mobile-0c93d08effd1bcc1c41aa839ed31e2cb8b5a6961.tar.bz2
etbsa-trackermap-mobile-0c93d08effd1bcc1c41aa839ed31e2cb8b5a6961.zip
Proper handling of user permission requests
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt8
-rw-r--r--androidApp/src/main/res/values-es-rMX/strings.xml9
-rw-r--r--androidApp/src/main/res/values/strings.xml9
3 files changed, 26 insertions, 0 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt
index 56d5c4b..9633332 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt
@@ -5,6 +5,7 @@ import android.content.pm.PackageManager
import android.os.Bundle
import android.util.Log
import androidx.activity.result.contract.ActivityResultContracts
+import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import com.google.android.material.tabs.TabLayout
@@ -108,6 +109,13 @@ class DetailsActivity : AppCompatActivity() {
}
ActivityCompat.shouldShowRequestPermissionRationale(this, permission) -> {
Log.d("DetailsActivity", "shouldShowRequestPermissionRationale")
+ AlertDialog.Builder(this)
+ .setTitle(R.string.write_rationale_title)
+ .setMessage(R.string.write_rationale_msg)
+ .setPositiveButton(R.string.shared_ok) { _, _ ->
+ launcher.launch(permission)
+ }
+ .create().show()
}
else -> {
Log.d("DetailsActivity", "Requesting $permission permission")
diff --git a/androidApp/src/main/res/values-es-rMX/strings.xml b/androidApp/src/main/res/values-es-rMX/strings.xml
index 7284b6c..2645205 100644
--- a/androidApp/src/main/res/values-es-rMX/strings.xml
+++ b/androidApp/src/main/res/values-es-rMX/strings.xml
@@ -88,11 +88,20 @@
<string name="stops">Paradas</string>
<string name="period">Periodo</string>
<string name="select_period">Seleccionar</string>
+
<string name="export_report">Guardar</string>
<string name="share_report">Compartir</string>
<string name="export_stored">El reporte ha sido descargado</string>
<string name="export_open_file_with">Abrir con</string>
+ <string name="write_rationale_title">
+ Necesitamos tu permiso
+ </string>
+ <string name="write_rationale_msg">
+ Esta aplicación requiere acceso de escritura a tus archivos.
+ Requerimos este permiso para guardar reportes en tu teléfono.
+ </string>
+
<!-- Report periods -->
<string name="period_today">Hoy</string>
<string name="period_last_24">Últimas 24H</string>
diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml
index 3e2b37a..8e59b14 100644
--- a/androidApp/src/main/res/values/strings.xml
+++ b/androidApp/src/main/res/values/strings.xml
@@ -101,11 +101,20 @@
<string name="stops">Stops</string>
<string name="period">Period</string>
<string name="select_period">Select</string>
+
<string name="export_report">Save</string>
<string name="share_report">Share</string>
<string name="export_stored">Report has been downloaded</string>
<string name="export_open_file_with">Open file with</string>
+ <string name="write_rationale_title">
+ We need your permission
+ </string>
+ <string name="write_rationale_msg">
+ This app relies on write access to your files.
+ We require access to this permission to save reports into your phone.
+ </string>
+
<!-- Report periods -->
<string name="period_today">Today</string>
<string name="period_last_24">Last 24H</string>