Example usage for android.text TextUtils join

List of usage examples for android.text TextUtils join

Introduction

In this page you can find the example usage for android.text TextUtils join.

Prototype

public static String join(@NonNull CharSequence delimiter, @NonNull Iterable tokens) 

Source Link

Document

Returns a string containing the tokens joined by delimiters.

Usage

From source file:com.eutectoid.dosomething.picker.PickerFragment.java

void saveSettingsToBundle(Bundle outState) {
    outState.putBoolean(SHOW_PICTURES_BUNDLE_KEY, showPictures);
    if (!extraFields.isEmpty()) {
        outState.putString(EXTRA_FIELDS_BUNDLE_KEY, TextUtils.join(",", extraFields));
    }//from   w w w . j  a  v a 2 s .c  om
    outState.putBoolean(SHOW_TITLE_BAR_BUNDLE_KEY, showTitleBar);
    outState.putString(TITLE_TEXT_BUNDLE_KEY, titleText);
    outState.putString(DONE_BUTTON_TEXT_BUNDLE_KEY, doneButtonText);
}

From source file:de.blinkt.openvpn.core.ConfigParser.java

@SuppressWarnings("ConstantConditions")
public VpnProfile convertProfile() throws ConfigParseError, IOException {
    boolean noauthtypeset = true;
    VpnProfile np = new VpnProfile(CONVERTED_PROFILE);
    // Pull, client, tls-client
    np.clearDefaults();//  w  w  w.  j  av  a 2  s.  com

    if (options.containsKey("client") || options.containsKey("pull")) {
        np.mUsePull = true;
        options.remove("pull");
        options.remove("client");
    }

    Vector<String> secret = getOption("secret", 1, 2);
    if (secret != null) {
        np.mAuthenticationType = VpnProfile.TYPE_STATICKEYS;
        noauthtypeset = false;
        np.mUseTLSAuth = true;
        np.mTLSAuthFilename = secret.get(1);
        if (secret.size() == 3)
            np.mTLSAuthDirection = secret.get(2);

    }

    Vector<Vector<String>> routes = getAllOption("route", 1, 4);
    if (routes != null) {
        String routeopt = "";
        String routeExcluded = "";
        for (Vector<String> route : routes) {
            String netmask = "255.255.255.255";
            String gateway = "vpn_gateway";

            if (route.size() >= 3)
                netmask = route.get(2);
            if (route.size() >= 4)
                gateway = route.get(3);

            String net = route.get(1);
            try {
                CIDRIP cidr = new CIDRIP(net, netmask);
                if (gateway.equals("net_gateway"))
                    routeExcluded += cidr.toString() + " ";
                else
                    routeopt += cidr.toString() + " ";
            } catch (ArrayIndexOutOfBoundsException aioob) {
                throw new ConfigParseError("Could not parse netmask of route " + netmask);
            } catch (NumberFormatException ne) {

                throw new ConfigParseError("Could not parse netmask of route " + netmask);
            }

        }
        np.mCustomRoutes = routeopt;
        np.mExcludedRoutes = routeExcluded;
    }

    Vector<Vector<String>> routesV6 = getAllOption("route-ipv6", 1, 4);
    if (routesV6 != null) {
        String customIPv6Routes = "";
        for (Vector<String> route : routesV6) {
            customIPv6Routes += route.get(1) + " ";
        }

        np.mCustomRoutesv6 = customIPv6Routes;
    }

    Vector<String> routeNoPull = getOption("route-nopull", 1, 1);
    if (routeNoPull != null)
        np.mRoutenopull = true;

    // Also recognize tls-auth [inline] direction ...
    Vector<Vector<String>> tlsauthoptions = getAllOption("tls-auth", 1, 2);
    if (tlsauthoptions != null) {
        for (Vector<String> tlsauth : tlsauthoptions) {
            if (tlsauth != null) {
                if (!tlsauth.get(1).equals("[inline]")) {
                    np.mTLSAuthFilename = tlsauth.get(1);
                    np.mUseTLSAuth = true;
                }
                if (tlsauth.size() == 3)
                    np.mTLSAuthDirection = tlsauth.get(2);
            }
        }
    }

    Vector<String> direction = getOption("key-direction", 1, 1);
    if (direction != null)
        np.mTLSAuthDirection = direction.get(1);

    Vector<Vector<String>> defgw = getAllOption("redirect-gateway", 0, 5);
    if (defgw != null) {
        np.mUseDefaultRoute = true;
        checkRedirectParameters(np, defgw);
    }

    Vector<Vector<String>> redirectPrivate = getAllOption("redirect-private", 0, 5);
    if (redirectPrivate != null) {
        checkRedirectParameters(np, redirectPrivate);
    }
    Vector<String> dev = getOption("dev", 1, 1);
    Vector<String> devtype = getOption("dev-type", 1, 1);

    if ((devtype != null && devtype.get(1).equals("tun")) || (dev != null && dev.get(1).startsWith("tun"))
            || (devtype == null && dev == null)) {
        //everything okay
    } else {
        throw new ConfigParseError("Sorry. Only tun mode is supported. See the FAQ for more detail");
    }

    Vector<String> mssfix = getOption("mssfix", 0, 1);

    if (mssfix != null) {
        if (mssfix.size() >= 2) {
            try {
                np.mMssFix = Integer.parseInt(mssfix.get(1));
            } catch (NumberFormatException e) {
                throw new ConfigParseError("Argument to --mssfix has to be an integer");
            }
        } else {
            np.mMssFix = 1450; // OpenVPN default size
        }
    }

    Vector<String> mode = getOption("mode", 1, 1);
    if (mode != null) {
        if (!mode.get(1).equals("p2p"))
            throw new ConfigParseError("Invalid mode for --mode specified, need p2p");
    }

    Vector<Vector<String>> dhcpoptions = getAllOption("dhcp-option", 2, 2);
    if (dhcpoptions != null) {
        for (Vector<String> dhcpoption : dhcpoptions) {
            String type = dhcpoption.get(1);
            String arg = dhcpoption.get(2);
            if (type.equals("DOMAIN")) {
                np.mSearchDomain = dhcpoption.get(2);
            } else if (type.equals("DNS")) {
                np.mOverrideDNS = true;
                if (np.mDNS1.equals(VpnProfile.DEFAULT_DNS1))
                    np.mDNS1 = arg;
                else
                    np.mDNS2 = arg;
            }
        }
    }

    Vector<String> ifconfig = getOption("ifconfig", 2, 2);
    if (ifconfig != null) {
        try {
            CIDRIP cidr = new CIDRIP(ifconfig.get(1), ifconfig.get(2));
            np.mIPv4Address = cidr.toString();
        } catch (NumberFormatException nfe) {
            throw new ConfigParseError("Could not pase ifconfig IP address: " + nfe.getLocalizedMessage());
        }

    }

    if (getOption("remote-random-hostname", 0, 0) != null)
        np.mUseRandomHostname = true;

    if (getOption("float", 0, 0) != null)
        np.mUseFloat = true;

    if (getOption("comp-lzo", 0, 1) != null)
        np.mUseLzo = true;

    Vector<String> cipher = getOption("cipher", 1, 1);
    if (cipher != null)
        np.mCipher = cipher.get(1);

    Vector<String> auth = getOption("auth", 1, 1);
    if (auth != null)
        np.mAuth = auth.get(1);

    Vector<String> ca = getOption("ca", 1, 1);
    if (ca != null) {
        np.mCaFilename = ca.get(1);
    }

    Vector<String> cert = getOption("cert", 1, 1);
    if (cert != null) {
        np.mClientCertFilename = cert.get(1);
        np.mAuthenticationType = VpnProfile.TYPE_CERTIFICATES;
        noauthtypeset = false;
    }
    Vector<String> key = getOption("key", 1, 1);
    if (key != null)
        np.mClientKeyFilename = key.get(1);

    Vector<String> pkcs12 = getOption("pkcs12", 1, 1);
    if (pkcs12 != null) {
        np.mPKCS12Filename = pkcs12.get(1);
        np.mAuthenticationType = VpnProfile.TYPE_KEYSTORE;
        noauthtypeset = false;
    }

    Vector<String> cryptoapicert = getOption("cryptoapicert", 1, 1);
    if (cryptoapicert != null) {
        np.mAuthenticationType = VpnProfile.TYPE_KEYSTORE;
        noauthtypeset = false;
    }

    Vector<String> compatnames = getOption("compat-names", 1, 2);
    Vector<String> nonameremapping = getOption("no-name-remapping", 1, 1);
    Vector<String> tlsremote = getOption("tls-remote", 1, 1);
    if (tlsremote != null) {
        np.mRemoteCN = tlsremote.get(1);
        np.mCheckRemoteCN = true;
        np.mX509AuthType = VpnProfile.X509_VERIFY_TLSREMOTE;

        if ((compatnames != null && compatnames.size() > 2) || (nonameremapping != null))
            np.mX509AuthType = VpnProfile.X509_VERIFY_TLSREMOTE_COMPAT_NOREMAPPING;
    }

    Vector<String> verifyx509name = getOption("verify-x509-name", 1, 2);
    if (verifyx509name != null) {
        np.mRemoteCN = verifyx509name.get(1);
        np.mCheckRemoteCN = true;
        if (verifyx509name.size() > 2) {
            if (verifyx509name.get(2).equals("name"))
                np.mX509AuthType = VpnProfile.X509_VERIFY_TLSREMOTE_RDN;
            else if (verifyx509name.get(2).equals("subject"))
                np.mX509AuthType = VpnProfile.X509_VERIFY_TLSREMOTE_DN;
            else if (verifyx509name.get(2).equals("name-prefix"))
                np.mX509AuthType = VpnProfile.X509_VERIFY_TLSREMOTE_RDN_PREFIX;
            else
                throw new ConfigParseError("Unknown parameter to verify-x509-name: " + verifyx509name.get(2));
        } else {
            np.mX509AuthType = VpnProfile.X509_VERIFY_TLSREMOTE_DN;
        }

    }

    Vector<String> x509usernamefield = getOption("x509-username-field", 1, 1);
    if (x509usernamefield != null) {
        np.mx509UsernameField = x509usernamefield.get(1);
    }

    Vector<String> verb = getOption("verb", 1, 1);
    if (verb != null) {
        np.mVerb = verb.get(1);
    }

    if (getOption("nobind", 0, 0) != null)
        np.mNobind = true;

    if (getOption("persist-tun", 0, 0) != null)
        np.mPersistTun = true;

    if (getOption("push-peer-info", 0, 0) != null)
        np.mPushPeerInfo = true;

    Vector<String> connectretry = getOption("connect-retry", 1, 2);
    if (connectretry != null) {
        np.mConnectRetry = connectretry.get(1);
        if (connectretry.size() > 2)
            np.mConnectRetryMaxTime = connectretry.get(2);
    }

    Vector<String> connectretrymax = getOption("connect-retry-max", 1, 1);
    if (connectretrymax != null)
        np.mConnectRetryMax = connectretrymax.get(1);

    Vector<Vector<String>> remotetls = getAllOption("remote-cert-tls", 1, 1);
    if (remotetls != null)
        if (remotetls.get(0).get(1).equals("server"))
            np.mExpectTLSCert = true;
        else
            options.put("remotetls", remotetls);

    Vector<String> authuser = getOption("auth-user-pass", 0, 1);

    if (authuser != null) {
        if (noauthtypeset) {
            np.mAuthenticationType = VpnProfile.TYPE_USERPASS;
        } else if (np.mAuthenticationType == VpnProfile.TYPE_CERTIFICATES) {
            np.mAuthenticationType = VpnProfile.TYPE_USERPASS_CERTIFICATES;
        } else if (np.mAuthenticationType == VpnProfile.TYPE_KEYSTORE) {
            np.mAuthenticationType = VpnProfile.TYPE_USERPASS_KEYSTORE;
        }
        if (authuser.size() > 1) {
            if (!authuser.get(1).startsWith(VpnProfile.INLINE_TAG))
                auth_user_pass_file = authuser.get(1);
            np.mUsername = null;
            useEmbbedUserAuth(np, authuser.get(1));
        }
    }

    Vector<String> crlfile = getOption("crl-verify", 1, 2);
    if (crlfile != null) {
        // If the 'dir' parameter is present just add it as custom option ..
        if (crlfile.size() == 3 && crlfile.get(2).equals("dir"))
            np.mCustomConfigOptions += TextUtils.join(" ", crlfile) + "\n";
        else
            // Save the filename for the config converter to add later
            np.mCrlFilename = crlfile.get(1);

    }

    Pair<Connection, Connection[]> conns = parseConnectionOptions(null);
    np.mConnections = conns.second;

    Vector<Vector<String>> connectionBlocks = getAllOption("connection", 1, 1);

    if (np.mConnections.length > 0 && connectionBlocks != null) {
        throw new ConfigParseError("Using a <connection> block and --remote is not allowed.");
    }

    if (connectionBlocks != null) {
        np.mConnections = new Connection[connectionBlocks.size()];

        int connIndex = 0;
        for (Vector<String> conn : connectionBlocks) {
            Pair<Connection, Connection[]> connectionBlockConnection = parseConnection(conn.get(1),
                    conns.first);

            if (connectionBlockConnection.second.length != 1)
                throw new ConfigParseError("A <connection> block must have exactly one remote");
            np.mConnections[connIndex] = connectionBlockConnection.second[0];
            connIndex++;
        }
    }
    if (getOption("remote-random", 0, 0) != null)
        np.mRemoteRandom = true;

    Vector<String> protoforce = getOption("proto-force", 1, 1);
    if (protoforce != null) {
        boolean disableUDP;
        String protoToDisable = protoforce.get(1);
        if (protoToDisable.equals("udp"))
            disableUDP = true;
        else if (protoToDisable.equals("tcp"))
            disableUDP = false;
        else
            throw new ConfigParseError(String.format("Unknown protocol %s in proto-force", protoToDisable));

        for (Connection conn : np.mConnections)
            if (conn.mUseUdp == disableUDP)
                conn.mEnabled = false;
    }

    // Parse OpenVPN Access Server extra
    Vector<String> friendlyname = meta.get("FRIENDLY_NAME");
    if (friendlyname != null && friendlyname.size() > 1)
        np.mName = friendlyname.get(1);

    Vector<String> ocusername = meta.get("USERNAME");
    if (ocusername != null && ocusername.size() > 1)
        np.mUsername = ocusername.get(1);

    checkIgnoreAndInvalidOptions(np);
    fixup(np);

    return np;
}

From source file:com.microsoft.services.msa.LiveAuthClient.java

/**
 * Refreshes the previously created session.
 *
 * @return true if the session was successfully refreshed.
 *///from   w w w  .j  av  a 2 s  .  c o m
Boolean tryRefresh(Iterable<String> scopes) {

    String scope = TextUtils.join(OAuth.SCOPE_DELIMITER, scopes);
    String refreshToken = this.session.getRefreshToken();

    if (TextUtils.isEmpty(refreshToken)) {
        Log.i(TAG, "No refresh token available, sorry!");
        return false;
    }

    Log.i(TAG, "Refresh token found, attempting to refresh access and refresh tokens.");
    RefreshAccessTokenRequest request = new RefreshAccessTokenRequest(this.httpClient, this.clientId,
            refreshToken, scope, mOAuthConfig);

    OAuthResponse response;
    try {
        response = request.execute();
    } catch (LiveAuthException e) {
        return false;
    }

    SessionRefresher refresher = new SessionRefresher(this.session);
    response.accept(refresher);
    response.accept(new RefreshTokenWriter());

    return refresher.visitedSuccessfulResponse();
}

From source file:org.thoughtland.xlocation.Util.java

public static Method getMethod(Class<?> clazz, String name, Object[] args) {
    Util.log(null, Log.DEBUG, "Looking for " + name);
    for (Method m : clazz.getDeclaredMethods()) {
        Util.log(null, Log.DEBUG, "Got method " + clazz.getSimpleName() + "." + m.getName() + "( "
                + TextUtils.join(", ", m.getParameterTypes()) + " )");
        if (m.getName().equals(name)) {
            Util.log(null, Log.DEBUG, "  names match!");
            if (args == null)
                return m;
            Class<?>[] params = m.getParameterTypes();
            if (params.length == args.length) {
                Util.log(null, Log.DEBUG, "  params length match!");
                boolean matches = true;
                for (int i = 0; i < params.length; i++) {
                    if (args[i] != null && !params[i].isInstance(args[i])) {
                        Util.log(null, Log.DEBUG, "  param[" + i + "] " + args[i].getClass().getName()
                                + " does not match type " + params[i].getSimpleName());
                        matches = false;
                        break;
                    }/*from w w  w . j  a va 2s . c o  m*/
                }
                if (matches) {
                    Util.log(null, Log.DEBUG, "Found match for " + name);
                    return m;
                }
            }
        }
    }
    return null;
}

From source file:com.facebook.Request.java

/**
 * Creates a new Request configured to post a status update to a user's feed.
 *
 * @param session/*from   w  w  w.  j  ava2 s  .co m*/
 *            the Session to use, or null; if non-null, the session must be in an opened state
 * @param message
 *            the text of the status update
 * @param placeId
 *            an optional place id to associate with the post
 * @param tagIds
 *            an optional list of user ids to tag in the post
 * @param callback
 *            a callback that will be called when the request is completed to handle success or error conditions
 * @return a Request that is ready to execute
 */
private static Request newStatusUpdateRequest(Session session, String message, String placeId,
        List<String> tagIds, Callback callback) {

    Bundle parameters = new Bundle();
    parameters.putString("message", message);

    if (placeId != null) {
        parameters.putString("place", placeId);
    }

    if (tagIds != null && tagIds.size() > 0) {
        String tags = TextUtils.join(",", tagIds);
        parameters.putString("tags", tags);
    }

    return new Request(session, MY_FEED, parameters, HttpMethod.POST, callback);
}

From source file:io.github.hidroh.materialistic.AppUtils.java

private static Intent makeShareIntent(String subject, String text) {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT,//w w w. j a v a 2 s .com
            !TextUtils.isEmpty(subject) ? TextUtils.join(" - ", new String[] { subject, text }) : text);
    return intent;
}

From source file:com.ichi2.libanki.Finder.java

private String _findTemplate(String val) {
    // were we given an ordinal number?
    Integer num = null;/*from  w w w  .ja v  a2s . co  m*/
    try {
        num = Integer.parseInt(val) - 1;
    } catch (NumberFormatException e) {
        num = null;
    }
    if (num != null) {
        return "c.ord = " + num;
    }
    // search for template names
    List<String> lims = new ArrayList<String>();
    try {
        for (JSONObject m : mCol.getModels().all()) {
            JSONArray tmpls = m.getJSONArray("tmpls");
            for (int ti = 0; ti < tmpls.length(); ++ti) {
                JSONObject t = tmpls.getJSONObject(ti);
                if (t.getString("name").equalsIgnoreCase(val)) {
                    if (m.getInt("type") == Consts.MODEL_CLOZE) {
                        // if the user has asked for a cloze card, we want
                        // to give all ordinals, so we just limit to the
                        // model instead
                        lims.add("(n.mid = " + m.getLong("id") + ")");
                    } else {
                        lims.add("(n.mid = " + m.getLong("id") + " and c.ord = " + t.getInt("ord") + ")");
                    }
                }
            }
        }
    } catch (JSONException e) {
        throw new RuntimeException(e);
    }
    return TextUtils.join(" or ", lims.toArray(new String[lims.size()]));
}

From source file:org.totschnig.myexpenses.fragment.CategoryList.java

@Override
public boolean dispatchCommandMultiple(int command, SparseBooleanArray positions, Long[] itemIds) {
    ManageCategories ctx = (ManageCategories) getActivity();
    ArrayList<Long> idList;
    switch (command) {
    case R.id.DELETE_COMMAND:
        int mappedTransactionsCount = 0, mappedTemplatesCount = 0, hasChildrenCount = 0;
        idList = new ArrayList<>();
        for (int i = 0; i < positions.size(); i++) {
            Cursor c;// ww w .  j a  v a2 s . co  m
            if (positions.valueAt(i)) {
                boolean deletable = true;
                int position = positions.keyAt(i);
                long pos = mListView.getExpandableListPosition(position);
                int type = ExpandableListView.getPackedPositionType(pos);
                int group = ExpandableListView.getPackedPositionGroup(pos),
                        child = ExpandableListView.getPackedPositionChild(pos);
                if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
                    c = mAdapter.getChild(group, child);
                    c.moveToPosition(child);
                } else {
                    c = mGroupCursor;
                    c.moveToPosition(group);
                }
                long itemId = c.getLong(c.getColumnIndex(KEY_ROWID));
                Bundle extras = ctx.getIntent().getExtras();
                if ((extras != null && extras.getLong(KEY_ROWID) == itemId)
                        || c.getInt(c.getColumnIndex(DatabaseConstants.KEY_MAPPED_TRANSACTIONS)) > 0) {
                    mappedTransactionsCount++;
                    deletable = false;
                } else if (c.getInt(c.getColumnIndex(DatabaseConstants.KEY_MAPPED_TEMPLATES)) > 0) {
                    mappedTemplatesCount++;
                    deletable = false;
                }
                if (deletable) {
                    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP
                            && c.getInt(c.getColumnIndex(KEY_CHILD_COUNT)) > 0) {
                        hasChildrenCount++;
                    }
                    idList.add(itemId);
                }
            }
        }
        if (!idList.isEmpty()) {
            Long[] objectIds = idList.toArray(new Long[idList.size()]);
            if (hasChildrenCount > 0) {
                MessageDialogFragment
                        .newInstance(R.string.dialog_title_warning_delete_main_category,
                                getResources().getQuantityString(R.plurals.warning_delete_main_category,
                                        hasChildrenCount, hasChildrenCount),
                                new MessageDialogFragment.Button(android.R.string.yes, R.id.DELETE_COMMAND_DO,
                                        objectIds),
                                null,
                                new MessageDialogFragment.Button(android.R.string.no,
                                        R.id.CANCEL_CALLBACK_COMMAND, null))
                        .show(ctx.getSupportFragmentManager(), "DELETE_CATEGORY");
            } else {
                ctx.dispatchCommand(R.id.DELETE_COMMAND_DO, objectIds);
            }
        }
        if (mappedTransactionsCount > 0 || mappedTemplatesCount > 0) {
            String message = "";
            if (mappedTransactionsCount > 0)
                message += getResources().getQuantityString(R.plurals.not_deletable_mapped_transactions,
                        mappedTransactionsCount, mappedTransactionsCount);
            if (mappedTemplatesCount > 0)
                message += getResources().getQuantityString(R.plurals.not_deletable_mapped_templates,
                        mappedTemplatesCount, mappedTemplatesCount);
            Toast.makeText(getActivity(), message, Toast.LENGTH_LONG).show();
        }
        return true;
    case R.id.SELECT_COMMAND_MULTIPLE:
        ArrayList<String> labelList = new ArrayList<>();
        for (int i = 0; i < positions.size(); i++) {
            Cursor c;
            if (positions.valueAt(i)) {
                int position = positions.keyAt(i);
                long pos = mListView.getExpandableListPosition(position);
                int type = ExpandableListView.getPackedPositionType(pos);
                int group = ExpandableListView.getPackedPositionGroup(pos),
                        child = ExpandableListView.getPackedPositionChild(pos);
                if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
                    c = mAdapter.getChild(group, child);
                    c.moveToPosition(child);
                } else {
                    c = mGroupCursor;
                    c.moveToPosition(group);
                }
                labelList.add(c.getString(c.getColumnIndex(KEY_LABEL)));
            }
        }
        Intent intent = new Intent();
        intent.putExtra(KEY_CATID, ArrayUtils.toPrimitive(itemIds));
        intent.putExtra(KEY_LABEL, TextUtils.join(",", labelList));
        ctx.setResult(ManageCategories.RESULT_FIRST_USER, intent);
        ctx.finish();
        return true;
    case R.id.MOVE_COMMAND:
        final Long[] excludedIds;
        final boolean inGroup = expandableListSelectionType == ExpandableListView.PACKED_POSITION_TYPE_GROUP;
        if (inGroup) {
            excludedIds = itemIds;
        } else {
            idList = new ArrayList<>();
            for (int i = 0; i < positions.size(); i++) {
                if (positions.valueAt(i)) {
                    int position = positions.keyAt(i);
                    long pos = mListView.getExpandableListPosition(position);
                    int group = ExpandableListView.getPackedPositionGroup(pos);
                    mGroupCursor.moveToPosition(group);
                    idList.add(mGroupCursor.getLong(mGroupCursor.getColumnIndex(KEY_ROWID)));
                }
            }
            excludedIds = idList.toArray(new Long[idList.size()]);
        }
        Bundle args = new Bundle(3);
        args.putBoolean(SelectMainCategoryDialogFragment.KEY_WITH_ROOT, !inGroup);
        args.putLongArray(SelectMainCategoryDialogFragment.KEY_EXCLUDED_ID,
                ArrayUtils.toPrimitive(excludedIds));
        args.putLongArray(TaskExecutionFragment.KEY_OBJECT_IDS, ArrayUtils.toPrimitive(itemIds));
        SelectMainCategoryDialogFragment.newInstance(args).show(getFragmentManager(), "SELECT_TARGET");
        return true;
    }
    return false;
}

From source file:com.android.mail.providers.Attachment.java

public String toJoinedString() {
    return TextUtils.join(UIProvider.ATTACHMENT_INFO_DELIMITER, Lists.newArrayList(partId == null ? "" : partId,
            name == null ? ""
                    : name.replaceAll("[" + UIProvider.ATTACHMENT_INFO_DELIMITER
                            + UIProvider.ATTACHMENT_INFO_SEPARATOR + "]", ""),
            getContentType(), String.valueOf(size), getContentType(),
            contentUri != null ? SERVER_ATTACHMENT : LOCAL_FILE,
            contentUri != null ? contentUri.toString() : "", "" /* cachedFileUri */, String.valueOf(type)));
}

From source file:com.abcvoipsip.ui.SipHome.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case ACCOUNTS_MENU:
        startActivity(new Intent(this, AccountsEditList.class));
        return true;
    case PARAMS_MENU:
        startActivity(new Intent(this, MainPrefs.class));
        return true;
    case CLOSE_MENU:
        Log.d(THIS_FILE, "CLOSE");
        if (prefProviderWrapper.isValidConnectionForIncoming()) {
            // Alert user that we will disable for all incoming calls as
            // he want to quit
            new AlertDialog.Builder(this).setTitle(R.string.warning)
                    .setMessage(getString(R.string.disconnect_and_incoming_explaination))
                    .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            // prefWrapper.disableAllForIncoming();
                            prefProviderWrapper.setPreferenceBooleanValue(PreferencesWrapper.HAS_BEEN_QUIT,
                                    true);
                            disconnectAndQuit();
                        }//from  w w  w.j  a  v a2 s  . co  m
                    }).setNegativeButton(R.string.cancel, null).show();
        } else {
            ArrayList<String> networks = prefProviderWrapper.getAllIncomingNetworks();
            if (networks.size() > 0) {
                String msg = getString(R.string.disconnect_and_will_restart, TextUtils.join(", ", networks));
                Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
            }
            disconnectAndQuit();
        }
        return true;
    case HELP_MENU:
        // Create the fragment and show it as a dialog.
        DialogFragment newFragment = Help.newInstance();
        newFragment.show(getSupportFragmentManager(), "dialog");
        return true;
    case DISTRIB_ACCOUNT_SIGNUP_MENU:
        // Open the signup page
        Intent itt = new Intent(Intent.ACTION_VIEW);
        itt.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        itt.setData(Uri.parse("http://m.abc-voip.com/#page2"));
        startActivity(itt);
        return true;
    case DISTRIB_ACCOUNT_MENU:
        WizardInfo distribWizard = CustomDistribution.getCustomDistributionWizard();

        Cursor c = getContentResolver().query(SipProfile.ACCOUNT_URI, new String[] { SipProfile.FIELD_ID },
                SipProfile.FIELD_WIZARD + "=?", new String[] { distribWizard.id }, null);

        Intent it = new Intent(this, BasePrefsWizard.class);
        it.putExtra(SipProfile.FIELD_WIZARD, distribWizard.id);
        Long accountId = null;
        if (c != null && c.getCount() > 0) {
            try {
                c.moveToFirst();
                accountId = c.getLong(c.getColumnIndex(SipProfile.FIELD_ID));
            } catch (Exception e) {
                Log.e(THIS_FILE, "Error while getting wizard", e);
            } finally {
                c.close();
            }
        }
        if (accountId != null) {
            it.putExtra(SipProfile.FIELD_ID, accountId);
        }
        startActivityForResult(it, REQUEST_EDIT_DISTRIBUTION_ACCOUNT);

        return true;
    default:
        break;
    }
    return super.onOptionsItemSelected(item);
}