Skip to content

Add profile pictures from files#3086

Open
arpitagarwal1301 wants to merge 2 commits into
recloudstream:masterfrom
arpitagarwal1301:fix/3079-account-pfp-from-file
Open

Add profile pictures from files#3086
arpitagarwal1301 wants to merge 2 commits into
recloudstream:masterfrom
arpitagarwal1301:fix/3079-account-pfp-from-file

Conversation

@arpitagarwal1301

@arpitagarwal1301 arpitagarwal1301 commented Jul 20, 2026

Copy link
Copy Markdown

What does this change?

Adds a file option to the profile image editor while preserving the existing URL flow.

Selected PNG and JPEG documents must decode successfully before preview, and read access is persisted using the existing document-import pattern. The shared picker works from both account-entry points, and restored images without an available URI grant fall back to the default avatar.

The edit icon also gains a content description and explicit D-pad focus navigation while retaining its existing touch background.

Closes #3079

Testing

  • :app:compileStableDebugKotlin
  • :app:testStableDebugUnitTest (8 tests, 0 failures)
  • :app:lintStableDebug (0 errors)
  • :app:assembleStableDebug
  • git diff --check

Limitations

  • The document picker and TV focus path were not exercised with UI instrumentation or on physical TV hardware.

AI disclosure

AI-assisted: implementation and review used OpenAI Codex; the listed checks were run on the submitted code.

@fire-light42 fire-light42 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for you contribution! Great job on the new feature!

Overall good code, but there are some minor nitpicks.

val activity = context.getActivity() as? ComponentActivity ?: return
var launcher: ActivityResultLauncher<Array<String>>? = null
try {
launcher = activity.activityResultRegistry.register(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use registerForActivityResult instead, to get a safer and lifecyle-aware file picking. It may be more difficult, but it removes the dirty getActivity() and having to unregister.

onError = { _, _ -> showToast(R.string.edit_profile_image_error_invalid) }
).build())
}
launcher.launch(arrayOf("image/png", "image/jpeg"))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should be "image/*" to support all types of images.

onSuccess = { _, _ ->
currentEditAccount = currentEditAccount.copy(customImage = url)
binding.accountImage.loadImage(url)
callback(url)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Elegant solution, very nice!

AlertDialog.Builder(context)
.setTitle(R.string.edit_profile_image_title)
.setItems(arrayOf(
context.getString(R.string.player_load_subtitles),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add another string in strings.xml, which references player_load_subtitles (like action_open_play). This makes it easier to prevent mistakes in the future, for example if player_load_subtitles is changed to something like "Load subtitle from file".

if (!dialog.isShowing) return@pickProfileImage
currentEditAccount = currentEditAccount.copy(customImage = image)
binding.accountImage.loadImage(image)
showToast(R.string.edit_profile_image_success, Toast.LENGTH_SHORT)

@fire-light42 fire-light42 Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This toast should be moved to pickProfileImage for consistency.

@arpitagarwal1301

Copy link
Copy Markdown
Author

Addressed the requested Activity Result API, image/* MIME, string alias, and toast placement changes in f59858c. I kept internal file copying out of scope as noted optional; persisted document permissions and the existing fallback remain in place. Ready for re-review when convenient.

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.

Account PFP from file

2 participants