package info.knacki.pass.ui.passwordPicker;

import android.app.Service;
import android.content.Context;
import android.os.Build;
import android.os.IBinder;

import info.knacki.pass.io.FileInterfaceFactory;
import info.knacki.pass.settings.SettingsManager;
import info.knacki.pass.ui.alertPrompt.AlertPromptGenerator;
import info.knacki.pass.ui.alertPrompt.ServiceAlertPromptGenerator;

public class PasswordPickerFactory {
    public static FileInterfaceFactory.PasswordGetter GetPasswordPicker(Context ctx) {
        final AlertPromptGenerator generator = new AlertPromptGenerator();

        if (SettingsManager.IsFingerprintEnabled(ctx) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
            return new FingerprintPicker(ctx, generator);
        return new PasswordPicker(ctx, generator);
    }

    public static FileInterfaceFactory.PasswordGetter GetPasswordPicker(Service ctx, IBinder windowToken) {
        final AlertPromptGenerator generator = new ServiceAlertPromptGenerator(windowToken);

        if (SettingsManager.IsFingerprintEnabled(ctx) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
            return new FingerprintPicker(ctx, generator);
        return new PasswordPicker(ctx, generator);
    }

    public static FileInterfaceFactory.ChangePasswordGetter GetPasswordEditor(Context ctx) {
        return new PasswordPicker.ChangePasswordPicker(ctx, new AlertPromptGenerator());
    }
}
