Search in sources :

Example 1 with FingerprintHandler

use of org.horaapps.leafpic.util.FingerprintHandler in project LeafPic by HoraApps.

the class SecurityActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_security);
    llroot = (LinearLayout) findViewById(R.id.root);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    swActiveSecurity = (SwitchCompat) findViewById(R.id.active_security_switch);
    swApplySecurityDelete = (SwitchCompat) findViewById(R.id.security_body_apply_delete_switch);
    swApplySecurityHidden = (SwitchCompat) findViewById(R.id.security_body_apply_hidden_switch);
    swFingerPrint = (SwitchCompat) findViewById(R.id.active_security_fingerprint_switch);
    llFingerprint = (LinearLayout) findViewById(R.id.ll_active_security_fingerprint);
    initUi();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        fingerprintHandler = new FingerprintHandler(this, null);
        if (fingerprintHandler.isFingerprintSupported()) {
            llFingerprint.setVisibility(View.VISIBLE);
        } else {
            llFingerprint.setVisibility(View.GONE);
        }
    } else {
        llFingerprint.setVisibility(View.GONE);
    }
    /**
     * - SWITCHES - *
     */
    /**
     * - ACTIVE SECURITY - *
     */
    swActiveSecurity.setChecked(Security.isPasswordSet());
    swActiveSecurity.setClickable(false);
    findViewById(R.id.ll_active_security).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            swActiveSecurity.setChecked(!swActiveSecurity.isChecked());
            setSwitchColor(getAccentColor(), swActiveSecurity);
            if (swActiveSecurity.isChecked())
                setPasswordDialog();
            else {
                Security.clearPassword();
                swApplySecurityHidden.setChecked(false);
                swApplySecurityDelete.setChecked(false);
                swFingerPrint.setChecked(false);
                Security.setFingerprintUnlock(swFingerPrint.isChecked());
                Security.setPasswordOnDelete(swApplySecurityDelete.isChecked());
                Security.setPasswordOnHidden(swApplySecurityHidden.isChecked());
                setSwitchColor(getAccentColor(), swApplySecurityHidden);
                setSwitchColor(getAccentColor(), swApplySecurityDelete);
                setSwitchColor(getAccentColor(), swFingerPrint);
            }
            toggleEnabledChild(swActiveSecurity.isChecked());
        }
    });
    /**
     * - ACTIVE SECURITY ON HIDDEN FOLDER - *
     */
    swApplySecurityHidden.setChecked(Hawk.get("password_on_hidden", false));
    swApplySecurityHidden.setClickable(false);
    findViewById(R.id.ll_security_body_apply_hidden).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            swApplySecurityHidden.setChecked(!swApplySecurityHidden.isChecked());
            Security.setPasswordOnHidden(swApplySecurityHidden.isChecked());
            setSwitchColor(getAccentColor(), swApplySecurityHidden);
        }
    });
    /**
     *ACTIVE SECURITY ON DELETE ACTION*
     */
    swApplySecurityDelete.setChecked(Hawk.get("password_on_delete", false));
    swApplySecurityDelete.setClickable(false);
    findViewById(R.id.ll_security_body_apply_delete).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            swApplySecurityDelete.setChecked(!swApplySecurityDelete.isChecked());
            Security.setPasswordOnDelete(swApplySecurityDelete.isChecked());
            setSwitchColor(getAccentColor(), swApplySecurityDelete);
        }
    });
    /**
     * - FINGERPRINT - *
     */
    swFingerPrint.setChecked(Hawk.get("fingerprint_security", false));
    swFingerPrint.setClickable(false);
    findViewById(R.id.ll_active_security_fingerprint).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            swFingerPrint.setChecked(!swFingerPrint.isChecked());
            Security.setFingerprintUnlock(swFingerPrint.isChecked());
            setSwitchColor(getAccentColor(), swFingerPrint);
        }
    });
}
Also used : FingerprintHandler(org.horaapps.leafpic.util.FingerprintHandler) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

CardView (android.support.v7.widget.CardView)1 View (android.view.View)1 TextView (android.widget.TextView)1 FingerprintHandler (org.horaapps.leafpic.util.FingerprintHandler)1