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

Option to change camera icon color #434

Open
or-else opened this issue Dec 20, 2022 · 2 comments
Open

Option to change camera icon color #434

or-else opened this issue Dec 20, 2022 · 2 comments

Comments

@or-else
Copy link

or-else commented Dec 20, 2022

Would like to reopen #144.

I would like to be able to change color of the Camera icon in the toolbar menu.

The change in the code is trivial, specifically, add one line to the menu item in
https://github.com/esafirm/android-image-picker/blob/main/imagepicker/src/main/res/menu/ef_image_picker_menu_main.xml

<item
        android:id="@+id/menu_camera"
        android:icon="@drawable/ef_ic_camera_white"
        android:title="@string/ef_camera"
        app:showAsAction="always"
        app:iconTint="?cameraIconTint" <<<< add this line
        tools:ignore="AlwaysShowAction" />

Then define the color cameraIconTint in your style.xml. That's it.

Alternatively, you can use vector icons with android:tint color defined in style. Like this:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:tint="?android:textColorPrimary" <<<<< ------ this line
    android:viewportWidth="24.0"
    android:viewportHeight="24.0">
    <path
        android:fillColor="#FFFFFFFF"
        android:pathData="...." />
</vector>

It's a highly unusual design decision to require custom component just to change color of a UI element. That's usually done with style.xml.

In the #144 you suggest to use custom components, but unfortunately there are no examples on how to do it. Would it be possible to provide some guidance on how to use it beyond what you have in custom_components.md?

I don't see anything related to toolbar styling in interface ImagePickerComponents:

    val imageLoader: ImageLoader
    val imageFileLoader: ImageFileLoader
    val cameraModule: CameraModule
@or-else or-else changed the title Option to change camera icon colour #144 Option to change camera icon color Dec 20, 2022
@or-else
Copy link
Author

or-else commented Dec 20, 2022

BTW, it would be nice to replace the PNG icon with an SVG icon.

@or-else
Copy link
Author

or-else commented Dec 21, 2022

Just checked: it's not possible to subclass ImagePickerActivity and override onOptionsMenuCreated because ImagePickerLauncher.resultLauncher is private.

The only way to change color of the icon is to fork the project and edit the code which is a shame.

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

No branches or pull requests

1 participant