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:de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.java

/**
 * Executes the request and returns a boolean.
 *
 * @param action          The action to execute.
 * @param argsArray       JSONArray of arguments for the plugin.
 * @param callbackContext The callback context used when calling back into JavaScript.
 * @return boolean./*w  w  w  .jav a 2  s .c o  m*/
 */
public boolean execute(String action, JSONArray argsArray, CallbackContext callbackContext)
        throws JSONException {
    JSONObject args;
    JSONObject options;
    if (argsArray.length() > 0) {
        args = argsArray.getJSONObject(0);
        options = args.getJSONObject(Args.OPTIONS);
    } else {
        //no arguments passed, initialize with empty JSON Objects
        args = new JSONObject();
        options = new JSONObject();
    }

    if (action.equals(Actions.VIEW_DOCUMENT)) {
        String url = args.getString(Args.URL);
        String contentType = args.getString(Args.CONTENT_TYPE);

        JSONObject androidOptions = options.getJSONObject(ANDROID_OPTIONS);

        String packageId = androidOptions.getString(Options.VIEWER_APP_PACKAGE_ID);
        String activity = androidOptions.getString(Options.VIEWER_APP_ACTIVITY);
        //put cordova arguments into Android Bundle in order to pass them to the external Activity
        Bundle viewerOptions = new Bundle();
        //exec
        viewerOptions.putString(DOCUMENTVIEW_OPTIONS + "." + Options.CLOSE_LABEL,
                options.getJSONObject(DOCUMENTVIEW_OPTIONS).getString(Options.CLOSE_LABEL));
        viewerOptions.putString(NAVIGATIONVIEW_OPTIONS + "." + Options.CLOSE_LABEL,
                options.getJSONObject(NAVIGATIONVIEW_OPTIONS).getString(Options.CLOSE_LABEL));
        viewerOptions.putBoolean(EMAIL_OPTIONS + "." + Options.ENABLED,
                options.getJSONObject(EMAIL_OPTIONS).getBoolean(Options.ENABLED));
        viewerOptions.putBoolean(PRINT_OPTIONS + "." + Options.ENABLED,
                options.getJSONObject(PRINT_OPTIONS).getBoolean(Options.ENABLED));
        viewerOptions.putBoolean(OPENWITH_OPTIONS + "." + Options.ENABLED,
                options.getJSONObject(OPENWITH_OPTIONS).getBoolean(Options.ENABLED));
        viewerOptions.putBoolean(BOOKMARKS_OPTIONS + "." + Options.ENABLED,
                options.getJSONObject(BOOKMARKS_OPTIONS).getBoolean(Options.ENABLED));
        viewerOptions.putBoolean(SEARCH_OPTIONS + "." + Options.ENABLED,
                options.getJSONObject(SEARCH_OPTIONS).getBoolean(Options.ENABLED));
        viewerOptions.putString(TITLE_OPTIONS, options.getString(TITLE_OPTIONS));

        this._open(url, contentType, packageId, activity, callbackContext, viewerOptions);
    } else if (action.equals(Actions.INSTALL_VIEWER_APP)) {
        String packageId = options.getJSONObject(ANDROID_OPTIONS).getString(Options.VIEWER_APP_PACKAGE_ID);

        this._install(packageId, callbackContext);
    } else if (action.equals(Actions.CAN_VIEW)) {
        String url = args.getString(Args.URL);

        String contentType = args.getString(Args.CONTENT_TYPE);

        JSONObject androidOptions = options.getJSONObject(ANDROID_OPTIONS);

        String packageId = androidOptions.getString(Options.VIEWER_APP_PACKAGE_ID);

        JSONObject successObj = null;
        if (PDF.equals(contentType)) {
            if (canGetFile(url)) {
                if (!this._appIsInstalled(packageId)) {
                    successObj = new JSONObject();
                    successObj.put(Result.STATUS, PluginResult.Status.NO_RESULT.ordinal());
                    successObj.put(Result.MISSING_APP_ID, packageId);
                } else {
                    successObj = new JSONObject();
                    successObj.put(Result.STATUS, PluginResult.Status.OK.ordinal());
                }
            } else {
                Log.d(TAG, "File " + url + " not available");
            }
        }

        if (successObj == null) {
            successObj = new JSONObject();
            successObj.put(Result.STATUS, PluginResult.Status.NO_RESULT.ordinal());
        }

        callbackContext.success(successObj);
    } else if (action.equals(Actions.GET_SUPPORT_INFO)) {
        JSONObject successObj = new JSONObject();
        JSONArray supported = new JSONArray();
        supported.put(PDF);
        successObj.put(Result.SUPPORTED, supported);
        callbackContext.success(successObj);
    } else {
        JSONObject errorObj = new JSONObject();
        errorObj.put(Result.STATUS, PluginResult.Status.INVALID_ACTION.ordinal());
        errorObj.put(Result.MESSAGE, "Invalid action '" + action + "'");
        callbackContext.error(errorObj);
    }
    return true;
}

From source file:com.odoo.addons.crm.models.CRMLead.java

/**
 * Setting reminder for lead/opportunity
 *
 * @param row_id//from   w  ww  .j av  a2  s  . c  o m
 */
public void setReminder(int row_id) {
    ODataRow row = browse(row_id);
    String time = " " + BaseSettings.getDayStartTime(mContext);
    Date now = new Date();
    Bundle extra = row.getPrimaryBundleData();
    extra.putString(ReminderUtils.KEY_REMINDER_TYPE, "opportunity");
    if (!row.getString("date_deadline").equals("false")) {
        row.put("date_deadline", row.getString("date_deadline") + time);
        Date date_deadline = ODateUtils.createDateObject(row.getString("date_deadline"),
                ODateUtils.DEFAULT_FORMAT, false);
        if (now.compareTo(date_deadline) < 0) {
            extra.putBoolean("expiry_date", true);
            if (ReminderUtils.get(mContext).resetReminder(date_deadline, extra)) {
                // Nothing to do. Reminder set for expiry date
            }
        }
    }

    if (!row.getString("date_action").equals("false")) {
        row.put("date_action", row.getString("date_action") + time);
        Date date_action = ODateUtils.createDateObject(row.getString("date_action"), ODateUtils.DEFAULT_FORMAT,
                false);
        if (now.compareTo(date_action) < 0) {
            extra.putBoolean("expiry_date", false);
            if (ReminderUtils.get(mContext).resetReminder(date_action, extra)) {
                // Nothing to do. Reminder set for next date action
            }
        }

    }
}

From source file:com.norman0406.slimgress.API.Game.GameState.java

public synchronized void intHandshake(final Handler handler) {
    mInterface.handshake(new Handshake.Callback() {
        @Override/*  www  .ja  v  a 2 s  .c  om*/
        public void handle(Handshake handshake) {
            mHandshake = handshake;
            mKnobs = mHandshake.getKnobs();

            Message msg = new Message();
            Bundle bundle = new Bundle();
            bundle.putBoolean("Successful", mHandshake.isValid());

            if (!mHandshake.isValid()) {
                String errString;
                if (mHandshake.getPregameStatus() == Handshake.PregameStatus.ClientMustUpgrade)
                    errString = "Client must upgrade";
                else if (mHandshake.getAgent() == null)
                    errString = "Invalid agent data";
                else
                    errString = "Unknown error";

                bundle.putString("Error", errString);
            }

            msg.setData(bundle);
            handler.sendMessage(msg);
        }
    });
}

From source file:key.secretkey.MainActivity.java

private void checkLocalRepository(File localDir) {
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    if (localDir != null && settings.getBoolean("repository_initialized", false)) {
        Log.d("PASS", "Check, dir: " + localDir.getAbsolutePath());
        // do not push the fragment if we already have it
        if (fragmentManager.findFragmentByTag("PasswordsList") == null
                || settings.getBoolean("repo_changed", false)) {
            settings.edit().putBoolean("repo_changed", false).apply();

            plist = new PasswordFragment();
            Bundle args = new Bundle();
            args.putString("Path",
                    PasswordStorage.getRepositoryDirectory(getApplicationContext()).getAbsolutePath());

            // if the activity was started from the autofill settings, the
            // intent is to match a clicked pwd with app. pass this to fragment
            if (getIntent().getBooleanExtra("matchWith", false)) {
                args.putBoolean("matchWith", true);
            }//from   w w  w .j  a va  2s  .  c om

            plist.setArguments(args);

            getSupportActionBar().show();
            getSupportActionBar().setDisplayHomeAsUpEnabled(false);

            fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);

            fragmentTransaction.replace(R.id.main_layout, plist, "PasswordsList");
            fragmentTransaction.commit();
        }
    } else {
        //            getSupportActionBar().hide();

        fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        //            Snackbar snack = Snackbar.make(findViewById(R.id.main_layout), "You fucked up, you shouldn't be here XD",
        //                    Snackbar.LENGTH_INDEFINITE);
        //            snack.show();

        createNewRepository();

        //            ToCloneOrNot cloneFrag = new ToCloneOrNot();
        //            fragmentTransaction.replace(R.id.main_layout, cloneFrag, "ToCloneOrNot");
        //            fragmentTransaction.commit();
    }
}

From source file:cn.finalteam.galleryfinal.PhotoEditActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putSerializable("selectPhotoMap", mSelectPhotoList);
    outState.putSerializable("editPhotoCacheFile", mEditPhotoCacheFile);
    outState.putSerializable("photoTempMap", mPhotoTempMap);

    outState.putInt("selectIndex", mSelectIndex);
    outState.putBoolean("cropState", mCropState);
    outState.putBoolean("rotating", mRotating);

    outState.putBoolean("takePhotoAction", mTakePhotoAction);
    outState.putBoolean("cropPhotoAction", mCropPhotoAction);
    outState.putBoolean("editPhotoAction", mEditPhotoAction);

}

From source file:com.bodeme.easycloud.syncadapter.EnterCredentialsFragment.java

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

    Bundle args = new Bundle();

    String url;//from  ww  w.ja va  2 s.com
    String username = editUserName.getText().toString();
    if (Constants.OWNCLOUD_URL == null) {
        url = editURL.getText().toString();
    } else {
        url = Constants.OWNCLOUD_URL;
    }

    if (url.charAt(url.length() - 1) != '/') {
        url = url + "/";
    }

    if (0 == typePosition) {
        url += "remote.php/caldav/principals/" + username + "/";
    } else {
        url += "remote.php/carddav/addressbooks/" + username + "/";
    }

    args.putString(QueryServerDialogFragment.EXTRA_BASE_URL, URIUtils.sanitize(url));
    args.putString(QueryServerDialogFragment.EXTRA_USER_NAME, username);
    args.putString(QueryServerDialogFragment.EXTRA_PASSWORD, editPassword.getText().toString());
    args.putBoolean(QueryServerDialogFragment.EXTRA_AUTH_PREEMPTIVE, true);

    DialogFragment dialog = new QueryServerDialogFragment();
    dialog.setArguments(args);
    dialog.show(ft, QueryServerDialogFragment.class.getName());
}

From source file:at.ac.tuwien.detlef.activities.MainActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);

    savedInstanceState.putBoolean(KEY_SHOW_PROGRESS_DIALOG, progressDialog.isShowing());
    savedInstanceState.putInt(KEY_NUM_POD_SYNC, numPodSync.get());
    savedInstanceState.putInt(KEY_CUR_POD_SYNC, curPodSync.get());
}

From source file:com.nearnotes.NoteEdit.java

/**
 * Populates the checkboxes on the side by analyzing the current text from
 * the body of the note.//ww w . ja v  a  2 s. com
 * 
 * @param currentString
 *            the current body of the note.
 * 
 */
public ArrayList<NoteRow> populateBoxes(String currentString) {

    // Load ArrayList<String> mLines with the current bodytext seperated into seperate lines.
    mLines = Arrays.asList(currentString.split(System.getProperty("line.separator")));

    // row counter to determine what the current line number is for the for loop
    int row = 0;

    // realRow counter to determine what line of text in the actual display we are on
    // used to get the number of characters on each line
    int realRow = 0;
    int activeRow = 0;
    int finishedCount = 0;

    ArrayList<NoteRow> tempRealRow = new ArrayList<NoteRow>();
    for (String line : mLines) {
        NoteRow temp = new NoteRow(0, 1, row); // Create a note row object with rowType of 0 (invisible), lineSize of 1 and the current row number

        if (!line.isEmpty()) {
            activeRow++;
            temp.setType(1); // Set the NoteRow object to 1 (visible)

            // Determine how many lines the note takes up
            int internalCounter = 0;
            try {
                float lineLength = (float) line.length();
                for (int k = 0; (lineLength
                        / (getFloatLineEnd(realRow + k) - getFloatLineEnd(realRow - 1))) > 1; k++) {
                    internalCounter++;
                }
            } catch (NullPointerException e) {
                e.printStackTrace();
            }

            // Detemine if the note is supposed to be checked and set the NoteRow object to 2 (Checked)
            if (line.startsWith("[X]")) {
                finishedCount++;
                int spanstart = 0;
                StrikethroughSpan STRIKE_THROUGH_SPAN = new StrikethroughSpan();
                Spannable spannable = (Spannable) mBodyText.getText();
                // TableRow checkRow1 = (TableRow) View.inflate(getActivity(), R.layout.table_row, null);

                for (int j = 0; j < row; j++) {
                    spanstart += mLines.get(j).length() + 1;
                }

                Object spansToRemove[] = spannable.getSpans(spanstart, spanstart + mLines.get(row).length(),
                        Object.class);
                for (Object span : spansToRemove) {
                    if (span instanceof CharacterStyle)
                        spannable.removeSpan(span);
                }

                spannable.setSpan(STRIKE_THROUGH_SPAN, spanstart, spanstart + mLines.get(row).length(),
                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                temp.setType(2);
            }

            temp.setSize(1 + internalCounter); // Set the amount of rows the note takes up
            realRow = realRow + internalCounter; // Determine the real line on the display text we are on
        }

        tempRealRow.add(temp); // NoteRow object has been finalized - add to the ListArray<NoteRow>
        realRow++; // Increase the noteRow and the displayRow for the next line
        row++;
    }

    if (finishedCount == activeRow && finishedCount != 0) {

        SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
        boolean useListPref = sharedPref.getBoolean("pref_key_use_checklist_default", false);
        String stringlistPref = sharedPref.getString("pref_key_checklist_listPref", "2");
        int listPref = Integer.parseInt(stringlistPref);

        ChecklistDialog newFragment = new ChecklistDialog();
        if (mRowId == null) {
            saveState();
        }
        Bundle args = new Bundle();
        args.putLong("_id", mRowId);
        args.putBoolean("useDefault", useListPref);
        args.putInt("listPref", listPref);
        newFragment.setArguments(args);
        if (listPref == 2 && useListPref) {
            return tempRealRow;
        }
        if (getFragmentManager().findFragmentByTag("MyDialog") == null) {
            newFragment.show(getFragmentManager(), "MyDialog");
        }

    }

    return tempRealRow;
}

From source file:co.taqat.call.assistant.AssistantActivity.java

public void displayAssistantCodeConfirm(String username, String phone, String dialcode,
        boolean recoverAccount) {
    CreateAccountCodeActivationFragment fragment = new CreateAccountCodeActivationFragment();
    newAccount = true;//from  ww w  .ja v a  2s .  c  o  m
    Bundle extras = new Bundle();
    extras.putString("Username", username);
    extras.putString("Phone", phone);
    extras.putString("Dialcode", dialcode);
    extras.putBoolean("RecoverAccount", recoverAccount);
    extras.putBoolean("LinkAccount", isLink);
    fragment.setArguments(extras);
    changeFragment(fragment);

    currentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT_CODE_ACTIVATION;
    back.setVisibility(View.INVISIBLE);
}

From source file:com.mci.firstidol.activity.MainActivity.java

private void obtainBaiduPushClickEvent(String customContentString) {
    // TODO Auto-generated method stub
    long articleId = 0, articleType = 0, channelId = 0, modelType = 0;
    // ??mykeymyvalue?
    if (!TextUtils.isEmpty(customContentString)) {
        JSONObject customJson = null;//w  w w.j ava2  s . c  o  m
        try {
            customJson = new JSONObject(customContentString);
            articleId = customJson.getLong("rel_id");
            articleType = customJson.getLong("rel_type");
            channelId = customJson.getLong("rel_channel");
            modelType = customJson.getLong("rel_modeltype");
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    // // Demo???
    // updateContent(context, notifyString);
    //
    //
    // Intent intent = new Intent();
    // intent.setClass(context.getApplicationContext(),
    // LoginActivity.class);
    // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    // context.getApplicationContext().startActivity(intent);

    // ?ChannelId  ModelType????
    // SquareLiveModel squareLiveModel = headers.get(position);
    if (channelId == 49) {// ?
        if (modelType == 2) {// ?
            Bundle bundle = new Bundle();
            bundle.putBoolean("IsVideo", true);
            bundle.putLong(Constant.IntentKey.articleID, articleId);
            Utily.go2Activity(context, SquareFoundDetailActivity.class, bundle, true);
        } else {// ?
            Bundle bundle = new Bundle();
            bundle.putLong(Constant.IntentKey.articleID, articleId);
            Utily.go2Activity(context, SquareFoundDetailActivity.class, bundle, true);
        }
    } else if (channelId == 44) {// 
        Bundle mbuBundle = new Bundle();
        mbuBundle.putBoolean(Constant.IntentKey.isSearch, true);
        mbuBundle.putSerializable(Constant.IntentKey.articleID, articleId);
        mbuBundle.putString(Constant.IntentKey.typeCode, Constant.IntentValue.ACTIVITY_SHOPPING);
        Utily.go2Activity(context, SquareWelfareDetailActivity.class, mbuBundle, true);
    } else if (channelId == 43) {// ?
        Bundle mbuBundle = new Bundle();
        mbuBundle.putBoolean(Constant.IntentKey.isSearch, true);
        mbuBundle.putSerializable(Constant.IntentKey.articleID, articleId);
        Utily.go2Activity(context, SquareWelfareDetailActivity.class, mbuBundle, true);
    } else if (channelId == 47) {// 
        Bundle mbuBundle = new Bundle();
        mbuBundle.putBoolean(Constant.IntentKey.isSearch, true);
        mbuBundle.putSerializable(Constant.IntentKey.articleID, articleId);
        Utily.go2Activity(context, SquareLiveActivity.class, mbuBundle, true);
    } else {// ,web
        Bundle mbuBundle = new Bundle();
        mbuBundle.putBoolean("IsFromFound", true);
        mbuBundle.putBoolean(Constant.IntentKey.isSearch, true);
        mbuBundle.putSerializable(Constant.IntentKey.articleID, articleId);
        Utily.go2Activity(context, SquareWelfareDetailActivity.class, mbuBundle, true);
    }
}