Skip to content

Commit

Permalink
fix: proguard make crash
Browse files Browse the repository at this point in the history
  • Loading branch information
ZTFtrue committed Feb 4, 2024
1 parent cfe9ac6 commit 222d786
Show file tree
Hide file tree
Showing 28 changed files with 121 additions and 77 deletions.
10 changes: 10 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ android {
signingConfig = signingConfigs.getByName("debug")
}
getByName("debug") {
isMinifyEnabled = true
isShrinkResources = true

proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("debug")
}
}
Expand Down Expand Up @@ -89,6 +96,9 @@ dependencies {
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3:1.1.2")
implementation("androidx.compose.material3:material3-window-size-class:1.1.2")

// splash
implementation("androidx.core:core-splashscreen")
// implementation("androidx.compose.material:material:1.5.4")
implementation ("androidx.constraintlayout:constraintlayout-compose:1.0.1")
//
Expand Down
21 changes: 20 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,23 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

# Keep Gson models
-keep class com.ztftrue.music.utils.model.* { *; }

# Keep Room entities and DAOs
-keep class com.ztftrue.music.sqlData.** { *; }
-keepclassmembers class com.ztftrue.music.sqlData.model.** { *; }

# Keep Room database class, change "AppDatabase" to your actual database class
-keep class com.ztftrue.music.sqlData.MusicDatabase { *; }
-keepclassmembers class com.ztftrue.music.sqlData.MusicDatabase { *; }


# Keep Room annotations
-keepattributes Room*Annotation*
# class com.google.common.reflect.TypeToken isn't parameterized
-keep class com.google.gson.reflect.TypeToken
-keep class * extends com.google.gson.reflect.TypeToken
-keep public class * implements java.lang.reflect.Type
58 changes: 32 additions & 26 deletions app/src/main/java/com/ztftrue/music/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.app.ActivityCompat
import androidx.core.splashscreen.SplashScreen
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.media3.common.Player
import androidx.media3.common.util.UnstableApi
import androidx.navigation.NavHostController
Expand Down Expand Up @@ -125,15 +126,15 @@ import com.ztftrue.music.ui.public.SleepTimeDialog
import com.ztftrue.music.ui.public.TracksListPage
import com.ztftrue.music.ui.public.TracksListView
import com.ztftrue.music.ui.theme.MusicPitchTheme
import com.ztftrue.music.utils.AnyListBase
import com.ztftrue.music.utils.model.AnyListBase
import com.ztftrue.music.utils.OperateType
import com.ztftrue.music.utils.OperateTypeInActivity
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.trackManager.PlaylistManager
import com.ztftrue.music.utils.trackManager.PlaylistManager.removeTrackFromM3U
import com.ztftrue.music.utils.SharedPreferencesUtils
import com.ztftrue.music.utils.Utils
import com.ztftrue.music.utils.stringToEnumForPlayListType
import com.ztftrue.music.utils.trackManager.PlaylistManager
import com.ztftrue.music.utils.trackManager.PlaylistManager.removeTrackFromM3U
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
Expand Down Expand Up @@ -410,19 +411,24 @@ class MainActivity : ComponentActivity() {
}
}
}

private lateinit var compatSplashScreen: SplashScreen
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
compatSplashScreen = installSplashScreen()
compatSplashScreen.setKeepOnScreenCondition() { musicViewModel.mainTabList.isEmpty() }
CoroutineScope(Dispatchers.IO).launch {
val db: MusicDatabase = MusicDatabase.getDatabase(this@MainActivity)
musicViewModel.themeSelected.intValue = getSharedPreferences(
"SelectedTheme",
Context.MODE_PRIVATE
).getInt("SelectedTheme", 0)
musicViewModel.textAlign.value = SharedPreferencesUtils.getDisplayAlign(this@MainActivity)
musicViewModel.textAlign.value =
SharedPreferencesUtils.getDisplayAlign(this@MainActivity)
musicViewModel.fontSize.intValue = SharedPreferencesUtils.getFontSize(this@MainActivity)
musicViewModel.autoScroll.value=SharedPreferencesUtils.getAutoScroll(this@MainActivity)
musicViewModel.autoHighLight.value=SharedPreferencesUtils.getAutoHighLight(this@MainActivity)
musicViewModel.autoScroll.value =
SharedPreferencesUtils.getAutoScroll(this@MainActivity)
musicViewModel.autoHighLight.value =
SharedPreferencesUtils.getAutoHighLight(this@MainActivity)
val dicApps = db.DictionaryAppDao().findAllDictionaryApp()
if (dicApps.isNullOrEmpty()) {
val list = ArrayList<DictionaryApp>()
Expand Down Expand Up @@ -766,24 +772,24 @@ class MainActivity : ComponentActivity() {
composable(route = Router.MainView.route) {
key(Router.MainView.route) {
if (musicViewModel.mainTabList.isEmpty()) {
Column(
modifier = Modifier
.fillMaxSize(),
verticalArrangement = Arrangement.Bottom,
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
painter =
painterResource(id = R.drawable.launcher_image),
contentDescription = "launching",
modifier = Modifier
.padding(0.dp)
.fillMaxWidth()
.fillMaxHeight(),
alignment = Alignment.BottomEnd,
contentScale = ContentScale.FillBounds
)
}
// Column(
// modifier = Modifier
// .fillMaxSize(),
// verticalArrangement = Arrangement.Bottom,
// horizontalAlignment = Alignment.CenterHorizontally
// ) {
// Image(
// painter =
// painterResource(id = R.drawable.launcher_image),
// contentDescription = "launching",
// modifier = Modifier
// .padding(0.dp)
// .fillMaxWidth()
// .fillMaxHeight(),
// alignment = Alignment.BottomEnd,
// contentScale = ContentScale.FillBounds
// )
// }
} else {
MainView(navController, pagerState)
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/ztftrue/music/MusicViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import com.ztftrue.music.sqlData.model.DictionaryApp
import com.ztftrue.music.sqlData.model.MainTab
import com.ztftrue.music.sqlData.model.MusicItem
import com.ztftrue.music.ui.play.Lyrics
import com.ztftrue.music.utils.ListStringCaption
import com.ztftrue.music.utils.AnyListBase
import com.ztftrue.music.utils.Caption
import com.ztftrue.music.utils.model.ListStringCaption
import com.ztftrue.music.utils.model.AnyListBase
import com.ztftrue.music.utils.model.Caption
import com.ztftrue.music.utils.CaptionUtils
import com.ztftrue.music.utils.EqualizerBand
import com.ztftrue.music.utils.model.EqualizerBand
import com.ztftrue.music.utils.LyricsType
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.ScrollDirectionType
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/com/ztftrue/music/play/PlayService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ import com.ztftrue.music.sqlData.model.CurrentList
import com.ztftrue.music.sqlData.model.MainTab
import com.ztftrue.music.sqlData.model.MusicItem
import com.ztftrue.music.sqlData.model.PlayConfig
import com.ztftrue.music.utils.AlbumList
import com.ztftrue.music.utils.AnyListBase
import com.ztftrue.music.utils.ArtistList
import com.ztftrue.music.utils.FolderList
import com.ztftrue.music.utils.GenresList
import com.ztftrue.music.utils.MusicPlayList
import com.ztftrue.music.utils.model.AlbumList
import com.ztftrue.music.utils.model.AnyListBase
import com.ztftrue.music.utils.model.ArtistList
import com.ztftrue.music.utils.model.FolderList
import com.ztftrue.music.utils.model.GenresList
import com.ztftrue.music.utils.model.MusicPlayList
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.stringToEnumForPlayListType
import com.ztftrue.music.utils.trackManager.AlbumManager
Expand Down Expand Up @@ -1263,10 +1263,10 @@ class PlayService : MediaBrowserServiceCompat() {
CoroutineScope(Dispatchers.IO).launch {
var c = db.CurrentListDao().findCurrentList()
if (c == null) {
c = CurrentList(null, playListCurrent?.id ?: -1, playList.type.name)
c = CurrentList(null, playList.id, playList.type.name)
db.CurrentListDao().insert(c)
} else {
c.listID = playListCurrent?.id ?: -1
c.listID = playList.id
c.type = playList.type.name
db.CurrentListDao().update(c)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ztftrue.music.sqlData

import androidx.room.TypeConverter
import com.google.common.reflect.TypeToken
import com.google.gson.reflect.TypeToken;
import com.google.gson.Gson
import java.lang.reflect.Type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import com.ztftrue.music.R
import com.ztftrue.music.Router
import com.ztftrue.music.ui.public.AddMusicToPlayListDialog
import com.ztftrue.music.ui.public.CreatePlayListDialog
import com.ztftrue.music.utils.AlbumList
import com.ztftrue.music.utils.model.AlbumList
import com.ztftrue.music.utils.trackManager.ArtistManager
import com.ztftrue.music.utils.OperateType
import com.ztftrue.music.utils.PlayListType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import com.ztftrue.music.R
import com.ztftrue.music.Router
import com.ztftrue.music.ui.public.AddMusicToPlayListDialog
import com.ztftrue.music.ui.public.CreatePlayListDialog
import com.ztftrue.music.utils.ArtistList
import com.ztftrue.music.utils.model.ArtistList
import com.ztftrue.music.utils.OperateType
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.ScrollDirectionType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import com.ztftrue.music.R
import com.ztftrue.music.Router
import com.ztftrue.music.ui.public.AddMusicToPlayListDialog
import com.ztftrue.music.ui.public.CreatePlayListDialog
import com.ztftrue.music.utils.FolderList
import com.ztftrue.music.utils.model.FolderList
import com.ztftrue.music.utils.OperateType
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.Utils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import com.ztftrue.music.R
import com.ztftrue.music.Router
import com.ztftrue.music.ui.public.AddMusicToPlayListDialog
import com.ztftrue.music.ui.public.CreatePlayListDialog
import com.ztftrue.music.utils.GenresList
import com.ztftrue.music.utils.model.GenresList
import com.ztftrue.music.utils.OperateType
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.ScrollDirectionType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import com.ztftrue.music.ui.public.AddMusicToPlayListDialog
import com.ztftrue.music.ui.public.CreatePlayListDialog
import com.ztftrue.music.ui.public.DeleteTip
import com.ztftrue.music.ui.public.RenamePlayListDialog
import com.ztftrue.music.utils.MusicPlayList
import com.ztftrue.music.utils.model.MusicPlayList
import com.ztftrue.music.utils.OperateType
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.trackManager.PlaylistManager
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/java/com/ztftrue/music/ui/other/SearchPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.text.TextStyle
Expand All @@ -53,9 +52,9 @@ import com.ztftrue.music.ui.home.AlbumGridView
import com.ztftrue.music.ui.home.ArtistsGridView
import com.ztftrue.music.ui.public.BackButton
import com.ztftrue.music.ui.public.TracksListView
import com.ztftrue.music.utils.AlbumList
import com.ztftrue.music.utils.AnyListBase
import com.ztftrue.music.utils.ArtistList
import com.ztftrue.music.utils.model.AlbumList
import com.ztftrue.music.utils.model.AnyListBase
import com.ztftrue.music.utils.model.ArtistList
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.ScrollDirectionType
import kotlinx.coroutines.CoroutineScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import com.ztftrue.music.play.ACTION_PlayLIST_CHANGE
import com.ztftrue.music.sqlData.model.MusicItem
import com.ztftrue.music.ui.public.BackButton
import com.ztftrue.music.ui.public.TracksListView
import com.ztftrue.music.utils.AnyListBase
import com.ztftrue.music.utils.model.AnyListBase
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.trackManager.PlaylistManager

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/ztftrue/music/ui/play/LyricsView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import androidx.compose.ui.window.PopupProperties
import androidx.media3.common.util.UnstableApi
import com.ztftrue.music.MainActivity
import com.ztftrue.music.MusicViewModel
import com.ztftrue.music.utils.ListStringCaption
import com.ztftrue.music.utils.model.ListStringCaption
import com.ztftrue.music.utils.LyricsType
import com.ztftrue.music.utils.Utils
import com.ztftrue.music.utils.textToolbar.CustomTextToolbar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import com.ztftrue.music.MusicViewModel
import com.ztftrue.music.sqlData.model.MusicItem
import com.ztftrue.music.utils.MusicPlayList
import com.ztftrue.music.utils.model.MusicPlayList
import com.ztftrue.music.utils.PlayListType

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import com.ztftrue.music.play.ACTION_PlayLIST_CHANGE
import com.ztftrue.music.play.ACTION_RemoveFromQueue
import com.ztftrue.music.play.ACTION_TRACKS_DELETE
import com.ztftrue.music.sqlData.model.MusicItem
import com.ztftrue.music.utils.AnyListBase
import com.ztftrue.music.utils.model.AnyListBase
import com.ztftrue.music.utils.OperateType
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.trackManager.PlaylistManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import androidx.compose.ui.zIndex
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.media3.common.util.UnstableApi
import com.ztftrue.music.MusicViewModel
import com.ztftrue.music.R
import com.ztftrue.music.sqlData.model.MusicItem
import com.ztftrue.music.utils.AnyListBase
import com.ztftrue.music.utils.model.AnyListBase
import kotlinx.coroutines.launch

/**
Expand All @@ -54,7 +56,9 @@ fun TracksListView(
Text(
text = "No music",
color = MaterialTheme.colorScheme.onBackground,
modifier = Modifier.horizontalScroll(rememberScrollState(0))
modifier = Modifier.horizontalScroll(rememberScrollState(0)).semantics {
contentDescription = "No music"
}
)
}else{
ConstraintLayout(
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/com/ztftrue/music/ui/public/TracksPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ import com.ztftrue.music.ui.home.ArtistsOperateDialog
import com.ztftrue.music.ui.home.FolderListOperateDialog
import com.ztftrue.music.ui.home.GenreListOperateDialog
import com.ztftrue.music.ui.home.PlayListOperateDialog
import com.ztftrue.music.utils.AlbumList
import com.ztftrue.music.utils.AnyListBase
import com.ztftrue.music.utils.ArtistList
import com.ztftrue.music.utils.model.AlbumList
import com.ztftrue.music.utils.model.AnyListBase
import com.ztftrue.music.utils.model.ArtistList
import com.ztftrue.music.utils.trackManager.ArtistManager
import com.ztftrue.music.utils.FolderList
import com.ztftrue.music.utils.GenresList
import com.ztftrue.music.utils.ListBase
import com.ztftrue.music.utils.MusicPlayList
import com.ztftrue.music.utils.model.FolderList
import com.ztftrue.music.utils.model.GenresList
import com.ztftrue.music.utils.model.ListBase
import com.ztftrue.music.utils.model.MusicPlayList
import com.ztftrue.music.utils.OperateType
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.ScrollDirectionType
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/ztftrue/music/utils/CaptionUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ztftrue.music.utils

import android.content.Context
import com.ztftrue.music.R
import com.ztftrue.music.utils.model.Caption
import java.io.File
import java.util.Locale
import java.util.regex.Matcher
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/ztftrue/music/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.ztftrue.music.play.ACTION_AddPlayQueue
import com.ztftrue.music.play.ACTION_GET_TRACKS
import com.ztftrue.music.play.ACTION_PlayLIST_CHANGE
import com.ztftrue.music.sqlData.model.MusicItem
import com.ztftrue.music.utils.model.AnyListBase
import com.ztftrue.music.utils.trackManager.PlaylistManager
import java.io.File
import java.io.FileInputStream
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ztftrue.music.utils
package com.ztftrue.music.utils.model

import android.os.Parcelable
import com.ztftrue.music.utils.PlayListType
import kotlinx.parcelize.Parcelize
import java.io.Serializable

Expand Down
Loading

0 comments on commit 222d786

Please sign in to comment.