WIP andorid auto
This commit is contained in:
parent
c2759e3ec0
commit
6acac46d45
9 changed files with 79 additions and 26 deletions
|
@ -259,6 +259,8 @@
|
|||
<meta-data
|
||||
android:name="com.google.android.gms.car.notification.SmallIcon"
|
||||
android:resource="@drawable/ic_notification" />
|
||||
|
||||
|
||||
</application>
|
||||
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
@ -272,4 +274,8 @@
|
|||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.type.automotive"
|
||||
android:required="true" />
|
||||
</manifest>
|
||||
|
|
|
@ -55,7 +55,9 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
|
|||
return contentView
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
override fun onCreate(
|
||||
savedInstanceState: Bundle?
|
||||
) {
|
||||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
|
@ -64,12 +66,9 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
|
|||
getBottomNavigationView().setOnNavigationItemSelectedListener {
|
||||
PreferenceUtil.getInstance().lastPage = it.itemId
|
||||
selectedFragment(it.itemId)
|
||||
|
||||
true
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
selectedFragment(PreferenceUtil.getInstance().lastPage)
|
||||
} else {
|
||||
|
|
|
@ -169,7 +169,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), Sliding
|
|||
slidingLayout.panelHeight = 0
|
||||
collapsePanel()
|
||||
} else {
|
||||
if (!MusicPlayerRemote.playingQueue.isEmpty()) {
|
||||
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||
slidingLayout.panelHeight = if (bottomNavigationView.visibility == View.VISIBLE) heightOfBarWithTabs else heightOfBar
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,6 +173,7 @@ abstract class AbsThemeActivity : ATHActivity(), Runnable {
|
|||
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
or View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
|
||||
|
||||
if (PreferenceUtil.getInstance().fullScreenMode) {
|
||||
window.decorView.systemUiVisibility = flags
|
||||
}
|
||||
|
|
|
@ -57,9 +57,7 @@ public class AutoMusicProvider {
|
|||
private static final int PATH_SEGMENT_ID = 0;
|
||||
private static final int PATH_SEGMENT_TITLE = 1;
|
||||
private static final int PATH_SEGMENT_ARTIST = 2;
|
||||
private static final int PATH_SEGMENT_ALBUM_ID = 3;
|
||||
|
||||
private WeakReference<MusicService> mMusicService;
|
||||
|
||||
// Categorized caches for music data
|
||||
private ConcurrentMap<Integer, Uri> mMusicListByHistory;
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
package code.name.monkey.retromusic.auto;
|
||||
|
||||
import android.app.UiModeManager;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
public class CarHelper {
|
||||
|
||||
private static final String TAG = "CarHelper";
|
||||
|
||||
public static boolean isCarUiMode(Context c) {
|
||||
UiModeManager uiModeManager = (UiModeManager) c.getSystemService(Context.UI_MODE_SERVICE);
|
||||
return uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR;
|
||||
}
|
||||
}
|
|
@ -24,7 +24,9 @@ interface DeezerApiService {
|
|||
): Call<DeezerResponse>
|
||||
|
||||
companion object {
|
||||
operator fun invoke(client: okhttp3.Call.Factory): DeezerApiService {
|
||||
operator fun invoke(
|
||||
client: okhttp3.Call.Factory
|
||||
): DeezerApiService {
|
||||
return Retrofit.Builder()
|
||||
.baseUrl(BASE_URL)
|
||||
.callFactory(client)
|
||||
|
@ -33,12 +35,16 @@ interface DeezerApiService {
|
|||
.create()
|
||||
}
|
||||
|
||||
fun createDefaultOkHttpClient(context: Context): OkHttpClient.Builder =
|
||||
fun createDefaultOkHttpClient(
|
||||
context: Context
|
||||
): OkHttpClient.Builder =
|
||||
OkHttpClient.Builder()
|
||||
.cache(createDefaultCache(context))
|
||||
.addInterceptor(createCacheControlInterceptor())
|
||||
|
||||
private fun createDefaultCache(context: Context): Cache? {
|
||||
private fun createDefaultCache(
|
||||
context: Context
|
||||
): Cache? {
|
||||
val cacheDir = File(context.applicationContext.cacheDir.absolutePath, "/okhttp-deezer/")
|
||||
if (cacheDir.mkdir() or cacheDir.isDirectory) {
|
||||
return Cache(cacheDir, 1024 * 1024 * 10)
|
||||
|
|
|
@ -32,7 +32,8 @@ object AlbumLoader {
|
|||
fun getAllAlbumsFlowable(
|
||||
context: Context
|
||||
): Observable<ArrayList<Album>> {
|
||||
val songs = SongLoader.getSongsFlowable(SongLoader.makeSongCursor(
|
||||
val songs = SongLoader.getSongsFlowable(
|
||||
SongLoader.makeSongCursor(
|
||||
context, null, null,
|
||||
getSongLoaderSortOrder())
|
||||
)
|
||||
|
@ -40,8 +41,12 @@ object AlbumLoader {
|
|||
return splitIntoAlbumsFlowable(songs)
|
||||
}
|
||||
|
||||
fun getAlbumsFlowable(context: Context, query: String): Observable<ArrayList<Album>> {
|
||||
val songs = SongLoader.getSongsFlowable(SongLoader.makeSongCursor(
|
||||
fun getAlbumsFlowable(
|
||||
context: Context,
|
||||
query: String
|
||||
): Observable<ArrayList<Album>> {
|
||||
val songs = SongLoader.getSongsFlowable(
|
||||
SongLoader.makeSongCursor(
|
||||
context,
|
||||
AudioColumns.ALBUM + " LIKE ?",
|
||||
arrayOf("%$query%"),
|
||||
|
@ -68,7 +73,14 @@ object AlbumLoader {
|
|||
albumId: Int
|
||||
): Observable<Album> {
|
||||
return Observable.create { e ->
|
||||
val songs = SongLoader.getSongsFlowable(SongLoader.makeSongCursor(context, AudioColumns.ALBUM_ID + "=?", arrayOf(albumId.toString()), getSongLoaderSortOrder()))
|
||||
val songs = SongLoader.getSongsFlowable(
|
||||
SongLoader.makeSongCursor(
|
||||
context,
|
||||
AudioColumns.ALBUM_ID + "=?",
|
||||
arrayOf(albumId.toString()),
|
||||
getSongLoaderSortOrder()
|
||||
)
|
||||
)
|
||||
songs.subscribe { songs1 ->
|
||||
e.onNext(Album(songs1))
|
||||
e.onComplete()
|
||||
|
@ -114,7 +126,8 @@ object AlbumLoader {
|
|||
fun getAllAlbums(
|
||||
context: Context
|
||||
): ArrayList<Album> {
|
||||
val songs = SongLoader.getSongs(SongLoader.makeSongCursor(
|
||||
val songs = SongLoader.getSongs(
|
||||
SongLoader.makeSongCursor(
|
||||
context, null, null,
|
||||
getSongLoaderSortOrder())
|
||||
)
|
||||
|
@ -178,7 +191,6 @@ object AlbumLoader {
|
|||
|
||||
private fun getSongLoaderSortOrder(): String {
|
||||
return PreferenceUtil.getInstance().albumSortOrder + ", " +
|
||||
//PreferenceUtil.getInstance().getAlbumSongSortOrder() + "," +
|
||||
PreferenceUtil.getInstance().albumDetailSongSortOrder
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,11 @@ import code.name.monkey.retromusic.R
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
|
||||
class BottomNavigationBarTinted @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) :
|
||||
BottomNavigationView(context, attrs, defStyleAttr) {
|
||||
class BottomNavigationBarTinted @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : BottomNavigationView(context, attrs, defStyleAttr) {
|
||||
|
||||
init {
|
||||
labelVisibilityMode = PreferenceUtil.getInstance().tabTitleMode
|
||||
|
|
Loading…
Reference in a new issue