-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add retrieve lyrics functionality
This commit introduces the ability to retrieve lyrics from a third-party app in the metadata editor. - A button was added to the metadata editor page to trigger lyrics retrieval. - An intent is used to launch the third-party app and request lyrics. - When the third-party app returns, the lyrics are extracted and populated into the lyrics field. - A music note icon is now displayed as a placeholder if the original file is not an image. - Horizontal and Vertical ButtonWithIconAndText composables were created for UI flexibility. - Support for landscape orientation was improved in the metadata editor.
- Loading branch information
Showing
10 changed files
with
346 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
309 changes: 179 additions & 130 deletions
309
.../java/com/bobbyesp/metadator/presentation/pages/utilities/tageditor/MetadataEditorPage.kt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...main/java/com/bobbyesp/metadator/presentation/pages/utilities/tageditor/SongSyncNeeded.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.bobbyesp.metadator.presentation.pages.utilities.tageditor | ||
|
||
import android.content.res.Configuration | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Lyrics | ||
import androidx.compose.material3.AlertDialog | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextButton | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalUriHandler | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.buildAnnotatedString | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.bobbyesp.utilities.R | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun SongSyncNeededDialog( | ||
modifier: Modifier = Modifier, | ||
onDismissRequest: () -> Unit, | ||
) { | ||
val uriLauncher = LocalUriHandler.current | ||
AlertDialog( | ||
icon = { | ||
Icon( | ||
imageVector = Icons.Filled.Lyrics, | ||
contentDescription = "SongSync app needed" | ||
) | ||
}, modifier = modifier, onDismissRequest = onDismissRequest, | ||
title = { | ||
Text(text = stringResource(id = R.string.song_sync_needed)) | ||
}, text = { | ||
Text( | ||
text = buildAnnotatedString { | ||
append(stringResource(id = R.string.song_sync_needed_desc)) | ||
append(" \n") | ||
append(stringResource(id = R.string.song_sync_not_installed)) | ||
append(".") | ||
}, | ||
) | ||
}, confirmButton = { | ||
TextButton( | ||
onClick = { | ||
uriLauncher.openUri("https://github.com/Lambada10/SongSync/releases/latest") | ||
} | ||
) { | ||
Text(stringResource(id = R.string.download)) | ||
} | ||
}, dismissButton = { | ||
TextButton( | ||
onClick = onDismissRequest | ||
) { | ||
Text(stringResource(id = R.string.dismiss)) | ||
} | ||
} | ||
) | ||
} | ||
|
||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) | ||
@Composable | ||
fun SongSyncNeededDialogPreview() { | ||
SongSyncNeededDialog(onDismissRequest = { }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/utilities/src/main/java/com/bobbyesp/utilities/Packages.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.bobbyesp.utilities | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.content.pm.PackageManager | ||
|
||
object Packages { | ||
fun isPackageInstalled(context: Context, packageName: String): Boolean { | ||
return try { | ||
context.packageManager.getPackageInfo(packageName, 0) | ||
true | ||
} catch (e: PackageManager.NameNotFoundException) { | ||
false | ||
} | ||
} | ||
|
||
fun Intent.launchOrAction(context: Context, action: () -> Unit) { | ||
if (resolveActivity(context.packageManager) != null) { | ||
context.startActivity(this) | ||
} else { | ||
action() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters