Skip to content

Commit

Permalink
change: remove buildConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
muedsa committed Sep 14, 2024
1 parent 09e5d75 commit c27b64c
Show file tree
Hide file tree
Showing 9 changed files with 479 additions and 875 deletions.
1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ android {
jvmTarget = JavaVersion.VERSION_17.toString()
}
buildFeatures {
buildConfig = true
compose = true
}
composeCompiler {
Expand Down
645 changes: 213 additions & 432 deletions app/src/main/generated/baselineProfiles/baseline-prof.txt

Large diffs are not rendered by default.

645 changes: 213 additions & 432 deletions app/src/main/generated/baselineProfiles/startup-prof.txt

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions app/src/main/kotlin/com/muedsa/jcytv/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.muedsa.jcytv.repository.DataStoreRepo
import com.muedsa.jcytv.repository.JcyRepo
import com.muedsa.jcytv.room.AppDatabase
import com.muedsa.jcytv.service.DanDanPlayApiService
import com.muedsa.uitl.AppUtil
import com.muedsa.uitl.LenientJson
import dagger.Module
import dagger.Provides
Expand Down Expand Up @@ -51,10 +52,10 @@ internal object AppModule {

@Provides
@Singleton
fun provideDanDanPlayApiService(): DanDanPlayApiService {
fun provideDanDanPlayApiService(@ApplicationContext context: Context): DanDanPlayApiService {
val client = OkHttpClient.Builder()
.also {
if (BuildConfig.DEBUG) {
if (AppUtil.debuggable(context)) {
val loggingInterceptor = HttpLoggingInterceptor()
loggingInterceptor.level = HttpLoggingInterceptor.Level.BODY
it.addInterceptor(loggingInterceptor)
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/kotlin/com/muedsa/jcytv/MainApp.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.muedsa.jcytv

import android.app.Application
import com.muedsa.uitl.AppUtil
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber

Expand All @@ -9,7 +10,7 @@ class MainApp : Application() {

override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) {
if (AppUtil.debuggable(applicationContext)) {
Timber.plant(Timber.DebugTree())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand All @@ -37,13 +38,13 @@ import com.muedsa.compose.tv.widget.ImmersiveList
import com.muedsa.compose.tv.widget.LoadingScreen
import com.muedsa.compose.tv.widget.ScreenBackgroundType
import com.muedsa.compose.tv.widget.StandardImageCardsRow
import com.muedsa.jcytv.BuildConfig
import com.muedsa.jcytv.exception.NeedValidateCaptchaException
import com.muedsa.jcytv.model.JcyVideoRow
import com.muedsa.jcytv.screens.NavigationItems
import com.muedsa.jcytv.screens.home.useLocalHomeScreenBackgroundState
import com.muedsa.jcytv.screens.nav
import com.muedsa.jcytv.theme.VideoPosterSize
import com.muedsa.uitl.AppUtil
import com.muedsa.uitl.LogUtil


Expand Down Expand Up @@ -88,6 +89,7 @@ fun MainScreenVideoRows(
val configuration = LocalConfiguration.current
val backgroundState = useLocalHomeScreenBackgroundState()
val navController = useLocalNavHostController()
val context = LocalContext.current


val firstRowHeight =
Expand Down Expand Up @@ -204,7 +206,7 @@ fun MainScreenVideoRows(
.padding(top = 16.dp)
.align(Alignment.CenterEnd)
.graphicsLayer { alpha = 0.6f },
text = "APP版本: ${BuildConfig.BUILD_TYPE}-${BuildConfig.VERSION_NAME}(${BuildConfig.VERSION_CODE})",
text = "APP版本: ${AppUtil.getVersionInfo(context)}${if(AppUtil.debuggable(context)) " DEBUG" else ""}",
color = MaterialTheme.colorScheme.onSurfaceVariant,
style = MaterialTheme.typography.labelSmall
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import com.kuaishou.akdanmaku.ecs.component.filter.DuplicateMergedFilter
import com.muedsa.compose.tv.useLocalToastMsgBoxController
import com.muedsa.compose.tv.widget.player.DanmakuVideoPlayer
import com.muedsa.compose.tv.widget.player.mergeDanmaku
import com.muedsa.jcytv.BuildConfig
import com.muedsa.model.LazyType
import com.muedsa.uitl.AppUtil
import com.muedsa.uitl.LogUtil
import kotlinx.coroutines.delay
import kotlin.math.max
Expand Down Expand Up @@ -124,7 +124,7 @@ fun PlaybackScreen(
val danmakuSetting = danmakuSettingLD.data!!

DanmakuVideoPlayer(
debug = BuildConfig.DEBUG,
debug = if(activity != null) AppUtil.debuggable(activity.applicationContext) else false,
danmakuConfigSetting = {
textSizeScale = danmakuSetting.danmakuSizeScale / 100f
alpha = danmakuSetting.danmakuAlpha / 100f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand All @@ -30,15 +31,15 @@ import androidx.tv.material3.SurfaceDefaults
import androidx.tv.material3.Text
import com.muedsa.compose.tv.theme.surfaceContainer
import com.muedsa.compose.tv.widget.FocusScaleSwitch
import com.muedsa.jcytv.BuildConfig
import com.muedsa.jcytv.model.AppSettingModel
import com.muedsa.uitl.AppUtil

@Composable
fun AppSettingScreen(
viewModel: AppSettingViewModel = hiltViewModel()
) {
val context = LocalContext.current
val model by viewModel.settingStateFlow.collectAsStateWithLifecycle()

if (model != null) {
val settingModel: AppSettingModel = model!!
Column(
Expand Down Expand Up @@ -232,12 +233,32 @@ fun AppSettingScreen(
style = MaterialTheme.typography.titleMedium
)
Text(
text = "${BuildConfig.VERSION_NAME}(${BuildConfig.VERSION_CODE})",
text = AppUtil.getVersionInfo(context),
color = MaterialTheme.colorScheme.onBackground,
style = MaterialTheme.typography.titleMedium
)
}

if (AppUtil.debuggable(context)) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 20.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "调试模式",
color = MaterialTheme.colorScheme.onBackground,
style = MaterialTheme.typography.titleMedium
)
Text(
text = "启用",
color = MaterialTheme.colorScheme.onBackground,
style = MaterialTheme.typography.titleMedium
)
}
}
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/kotlin/com/muedsa/uitl/AppUtil.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.muedsa.uitl

import android.content.Context
import android.content.pm.ApplicationInfo

object AppUtil {

fun getVersionInfo(context: Context): String {
return try {
val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0)
"${packageInfo.versionName}(${packageInfo.longVersionCode})"
} catch (t: Throwable) {
""
}
}

fun debuggable(context: Context): Boolean = (context.applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE) != 0
}

0 comments on commit c27b64c

Please sign in to comment.