From 1225357c5bba0fd9f215e86f9a077aec8c761908 Mon Sep 17 00:00:00 2001 From: Gary Kipnis Date: Tue, 7 Jun 2016 16:56:44 -0700 Subject: Fixed storage permission issue for attachments Moved some audio library tab related string to cm_strings.xml When Storage Permissions were being requested and granted, they were applied to either the Gallery (image & video) or Audio tab. This patch makes sure that the permissions are propagated to both. Change-Id: Ic8a3316616fad6fdf1cbc771aba360a031db88ad TicketId: Kipper-587 TicketId: Crackling-937 TicketId: Feij-143 TicketId: Porridge-64 --- res/values/cm_strings.xml | 13 +++++++++++++ res/values/strings.xml | 13 ------------- .../android/messaging/ui/mediapicker/AudioListChooser.java | 7 +++++-- .../messaging/ui/mediapicker/GalleryMediaChooser.java | 4 +++- src/com/android/messaging/ui/mediapicker/MediaPicker.java | 1 + 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 15110df..1914da1 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -22,4 +22,17 @@ Emoticons access Show the emoticons key on the keyboard + + + Choose images or videos from this + device + Choose audio files from this + device + Can\'t attach video. + Max message size exceeded. + Choose audio + Selected audio + Tap to select + %d selected + diff --git a/res/values/strings.xml b/res/values/strings.xml index 30a8bd9..3d21f3a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -53,7 +53,6 @@ Capture pictures or video Choose images or videos from this device - Choose audios from this device Record audio Choose photo The media is selected. @@ -62,20 +61,8 @@ image %1$tB %1$te %1$tY %1$tl %1$tM %1$tp image - Can\'t attach video. - Max message size exceeded. - Choose audio - The audio is selected - . - The audio is - unselected - . - %d selected - Record audio - Share - "Just now" "Now" diff --git a/src/com/android/messaging/ui/mediapicker/AudioListChooser.java b/src/com/android/messaging/ui/mediapicker/AudioListChooser.java index 2ce42b3..de0445c 100644 --- a/src/com/android/messaging/ui/mediapicker/AudioListChooser.java +++ b/src/com/android/messaging/ui/mediapicker/AudioListChooser.java @@ -174,6 +174,9 @@ class AudioListChooser extends MediaChooser implements // Work around a bug in MediaStore where cursors querying the Files provider don't get // updated for changes to Images.Media or Video.Media. startMediaPickerDataLoader(); + updateForPermissionState(true); + } else { + updateForPermissionState(false); } } @@ -183,7 +186,7 @@ class AudioListChooser extends MediaChooser implements if (selected && !OsUtil.hasStoragePermission()) { mMediaPicker.requestPermissions( new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, - MediaPicker.GALLERY_PERMISSION_REQUEST_CODE); + MediaPicker.AUDIO_LIBRARY_PERMISSION_REQUEST_CODE); } } @@ -195,7 +198,7 @@ class AudioListChooser extends MediaChooser implements @Override protected void onRequestPermissionsResult( final int requestCode, final String permissions[], final int[] grantResults) { - if (requestCode == MediaPicker.GALLERY_PERMISSION_REQUEST_CODE) { + if (requestCode == MediaPicker.AUDIO_LIBRARY_PERMISSION_REQUEST_CODE) { final boolean permissionGranted = grantResults[0] == PackageManager.PERMISSION_GRANTED; if (permissionGranted) { startMediaPickerDataLoader(); diff --git a/src/com/android/messaging/ui/mediapicker/GalleryMediaChooser.java b/src/com/android/messaging/ui/mediapicker/GalleryMediaChooser.java index b39cc0d..af360bc 100644 --- a/src/com/android/messaging/ui/mediapicker/GalleryMediaChooser.java +++ b/src/com/android/messaging/ui/mediapicker/GalleryMediaChooser.java @@ -24,7 +24,6 @@ import android.database.MergeCursor; import android.provider.Telephony; import android.support.v7.app.ActionBar; import android.support.v7.mms.CarrierConfigValuesLoader; -import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -196,6 +195,9 @@ class GalleryMediaChooser extends MediaChooser implements // Work around a bug in MediaStore where cursors querying the Files provider don't get // updated for changes to Images.Media or Video.Media. startMediaPickerDataLoader(); + updateForPermissionState(true); + } else { + updateForPermissionState(false); } } diff --git a/src/com/android/messaging/ui/mediapicker/MediaPicker.java b/src/com/android/messaging/ui/mediapicker/MediaPicker.java index 7842e3b..6692620 100644 --- a/src/com/android/messaging/ui/mediapicker/MediaPicker.java +++ b/src/com/android/messaging/ui/mediapicker/MediaPicker.java @@ -726,6 +726,7 @@ public class MediaPicker extends Fragment implements DraftMessageSubscriptionDat protected static final int LOCATION_PERMISSION_REQUEST_CODE = 2; protected static final int RECORD_AUDIO_PERMISSION_REQUEST_CODE = 3; protected static final int GALLERY_PERMISSION_REQUEST_CODE = 4; + protected static final int AUDIO_LIBRARY_PERMISSION_REQUEST_CODE = 5; @Override public void onRequestPermissionsResult( -- cgit v1.2.3