summaryrefslogtreecommitdiff
path: root/packages/SoundPicker/src
diff options
context:
space:
mode:
authorHeemin Seog <hseog@google.com>2019-09-13 10:26:29 -0700
committerHeemin Seog <hseog@google.com>2019-09-13 10:26:29 -0700
commitc39e4bf51e0d403e0b483f1ccdf165f587e75a69 (patch)
treee27b23dad203bb2d959805e91c0e6bdc72c4386e /packages/SoundPicker/src
parent95eb6ea09788bd79c59a287bb860425a02de976e (diff)
Restrict showing "new ringtone" for missing picker
Automotive builds can come without a file picker. In such cases, the RingtonePickerActivity shouldn't need to show the "Add New Ringtone" list item. Bug: 138454052 Test: manual Change-Id: Iceb5555493420898d6eafe79e3299d5bd3a77a98
Diffstat (limited to 'packages/SoundPicker/src')
-rw-r--r--packages/SoundPicker/src/com/android/soundpicker/RingtonePickerActivity.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/packages/SoundPicker/src/com/android/soundpicker/RingtonePickerActivity.java b/packages/SoundPicker/src/com/android/soundpicker/RingtonePickerActivity.java
index 4ba5146b8d39..d2f168eb5e3e 100644
--- a/packages/SoundPicker/src/com/android/soundpicker/RingtonePickerActivity.java
+++ b/packages/SoundPicker/src/com/android/soundpicker/RingtonePickerActivity.java
@@ -52,7 +52,6 @@ import com.android.internal.app.AlertActivity;
import com.android.internal.app.AlertController;
import java.io.IOException;
-import java.util.Objects;
import java.util.regex.Pattern;
/**
@@ -154,10 +153,7 @@ public final class RingtonePickerActivity extends AlertActivity implements
if (which == mCursor.getCount() + mStaticItemCount) {
// The "Add new ringtone" item was clicked. Start a file picker intent to select
// only audio files (MIME type "audio/*")
- final Intent chooseFile = new Intent(Intent.ACTION_GET_CONTENT);
- chooseFile.setType("audio/*");
- chooseFile.putExtra(Intent.EXTRA_MIME_TYPES,
- new String[] { "audio/*", "application/ogg" });
+ final Intent chooseFile = getMediaFilePickerIntent();
startActivityForResult(chooseFile, ADD_FILE_REQUEST_CODE);
return;
}
@@ -375,7 +371,8 @@ public final class RingtonePickerActivity extends AlertActivity implements
setSuccessResultWithRingtone(getCurrentlySelectedRingtoneUri());
}
// If external storage is available, add a button to install sounds from storage.
- if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+ if (resolvesMediaFilePicker()
+ && Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
addNewSoundItem(listView);
}
@@ -633,6 +630,18 @@ public final class RingtonePickerActivity extends AlertActivity implements
return ringtoneManagerPos + mStaticItemCount;
}
+ private Intent getMediaFilePickerIntent() {
+ final Intent chooseFile = new Intent(Intent.ACTION_GET_CONTENT);
+ chooseFile.setType("audio/*");
+ chooseFile.putExtra(Intent.EXTRA_MIME_TYPES,
+ new String[] { "audio/*", "application/ogg" });
+ return chooseFile;
+ }
+
+ private boolean resolvesMediaFilePicker() {
+ return getMediaFilePickerIntent().resolveActivity(getPackageManager()) != null;
+ }
+
private static class LocalizedCursor extends CursorWrapper {
final int mTitleIndex;