List of usage examples for android.content Context FINGERPRINT_SERVICE
String FINGERPRINT_SERVICE
To view the source code for android.content Context FINGERPRINT_SERVICE.
Click Source Link
From source file:com.z299studio.pb.FingerprintDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.dialog_fingerprint, container, false); if (!mIsFirstTime) { ((TextView) rootView.findViewById(R.id.fp_desc)).setText(R.string.fp_confirm); }//from ww w .j a va 2s . co m rootView.findViewById(R.id.cancel).setOnClickListener(this); initCipher(mIsFirstTime ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE); FingerprintManager fpManager = (FingerprintManager) getContext() .getSystemService(Context.FINGERPRINT_SERVICE); mFingerprintUiHelper = FingerprintUiHelper.build(fpManager, (ImageView) rootView.findViewById(R.id.fp_icon), (TextView) rootView.findViewById(R.id.fp_area), this); return rootView; }
From source file:com.breadwallet.BreadWalletApp.java
@Override public void onCreate() { super.onCreate(); WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from w w w . j a va 2 s . c om int DISPLAY_WIDTH_PX = size.x; DISPLAY_HEIGHT_PX = size.y; mFingerprintManager = (FingerprintManager) getSystemService(Context.FINGERPRINT_SERVICE); }
From source file:com.owncloud.android.ui.activity.FingerprintActivity.java
private void startFingerprint() { TextView fingerprintTextView = (TextView) findViewById(R.id.scanfingerprinttext); FingerprintManager fingerprintManager = (FingerprintManager) MainApp.getAppContext() .getSystemService(Context.FINGERPRINT_SERVICE); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return;// w ww . ja v a 2 s.co m } KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE); if (!keyguardManager.isKeyguardSecure()) { return; } else { generateKey(); if (cipherInit()) { cryptoObject = new FingerprintManager.CryptoObject(cipher); FingerprintHandler.Callback callback = new FingerprintHandler.Callback() { @Override public void onAuthenticated() { fingerprintResult(true); } @Override public void onFailed(String error) { Toast.makeText(MainApp.getAppContext(), error, Toast.LENGTH_LONG).show(); ImageView imageView = (ImageView) findViewById(R.id.fingerprinticon); int[][] states = new int[][] { new int[] { android.R.attr.state_activated }, new int[] { -android.R.attr.state_activated } }; int[] colors = new int[] { Color.parseColor("#FF0000"), Color.RED }; ColorStateList csl = new ColorStateList(states, colors); Drawable drawable = DrawableCompat.wrap(imageView.getDrawable()); DrawableCompat.setTintList(drawable, csl); imageView.setImageDrawable(drawable); } }; helper = new FingerprintHandler(fingerprintTextView, callback); cancellationSignal = new CancellationSignal(); if (ActivityCompat.checkSelfPermission(MainApp.getAppContext(), Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return; } fingerprintManager.authenticate(cryptoObject, cancellationSignal, 0, helper, null); } } }
From source file:com.breadwallet.presenter.fragments.FragmentSettings.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // The last two arguments ensure LayoutParams are inflated // properly.//w ww . jav a2 s . co m View rootView = inflater.inflate(R.layout.fragment_settings, container, false); app = MainActivity.app; fragmentSettings = this; initList(); RelativeLayout about = (RelativeLayout) rootView.findViewById(R.id.about); TextView currencyName = (TextView) rootView.findViewById(R.id.three_letters_currency); RelativeLayout changePassword = (RelativeLayout) rootView.findViewById(R.id.change_password); final String tmp = SharedPreferencesManager.getIso(getActivity()); currencyName.setText(tmp); RelativeLayout localCurrency = (RelativeLayout) rootView.findViewById(R.id.local_currency); RelativeLayout recoveryPhrase = (RelativeLayout) rootView.findViewById(R.id.recovery_phrase); RelativeLayout startRecoveryWallet = (RelativeLayout) rootView.findViewById(R.id.start_recovery_wallet); RelativeLayout fingerprintLimit = (RelativeLayout) rootView.findViewById(R.id.fingerprint_limit); RelativeLayout earlyAccess = (RelativeLayout) rootView.findViewById(R.id.early_access); RelativeLayout line5 = (RelativeLayout) rootView.findViewById(R.id.settings_line_5); TextView theLimit = (TextView) rootView.findViewById(R.id.fingerprint_limit_text); RelativeLayout rescan = (RelativeLayout) rootView.findViewById(R.id.rescan_blockchain); theLimit.setText(BRStringFormatter.getFormattedCurrencyString("BTC", PassCodeManager.getInstance().getLimit(getActivity()))); FingerprintManager mFingerprintManager; mFingerprintManager = (FingerprintManager) getActivity().getSystemService(Context.FINGERPRINT_SERVICE); boolean useFingerPrint; useFingerPrint = ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.USE_FINGERPRINT) == PackageManager.PERMISSION_GRANTED && mFingerprintManager.isHardwareDetected() && mFingerprintManager.hasEnrolledFingerprints(); if (!useFingerPrint) { fingerprintLimit.setVisibility(View.GONE); line5.setVisibility(View.GONE); } fingerprintLimit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (BRAnimator.checkTheMultipressingAvailability()) { ((BreadWalletApp) getActivity().getApplicationContext()).promptForAuthentication(getActivity(), BRConstants.AUTH_FOR_LIMIT, null, null, null, null, false); } } }); startRecoveryWallet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (BRAnimator.checkTheMultipressingAvailability()) { BRAnimator.pressWipeWallet(app, new FragmentWipeWallet()); app.activityButtonsEnable(false); } } }); recoveryPhrase.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { BRWalletManager.getInstance(getActivity()).animateSavePhraseFlow(); } }); about.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (BRAnimator.checkTheMultipressingAvailability()) { BRAnimator.animateSlideToLeft(app, new FragmentAbout(), fragmentSettings); } } }); localCurrency.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (BRAnimator.checkTheMultipressingAvailability()) { BRAnimator.animateSlideToLeft(app, new FragmentCurrency(), fragmentSettings); } } }); changePassword.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (BRAnimator.checkTheMultipressingAvailability()) { final android.app.FragmentManager fm = getActivity().getFragmentManager(); new PasswordDialogFragment().show(fm, PasswordDialogFragment.class.getName()); } } } ); rescan.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (BRAnimator.checkTheMultipressingAvailability()) { new Thread(new Runnable() { @Override public void run() { BRAnimator.goToMainActivity(fragmentSettings); BRPeerManager.getInstance(getActivity()).rescan(); SharedPreferencesManager.putStartHeight(getActivity(), 0); } }).start(); } } } ); //keep it hidden until finished if (!PLATFORM_ON) { earlyAccess.setVisibility(View.GONE); rootView.findViewById(R.id.early_access_separator).setVisibility(View.GONE); rootView.findViewById(R.id.early_access_separator2).setVisibility(View.GONE); } else { earlyAccess.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (BRAnimator.checkTheMultipressingAvailability()) { BRAnimator.animateSlideToLeft(app, new FragmentWebView(), fragmentSettings); } } }); } return rootView; }
From source file:com.amaze.carbonfilemanager.fragments.preference_fragments.Preffrag.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); utilsProvider = (UtilitiesProviderInterface) getActivity(); PreferenceUtils.reset();//from w w w.j ava 2 s. co m // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preferences); sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity()); for (String PREFERENCE_KEY : PREFERENCE_KEYS) { findPreference(PREFERENCE_KEY).setOnPreferenceClickListener(this); } gplus = (CheckBox) findPreference("plus_pic"); if (BuildConfig.IS_VERSION_FDROID) gplus.setEnabled(false); // crypt master password final EditTextPreference masterPasswordPreference = (EditTextPreference) findPreference( PREFERENCE_CRYPT_MASTER_PASSWORD); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { // encryption feature not available masterPasswordPreference.setEnabled(false); } if (sharedPref.getBoolean(PREFERENCE_CRYPT_FINGERPRINT, false)) { masterPasswordPreference.setEnabled(false); } CheckBox checkBoxFingerprint = (CheckBox) findPreference(PREFERENCE_CRYPT_FINGERPRINT); try { // finger print sensor final FingerprintManager fingerprintManager = (FingerprintManager) getActivity() .getSystemService(Context.FINGERPRINT_SERVICE); final KeyguardManager keyguardManager = (KeyguardManager) getActivity() .getSystemService(Context.KEYGUARD_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && fingerprintManager.isHardwareDetected()) { checkBoxFingerprint.setEnabled(true); } checkBoxFingerprint.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { Toast.makeText(getActivity(), getResources().getString(R.string.crypt_fingerprint_no_permission), Toast.LENGTH_LONG).show(); return false; } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !fingerprintManager.hasEnrolledFingerprints()) { Toast.makeText(getActivity(), getResources().getString(R.string.crypt_fingerprint_not_enrolled), Toast.LENGTH_LONG).show(); return false; } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !keyguardManager.isKeyguardSecure()) { Toast.makeText(getActivity(), getResources().getString(R.string.crypt_fingerprint_no_security), Toast.LENGTH_LONG) .show(); return false; } masterPasswordPreference.setEnabled(false); return true; } }); } catch (NoClassDefFoundError error) { error.printStackTrace(); // fingerprint manager class not defined in the framework checkBoxFingerprint.setEnabled(false); } // Hide root preference Preference mRootMode = findPreference("rootmode"); PreferenceCategory mMisc = (PreferenceCategory) findPreference("misc"); mMisc.removePreference(mRootMode); }
From source file:com.aitorvs.android.fingerlock.FingerLockApi23.java
@TargetApi(Build.VERSION_CODES.M) @Nullable/*w w w .j a v a 2 s . c om*/ private FingerprintManager getFingerprintManager() { if (mFingerprintManager == null) { invalidContext(); mFingerprintManager = (FingerprintManager) mContext.getSystemService(Context.FINGERPRINT_SERVICE); } return mFingerprintManager; }
From source file:com.nick.scalpel.core.AutoFoundWirer.java
private void wireFromContext(Context context, AutoFound.Type type, int idRes, Resources.Theme theme, Field field, Object forWho) { Resources resources = context.getResources(); switch (type) { case STRING://from ww w .j a v a 2s .co m setField(field, forWho, resources.getString(idRes)); break; case COLOR: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, resources.getColor(idRes, theme)); } else { //noinspection deprecation setField(field, forWho, resources.getColor(idRes)); } break; case INTEGER: setField(field, forWho, resources.getInteger(idRes)); break; case BOOL: setField(field, forWho, resources.getBoolean(idRes)); break; case STRING_ARRAY: setField(field, forWho, resources.getStringArray(idRes)); break; case INT_ARRAY: setField(field, forWho, resources.getIntArray(idRes)); break; case PM: setField(field, forWho, context.getSystemService(Context.POWER_SERVICE)); break; case ACCOUNT: setField(field, forWho, context.getSystemService(Context.ACCOUNT_SERVICE)); break; case ALARM: setField(field, forWho, context.getSystemService(Context.ALARM_SERVICE)); break; case AM: setField(field, forWho, context.getSystemService(Context.ACTIVITY_SERVICE)); break; case WM: setField(field, forWho, context.getSystemService(Context.WINDOW_SERVICE)); break; case NM: setField(field, forWho, context.getSystemService(Context.NOTIFICATION_SERVICE)); break; case TM: setField(field, forWho, context.getSystemService(Context.TELEPHONY_SERVICE)); break; case TCM: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.TELECOM_SERVICE)); } break; case SP: setField(field, forWho, PreferenceManager.getDefaultSharedPreferences(context)); break; case PKM: setField(field, forWho, context.getPackageManager()); break; case HANDLE: setField(field, forWho, new Handler(Looper.getMainLooper())); break; case ASM: setField(field, forWho, context.getSystemService(Context.ACCESSIBILITY_SERVICE)); break; case CAP: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setField(field, forWho, context.getSystemService(Context.CAPTIONING_SERVICE)); } break; case KGD: setField(field, forWho, context.getSystemService(Context.KEYGUARD_SERVICE)); break; case LOCATION: setField(field, forWho, context.getSystemService(Context.LOCATION_SERVICE)); break; case SEARCH: setField(field, forWho, context.getSystemService(Context.SEARCH_SERVICE)); break; case SENSOR: setField(field, forWho, context.getSystemService(Context.SENSOR_SERVICE)); break; case STORAGE: setField(field, forWho, context.getSystemService(Context.STORAGE_SERVICE)); break; case WALLPAPER: setField(field, forWho, context.getSystemService(Context.WALLPAPER_SERVICE)); break; case VIBRATOR: setField(field, forWho, context.getSystemService(Context.VIBRATOR_SERVICE)); break; case CONNECT: setField(field, forWho, context.getSystemService(Context.CONNECTIVITY_SERVICE)); break; case NETWORK_STATUS: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, context.getSystemService(Context.NETWORK_STATS_SERVICE)); } break; case WIFI: setField(field, forWho, context.getSystemService(Context.WIFI_SERVICE)); break; case AUDIO: setField(field, forWho, context.getSystemService(Context.AUDIO_SERVICE)); break; case FP: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, context.getSystemService(Context.FINGERPRINT_SERVICE)); } break; case MEDIA_ROUTER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { setField(field, forWho, context.getSystemService(Context.MEDIA_ROUTER_SERVICE)); } break; case SUB: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { setField(field, forWho, context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)); } break; case IME: setField(field, forWho, context.getSystemService(Context.INPUT_METHOD_SERVICE)); break; case CLIP_BOARD: setField(field, forWho, context.getSystemService(Context.CLIPBOARD_SERVICE)); break; case APP_WIDGET: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.APPWIDGET_SERVICE)); } break; case DEVICE_POLICY: setField(field, forWho, context.getSystemService(Context.DEVICE_POLICY_SERVICE)); break; case DOWNLOAD: setField(field, forWho, context.getSystemService(Context.DOWNLOAD_SERVICE)); break; case BATTERY: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.BATTERY_SERVICE)); } break; case NFC: setField(field, forWho, context.getSystemService(Context.NFC_SERVICE)); break; case DISPLAY: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setField(field, forWho, context.getSystemService(Context.DISPLAY_SERVICE)); } break; case USER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setField(field, forWho, context.getSystemService(Context.USER_SERVICE)); } break; case APP_OPS: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setField(field, forWho, context.getSystemService(Context.APP_OPS_SERVICE)); } break; case BITMAP: setField(field, forWho, BitmapFactory.decodeResource(resources, idRes, null)); break; } }
From source file:com.owncloud.android.ui.activity.FingerprintActivity.java
final static public boolean isFingerprintCapable(Context context) { try {// www .j av a 2s .com FingerprintManager fingerprintManager = (FingerprintManager) context .getSystemService(Context.FINGERPRINT_SERVICE); if (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return false; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return fingerprintManager.isHardwareDetected(); } } catch (Exception e) { return false; } return false; }
From source file:com.owncloud.android.ui.activity.FingerprintActivity.java
final static public boolean isFingerprintReady(Context context) { try {//from w w w .jav a 2 s . com FingerprintManager fingerprintManager = (FingerprintManager) context .getSystemService(Context.FINGERPRINT_SERVICE); if (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return false; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints(); } } catch (Exception e) { return false; } return false; }
From source file:nl.hnogames.domoticz.Preference.Preference.java
private void setPreferences() { final android.preference.SwitchPreference MultiServerPreference = (android.preference.SwitchPreference) findPreference( "enableMultiServers"); android.preference.Preference ServerSettings = findPreference("server_settings"); android.preference.Preference PermissionsSettings = findPreference("permissionssettings"); android.preference.Preference NotificationLogged = findPreference("notification_show_logs"); android.preference.Preference fetchServerConfig = findPreference("server_force_fetch_config"); android.preference.Preference resetApplication = findPreference("reset_settings"); android.preference.ListPreference displayLanguage = (ListPreference) findPreference("displayLanguage"); final android.preference.Preference registrationId = findPreference("notification_registration_id"); android.preference.Preference GeoSettings = findPreference("geo_settings"); android.preference.SwitchPreference WearPreference = (android.preference.SwitchPreference) findPreference( "enableWearItems"); android.preference.Preference NFCPreference = findPreference("nfc_settings"); android.preference.Preference QRCodePreference = findPreference("qrcode_settings"); android.preference.Preference SpeechPreference = findPreference("speech_settings"); android.preference.SwitchPreference EnableNFCPreference = (android.preference.SwitchPreference) findPreference( "enableNFC"); android.preference.SwitchPreference EnableQRCodePreference = (android.preference.SwitchPreference) findPreference( "enableQRCode"); android.preference.SwitchPreference EnableSpeechPreference = (android.preference.SwitchPreference) findPreference( "enableSpeech"); android.preference.SwitchPreference EnableTalkBackPreference = (android.preference.SwitchPreference) findPreference( "talkBack"); MultiSelectListPreference drawerItems = (MultiSelectListPreference) findPreference("enable_menu_items"); @SuppressWarnings("SpellCheckingInspection") android.preference.SwitchPreference AlwaysOnPreference = (android.preference.SwitchPreference) findPreference( "alwayson"); @SuppressWarnings("SpellCheckingInspection") android.preference.PreferenceScreen preferenceScreen = (android.preference.PreferenceScreen) findPreference( "settingsscreen"); android.preference.PreferenceCategory premiumCategory = (android.preference.PreferenceCategory) findPreference( "premium_category"); android.preference.Preference premiumPreference = findPreference("premium_settings"); NotificationsMultiSelectListPreference notificationsMultiSelectListPreference = (NotificationsMultiSelectListPreference) findPreference( "suppressNotifications"); NotificationsMultiSelectListPreference alarmMultiSelectListPreference = (NotificationsMultiSelectListPreference) findPreference( "alarmNotifications"); android.preference.SwitchPreference ThemePreference = (android.preference.SwitchPreference) findPreference( "darkTheme"); android.preference.Preference FingerPrintSettingsPreference = findPreference("SecuritySettings"); android.preference.SwitchPreference FingerPrintPreference = (android.preference.SwitchPreference) findPreference( "enableSecurity"); if (!BuildConfig.DEBUG) { PreferenceCategory oAndroidAutoCategory = (android.preference.PreferenceCategory) findPreference( "androidautocategory"); PreferenceScreen oNotificationScreen = (android.preference.PreferenceScreen) findPreference( "notificationscreen"); oNotificationScreen.removePreference(oAndroidAutoCategory); }/* w w w .j a va2s . co m*/ List<String> notifications = mSharedPrefs.getReceivedNotifications(); if (notifications == null || notifications.size() <= 0) { notificationsMultiSelectListPreference.setEnabled(false); alarmMultiSelectListPreference.setEnabled(false); } else { notificationsMultiSelectListPreference.setEnabled(true); alarmMultiSelectListPreference.setEnabled(true); } PermissionsSettings .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { permissionHelper.openSettingsScreen(); return true; } }); drawerItems.setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { try { final HashSet selectedDrawerItems = (HashSet) newValue; if (selectedDrawerItems.size() < 1) { showSnackbar(mContext.getString(R.string.error_atLeastOneItemInDrawer)); return false; } } catch (Exception ex) { ex.printStackTrace(); return false; } return true; } }); ThemePreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_theme)); return false; } else { ((SettingsActivity) getActivity()).reloadSettings(); return true; } } }); MultiServerPreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.multi_server)); return false; } return true; } }); ServerSettings.setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { if (!MultiServerPreference.isChecked()) { Intent intent = new Intent(mContext, ServerSettingsActivity.class); startActivity(intent); } else { Intent intent = new Intent(mContext, ServerListSettingsActivity.class); startActivity(intent); } return true; } }); FingerPrintSettingsPreference .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { mContext.startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS)); return true; } }); fetchServerConfig .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { UsefulBits.getServerConfigForActiveServer(mContext, true, new ConfigReceiver() { @Override public void onReceiveConfig(ConfigInfo settings) { showSnackbar(mContext.getString(R.string.fetched_server_config_success)); } @Override public void onError(Exception error) { showSnackbar(mContext.getString(R.string.fetched_server_config_failed)); } }, null); return true; } }); displayLanguage .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { showRestartMessage(); return true; } }); registrationId.setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!PermissionsUtil.canAccessDeviceState(mContext)) { permissionHelper.request(PermissionsUtil.INITIAL_DEVICE_PERMS); } else { pushGCMRegistrationIds(); } } else { pushGCMRegistrationIds(); } return true; } }); GeoSettings.setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.geofence)); return false; } else { Intent intent = new Intent(mContext, GeoSettingsActivity.class); startActivity(intent); return true; } } }); EnableNFCPreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_nfc)); return false; } if (NfcAdapter.getDefaultAdapter(mContext) == null) { showSnackbar(mContext.getString(R.string.nfc_not_supported)); return false; } return true; } }); EnableQRCodePreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_QRCode)); return false; } return true; } }); EnableSpeechPreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_Speech)); return false; } return true; } }); EnableTalkBackPreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_talk_back)); return false; } return true; } }); NFCPreference.setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_nfc)); return false; } else { Intent intent = new Intent(mContext, NFCSettingsActivity.class); startActivity(intent); return true; } } }); QRCodePreference .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_QRCode)); return false; } else { Intent intent = new Intent(mContext, QRCodeSettingsActivity.class); startActivity(intent); return true; } } }); SpeechPreference .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_Speech)); return false; } else { Intent intent = new Intent(mContext, SpeechSettingsActivity.class); startActivity(intent); return true; } } }); WearPreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_wear)); return false; } return true; } }); AlwaysOnPreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) { if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.always_on_title)); return false; } return true; } }); NotificationLogged .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { //show dialog List<String> logs = mSharedPrefs.getLoggedNotifications(); if (logs != null && logs.size() > 0) { Collections.reverse(logs); new MaterialDialog.Builder(mContext) .title(mContext.getString(R.string.notification_show_title)) .items((CharSequence[]) logs.toArray(new String[0])).show(); } else UsefulBits.showSimpleToast(mContext, getString(R.string.notification_show_nothing), Toast.LENGTH_LONG); return true; } }); //noinspection PointlessBooleanExpression if (!BuildConfig.LITE_VERSION) { preferenceScreen.removePreference(premiumCategory); } else { premiumPreference .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { String packageID = mContext.getPackageName() + ".premium"; try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageID))); } catch (android.content.ActivityNotFoundException ignored) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + packageID))); } return true; } }); } resetApplication .setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(android.preference.Preference preference) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { new MaterialDialog.Builder(mContext).title(R.string.category_Reset) .content(R.string.are_you_sure).positiveText(R.string.ok) .negativeText(R.string.cancel) .onPositive(new MaterialDialog.SingleButtonCallback() { @SuppressLint("NewApi") @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { ((ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE)) .clearApplicationUserData(); } }).show(); } else { startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0); } return true; } }); FingerPrintPreference .setOnPreferenceChangeListener(new android.preference.Preference.OnPreferenceChangeListener() { @SuppressLint("NewApi") @Override public boolean onPreferenceChange(android.preference.Preference preference, Object o) { if (mSharedPrefs.isStartupSecurityEnabled()) return true; if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { showPremiumSnackbar(getString(R.string.category_startup_security)); return false; } else { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { UsefulBits.showSimpleToast(mContext, getString(R.string.fingerprint_not_supported), Toast.LENGTH_LONG); return false; } if (!PermissionsUtil.canAccessFingerprint(mContext)) { permissionHelper.request(PermissionsUtil.INITIAL_FINGERPRINT_PERMS); } else { FingerprintManager fingerprintManager = (FingerprintManager) mContext .getSystemService(Context.FINGERPRINT_SERVICE); if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return false; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!fingerprintManager.isHardwareDetected()) { return false; } else if (!fingerprintManager.hasEnrolledFingerprints()) { UsefulBits.showSimpleToast(mContext, getString(R.string.fingerprint_not_setup_in_android), Toast.LENGTH_LONG); return false; } else { new MaterialDialog.Builder(mContext) .title(R.string.category_startup_security) .content(R.string.fingerprint_sure).positiveText(R.string.ok) .negativeText(R.string.cancel) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { mSharedPrefs.setStartupSecurityEnabled(true); ((SettingsActivity) getActivity()).reloadSettings(); } }).show(); return false; } } } } return false; } }); }