Example usage for android.content.res Resources getConfiguration

List of usage examples for android.content.res Resources getConfiguration

Introduction

In this page you can find the example usage for android.content.res Resources getConfiguration.

Prototype

public Configuration getConfiguration() 

Source Link

Document

Return the current configuration that is in effect for this resource object.

Usage

From source file:com.money.manager.ex.core.Core.java

private void setAppLocale_Internal(String languageToLoad) {
    Locale locale;/*from  w  ww  .ja  v  a 2s . c o m*/

    if (!TextUtils.isEmpty(languageToLoad)) {
        locale = new Locale(languageToLoad);
        //                locale = Locale.forLanguageTag(languageToLoad);
    } else {
        locale = Locale.getDefault();
    }
    // http://developer.android.com/reference/java/util/Locale.html#setDefault%28java.util.Locale%29
    //            Locale.setDefault(locale);

    // change locale of the configuration
    Resources resources = getContext().getResources();
    Configuration config = resources.getConfiguration();

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
        config.locale = locale;
    } else {
        config.setLocale(locale);
    }

    // set new locale
    resources.updateConfiguration(config, resources.getDisplayMetrics());
}

From source file:org.mariotaku.twidere.view.holder.ActivityTitleSummaryViewHolder.java

private Spanned getTitleStringAboutMe(int stringRes, int stringResMulti, ParcelableUser[] sources) {
    if (sources == null || sources.length == 0)
        return null;
    final Context context = adapter.getContext();
    final boolean nameFirst = adapter.isNameFirst();
    final UserColorNameManager manager = adapter.getUserColorNameManager();
    final Resources resources = context.getResources();
    final Configuration configuration = resources.getConfiguration();
    final SpannableString firstDisplayName = new SpannableString(
            manager.getDisplayName(sources[0], nameFirst, false));
    firstDisplayName.setSpan(new StyleSpan(Typeface.BOLD), 0, firstDisplayName.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    if (sources.length == 1) {
        final String format = context.getString(stringRes);
        return SpanFormatter.format(configuration.locale, format, firstDisplayName);
    } else if (sources.length == 2) {
        final String format = context.getString(stringResMulti);
        final SpannableString secondDisplayName = new SpannableString(
                manager.getDisplayName(sources[1], nameFirst, false));
        secondDisplayName.setSpan(new StyleSpan(Typeface.BOLD), 0, secondDisplayName.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        return SpanFormatter.format(configuration.locale, format, firstDisplayName, secondDisplayName);
    } else {//from w  w w  .  j  a  va  2  s.c  o  m
        final int othersCount = sources.length - 1;
        final SpannableString nOthers = new SpannableString(
                resources.getQuantityString(R.plurals.N_others, othersCount, othersCount));
        nOthers.setSpan(new StyleSpan(Typeface.BOLD), 0, nOthers.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        final String format = context.getString(stringResMulti);
        return SpanFormatter.format(configuration.locale, format, firstDisplayName, nOthers);
    }
}

From source file:me.lizheng.deckview.helpers.DeckViewConfig.java

/**
 * Updates the state, given the specified context
 *///from w ww. j a  va  2s . c  o  m
void update(Context context) {
    Resources res = context.getResources();
    DisplayMetrics dm = res.getDisplayMetrics();

    // Debug mode
    debugModeEnabled = false;

    // Layout
    isLandscape = res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;

    // Insets
    displayRect.set(0, 0, dm.widthPixels, dm.heightPixels);

    // Animations
    animationPxMovementPerSecond = res.getDimensionPixelSize(R.dimen.animation_movement_in_dps_per_second);

    // Filtering
    filteringCurrentViewsAnimDuration = res.getInteger(R.integer.filter_animate_current_views_duration);
    filteringNewViewsAnimDuration = res.getInteger(R.integer.filter_animate_new_views_duration);

    // Task stack
    taskStackScrollDuration = res.getInteger(R.integer.animate_deck_scroll_duration);
    TypedValue widthPaddingPctValue = new TypedValue();
    res.getValue(R.dimen.deck_width_padding_percentage, widthPaddingPctValue, true);
    taskStackWidthPaddingPct = widthPaddingPctValue.getFloat();
    TypedValue stackOverscrollPctValue = new TypedValue();
    res.getValue(R.dimen.deck_overscroll_percentage, stackOverscrollPctValue, true);
    taskStackOverscrollPct = stackOverscrollPctValue.getFloat();
    taskStackMaxDim = res.getInteger(R.integer.max_deck_view_dim);
    taskStackTopPaddingPx = res.getDimensionPixelSize(R.dimen.deck_top_padding);

    // Transition
    transitionEnterFromAppDelay = res.getInteger(R.integer.enter_from_app_transition_duration);
    transitionEnterFromHomeDelay = res.getInteger(R.integer.enter_from_home_transition_duration);

    // Task view animation and styles
    taskViewEnterFromAppDuration = res.getInteger(R.integer.task_enter_from_app_duration);
    taskViewEnterFromHomeDuration = res.getInteger(R.integer.task_enter_from_home_duration);
    taskViewEnterFromHomeStaggerDelay = res.getInteger(R.integer.task_enter_from_home_stagger_delay);
    taskViewExitToAppDuration = res.getInteger(R.integer.task_exit_to_app_duration);
    taskViewExitToHomeDuration = res.getInteger(R.integer.task_exit_to_home_duration);
    taskViewRemoveAnimDuration = res.getInteger(R.integer.animate_task_view_remove_duration);
    taskViewRemoveAnimTranslationXPx = res.getDimensionPixelSize(R.dimen.task_view_remove_anim_translation_x);
    taskViewRoundedCornerRadiusPx = res.getDimensionPixelSize(R.dimen.task_view_rounded_corners_radius);
    taskViewHighlightPx = res.getDimensionPixelSize(R.dimen.task_view_highlight);
    taskViewTranslationZMinPx = res.getDimensionPixelSize(R.dimen.task_view_z_min);
    taskViewTranslationZMaxPx = res.getDimensionPixelSize(R.dimen.task_view_z_max);
    taskViewAffiliateGroupEnterOffsetPx = res
            .getDimensionPixelSize(R.dimen.task_view_affiliate_group_enter_offset);
    TypedValue thumbnailAlphaValue = new TypedValue();
    res.getValue(R.dimen.task_view_thumbnail_alpha, thumbnailAlphaValue, true);
    taskViewThumbnailAlpha = thumbnailAlphaValue.getFloat();

    // Task bar colors
    taskBarViewDefaultBackgroundColor = ContextCompat.getColor(context,
            R.color.task_bar_default_background_color);

    taskBarViewLightTextColor = ContextCompat.getColor(context, R.color.task_bar_light_text_color);

    taskBarViewDarkTextColor = ContextCompat.getColor(context, R.color.task_bar_dark_text_color);

    taskBarViewHighlightColor = ContextCompat.getColor(context, R.color.task_bar_highlight_color);

    TypedValue affMinAlphaPctValue = new TypedValue();
    res.getValue(R.dimen.task_affiliation_color_min_alpha_percentage, affMinAlphaPctValue, true);
    taskBarViewAffiliationColorMinAlpha = affMinAlphaPctValue.getFloat();

    // Task bar size & animations
    taskBarHeight = res.getDimensionPixelSize(R.dimen.deck_child_header_bar_height);
    taskBarDismissDozeDelaySeconds = res.getInteger(R.integer.task_bar_dismiss_delay_seconds);

    // Nav bar scrim
    navBarScrimEnterDuration = res.getInteger(R.integer.nav_bar_scrim_enter_duration);

    // Misc
    useHardwareLayers = res.getBoolean(R.bool.config_use_hardware_layers);
    altTabKeyDelay = res.getInteger(R.integer.deck_alt_tab_key_delay);
    fakeShadows = res.getBoolean(R.bool.config_fake_shadows);
    svelteLevel = res.getInteger(R.integer.deck_svelte_level);
}

From source file:org.mariotaku.twidere.view.holder.ActivityTitleSummaryViewHolder.java

private Spanned getTitleStringByFriends(int stringRes, int stringResMulti, ParcelableUser[] sources,
        Object[] targets) {/*from  w w w . jav  a  2  s  .c om*/
    if (sources == null || sources.length == 0)
        return null;
    final Context context = adapter.getContext();
    final Resources resources = context.getResources();
    final Configuration configuration = resources.getConfiguration();
    final UserColorNameManager manager = adapter.getUserColorNameManager();
    final boolean nameFirst = adapter.isNameFirst();
    final SpannableString firstSourceName = new SpannableString(
            manager.getDisplayName(sources[0], nameFirst, false));
    firstSourceName.setSpan(new StyleSpan(Typeface.BOLD), 0, firstSourceName.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    final String displayName;
    final Object target = targets[0];
    if (target instanceof ParcelableUser) {
        displayName = manager.getDisplayName((ParcelableUser) target, nameFirst, false);
    } else if (target instanceof ParcelableStatus) {
        displayName = manager.getDisplayName((ParcelableStatus) target, nameFirst, false);
    } else {
        throw new IllegalArgumentException();
    }
    final SpannableString firstTargetName = new SpannableString(displayName);
    firstTargetName.setSpan(new StyleSpan(Typeface.BOLD), 0, firstTargetName.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    if (sources.length == 1) {
        final String format = context.getString(stringRes);
        return SpanFormatter.format(configuration.locale, format, firstSourceName, firstTargetName);
    } else if (sources.length == 2) {
        final String format = context.getString(stringResMulti);
        final SpannableString secondSourceName = new SpannableString(
                manager.getDisplayName(sources[1], nameFirst, false));
        secondSourceName.setSpan(new StyleSpan(Typeface.BOLD), 0, secondSourceName.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        return SpanFormatter.format(configuration.locale, format, firstSourceName, secondSourceName,
                firstTargetName);
    } else {
        final int othersCount = sources.length - 1;
        final SpannableString nOthers = new SpannableString(
                resources.getQuantityString(R.plurals.N_others, othersCount, othersCount));
        nOthers.setSpan(new StyleSpan(Typeface.BOLD), 0, nOthers.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        final String format = context.getString(stringResMulti);
        return SpanFormatter.format(configuration.locale, format, firstSourceName, nOthers, firstTargetName);
    }
}

From source file:com.sourceallies.android.zonebeacon.activity.MainActivity.java

/**
 * Get the number of columns in the grid.
 *
 * @return integer for the number of columns used in the grid
 *///  w w  w .j a va 2  s .  c  o  m
@VisibleForTesting
protected int getColumnCount() {
    Resources res = getResources();

    if (res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
        return 2;
    if (res.getBoolean(R.bool.tablet))
        return 2;

    return 1;
}

From source file:ota.otaupdates.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    if (sharedPreferences.getBoolean("force_english", false)) {
        Locale myLocale = new Locale("en");
        Resources res = getResources();
        DisplayMetrics dm = res.getDisplayMetrics();
        Configuration conf = res.getConfiguration();
        conf.locale = myLocale;/*from  w w  w. j a v  a  2 s  .  c o  m*/
        res.updateConfiguration(conf, dm);
    }

    if (sharedPreferences.getBoolean("apptheme_light", false))
        setTheme(R.style.AppTheme_Light);
    else
        setTheme(R.style.AppTheme_Dark);

    setContentView(R.layout.activity_main);

    build_url
            .append((Utils.doesPropExist(Constants.URL_PROP)) ? Utils.getProp(Constants.URL_PROP)
                    : getString(R.string.download_url))
            .append("/api/").append(Build.DEVICE).append("/").append(Build.TIME / 1000);

    build_dl_url.append((Utils.doesPropExist(Constants.URL_PROP)) ? Utils.getProp(Constants.URL_PROP)
            : getString(R.string.download_url)).append("/builds/");

    delta_url.append((Utils.doesPropExist(Constants.URL_PROP) ? Utils.getProp(Constants.URL_PROP)
            : getString(R.string.download_url))).append("/delta/").append(Build.VERSION.INCREMENTAL);

    delta_dl_url.append((Utils.doesPropExist(Constants.URL_PROP)) ? Utils.getProp(Constants.URL_PROP)
            : getString(R.string.download_url)).append("/deltas/");

    otaList = new ArrayList<>();
    get_builds();
    pb = (ProgressBar) findViewById(R.id.pb);
    pb.setVisibility(View.VISIBLE);

    final ListView ota_list = (ListView) findViewById(R.id.ota_list);

    adapter = new OTAUpdatesAdapter(getApplicationContext(), R.layout.row, otaList);
    ota_list.setAdapter(adapter);

    final CoordinatorLayout coordinator_root = (CoordinatorLayout) findViewById(R.id.coordinator_root);
    ota_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, final int position, long id) {
            final String url = build_dl_url.toString() + otaList.get(position).getOta_filename();

            if (Build.VERSION.SDK_INT >= 23 && !checkPermission())
                allow_write_sd();
            else if (sharedPreferences.getBoolean("disable_mobile", true) && isMobileDataEnabled()) {
                sb_network = Snackbar.make(coordinator_root, getString(R.string.disable_mobile_message),
                        Snackbar.LENGTH_SHORT);
                sb_network.getView()
                        .setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.colorSecond));
                sb_network.show();
            } else {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        create_notification(1, getString(R.string.app_name), getString(
                                R.string.downloader_notification, otaList.get(position).getOta_filename()));
                        Utils.DownloadFromUrl(url, otaList.get(position).getOta_filename());
                        ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancel(1);
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                if (MD5.checkMD5(otaList.get(position).getOta_md5(),
                                        new File(DL_PATH + otaList.get(position).getOta_filename()))
                                        || !sharedPreferences.getBoolean("md5_checking", true))
                                    trigger_autoinstall(DL_PATH + otaList.get(position).getOta_filename());
                                else {
                                    new AlertDialog.Builder(MainActivity.this)
                                            .setTitle(getString(R.string.md5_title))
                                            .setMessage(getString(R.string.md5_message)).setNeutralButton(
                                                    R.string.button_ok, new DialogInterface.OnClickListener() {
                                                        public void onClick(DialogInterface dialog, int which) {
                                                        }
                                                    })
                                            .show();
                                }
                            }
                        });
                    }
                }).start();
            }
        }
    });

}

From source file:org.lyricue.android.Lyricue.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    Resources res = getBaseContext().getResources();
    Configuration conf = res.getConfiguration();
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    boolean isLarge = (conf.screenLayout & 0x4) == 0x4;
    boolean isLandscape = (conf.orientation == Configuration.ORIENTATION_LANDSCAPE);
    if (isLarge && isLandscape) {
        Log.d(TAG, "rotate: landscape");
        fragmentTransaction.hide(getSupportFragmentManager().findFragmentById(R.layout.control));
    } else {/*  w  ww .j  a v  a  2 s  .c o  m*/
        Log.d(TAG, "rotate: portrait");
        fragmentTransaction.show(getSupportFragmentManager().findFragmentById(R.layout.control));
    }
    fragmentTransaction.commit();
}

From source file:org.dalol.orthodoxmezmurmedia.utilities.widgets.AmharicKeyboardView.java

/**
 * This method is responsible to handle the keyboard height based on the current orientation
 *///w  w w. j  a  va  2 s  . c  o  m
private void resolveKeyboardHeight() {
    Resources resources = getResources();
    DisplayMetrics displayMetrics = resources.getDisplayMetrics();
    int orientation = resources.getConfiguration().orientation;

    switch (orientation) {
    case Configuration.ORIENTATION_PORTRAIT:
        mKeyboardHeight = Math.round(displayMetrics.heightPixels / PORTRAIT_HEIGHT_SCALE);
        break;
    case Configuration.ORIENTATION_LANDSCAPE:
        mKeyboardHeight = Math.round(displayMetrics.heightPixels / LANDSCAPE_HEIGHT_SCALE);
        break;
    }
}

From source file:org.lyricue.android.Lyricue.java

/**
 * Called when the activity is first created.
 *///from  w  ww.  j  a  v  a 2s .c om
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i(TAG, "onCreate()");
    activity = this;
    setContentView(R.layout.main);
    FragmentManager fragman = getSupportFragmentManager();
    vib = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);

    if (savedInstanceState != null) {
        for (Fragment frag : fragman.getFragments()) {
            if (frag != null) {
                Log.d(TAG, frag.toString());
                Log.d(TAG, frag.getClass().getName());
                fragments.put(frag.getClass().getName(), frag);
            }
        }
        hosts = (HostItem[]) savedInstanceState.getParcelableArray("hosts");
        profile = savedInstanceState.getString("profile");
        playlistid = savedInstanceState.getLong("playlistid");
        playlists_text = savedInstanceState.getStringArray("playlists_text");
        playlists_id = savedInstanceState.getLongArray("playlists_id");
        bibles_text = savedInstanceState.getStringArray("bibles_text");
        bibles_id = savedInstanceState.getStringArray("bibles_id");
        bibles_type = savedInstanceState.getStringArray("bibles_type");
        ld = new LyricueDisplay(hosts);
    }

    LyricuePagerAdapter adapter = new LyricuePagerAdapter(fragman, activity, activity);
    pager = (ViewPager) findViewById(R.id.viewpager);
    pager.setAdapter(adapter);

    actionBar = getSupportActionBar();
    ActionBar.TabListener tabListener = new ActionBar.TabListener() {
        public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
            // When the tab is selected, switch to the
            // corresponding page in the ViewPager.
            pager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabReselected(Tab arg0, FragmentTransaction arg1) {
        }

        @Override
        public void onTabUnselected(Tab arg0, FragmentTransaction arg1) {
        }
    };

    Tab controlTab = actionBar.newTab().setText("Control").setTabListener(tabListener);
    actionBar.addTab(actionBar.newTab().setText(R.string.playlist).setTabListener(tabListener));
    actionBar.addTab(actionBar.newTab().setText(R.string.available).setTabListener(tabListener));
    actionBar.addTab(actionBar.newTab().setText(R.string.bible).setTabListener(tabListener));
    actionBar.addTab(actionBar.newTab().setText(R.string.display).setTabListener(tabListener));
    actionBar.addTab(controlTab);

    pager.setOffscreenPageLimit(actionBar.getTabCount());

    Resources res = getResources();
    Configuration conf = res.getConfiguration();
    boolean isLandscape = (conf.orientation == Configuration.ORIENTATION_LANDSCAPE);
    boolean isLarge = (conf.screenLayout & 0x4) == 0x4;
    Log.d(TAG, "Status:" + isLarge + ":" + isLandscape);
    if (isLarge && isLandscape) {
        activity.setQuickBar(false);
        actionBar.removeTab(controlTab);
        pager.setCurrentItem(0);
    } else {
        pager.setCurrentItem(4);
    }
    pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            getSupportActionBar().setSelectedNavigationItem(position);
        }
    });

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        getWindow().setStatusBarColor(Color.RED);

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    thumbnail_width = Math.min(displaymetrics.widthPixels, displaymetrics.heightPixels) / 2;
    if (profile.equals("")) {
        getPrefs();
    }
}

From source file:de.niklasmerz.cordova.fingerprint.Fingerprint.java

/**
 * Executes the request and returns PluginResult.
 *
 * @param action          The action to execute.
 * @param args            JSONArry of arguments for the plugin.
 * @param callbackContext The callback id used when calling back into JavaScript.
 * @return A PluginResult object with a status and message.
 *//*from w w w .  ja v a2 s  .  co m*/
public boolean execute(final String action, JSONArray args, CallbackContext callbackContext)
        throws JSONException {
    mCallbackContext = callbackContext;
    Log.v(TAG, "Fingerprint action: " + action);
    if (android.os.Build.VERSION.SDK_INT < 23) {
        Log.e(TAG, "minimum SDK version 23 required");
        mPluginResult = new PluginResult(PluginResult.Status.ERROR);
        mCallbackContext.error("minimum SDK version 23 required");
        mCallbackContext.sendPluginResult(mPluginResult);
        return true;
    }

    final JSONObject arg_object = args.getJSONObject(0);

    if (action.equals("authenticate")) {
        if (!arg_object.has("clientId") || !arg_object.has("clientSecret")) {
            mPluginResult = new PluginResult(PluginResult.Status.ERROR);
            mCallbackContext.error("Missing required parameters");
            mCallbackContext.sendPluginResult(mPluginResult);
            return true;
        }
        mClientId = arg_object.getString("clientId");
        mClientSecret = arg_object.getString("clientSecret");
        if (arg_object.has("disableBackup")) {
            mDisableBackup = arg_object.getBoolean("disableBackup");
        }
        // Set language
        Resources res = cordova.getActivity().getResources();
        // Change locale settings in the app.
        DisplayMetrics dm = res.getDisplayMetrics();
        Configuration conf = res.getConfiguration();
        //Do not change locale
        res.updateConfiguration(conf, dm);

        if (isFingerprintAuthAvailable()) {
            SecretKey key = getSecretKey();
            boolean isCipherInit = true;
            if (key == null) {
                if (createKey()) {
                    key = getSecretKey();
                }
            }
            if (key != null && !initCipher()) {
                isCipherInit = false;
            }
            if (key != null) {
                cordova.getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        // Set up the crypto object for later. The object will be authenticated by use
                        // of the fingerprint.
                        mFragment = new FingerprintAuthenticationDialogFragment();
                        Bundle bundle = new Bundle();
                        bundle.putBoolean("disableBackup", mDisableBackup);
                        mFragment.setArguments(bundle);

                        if (initCipher()) {
                            mFragment.setCancelable(false);
                            // Show the fingerprint dialog. The user has the option to use the fingerprint with
                            // crypto, or you can fall back to using a server-side verified password.
                            mFragment.setCryptoObject(new FingerprintManager.CryptoObject(mCipher));
                            mFragment.show(cordova.getActivity().getFragmentManager(), DIALOG_FRAGMENT_TAG);
                        } else {
                            if (!mDisableBackup) {
                                // This happens if the lock screen has been disabled or or a fingerprint got
                                // enrolled. Thus show the dialog to authenticate with their password
                                mFragment.setCryptoObject(new FingerprintManager.CryptoObject(mCipher));
                                mFragment.setStage(
                                        FingerprintAuthenticationDialogFragment.Stage.NEW_FINGERPRINT_ENROLLED);
                                mFragment.show(cordova.getActivity().getFragmentManager(), DIALOG_FRAGMENT_TAG);
                            } else {
                                mCallbackContext.error("Failed to init Cipher and backup disabled.");
                                mPluginResult = new PluginResult(PluginResult.Status.ERROR);
                                mCallbackContext.sendPluginResult(mPluginResult);
                            }
                        }
                    }
                });
                mPluginResult.setKeepCallback(true);
            } else {
                mCallbackContext.sendPluginResult(mPluginResult);
            }

        } else {
            mPluginResult = new PluginResult(PluginResult.Status.ERROR);
            mCallbackContext.error("Fingerprint authentication not available");
            mCallbackContext.sendPluginResult(mPluginResult);
        }
        return true;
    } else if (action.equals("isAvailable")) {
        if (isFingerprintAuthAvailable() && mFingerPrintManager.isHardwareDetected()
                && mFingerPrintManager.hasEnrolledFingerprints()) {
            mPluginResult = new PluginResult(PluginResult.Status.OK);
            mCallbackContext.success();
        } else {
            mPluginResult = new PluginResult(PluginResult.Status.ERROR);
            mCallbackContext.error("Fingerprint authentication not ready");
        }
        mCallbackContext.sendPluginResult(mPluginResult);
        return true;
    }
    return false;
}