Search in sources :

Example 1 with FingerprintManagerCompat

use of android.support.v4.hardware.fingerprint.FingerprintManagerCompat in project MaxLock by Maxr1998.

the class FingerprintView method onWindowFocusChanged.

@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
    super.onWindowFocusChanged(hasWindowFocus);
    if (hasWindowFocus) {
        FingerprintManagerCompat mFingerprintManager = FingerprintManagerCompat.from(getContext());
        if (mFingerprintManager.isHardwareDetected() && mFingerprintManager.hasEnrolledFingerprints()) {
            if (!mLockView.allowFingerprint()) {
                handleFingerprintIndicator(R.drawable.lockscreen_fingerprint_fp_to_error_state_animation);
                setOnClickListener(mNotAllowedToast);
                return;
            }
            if (mCancelFingerprint.isCanceled()) {
                mCancelFingerprint = new CancellationSignal();
            }
            mFingerprintManager.authenticate(null, 0, mCancelFingerprint, mFPAuthenticationCallback, null);
            handleFingerprintIndicator(R.drawable.lockscreen_fingerprint_draw_on_animation);
        } else {
            setVisibility(GONE);
        }
    } else {
        mCancelFingerprint.cancel();
    }
}
Also used : FingerprintManagerCompat(android.support.v4.hardware.fingerprint.FingerprintManagerCompat) CancellationSignal(android.support.v4.os.CancellationSignal)

Example 2 with FingerprintManagerCompat

use of android.support.v4.hardware.fingerprint.FingerprintManagerCompat in project MaxLock by Maxr1998.

the class MaxLockPreferenceFragment method onCreate.

@SuppressLint("WorldReadableFiles")
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle paramBundle) {
    super.onCreate(paramBundle);
    if (getArguments() != null) {
        screen = Screen.valueOf(getArguments().getString(Screen.KEY, Screen.MAIN.toString()));
    } else {
        screen = Screen.MAIN;
    }
    prefs = MLPreferences.getPreferences(getActivity());
    setTitle();
    if (screen == Screen.IMOD) {
        getPreferenceManager().setSharedPreferencesName(Common.PREFS_APPS);
    }
    if (SDK_INT < Build.VERSION_CODES.N)
        getPreferenceManager().setSharedPreferencesMode(Context.MODE_WORLD_READABLE);
    addPreferencesFromResource(screen.preferenceXML);
    switch(screen) {
        case MAIN:
            updateImplementationStatus();
            PreferenceCategory catAppUI = (PreferenceCategory) findPreference(Common.CATEGORY_APPLICATION_UI);
            CheckBoxPreference useDark = (CheckBoxPreference) findPreference(Common.USE_DARK_STYLE);
            if (!useDark.isChecked()) {
                catAppUI.removePreference(findPreference(Common.USE_AMOLED_BLACK));
            }
            if (SDK_INT >= Build.VERSION_CODES.O) {
                catAppUI.removePreference(findPreference(Common.NEW_APP_NOTIFICATION));
            }
            break;
        case TYPE:
            FingerprintManagerCompat fpm = FingerprintManagerCompat.from(getActivity());
            if (!fpm.isHardwareDetected()) {
                getPreferenceScreen().removePreference(findPreference(Common.SHADOW_FINGERPRINT));
                getPreferenceScreen().removePreference(findPreference(Common.CATEGORY_FINGERPRINT));
            } else {
                CheckBoxPreference disableFP = (CheckBoxPreference) findPreference(Common.DISABLE_FINGERPRINT);
                if (!fpm.hasEnrolledFingerprints() && !disableFP.isChecked()) {
                    disableFP.setSummary(disableFP.getSummary() + getResources().getString(R.string.pref_fingerprint_summary_non_enrolled));
                }
            }
            break;
        case UI:
            ListPreference lp = (ListPreference) findPreference(Common.BACKGROUND);
            findPreference(Common.BACKGROUND_COLOR).setEnabled(lp.getValue().equals("color"));
            lp.setOnPreferenceChangeListener((preference, newValue) -> {
                if (preference.getKey().equals(Common.BACKGROUND)) {
                    if (newValue.toString().equals("custom")) {
                        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                        intent.setType("image/*");
                        startActivityForResult(intent, WALLPAPER_REQUEST_CODE);
                    } else {
                        FileUtils.deleteQuietly(new File(getActivity().getFilesDir(), "background"));
                    }
                    findPreference(Common.BACKGROUND_COLOR).setEnabled(newValue.toString().equals("color"));
                }
                return true;
            });
            break;
        case OPTIONS:
            Preference el = findPreference(Common.ENABLE_LOGGING);
            el.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false));
            if (!prefs.getBoolean(Common.ENABLE_PRO, false)) {
                el.setSummary(R.string.toast_pro_required);
            }
            if (MLImplementation.getImplementation(prefs) != MLImplementation.DEFAULT) {
                PreferenceCategory catOther = (PreferenceCategory) findPreference(Common.CATEGORY_OTHER);
                catOther.removePreference(findPreference(Common.HIDE_RECENTS_THUMBNAILS));
            }
            break;
        case IMOD:
            // Intika I.Mod - Pro setup
            Preference iModDelayGlobal = findPreference(Common.ENABLE_IMOD_DELAY_GLOBAL);
            Preference iModDelayPerApp = findPreference(Common.ENABLE_IMOD_DELAY_APP);
            iModDelayGlobal.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false));
            iModDelayPerApp.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false));
            if (!prefs.getBoolean(Common.ENABLE_PRO, false)) {
                iModDelayGlobal.setTitle(R.string.pref_delay_needpro);
                iModDelayPerApp.setTitle(R.string.pref_delay_needpro);
            }
            break;
    }
}
Also used : PreferenceCategory(android.preference.PreferenceCategory) CheckBoxPreference(android.preference.CheckBoxPreference) ListPreference(android.preference.ListPreference) CheckBoxPreference(android.preference.CheckBoxPreference) ImplementationPreference(de.Maxr1998.xposed.maxlock.preference.ImplementationPreference) TwoStatePreference(android.preference.TwoStatePreference) Preference(android.preference.Preference) FingerprintManagerCompat(android.support.v4.hardware.fingerprint.FingerprintManagerCompat) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) ListPreference(android.preference.ListPreference) FileProvider.getUriForFile(android.support.v4.content.FileProvider.getUriForFile) File(java.io.File) SuppressLint(android.annotation.SuppressLint)

Aggregations

FingerprintManagerCompat (android.support.v4.hardware.fingerprint.FingerprintManagerCompat)2 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 CheckBoxPreference (android.preference.CheckBoxPreference)1 ListPreference (android.preference.ListPreference)1 Preference (android.preference.Preference)1 PreferenceCategory (android.preference.PreferenceCategory)1 TwoStatePreference (android.preference.TwoStatePreference)1 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)1 FileProvider.getUriForFile (android.support.v4.content.FileProvider.getUriForFile)1 CancellationSignal (android.support.v4.os.CancellationSignal)1 ImplementationPreference (de.Maxr1998.xposed.maxlock.preference.ImplementationPreference)1 File (java.io.File)1