Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0679a159 authored by Heemin Seog's avatar Heemin Seog Committed by Android (Google) Code Review
Browse files

Merge "Restrict showing "new ringtone" for missing picker"

parents c4e19883 c39e4bf5
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -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;