Skip to content
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
2 changes: 1 addition & 1 deletion .idea/compiler.xml

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

10 changes: 0 additions & 10 deletions .idea/deploymentTargetSelector.xml

This file was deleted.

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

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

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

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

1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ android {

dependencies {
implementation("androidx.activity:activity-compose:1.7.0")
implementation("androidx.activity:activity:1.9.3")
implementation("androidx.compose.material3:material3:1.0.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.0")
implementation("com.google.android.exoplayer:exoplayer:2.19.1")
Expand Down
174 changes: 104 additions & 70 deletions app/src/main/java/com/platon/easymusicandroid/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.platon.easymusicandroid

import android.annotation.SuppressLint
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
Expand All @@ -26,6 +30,8 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.MediaItem
import androidx.activity.enableEdgeToEdge
import androidx.compose.ui.platform.LocalContext

data class Station(
val name: String,
Expand Down Expand Up @@ -74,7 +80,9 @@ class MainActivity : ComponentActivity() {
private var currentStationIndex = mutableStateOf(0)

override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
window.isNavigationBarContrastEnforced = false

// Initialize ExoPlayer
player = ExoPlayer.Builder(this).build()
Expand Down Expand Up @@ -119,6 +127,8 @@ class MainActivity : ComponentActivity() {
}
}

@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EasyMusicApp(
stations: List<Station>,
Expand All @@ -128,91 +138,115 @@ fun EasyMusicApp(
onStationChange: (Int) -> Unit
) {
val station = stations[currentStationIndex]
val context = LocalContext.current
val intent = remember { Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/easymusicplatonoferon/")) }

Box(
Scaffold(
modifier = Modifier
.fillMaxSize()
.background(
brush = Brush.verticalGradient(
colors = station.gradientColors
)
),
contentAlignment = Alignment.Center
)
.safeDrawingPadding(),
containerColor = Color.Transparent
) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Spacer(modifier = Modifier.height(16.dp))

Text(
text = station.name,
style = MaterialTheme.typography.titleLarge.copy(
fontSize = 28.sp,
fontWeight = FontWeight.Bold,
fontFamily = FontFamily.SansSerif
Box {
TextButton(
onClick = {
try {
context.startActivity(intent)
}
catch (e: Exception) {
Toast.makeText(context, "Ошибка. Ищи вручную:\n@easymusicplatonoferon", Toast.LENGTH_LONG).show()
}
},
colors = ButtonDefaults.buttonColors(
containerColor = Color.Transparent,
contentColor = Color(0xA0FFFFFF)
),
color = Color.White,
modifier = Modifier.padding(bottom = 8.dp)
)
modifier = Modifier.padding(horizontal = 20.dp)
) {
Text(text = "тг чат")
}

Text(
text = station.description,
style = MaterialTheme.typography.bodyMedium.copy(
fontFamily = FontFamily.SansSerif
),
color = Color.White,
textAlign = TextAlign.Center,
modifier = Modifier.padding(horizontal = 16.dp)
)
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Spacer(modifier = Modifier.height(16.dp))

Text(
text = station.name,
style = MaterialTheme.typography.titleLarge.copy(
fontSize = 28.sp,
fontWeight = FontWeight.Bold,
fontFamily = FontFamily.SansSerif
),
color = Color.White,
modifier = Modifier.padding(bottom = 8.dp)
)

Spacer(modifier = Modifier.weight(1f))
Text(
text = station.description,
style = MaterialTheme.typography.bodyMedium.copy(
fontFamily = FontFamily.SansSerif
),
color = Color.White,
textAlign = TextAlign.Center,
modifier = Modifier.padding(horizontal = 16.dp)
)

Text(
text = if (isPlaying) "Now Playing: Streaming" else "Now Playing: Paused",
color = Color.White,
modifier = Modifier.padding(bottom = 32.dp)
)
Spacer(modifier = Modifier.weight(1f))

Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
IconButton(onClick = {
if (currentStationIndex > 0) onStationChange(currentStationIndex - 1)
}) {
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = "Previous",
tint = Color.White
)
}
Text(
text = if (isPlaying) "Now Playing: Streaming" else "Now Playing: Paused",
color = Color.White,
modifier = Modifier.padding(bottom = 32.dp)
)

Box(
modifier = Modifier
.size(80.dp)
.background(Color.White, CircleShape)
.clickable { onPlayPauseToggle() },
contentAlignment = Alignment.Center
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Icon(
imageVector = if (isPlaying) Icons.Filled.Close else Icons.Filled.PlayArrow,
contentDescription = if (isPlaying) "Pause" else "Play",
tint = Color.Red
)
}
IconButton(onClick = {
if (currentStationIndex > 0) onStationChange(currentStationIndex - 1)
}) {
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = "Previous",
tint = Color.White
)
}

IconButton(onClick = {
if (currentStationIndex < stations.size - 1) onStationChange(currentStationIndex + 1)
}) {
Icon(
imageVector = Icons.Filled.ArrowForward,
contentDescription = "Next",
tint = Color.White
)
Box(
modifier = Modifier
.size(80.dp)
.background(Color.White, CircleShape)
.clickable { onPlayPauseToggle() },
contentAlignment = Alignment.Center
) {
Icon(
imageVector = if (isPlaying) Icons.Filled.Close else Icons.Filled.PlayArrow,
contentDescription = if (isPlaying) "Pause" else "Play",
tint = Color.Red
)
}

IconButton(onClick = {
if (currentStationIndex < stations.size - 1) onStationChange(
currentStationIndex + 1
)
}) {
Icon(
imageVector = Icons.Filled.ArrowForward,
contentDescription = "Next",
tint = Color.White
)
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
agp = "8.6.1"
agp = "8.7.2"
kotlin = "1.9.0"
coreKtx = "1.15.0"
junit = "4.13.2"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Dec 08 18:38:14 MSK 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading