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

Playlist thumbnail #4411

Merged
merged 9 commits into from
Nov 10, 2024
Merged

Playlist thumbnail #4411

merged 9 commits into from
Nov 10, 2024

Conversation

Abhinavreddy-B
Copy link

Functionality to pick custom thumbnails for playlist

@Abhinavreddy-B
Copy link
Author

Moderators,
please do check this PR thoroughly for any mistakes, since this is my first contribution.

This was referenced Nov 9, 2024
@Abhinavreddy-B
Copy link
Author

btw, i used this api for photo picker

@fast4x
Copy link
Owner

fast4x commented Nov 9, 2024

Thanks, but app must remain FOSS and isn't possible to use Google Play Service api, instead try a solution without it.

@Abhinavreddy-B
Copy link
Author

Updated, now i am using ActivityResultContracts.GetContent. removed the dependency from the manifest. i hope now it is fine!

Copy link

@knighthat knighthat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some suggestions to make the code easier to read and understand

@@ -503,6 +505,31 @@ fun PlaylistsItemGridMenu(
)
}

onEditThumbnail?.let { onEditThumbnail ->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two are identical, except for the title. Having two similar blocks of code makes it harder to read and harder to maintain.

I can suggest a solution

var title: Int? = null
if( onEditThumbnail != null )
    title = R.string.edit_thumbnail
if( onResetThumbnail != null )
    title = R.string.reset_thumbnail

title ?: return // Or something that skip next line

GridMenuItem(
    icon = R.drawable.image,
    title = title,
    colorIcon = colorPalette.text,
    colorText = colorPalette.text,
    onClick = {
        onDismiss()
        onEditThumbnail()
    }
)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This code snippet doesn't allow both options simultaneously, right?
  2. They differ in the callback function too, not just the title.
  3. It's kind of repetitive, I agree, but thats how all the other options were written

@@ -566,6 +570,28 @@ fun PlaylistsItemMenu(
}
)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing.

Even better, make a separate function handles this particular thing

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that they are kind of repetitive. But, Since all the other menu items are listed this way, putting only these 2 items in a separate function and then calling them here will lead to more confusion is what I feel.

false
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use rememberLauncherForActivityResult. Example HERE

Copy link
Author

@Abhinavreddy-B Abhinavreddy-B Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But these are operations on file that are stored in internal storage of the apps, so there is no need to ask user consent right? Hence, rememberLauncherForActivityResult is unnecessary right?

@fast4x
Copy link
Owner

fast4x commented Nov 10, 2024

@Abhinavreddy-B Two improvements:

  • Replace Log.d with Timber.d
  • Save images to folder so all thumbnails will be inside a specific folder, obviously always inside app files folder.

@Abhinavreddy-B
Copy link
Author

@Abhinavreddy-B Two improvements:

  • Replace Log.d with Timber.d
  • Save images to folder so all thumbnails will be inside a specific folder, obviously always inside app files folder.

Resolved in 29e21f6

@fast4x
Copy link
Owner

fast4x commented Nov 10, 2024

Update your repo and resolve conflict in your branch please, i can't merge it.

@Abhinavreddy-B
Copy link
Author

Resolved conflicts now :)

@fast4x
Copy link
Owner

fast4x commented Nov 10, 2024

Thanks for patience

@fast4x
Copy link
Owner

fast4x commented Nov 10, 2024

@knighthat it's ok, isn't necessary add other extreme code optimizations.

@Abhinavreddy-B merge in progress...

@fast4x fast4x merged commit b07639e into fast4x:master Nov 10, 2024
@fast4x
Copy link
Owner

fast4x commented Nov 10, 2024

Please fix image in playlists list when custom image is present...
Screenshot_20241110_154559

@knighthat
Copy link

@fast4x not extreme but eaiser down the road to read and fix bugs. I'm fixing tons of ridiculous errors in the code base and you couldn't believe the amount of duplicate/nested code

@fast4x
Copy link
Owner

fast4x commented Nov 10, 2024

Please don’t change the code, because it can indirectly generate bugs. Focus on other things please, code it's ok, not necessary change it.
Thank you for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants