Commit 48d026a3 authored by Geoffrey Métais's avatar Geoffrey Métais

Add instructions to SD card permission dialog

parent de313019
<?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
......@@ -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
......@@ -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
......@@ -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>
......@@ -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?) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment