Skip to content

Commit ffb257f

Browse files
authored
Благодарим Фиша за добавление edge-to-edge и ссылки на канал!
Всем сладких снов (по мск*)
2 parents faf13b0 + 144febd commit ffb257f

File tree

8 files changed

+110
-85
lines changed

8 files changed

+110
-85
lines changed

.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/deploymentTargetSelector.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.idea/gradle.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ android {
5252

5353
dependencies {
5454
implementation("androidx.activity:activity-compose:1.7.0")
55+
implementation("androidx.activity:activity:1.9.3")
5556
implementation("androidx.compose.material3:material3:1.0.1")
5657
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.0")
5758
implementation("com.google.android.exoplayer:exoplayer:2.19.1")

app/src/main/java/com/platon/easymusicandroid/MainActivity.kt

Lines changed: 104 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package com.platon.easymusicandroid
22

3+
import android.annotation.SuppressLint
34
import android.content.Intent
5+
import android.net.Uri
46
import android.os.Bundle
7+
import android.view.View
8+
import android.widget.Toast
59
import androidx.activity.ComponentActivity
610
import androidx.activity.compose.setContent
711
import androidx.compose.foundation.background
@@ -26,6 +30,8 @@ import androidx.compose.ui.unit.dp
2630
import androidx.compose.ui.unit.sp
2731
import com.google.android.exoplayer2.ExoPlayer
2832
import com.google.android.exoplayer2.MediaItem
33+
import androidx.activity.enableEdgeToEdge
34+
import androidx.compose.ui.platform.LocalContext
2935

3036
data class Station(
3137
val name: String,
@@ -74,7 +80,9 @@ class MainActivity : ComponentActivity() {
7480
private var currentStationIndex = mutableStateOf(0)
7581

7682
override fun onCreate(savedInstanceState: Bundle?) {
83+
enableEdgeToEdge()
7784
super.onCreate(savedInstanceState)
85+
window.isNavigationBarContrastEnforced = false
7886

7987
// Initialize ExoPlayer
8088
player = ExoPlayer.Builder(this).build()
@@ -119,6 +127,8 @@ class MainActivity : ComponentActivity() {
119127
}
120128
}
121129

130+
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
131+
@OptIn(ExperimentalMaterial3Api::class)
122132
@Composable
123133
fun EasyMusicApp(
124134
stations: List<Station>,
@@ -128,91 +138,115 @@ fun EasyMusicApp(
128138
onStationChange: (Int) -> Unit
129139
) {
130140
val station = stations[currentStationIndex]
141+
val context = LocalContext.current
142+
val intent = remember { Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/easymusicplatonoferon/")) }
131143

132-
Box(
144+
Scaffold(
133145
modifier = Modifier
134-
.fillMaxSize()
135146
.background(
136147
brush = Brush.verticalGradient(
137148
colors = station.gradientColors
138149
)
139-
),
140-
contentAlignment = Alignment.Center
150+
)
151+
.safeDrawingPadding(),
152+
containerColor = Color.Transparent
141153
) {
142-
Column(
143-
modifier = Modifier
144-
.fillMaxSize()
145-
.padding(16.dp),
146-
horizontalAlignment = Alignment.CenterHorizontally
147-
) {
148-
Spacer(modifier = Modifier.height(16.dp))
149-
150-
Text(
151-
text = station.name,
152-
style = MaterialTheme.typography.titleLarge.copy(
153-
fontSize = 28.sp,
154-
fontWeight = FontWeight.Bold,
155-
fontFamily = FontFamily.SansSerif
154+
Box {
155+
TextButton(
156+
onClick = {
157+
try {
158+
context.startActivity(intent)
159+
}
160+
catch (e: Exception) {
161+
Toast.makeText(context, "Ошибка. Ищи вручную:\n@easymusicplatonoferon", Toast.LENGTH_LONG).show()
162+
}
163+
},
164+
colors = ButtonDefaults.buttonColors(
165+
containerColor = Color.Transparent,
166+
contentColor = Color(0xA0FFFFFF)
156167
),
157-
color = Color.White,
158-
modifier = Modifier.padding(bottom = 8.dp)
159-
)
168+
modifier = Modifier.padding(horizontal = 20.dp)
169+
) {
170+
Text(text = "тг чат")
171+
}
160172

161-
Text(
162-
text = station.description,
163-
style = MaterialTheme.typography.bodyMedium.copy(
164-
fontFamily = FontFamily.SansSerif
165-
),
166-
color = Color.White,
167-
textAlign = TextAlign.Center,
168-
modifier = Modifier.padding(horizontal = 16.dp)
169-
)
173+
Column(
174+
modifier = Modifier
175+
.fillMaxSize()
176+
.padding(16.dp),
177+
horizontalAlignment = Alignment.CenterHorizontally
178+
) {
179+
Spacer(modifier = Modifier.height(16.dp))
180+
181+
Text(
182+
text = station.name,
183+
style = MaterialTheme.typography.titleLarge.copy(
184+
fontSize = 28.sp,
185+
fontWeight = FontWeight.Bold,
186+
fontFamily = FontFamily.SansSerif
187+
),
188+
color = Color.White,
189+
modifier = Modifier.padding(bottom = 8.dp)
190+
)
170191

171-
Spacer(modifier = Modifier.weight(1f))
192+
Text(
193+
text = station.description,
194+
style = MaterialTheme.typography.bodyMedium.copy(
195+
fontFamily = FontFamily.SansSerif
196+
),
197+
color = Color.White,
198+
textAlign = TextAlign.Center,
199+
modifier = Modifier.padding(horizontal = 16.dp)
200+
)
172201

173-
Text(
174-
text = if (isPlaying) "Now Playing: Streaming" else "Now Playing: Paused",
175-
color = Color.White,
176-
modifier = Modifier.padding(bottom = 32.dp)
177-
)
202+
Spacer(modifier = Modifier.weight(1f))
178203

179-
Row(
180-
modifier = Modifier.fillMaxWidth(),
181-
horizontalArrangement = Arrangement.SpaceBetween,
182-
verticalAlignment = Alignment.CenterVertically
183-
) {
184-
IconButton(onClick = {
185-
if (currentStationIndex > 0) onStationChange(currentStationIndex - 1)
186-
}) {
187-
Icon(
188-
imageVector = Icons.Filled.ArrowBack,
189-
contentDescription = "Previous",
190-
tint = Color.White
191-
)
192-
}
204+
Text(
205+
text = if (isPlaying) "Now Playing: Streaming" else "Now Playing: Paused",
206+
color = Color.White,
207+
modifier = Modifier.padding(bottom = 32.dp)
208+
)
193209

194-
Box(
195-
modifier = Modifier
196-
.size(80.dp)
197-
.background(Color.White, CircleShape)
198-
.clickable { onPlayPauseToggle() },
199-
contentAlignment = Alignment.Center
210+
Row(
211+
modifier = Modifier.fillMaxWidth(),
212+
horizontalArrangement = Arrangement.SpaceBetween,
213+
verticalAlignment = Alignment.CenterVertically
200214
) {
201-
Icon(
202-
imageVector = if (isPlaying) Icons.Filled.Close else Icons.Filled.PlayArrow,
203-
contentDescription = if (isPlaying) "Pause" else "Play",
204-
tint = Color.Red
205-
)
206-
}
215+
IconButton(onClick = {
216+
if (currentStationIndex > 0) onStationChange(currentStationIndex - 1)
217+
}) {
218+
Icon(
219+
imageVector = Icons.Filled.ArrowBack,
220+
contentDescription = "Previous",
221+
tint = Color.White
222+
)
223+
}
207224

208-
IconButton(onClick = {
209-
if (currentStationIndex < stations.size - 1) onStationChange(currentStationIndex + 1)
210-
}) {
211-
Icon(
212-
imageVector = Icons.Filled.ArrowForward,
213-
contentDescription = "Next",
214-
tint = Color.White
215-
)
225+
Box(
226+
modifier = Modifier
227+
.size(80.dp)
228+
.background(Color.White, CircleShape)
229+
.clickable { onPlayPauseToggle() },
230+
contentAlignment = Alignment.Center
231+
) {
232+
Icon(
233+
imageVector = if (isPlaying) Icons.Filled.Close else Icons.Filled.PlayArrow,
234+
contentDescription = if (isPlaying) "Pause" else "Play",
235+
tint = Color.Red
236+
)
237+
}
238+
239+
IconButton(onClick = {
240+
if (currentStationIndex < stations.size - 1) onStationChange(
241+
currentStationIndex + 1
242+
)
243+
}) {
244+
Icon(
245+
imageVector = Icons.Filled.ArrowForward,
246+
contentDescription = "Next",
247+
tint = Color.White
248+
)
249+
}
216250
}
217251
}
218252
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
agp = "8.6.1"
2+
agp = "8.7.2"
33
kotlin = "1.9.0"
44
coreKtx = "1.15.0"
55
junit = "4.13.2"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Sun Dec 08 18:38:14 MSK 2024
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)