Example usage for android.os Bundle putBoolean

List of usage examples for android.os Bundle putBoolean

Introduction

In this page you can find the example usage for android.os Bundle putBoolean.

Prototype

public void putBoolean(@Nullable String key, boolean value) 

Source Link

Document

Inserts a Boolean value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:at.bitfire.davdroid.mirakel.syncadapter.EnterCredentialsFragment.java

void queryServer() {
    FragmentTransaction ft = getFragmentManager().beginTransaction();

    Bundle args = new Bundle();

    String host_path = editBaseURL.getText().toString();
    args.putString(QueryServerDialogFragment.EXTRA_BASE_URL, URIUtils.sanitize(protocol + host_path));
    args.putString(QueryServerDialogFragment.EXTRA_USER_NAME, editUserName.getText().toString());
    args.putString(QueryServerDialogFragment.EXTRA_PASSWORD, editPassword.getText().toString());
    args.putBoolean(QueryServerDialogFragment.EXTRA_AUTH_PREEMPTIVE, checkboxPreemptive.isChecked());

    DialogFragment dialog = new QueryServerDialogFragment();
    dialog.setArguments(args);/*from www. j  av  a2  s  .  c  o m*/
    dialog.show(ft, QueryServerDialogFragment.class.getName());
}

From source file:androidx.navigation.fragment.NavHostFragment.java

@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
    super.onSaveInstanceState(outState);
    Bundle navState = mNavController.saveState();
    if (navState != null) {
        outState.putBundle(KEY_NAV_CONTROLLER_STATE, navState);
    }/*from  w  w w  . j a v a  2 s  . com*/
    if (mDefaultNavHost) {
        outState.putBoolean(KEY_DEFAULT_NAV_HOST, true);
    }
}

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.
 *//* w  ww  .  j  a va 2 s . c  o  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;
}

From source file:au.com.wallaceit.reddinator.ViewRedditActivity.java

/**
 * Step 2: Setup TabHost// ww  w.j  a  va 2s . co m
 */
private void initialiseTabHost(Bundle args) {
    Bundle rargs = new Bundle();
    rargs.putBoolean("loadcom", true);
    rargs.putString("cookie", global.mRedditData.getSessionCookie());
    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();
    if (prefs.getString("widgetthemepref", "1").equals("1")) {
        mTabHost.getTabWidget().setBackgroundColor(Color.parseColor("#CEE3F8")); // set light theme
    } else {
        mTabHost.getTabWidget().setBackgroundColor(Color.parseColor("#5F99CF")); // set dark theme
    }
    // add tabs
    TabInfo tabInfo;
    ViewRedditActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator("Content"),
            (tabInfo = new TabInfo("Tab1", TabWebFragment.class, args)));
    this.mapTabInfo.put(tabInfo.tag, tabInfo);
    ViewRedditActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator("Reddit"),
            (tabInfo = new TabInfo("Tab2", TabWebFragment.class, rargs)));
    this.mapTabInfo.put(tabInfo.tag, tabInfo);
    // Default to first tab
    // get shared preferences
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ViewRedditActivity.this);
    if (prefs.getBoolean("commentsfirstpref", false)) {
        this.mTabHost.setCurrentTab(1);
        this.onTabChanged("Tab2"); // load comments tab first
    } else {
        this.onTabChanged("Tab1");
    }
    // set change listener
    mTabHost.setOnTabChangedListener(this);
}

From source file:es.uma.lcc.lockpic.MainActivity.java

@Override
public void onSaveInstanceState(Bundle bundle) {
    bundle.putBoolean("firstTime", false);
    // avoid repeating direct decrypt in unnecesary situations
}

From source file:com.mindmeapp.extensions.ExtensionData.java

/**
 * Serializes the contents of this object to a {@link Bundle}.
 *//*from   w w w  . java2 s.com*/
public Bundle toBundle() {
    Bundle data = new Bundle();
    data.putBoolean(KEY_VISIBLE, mVisible);
    data.putInt(KEY_ICON, mIcon);
    data.putString(KEY_ICON_URI, (mIconUri == null ? null : mIconUri.toString()));
    data.putString(KEY_STATUS_TO_DISPLAY, mStatusToDisplay);
    data.putString(KEY_STATUS_TO_SPEAK, mStatusToSpeak);
    data.putParcelable(KEY_VIEWS_TO_DISPLAY, mViewsToDisplay);
    data.putString(KEY_CONTENT_DESCRIPTION, mContentDescription);
    data.putSerializable(KEY_LANGUAGE_TO_SPEAK, mLanguageToSpeak);
    data.putInt(KEY_BACKGROUND, mBackground);
    data.putString(KEY_BACKGROUND_URI, (mBackgroundUri == null ? null : mBackgroundUri.toString()));
    return data;
}

From source file:com.amazon.cordova.plugin.ADMMessageHandler.java

/** {@inheritDoc} */
@Override//from   w w w  . j  a  v a  2  s.  c om
protected void onMessage(final Intent intent) {
    // Extract the message content from the set of extras attached to
    // the com.amazon.device.messaging.intent.RECEIVE intent.

    // Extract the payload from the message
    Bundle extras = intent.getExtras();
    if (extras != null && (extras.getString(PushPlugin.MESSAGE) != null)) {
        // if we are in the foreground, just surface the payload, else post
        // it to the statusbar
        if (PushPlugin.isInForeground()) {
            extras.putBoolean(PushPlugin.FOREGROUND, true);
            PushPlugin.sendExtras(extras);
        } else {
            extras.putBoolean(PushPlugin.FOREGROUND, false);
            createNotification(this, extras);
        }
    }
}

From source file:cn.njmeter.njmeter.widget.spinner.NiceSpinner.java

@Override
public Parcelable onSaveInstanceState() {
    Bundle bundle = new Bundle();
    bundle.putParcelable(INSTANCE_STATE, super.onSaveInstanceState());
    bundle.putInt(SELECTED_INDEX, selectedIndex);
    bundle.putBoolean(IS_ARROW_HIDDEN, isArrowHidden);
    bundle.putInt(ARROW_DRAWABLE_RES_ID, arrowDrawableResId);
    if (popupWindow != null) {
        bundle.putBoolean(IS_POPUP_SHOWING, popupWindow.isShowing());
    }//from w  ww  .jav a2s .  com
    return bundle;
}

From source file:com.meetingninja.csse.MainActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBoolean(KEY_SQL_CACHE, isDataCached);
}

From source file:at.bitfire.davdroid.mirakel.syncadapter.LoginURLFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.next:
        FragmentTransaction ft = getFragmentManager().beginTransaction();

        Bundle args = new Bundle();
        String host_path = editBaseURI.getText().toString();
        args.putString(QueryServerDialogFragment.EXTRA_BASE_URI, URLUtils.sanitize(scheme + host_path));
        args.putString(QueryServerDialogFragment.EXTRA_USER_NAME, editUserName.getText().toString());
        args.putString(QueryServerDialogFragment.EXTRA_PASSWORD, editPassword.getText().toString());
        args.putBoolean(QueryServerDialogFragment.EXTRA_AUTH_PREEMPTIVE, checkboxPreemptive.isChecked());

        DialogFragment dialog = new QueryServerDialogFragment();
        dialog.setArguments(args);//from  w  ww.j a  v  a  2 s  .  c  o m
        dialog.show(ft, QueryServerDialogFragment.class.getName());
        break;
    default:
        return false;
    }
    return true;
}