Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #36

Merged
merged 2 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 27 additions & 39 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,35 @@ plugins {
kotlin("kapt")
}

/**
* The secrets that needs to be added to BuildConfig at runtime.
*/
val secrets = arrayOf(
"IAP_BUY_ME_COFFEE",
"IAP_NO_ADS",
"PLACEMENT_BANNER_1",
"PLACEMENT_BANNER_2",
"PLACEMENT_INTERSTITIAL",
"UNITY_APP_ID",
"PLAY_CONSOLE_APP_RSA_KEY",
)

android {
compileSdk = 34
namespace = "com.prime.media"
defaultConfig {
applicationId = "com.prime.player"
minSdk = 21
targetSdk = 34
versionCode = 47
versionCode = 48
versionName = "2.3.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables { useSupportLibrary = true }
// Add necessary const to BuildConfig
// These filed will be provided in github
// secrets when released else defualt value will be used
secrets()
//Load secrets into BuildConfig
secrets.forEach { secret ->
val value = "\"" + (System.getenv(secret) ?: "no_value") + "\""
buildConfigField("String", secret, value)
}
}

buildTypes {
Expand Down Expand Up @@ -55,7 +69,7 @@ android {
freeCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn", "-Xcontext-receivers")
}
buildFeatures { compose = true }
composeOptions { kotlinCompilerExtensionVersion = "1.5.1" }
composeOptions { kotlinCompilerExtensionVersion = "1.5.3" }
packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } }
}

Expand All @@ -74,11 +88,11 @@ dependencies {
implementation("androidx.compose.material:material-icons-extended:$compose_version")
// The Accompanist Libraries
implementation("io.coil-kt:coil-compose:2.4.0")
implementation("com.google.accompanist:accompanist-permissions:0.31.5-beta")
implementation("com.google.accompanist:accompanist-permissions:0.32.0")
//Lottie
implementation("com.airbnb.android:lottie-compose:6.1.0")
// Preferences and other widgets
val toolkit_version = "1.0.9-beta"
val toolkit_version = "1.1.1"
implementation("com.github.prime-zs.toolkit:preferences:$toolkit_version")
implementation("com.github.prime-zs.toolkit:core-ktx:$toolkit_version")
implementation("com.github.prime-zs.toolkit:material2:$toolkit_version")
Expand All @@ -89,7 +103,7 @@ dependencies {
implementation("com.google.firebase:firebase-analytics-ktx")
implementation("com.google.firebase:firebase-crashlytics-ktx")
// WindowSizeClasses
implementation("androidx.compose.material3:material3-window-size-class:1.2.0-alpha05")
implementation("androidx.compose.material3:material3-window-size-class:1.1.1")
// Google Play InAppUpdate
val in_app_update_version = "2.1.0"
implementation("com.google.android.play:app-update:$in_app_update_version")
Expand All @@ -105,15 +119,15 @@ dependencies {
// Unity Ads
implementation("com.unity3d.ads:unity-ads:4.8.0")
// Compose navigation
implementation("androidx.navigation:navigation-compose:2.7.0")
implementation("androidx.navigation:navigation-compose:2.7.1")
// Compose Downloadable fonts
implementation("androidx.compose.ui:ui-text-google-fonts:1.5.0")
// Hilt
implementation("com.google.dagger:hilt-android:2.47")
kapt("com.google.dagger:hilt-android-compiler:2.47")
implementation("com.google.dagger:hilt-android:2.48")
kapt("com.google.dagger:hilt-android-compiler:2.48")
implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
// Room Database
val room_version = "2.6.0-alpha03"
val room_version = "2.6.0-beta01"
implementation("androidx.room:room-runtime:$room_version")
kapt("androidx.room:room-compiler:$room_version")
implementation("androidx.room:room-ktx:$room_version")
Expand All @@ -129,30 +143,4 @@ dependencies {
implementation("androidx.media3:media3-exoplayer:$media3_version")
// For exposing and controlling media sessions
implementation("androidx.media3:media3-session:$media3_version")
}

/**
* Init adn add git secrets to BuildConfig
*/
fun ApplicationDefaultConfig.secrets() {
var value = "\"" + (System.getenv("IAP_BUY_ME_COFFEE") ?: "empty") + "\""
buildConfigField("String", "IAP_BUY_ME_COFFEE", value)

value = "\"" + (System.getenv("IAP_NO_ADS") ?: "empty") + "\""
buildConfigField("String", "IAP_NO_ADS", value)

value = "\"" + (System.getenv("PLACEMENT_BANNER_1") ?: "empty") + "\""
buildConfigField("String", "PLACEMENT_BANNER_1", value)

value = "\"" + (System.getenv("PLACEMENT_BANNER_2") ?: "empty") + "\""
buildConfigField("String", "PLACEMENT_BANNER_2", value)

value = "\"" + (System.getenv("PLACEMENT_INTERSTITIAL") ?: "empty") + "\""
buildConfigField("String", "PLACEMENT_INTERSTITIAL", value)

value = "\"" + (System.getenv("UNITY_APP_ID") ?: "empty") + "\""
buildConfigField("String", "UNITY_APP_ID", value)

value = "\"" + (System.getenv("PLAY_CONSOLE_APP_RSA_KEY") ?: "empty") + "\""
buildConfigField("String", "PLAY_CONSOLE_APP_RSA_KEY", value)
}
10 changes: 5 additions & 5 deletions app/src/main/java/com/prime/media/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ private fun Permission() {
}
Placeholder(
iconResId = R.raw.lt_permission,
title = stringResource(R.string.storage_permission),
message = stringResource(R.string.storage_permission_message),
title = stringResource(R.string.permission_screen_title),
message = stringResource(R.string.permission_screen_desc),
) {
OutlinedButton(
onClick = { permission.launchPermissionRequest() },
Expand All @@ -251,8 +251,8 @@ private fun Permission() {
}
}

private val LightPrimaryColor = Color(0xFF17618D)
private val LightPrimaryVariantColor = Color(0xFF14547B)
private val LightPrimaryColor = Color(0xFF244285)
private val LightPrimaryVariantColor = Color(0xFF305EA5)
private val LightSecondaryColor = Color(0xFF8B008B)
private val LightSecondaryVariantColor = Color(0xFF7B0084)
private val DarkPrimaryColor = Color(0xFFff8f00)
Expand Down Expand Up @@ -297,7 +297,7 @@ fun Material(
MaterialTheme(
colors = colors,
content = content,
typography = Typography(Settings.LatoFontFamily)
typography = Typography(Settings.DefaultFontFamily)
)
}

Expand Down
21 changes: 9 additions & 12 deletions app/src/main/java/com/prime/media/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.prime.media

import android.animation.ObjectAnimator
import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.pm.PackageManager
import android.media.audiofx.AudioEffect
Expand All @@ -10,7 +9,6 @@ import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.animation.AnticipateInterpolator
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material.icons.Icons
Expand Down Expand Up @@ -241,7 +239,7 @@ class MainActivity : ComponentActivity(), SystemFacade {
manager.requestUpdateFlow().collect { result ->
when (result) {
AppUpdateResult.NotAvailable ->
if (report) channel.show("The app is already updated to the latest version.")
if (report) channel.show(R.string.msg_no_new_update_available)

is AppUpdateResult.InProgress -> {
val state = result.installState
Expand Down Expand Up @@ -270,9 +268,8 @@ class MainActivity : ComponentActivity(), SystemFacade {
}
// else show the toast.
val res = channel.show(
title = "Update",
message = "An update has just been downloaded.",
action = "RESTART",
message = R.string.msg_new_update_downloaded,
action = R.string.update,
duration = Duration.Indefinite,
accent = Color.MetroGreen
)
Expand Down Expand Up @@ -301,7 +298,7 @@ class MainActivity : ComponentActivity(), SystemFacade {
override fun shareApp() {
ShareCompat.IntentBuilder(this).setType("text/plain")
.setChooserTitle(getString(R.string.app_name))
.setText("Let me recommend you this application ${Audiofy.GOOGLE_STORE}").startChooser()
.setText(getString(R.string.share_app_desc_s, Audiofy.GOOGLE_STORE)).startChooser()
}

override fun onNewIntent(intent: Intent?) {
Expand All @@ -317,8 +314,8 @@ class MainActivity : ComponentActivity(), SystemFacade {
) == PackageManager.PERMISSION_GRANTED
if (!isPermitted) {
show(
R.string.storage_permission_message,
R.string.storage_permission,
R.string.permission_screen_desc,
R.string.permission_screen_title,
icon = Icons.TwoTone.Memory
)
return
Expand All @@ -327,7 +324,7 @@ class MainActivity : ComponentActivity(), SystemFacade {
lifecycleScope.launch {
val audio = runCatching { findAudio(data) }.getOrNull()
if (audio == null) {
show(R.string.error_msg, R.string.error)
show(R.string.msg_unknown_error, R.string.error)
return@launch
}
remote.set(listOf(audio.toMediaItem))
Expand All @@ -338,7 +335,7 @@ class MainActivity : ComponentActivity(), SystemFacade {
override fun launchEqualizer(id: Int) {
lifecycleScope.launch {
if (id == AudioEffect.ERROR_BAD_VALUE)
return@launch show(R.string.error_msg, R.string.error)
return@launch show(R.string.msg_unknown_error, R.string.error)
val result = kotlin.runCatching {
startActivity(
Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL).apply {
Expand All @@ -351,7 +348,7 @@ class MainActivity : ComponentActivity(), SystemFacade {
if (!result.isFailure)
return@launch
val res = channel.show(
message = R.string.equalizer_3rd_party_not_found_msg,
message = R.string.msg_3rd_party_equalizer_not_found,
action = R.string.launch,
accent = Color.OrientRed,
duration = Duration.Short
Expand Down
15 changes: 9 additions & 6 deletions app/src/main/java/com/prime/media/console/Console.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ import androidx.media3.common.Player
import com.prime.media.Material
import com.prime.media.R
import com.prime.media.caption2
import com.prime.media.core.Anim
import com.prime.media.core.ContentElevation
import com.prime.media.core.ContentPadding
import com.prime.media.core.compose.AVDIconButton
import com.prime.media.core.LongDurationMills
import com.prime.media.core.MediumDurationMills
import com.prime.media.core.compose.AnimatedIconButton
import com.prime.media.core.compose.Image
import com.prime.media.core.compose.LocalSystemFacade
import com.prime.media.core.compose.LottieAnimButton
import com.prime.media.core.compose.LottieAnimation
import com.prime.media.core.compose.marque
import com.prime.media.core.compose.rememberAnimatedVectorResource
import com.prime.media.core.compose.shape.CompactDisk
import com.prime.media.core.util.DateUtils
import com.prime.media.darkShadowColor
Expand Down Expand Up @@ -152,8 +154,9 @@ private fun PlayButton(
id = R.raw.lt_play_pause,
atEnd = !isPlaying,
scale = 1.5f,
progressRange = 0.0f..0.5f,
duration = 1200
progressRange = 0.0f..0.29f,
duration = Anim.MediumDurationMills,
easing = LinearEasing
)
}
}
Expand Down Expand Up @@ -295,7 +298,7 @@ private fun Vertical(
// Signature
Text(
text = stringResource(id = R.string.app_name),
fontFamily = FontFamily.Cursive,
fontFamily = Settings.DancingScriptFontFamily,
fontWeight = FontWeight.Bold,
fontSize = 70.sp,
modifier = Modifier
Expand Down Expand Up @@ -491,7 +494,7 @@ private fun Vertical(
)

val mode = state.repeatMode
AVDIconButton(
AnimatedIconButton(
id = R.drawable.avd_repeat_more_one_all,
onClick = { state.cycleRepeatMode();facade.launchReviewFlow(); },
atEnd = mode == Player.REPEAT_MODE_ALL,
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/com/prime/media/core/compose/Delegates.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.core.AnimationConstants
import androidx.compose.animation.core.Easing
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
Expand Down Expand Up @@ -149,14 +151,15 @@ inline fun LottieAnimation(
atEnd: Boolean = false,
scale: Float = 1f,
progressRange: ClosedFloatingPointRange<Float> = 0f..1f,
duration: Int = -1
duration: Int = -1,
easing: Easing = FastOutSlowInEasing
) {
val composition by rememberLottieComposition(spec = LottieCompositionSpec.RawRes(id))
val duration2 = composition?.duration?.roundToLong() ?: AnimationConstants.LongDurationMills
val progress by animateFloatAsState(
targetValue = if (atEnd) progressRange.start else progressRange.endInclusive,
label = "Lottie $id",
animationSpec = tween(if (duration == -1) duration2.toInt() else duration)
animationSpec = tween(if (duration == -1) duration2.toInt() else duration, easing = easing)
)
LottieAnimation(
composition = composition,
Expand Down Expand Up @@ -285,7 +288,7 @@ inline fun LottieAnimButton(
*/
@OptIn(ExperimentalAnimationGraphicsApi::class)
@Composable
inline fun AVDIconButton(
inline fun AnimatedIconButton(
@DrawableRes id: Int,
noinline onClick: () -> Unit,
modifier: Modifier = Modifier,
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/prime/media/core/compose/Snackbar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,9 @@ private fun Snackbar2(
text = {
Label(
text = data.message.value,
color = LocalContentColor.current.copy(ContentAlpha.medium),
color = LocalContentColor.current,
style = MaterialTheme.typography.body2,
maxLines = 4,
maxLines = 5,
)
},
overlineText = composableOrNull(data.title != null) {
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/java/com/prime/media/core/compose/core-ktx.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController
import androidx.navigation.compose.currentBackStackEntryAsState
import com.primex.core.Text
import com.primex.core.resolve

private const val TAG = "ComposeUtil"

Expand Down Expand Up @@ -76,11 +75,6 @@ val LocalWindowSizeClass = staticCompositionLocalOf<WindowSizeClass> {
val NavHostController.current
@Composable inline get() = currentBackStackEntryAsState().value?.destination?.route

inline fun Resources.stringResource(res: Text) = resolve(res)

@JvmName("stringResource1")
inline fun Resources.stringResource(res: Text?) = resolve(res)

/**
* @return [content] if [condition] is true else null
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class Playback : MediaLibraryService(), Callback, Player.Listener {

override fun onPlayerError(error: PlaybackException) {
// make a simple toast
Toast.makeText(this, getString(R.string.unplayable_file), Toast.LENGTH_SHORT).show()
Toast.makeText(this, getString(R.string.msg_unplayable_file), Toast.LENGTH_SHORT).show()
//player.seekToNextMediaItem()
}
}
Loading