Skip to content

0.6.2

Pre-release
Pre-release
Compare
Choose a tag to compare
@Arturo254 Arturo254 released this 09 Jun 22:04
· 18 commits to master since this release
94e3c2f

InnerTune 0.6.1

CAMBIOS:

  • Se agregaron mas funciones beta
  • Se optimizo el codigo de la aplicación
  • Se agregaron tarjetas en el apartado de "Ajustes"
  • Se soluciono el error que aparecia en el apartado de playlist. (Desaparecian las Canciones)

Cards

image

Ahora aparecen cards aleatoriamente en el apartado de settings

var isBetaFunEnabled by remember { mutableStateOf(false) }
    val backgroundImages = listOf(
        R.drawable.cardbg1,
        R.drawable.cardbg2,
        R.drawable.cardbg3,
        R.drawable.cardbg4,
        R.drawable.cardbg5,
        R.drawable.cardbg6,
        R.drawable.cardbg7,
        R.drawable.cardbg8,
        R.drawable.cardbg9,




        // ...
    )
    var currentImageIndex by remember { mutableStateOf(0) }


    fun changeBackgroundImage(offset: Int) {
        currentImageIndex = (currentImageIndex + offset + backgroundImages.size) % backgroundImages.size
    }


    Column(
        modifier = Modifier
            .windowInsetsPadding(LocalPlayerAwareWindowInsets.current)
            .verticalScroll(rememberScrollState())
    ) {
        Box(
            modifier = Modifier
                .height(220.dp)
                .clip(RoundedCornerShape(cornerRadius))
                .background(color = Color.Transparent)
                .pointerInput(Unit) {
                    detectHorizontalDragGestures { _, dragAmount ->
                        if (dragAmount > 100f) {
                            changeBackgroundImage(-1) // Change Image to previous
                        } else if (dragAmount < -100f) {
                            changeBackgroundImage(1) // Change Image to next
                        }
                    }
                }
        ) {


            Image(

                painter = painterResource(id = backgroundImages[currentImageIndex]),
                contentDescription = "Image Background",
                contentScale = ContentScale.Crop,
                modifier = Modifier.fillMaxSize(),

            )
            Icon(
                painter = painterResource(R.drawable.launcher_monochrome),
                contentDescription = null,
                tint = Color.White,
                modifier = Modifier.padding( 1.dp, 20.dp, 12.dp),

            )

            Text(
                text = "InnerTune",
                color = Color.White,
                fontSize = 26.sp,
                modifier = Modifier.padding(16.dp),
                style = MaterialTheme.typography.titleSmall,

            )




        }

Dependencias:

dependencies {
    implementation "com.squareup.okhttp3:okhttp:4.9.3"
    implementation "com.squareup.okhttp3:logging-interceptor:4.9.3"
    implementation "com.google.code.gson:gson:2.8.8"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"
}

solicitud HTTP:

import com.google.gson.Gson
import okhttp3.OkHttpClient
import okhttp3.Request
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.IOException

data class GitHubRelease(
    val tag_name: String,
    val assets: List<Asset>
)

data class Asset(
    val browser_download_url: String
)

private val client = OkHttpClient()
private val gson = Gson()

suspend fun getLatestRelease(): GitHubRelease? = withContext(Dispatchers.IO) {
    val request = Request.Builder()
        .url("https://api.github.com/repos/Arturo254/InnerTune/releases/latest")
        .build()

    try {
        val response = client.newCall(request).execute()
        if (response.isSuccessful) {
            response.body?.string()?.let { responseBody ->
                return@withContext gson.fromJson(responseBody, GitHubRelease::class.java)
            }
        }
    } catch (e: IOException) {
        // Handle network error
    }
    return@withContext null
}