Search in sources :

Example 26 with RequiresApi

use of android.support.annotation.RequiresApi in project run-wallet-android by runplay.

the class NotificationHelper method createNotificationChannel.

@RequiresApi(api = Build.VERSION_CODES.O)
private static void createNotificationChannel(Context context) {
    NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
    NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL, context.getResources().getString(R.string.app_name), NotificationManager.IMPORTANCE_MIN);
    notificationManager.createNotificationChannel(channel);
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationManager(android.app.NotificationManager) RequiresApi(android.support.annotation.RequiresApi)

Example 27 with RequiresApi

use of android.support.annotation.RequiresApi in project AlarmAndJob by dxsdyhm.

the class TostServiceHelper method initScedule.

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static void initScedule(Context context) {
    JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
    JobInfo jobInfo = new JobInfo.Builder(1, new ComponentName(context.getPackageName(), ToastJobService.class.getName())).setPeriodic(SCEDULE_TIME).setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY).setRequiresCharging(true).build();
    jobScheduler.schedule(jobInfo);
}
Also used : JobScheduler(android.app.job.JobScheduler) JobInfo(android.app.job.JobInfo) ComponentName(android.content.ComponentName) RequiresApi(android.support.annotation.RequiresApi)

Example 28 with RequiresApi

use of android.support.annotation.RequiresApi in project KeePassDX by Kunzisoft.

the class GroupActivity method launch.

@RequiresApi(api = Build.VERSION_CODES.O)
public static void launch(Activity act, PwGroup group, AssistStructure assistStructure) {
    if (assistStructure != null) {
        if (LockingActivity.checkTimeIsAllowedOrFinish(act)) {
            Intent intent = new Intent(act, GroupActivity.class);
            if (group != null) {
                intent.putExtra(GROUP_ID_KEY, group.getId());
            }
            AutofillHelper.addAssistStructureExtraInIntent(intent, assistStructure);
            act.startActivityForResult(intent, AutofillHelper.AUTOFILL_RESPONSE_REQUEST_CODE);
        }
    } else {
        launch(act, group);
    }
}
Also used : Intent(android.content.Intent) RequiresApi(android.support.annotation.RequiresApi)

Example 29 with RequiresApi

use of android.support.annotation.RequiresApi in project KeePassDX by Kunzisoft.

the class PasswordActivity method initForFingerprint.

// fingerprint related code here
@RequiresApi(api = Build.VERSION_CODES.M)
private void initForFingerprint() {
    fingerPrintMode = NOT_CONFIGURED_MODE;
    fingerPrintHelper = new FingerPrintHelper(this, this);
    // when text entered we can enable the logon/purchase button and if required update encryption/decryption mode
    passwordView.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {
        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {
        }

        @Override
        public void afterTextChanged(final Editable s) {
            if (!fingerprintMustBeConfigured) {
                final boolean validInput = s.length() > 0;
                // encrypt or decrypt mode based on how much input or not
                setFingerPrintView(validInput ? R.string.store_with_fingerprint : R.string.scanning_fingerprint);
                if (validInput)
                    toggleFingerprintMode(STORE_MODE);
                else
                    toggleFingerprintMode(OPEN_MODE);
            }
        }
    });
    // callback for fingerprint findings
    fingerPrintHelper.setAuthenticationCallback(new FingerprintManagerCompat.AuthenticationCallback() {

        @Override
        public void onAuthenticationError(final int errorCode, final CharSequence errString) {
            switch(errorCode) {
                case 5:
                    Log.i(TAG, "Fingerprint authentication error. Code : " + errorCode + " Error : " + errString);
                    break;
                default:
                    Log.e(TAG, "Fingerprint authentication error. Code : " + errorCode + " Error : " + errString);
                    setFingerPrintView(errString.toString(), true);
            }
        }

        @Override
        public void onAuthenticationHelp(final int helpCode, final CharSequence helpString) {
            Log.w(TAG, "Fingerprint authentication help. Code : " + helpCode + " Help : " + helpString);
            showError(helpString);
            setFingerPrintView(helpString.toString(), true);
            fingerprintTextView.setText(helpString);
        }

        @Override
        public void onAuthenticationFailed() {
            Log.e(TAG, "Fingerprint authentication failed, fingerprint not recognized");
            showError(R.string.fingerprint_not_recognized);
        }

        @Override
        public void onAuthenticationSucceeded(final FingerprintManagerCompat.AuthenticationResult result) {
            switch(fingerPrintMode) {
                case STORE_MODE:
                    // newly store the entered password in encrypted way
                    final String password = passwordView.getText().toString();
                    fingerPrintHelper.encryptData(password);
                    break;
                case OPEN_MODE:
                    // retrieve the encrypted value from preferences
                    final String encryptedValue = prefsNoBackup.getString(getPreferenceKeyValue(), null);
                    if (encryptedValue != null) {
                        fingerPrintHelper.decryptData(encryptedValue);
                    }
                    break;
            }
        }
    });
}
Also used : FingerprintManagerCompat(android.support.v4.hardware.fingerprint.FingerprintManagerCompat) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) FingerPrintHelper(com.keepassdroid.fingerprint.FingerPrintHelper) RequiresApi(android.support.annotation.RequiresApi)

Example 30 with RequiresApi

use of android.support.annotation.RequiresApi in project KeePassDX by Kunzisoft.

the class PasswordActivity method launch.

@RequiresApi(api = Build.VERSION_CODES.O)
public static void launch(Activity act, String fileName, String keyFile, AssistStructure assistStructure) throws FileNotFoundException {
    verifyFileNameUriFromLaunch(fileName);
    if (assistStructure != null) {
        Intent intent = new Intent(act, PasswordActivity.class);
        intent.putExtra(UriIntentInitTask.KEY_FILENAME, fileName);
        intent.putExtra(UriIntentInitTask.KEY_KEYFILE, keyFile);
        AutofillHelper.addAssistStructureExtraInIntent(intent, assistStructure);
        act.startActivityForResult(intent, AutofillHelper.AUTOFILL_RESPONSE_REQUEST_CODE);
    } else {
        launch(act, fileName, keyFile);
    }
}
Also used : Intent(android.content.Intent) RequiresApi(android.support.annotation.RequiresApi)

Aggregations

RequiresApi (android.support.annotation.RequiresApi)217 Intent (android.content.Intent)30 Allocation (android.renderscript.Allocation)30 NotificationChannel (android.app.NotificationChannel)27 View (android.view.View)26 Bitmap (android.graphics.Bitmap)24 Paint (android.graphics.Paint)20 Point (android.graphics.Point)20 NotificationManager (android.app.NotificationManager)17 ViewGroup (android.view.ViewGroup)15 RecyclerView (android.support.v7.widget.RecyclerView)13 Uri (android.net.Uri)12 ViewTreeObserver (android.view.ViewTreeObserver)12 WindowInsets (android.view.WindowInsets)12 SuppressLint (android.annotation.SuppressLint)11 ActionBar (android.support.v7.app.ActionBar)11 Toolbar (android.support.v7.widget.Toolbar)11 TextView (android.widget.TextView)11 IOException (java.io.IOException)10 StatFs (android.os.StatFs)9