diff options
28 files changed, 103 insertions, 16 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 49e0d35..8a76011 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -26,7 +26,8 @@ <application android:allowBackup="true" - android:icon="@drawable/ic_launcher" + android:icon="@mipmap/ic_launcher" + android:roundIcon="@mipmap/ic_launcher_round" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/LocalMediaPlayerAppTheme" > @@ -42,10 +43,6 @@ <activity android:name=".PermissionsActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> </activity> </application> diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 5236774..0000000 --- a/res/drawable-hdpi/ic_launcher.png +++ /dev/null diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 00b8a8b..0000000 --- a/res/drawable-mdpi/ic_launcher.png +++ /dev/null diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png Binary files differdeleted file mode 100644 index c7daa2a..0000000 --- a/res/drawable-xhdpi/ic_launcher.png +++ /dev/null diff --git a/res/drawable-xxhdpi/ic_launcher.png b/res/drawable-xxhdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 6452e12..0000000 --- a/res/drawable-xxhdpi/ic_launcher.png +++ /dev/null diff --git a/res/drawable-xxxhdpi/ic_launcher.png b/res/drawable-xxxhdpi/ic_launcher.png Binary files differdeleted file mode 100644 index eaea024..0000000 --- a/res/drawable-xxxhdpi/ic_launcher.png +++ /dev/null diff --git a/res/drawable/ic_launcher_background.xml b/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..01f0af0 --- /dev/null +++ b/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8"?> +<vector + android:height="108dp" + android:width="108dp" + android:viewportHeight="108" + android:viewportWidth="108" + xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#26A69A" + android:pathData="M0,0h108v108h-108z"/> + <path android:fillColor="#00000000" android:pathData="M9,0L9,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,0L19,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M29,0L29,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M39,0L39,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M49,0L49,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M59,0L59,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M69,0L69,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M79,0L79,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M89,0L89,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M99,0L99,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,9L108,9" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,19L108,19" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,29L108,29" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,39L108,39" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,49L108,49" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,59L108,59" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,69L108,69" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,79L108,79" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,89L108,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,99L108,99" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,29L89,29" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,39L89,39" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,49L89,49" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,59L89,59" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,69L89,69" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,79L89,79" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M29,19L29,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M39,19L39,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M49,19L49,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M59,19L59,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M69,19L69,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M79,19L79,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> +</vector> diff --git a/res/mipmap-anydpi-v26/ic_launcher.xml b/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..c4a603d --- /dev/null +++ b/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@drawable/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon>
\ No newline at end of file diff --git a/res/mipmap-anydpi-v26/ic_launcher_round.xml b/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..c4a603d --- /dev/null +++ b/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@drawable/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon>
\ No newline at end of file diff --git a/res/mipmap-hdpi/ic_launcher.png b/res/mipmap-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..2437dd1 --- /dev/null +++ b/res/mipmap-hdpi/ic_launcher.png diff --git a/res/mipmap-hdpi/ic_launcher_foreground.png b/res/mipmap-hdpi/ic_launcher_foreground.png Binary files differnew file mode 100644 index 0000000..ff533ae --- /dev/null +++ b/res/mipmap-hdpi/ic_launcher_foreground.png diff --git a/res/mipmap-hdpi/ic_launcher_round.png b/res/mipmap-hdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 0000000..51ca9f5 --- /dev/null +++ b/res/mipmap-hdpi/ic_launcher_round.png diff --git a/res/mipmap-mdpi/ic_launcher.png b/res/mipmap-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..b7a4f60 --- /dev/null +++ b/res/mipmap-mdpi/ic_launcher.png diff --git a/res/mipmap-mdpi/ic_launcher_foreground.png b/res/mipmap-mdpi/ic_launcher_foreground.png Binary files differnew file mode 100644 index 0000000..183944a --- /dev/null +++ b/res/mipmap-mdpi/ic_launcher_foreground.png diff --git a/res/mipmap-mdpi/ic_launcher_round.png b/res/mipmap-mdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 0000000..c8562f8 --- /dev/null +++ b/res/mipmap-mdpi/ic_launcher_round.png diff --git a/res/mipmap-xhdpi/ic_launcher.png b/res/mipmap-xhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..4346db3 --- /dev/null +++ b/res/mipmap-xhdpi/ic_launcher.png diff --git a/res/mipmap-xhdpi/ic_launcher_foreground.png b/res/mipmap-xhdpi/ic_launcher_foreground.png Binary files differnew file mode 100644 index 0000000..412b79c --- /dev/null +++ b/res/mipmap-xhdpi/ic_launcher_foreground.png diff --git a/res/mipmap-xhdpi/ic_launcher_round.png b/res/mipmap-xhdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 0000000..3e4dfe2 --- /dev/null +++ b/res/mipmap-xhdpi/ic_launcher_round.png diff --git a/res/mipmap-xxhdpi/ic_launcher.png b/res/mipmap-xxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..c4dfa82 --- /dev/null +++ b/res/mipmap-xxhdpi/ic_launcher.png diff --git a/res/mipmap-xxhdpi/ic_launcher_foreground.png b/res/mipmap-xxhdpi/ic_launcher_foreground.png Binary files differnew file mode 100644 index 0000000..4f91eee --- /dev/null +++ b/res/mipmap-xxhdpi/ic_launcher_foreground.png diff --git a/res/mipmap-xxhdpi/ic_launcher_round.png b/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 0000000..4475ec2 --- /dev/null +++ b/res/mipmap-xxhdpi/ic_launcher_round.png diff --git a/res/mipmap-xxxhdpi/ic_launcher.png b/res/mipmap-xxxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..959b1d1 --- /dev/null +++ b/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/res/mipmap-xxxhdpi/ic_launcher_foreground.png Binary files differnew file mode 100644 index 0000000..85aaa77 --- /dev/null +++ b/res/mipmap-xxxhdpi/ic_launcher_foreground.png diff --git a/res/mipmap-xxxhdpi/ic_launcher_round.png b/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 0000000..5207be3 --- /dev/null +++ b/res/mipmap-xxxhdpi/ic_launcher_round.png diff --git a/src/com/android/car/media/localmediaplayer/DataModel.java b/src/com/android/car/media/localmediaplayer/DataModel.java index ba17306..1b94855 100644 --- a/src/com/android/car/media/localmediaplayer/DataModel.java +++ b/src/com/android/car/media/localmediaplayer/DataModel.java @@ -75,8 +75,6 @@ public class DataModel { private static final String INTERNAL = "internal"; private static final Uri ART_BASE_URI = Uri.parse("content://media/external/audio/albumart"); - // Need a context to create this constant so it can't be static. - private final String DEFAULT_ALBUM_ART_URI; public static final String PATH_KEY = "PATH"; @@ -89,8 +87,6 @@ public class DataModel { public DataModel(Context context) { mContext = context; mResolver = context.getContentResolver(); - DEFAULT_ALBUM_ART_URI = - Utils.getUriForResource(context, R.drawable.ic_sd_storage_black).toString(); } public void onQueryByFolder(String parentId, Result<List<MediaItem>> result) { @@ -174,7 +170,7 @@ public class DataModel { metadata.putLong(MediaMetadata.METADATA_KEY_DURATION, cursor.getLong(duration)); - String albumArt = DEFAULT_ALBUM_ART_URI; + String albumArt = null; Uri albumArtUri = ContentUris.withAppendedId(ART_BASE_URI, cursor.getLong(albumId)); try { diff --git a/src/com/android/car/media/localmediaplayer/LocalMediaBrowserService.java b/src/com/android/car/media/localmediaplayer/LocalMediaBrowserService.java index 3ec86b6..5b5ae1c 100644 --- a/src/com/android/car/media/localmediaplayer/LocalMediaBrowserService.java +++ b/src/com/android/car/media/localmediaplayer/LocalMediaBrowserService.java @@ -113,12 +113,8 @@ public class LocalMediaBrowserService extends MediaBrowserService { public void onCreate() { super.onCreate(); - // TODO: This doesn't handle the case where the user revokes the permission very well, the - // prompt will only show up once this service has been recreated which is non-deterministic. if (!Utils.hasRequiredPermissions(this)) { - Intent intent = new Intent(this, PermissionsActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); + Utils.startPermissionRequest(this); } mDataModel = new DataModel(this); diff --git a/src/com/android/car/media/localmediaplayer/Player.java b/src/com/android/car/media/localmediaplayer/Player.java index f70e05c..0aade15 100644 --- a/src/com/android/car/media/localmediaplayer/Player.java +++ b/src/com/android/car/media/localmediaplayer/Player.java @@ -171,7 +171,12 @@ public class Player extends MediaSession.Callback { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "onPlay"); } - requestAudioFocus(() -> resumePlayback()); + // Check permissions every time we try to play + if (!Utils.hasRequiredPermissions(mContext)) { + Utils.startPermissionRequest(mContext); + } else { + requestAudioFocus(() -> resumePlayback()); + } } @Override diff --git a/src/com/android/car/media/localmediaplayer/Utils.java b/src/com/android/car/media/localmediaplayer/Utils.java index a285589..d761794 100644 --- a/src/com/android/car/media/localmediaplayer/Utils.java +++ b/src/com/android/car/media/localmediaplayer/Utils.java @@ -17,6 +17,7 @@ package com.android.car.media.localmediaplayer; import android.content.ContentResolver; import android.content.Context; +import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Resources; import android.net.Uri; @@ -42,4 +43,12 @@ public class Utils { } return true; } + + static void startPermissionRequest(Context context) { + if (!Utils.hasRequiredPermissions(context)) { + Intent intent = new Intent(context, PermissionsActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + } + } } |