smstuebe / xamarin-fingerprint

Xamarin and MvvMCross plugin for authenticate a user via fingerprint sensor
Microsoft Public License
490 stars 115 forks source link

Default setup uses white fragment with white fingerprint icon #51

Closed ChaseFlorell closed 2 years ago

ChaseFlorell commented 7 years ago

When I create a default setup using a light theme, the baked in fragment shows a white background with a white fingerprint icon. I'd like the ability to tint the icon to a different color if possible.

I know we can create a custom Fragment, but I'm not sure how that works within your plugin. I'd like to keep everything else exactly as it is (white background, black text), but simply color the icon something different so that it is visible.

Steps to reproduce

  1. Follow initial setup and use the following theme in your android app ``Theme.AppCompat.Light.NoActionBar

  2. Test

Expected behavior

Fingerprint image should be visible on the dialog fragment

Actual behavior

Fingerprint image is the same color as the background (white).

Configuration

Version of the Plugin: 1.4.2

Platform: Android 7.1

Device: Google Pixel XL

smsissuechecker commented 7 years ago

Hi @ChaseFlorell,

I'm the friendly issue checker. Thanks for using the issue template :star2: I appreciate it very much. I'm sure, the maintainers of this repository will answer, soon.

ChaseFlorell commented 7 years ago

Well I took a stab at tinting your image and it seems to work. For anyone else...

public class CustomFingerprintDialogFragment : FingerprintDialogFragment
{
    public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        var view=base.OnCreateView(inflater, container, savedInstanceState);

        var image = view.FindViewById<ImageView>(Resource.Id.fingerprint_imgFingerprint);
        image.SetColorFilter(Color.ParseColor("#000000")); // black 

        return view;
    }
}
smstuebe commented 7 years ago

I know we can create a custom Fragment, but I'm not sure how that works within your plugin.

See the documentation: https://github.com/smstuebe/xamarin-fingerprint#configuration

public class MyCustomDialogFragment : FingerprintDialogFragment
{
    public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        var view = base.OnCreateView(inflater, container, savedInstanceState);
        var image = view.FindViewById<ImageView>(Resource.Id.fingerprint_imgFingerprint);
        image.SetImageResource(Resource.Drawable.fingerprint_black);
        return view;
    }
}

Unfortunately, the fragment is calling ClearColorFilter() after each animation. That's why you have to add a black copy of the icon to your project.

I'll change the code, so you will be able to set a tint for the icon in the next release.

ChaseFlorell commented 7 years ago

That would be pretty cool @smstuebe. For now my workaround will do just fine.

smstuebe commented 7 years ago

Sure? have you tested a negative try where the icon turns red and then back to white? I'd be suprised, if it turns back to black.

Btw: don't close it. It contains a new feature request ^^

ChaseFlorell commented 7 years ago

ah, you are right. If I scan the correct finger, it goes green then disappears (thats what I tested). When I use the incorrect finger, it goes red then goes white.

ChaseFlorell commented 7 years ago

Not sure I can submit a PR, but here's my thought.

        private async Task AnimateFailedTryAsync()
        {
            if (_icon == null)
                return;
            var originalColorFilter = _icon.ColorFilter;
            _icon.SetColorFilter(NegativeColor);
            var shake = ObjectAnimator.OfFloat(_icon, "translationX", -10f, 10f);
            shake.SetDuration(500);
            shake.SetInterpolator(new CycleInterpolator(5));
            await shake.StartAsync();
            _icon.SetColorFilter(originalColorFilter);
        }
smstuebe commented 7 years ago

I'll make it completely customizable like NegativeColor. Or better: I may add a styling mechanism, so you don't have to create a custom just class for styling.

NightOwlCoder commented 6 years ago

Hey guys, was this fixed? I'm having a hard time on my app with the white on white...

smstuebe commented 6 years ago

oupsi, no. I'll move it to Milestone 1.4.6.

ruisilva450 commented 6 years ago

As of now there is a way that I can apply my own FingerprintCustomDialog.axml? If I do that in the OnCreateView it will lose the bindings even if I use the same resource ids that you use in your .axml file.

foehammer88 commented 6 years ago

@smstuebe any update on this?

smstuebe commented 6 years ago

-> 1.4.6 You can set DefaultColor in a custom dialog now.

marualderete commented 6 years ago

@smstuebe is there any way to customize the text color of "Cancel" button? It is taking native color right now.

Kind regards

alvynfash commented 5 years ago

@smstuebe any update on this?

You can do this =>

public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.Inflate(Resource.Layout.some_xml_file, container, false); }

Bogenbai commented 5 years ago

-> 1.4.6 You can set DefaultColor in a custom dialog now.

Hello! How can I change tooltip text color in the dialog?

alvynfash commented 5 years ago

-> 1.4.6 You can set DefaultColor in a custom dialog now.

Hello! How can I change tooltip text color in the dialog?

@BogaDev get reference to the widget in the onCreateView override then customise it as you want

Bogenbai commented 5 years ago

-> 1.4.6 You can set DefaultColor in a custom dialog now.

Hello! How can I change tooltip text color in the dialog?

@BogaDev get reference to the widget in the onCreateView override then customise it as you want

Thank you for the answer! Could you please give an example? Because Im really stuck at this point

georgeharnwell commented 5 years ago

I could do with some examples on this. I can only seem to find the background property to update. Not text color.

Bogenbai commented 5 years ago

I could do with some examples on this. I can only seem to find the background property to update. Not text color.

I found how to change background color, that was pretty simple, but text color changing looks really complicated. If you could help, I would be very grateful

alvynfash commented 5 years ago

@BogaDev @georgeharnwell @foehammer88 @ruisilva450 @marualderete

So I finally got the time to upload my implementation that allows me use my custom xml layout, reference widgets from the layout in my extended FingerprintDialogFragment => "ZetagikCustomFingerprintDialogFragment" and even change the dialog type to "BottomSheetDialog". Also, don't forget to modify your MainApplication.cs to use this customised FingerprintDialogFragment.

Hope this answers the questions related to customisations and @smstuebe accepts my PR since it modifies only the sample project and can serve as a guide for others too hopefully.

https://github.com/smstuebe/xamarin-fingerprint/commit/c7262476758fc1b459b2569c38b789c88e6a9e8c

georgeharnwell commented 5 years ago

That is NICE! Thank you!

Bogenbai commented 5 years ago

@alvynfash you are just... wizard. Thank you so much