[Android] Add instructions to SD card permission dialog
Geoffrey Métais
git at videolan.org
Mon Jan 29 18:12:15 CET 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jan 29 18:11:27 2018 +0100| [48d026a3d307c0bdcc499d1098987cd1bdd0902e] | committer: Geoffrey Métais
Add instructions to SD card permission dialog
> https://code.videolan.org/videolan/vlc-android/commit/48d026a3d307c0bdcc499d1098987cd1bdd0902e
---
vlc-android/res/layout/dialog_sd_write.xml | 11 ++++++++
vlc-android/res/values-sw600dp/dimens.xml | 3 +++
vlc-android/res/values/dimens.xml | 2 ++
vlc-android/res/values/strings.xml | 3 +++
.../vlc/gui/helpers/hf/WriteExternalDelegate.kt | 29 +++++++++++++++++++---
5 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/vlc-android/res/layout/dialog_sd_write.xml b/vlc-android/res/layout/dialog_sd_write.xml
new file mode 100644
index 000000000..78bc49825
--- /dev/null
+++ b/vlc-android/res/layout/dialog_sd_write.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center">
+ <ImageView
+ android:layout_width="@dimen/dialog_sd_wisard_width"
+ android:layout_height="@dimen/dialog_sd_wisard_height"
+ android:scaleType="centerInside"
+ android:src="@drawable/img_tips_sdcard" />
+</LinearLayout>
\ No newline at end of file
diff --git a/vlc-android/res/values-sw600dp/dimens.xml b/vlc-android/res/values-sw600dp/dimens.xml
index d3b7de317..8ba799228 100644
--- a/vlc-android/res/values-sw600dp/dimens.xml
+++ b/vlc-android/res/values-sw600dp/dimens.xml
@@ -15,4 +15,7 @@
<!-- pop-Up player -->
<dimen name="video_pip_width">512dp</dimen>
<dimen name="video_pip_heigth">288dp</dimen>
+
+ <dimen name="dialog_sd_wisard_width">448dp</dimen>
+ <dimen name="dialog_sd_wisard_height">576dp</dimen>
</resources>
\ No newline at end of file
diff --git a/vlc-android/res/values/dimens.xml b/vlc-android/res/values/dimens.xml
index 93b366eb7..4abee5f3c 100644
--- a/vlc-android/res/values/dimens.xml
+++ b/vlc-android/res/values/dimens.xml
@@ -72,4 +72,6 @@
<dimen name="audio_player_cover_margin">8dp</dimen>
<dimen name="audio_player_elevation">16dp</dimen>
<dimen name="progress_layout_height">24dp</dimen>
+ <dimen name="dialog_sd_wisard_width">320dp</dimen>
+ <dimen name="dialog_sd_wisard_height">420dp</dimen>
</resources>
\ No newline at end of file
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index f8cbdc0eb..e6a73286f 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -589,4 +589,7 @@
<string name="msg_delete_failed">Failed to delete media %1$s</string>
<string name="renderer_list_title">Displays</string>
<string name="feedback_player_crashed">Sorry, VLC just crashed. Please try again.</string>
+ <string name="sdcard_permission_dialog_title">You have to grant VLC write access to your SD Card</string>
+ <string name="sdcard_permission_dialog_message">VLC cannot delete this file without write access permission.\nPlease go to your SD Card and click on \"Select\".\nYou may have to click on \"Show SD card\" first in the top-right menu</string>
+ <string name="dialog_sd_wizard">Show me</string>
</resources>
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/hf/WriteExternalDelegate.kt b/vlc-android/src/org/videolan/vlc/gui/helpers/hf/WriteExternalDelegate.kt
index 113925d6a..99dd48d6a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/hf/WriteExternalDelegate.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/hf/WriteExternalDelegate.kt
@@ -9,9 +9,11 @@ import android.os.Bundle
import android.provider.DocumentsContract
import android.support.v4.app.FragmentActivity
import android.support.v4.provider.DocumentFile
+import android.support.v7.app.AlertDialog
import android.support.v7.preference.PreferenceManager
import android.text.TextUtils
import org.videolan.libvlc.util.AndroidUtil
+import org.videolan.vlc.R
import org.videolan.vlc.VLCApplication
import org.videolan.vlc.util.AndroidDevices
import org.videolan.vlc.util.FileUtils
@@ -22,9 +24,30 @@ class WriteExternalDelegate : BaseHeadlessFragment() {
@TargetApi(Build.VERSION_CODES.O)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
- arguments?.getString(KEY_STORAGE_PATH)?.let { intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, Uri.parse(it)) }
- startActivityForResult(intent, REQUEST_CODE_STORAGE_ACCES)
+ showDialog()
+ }
+
+ private fun showDialog() {
+ if (!isAdded) return
+ val builder = AlertDialog.Builder(activity)
+ builder.setMessage(R.string.sdcard_permission_dialog_message)
+ .setTitle(R.string.sdcard_permission_dialog_title)
+ .setPositiveButton(R.string.ok, { _, _ ->
+ val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
+ arguments?.getString(KEY_STORAGE_PATH)?.let { intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, Uri.parse(it)) }
+ startActivityForResult(intent, REQUEST_CODE_STORAGE_ACCES)
+ })
+ .setNeutralButton(getString(R.string.dialog_sd_wizard), { _, _ ->
+ showHelpDialog()
+ }).create().show()
+ }
+
+ private fun showHelpDialog() {
+ if (!isAdded) return
+ val inflater = activity.layoutInflater
+ AlertDialog.Builder(activity).setView(inflater.inflate(R.layout.dialog_sd_write, null))
+ .setOnDismissListener { showDialog() }
+ .create().show()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
More information about the Android
mailing list