List of usage examples for android.text TextUtils join
public static String join(@NonNull CharSequence delimiter, @NonNull Iterable tokens)
From source file:cn.com.loopj.android.http.PersistentCookieStore.java
@Override public void addCookie(Cookie cookie) { if (omitNonPersistentCookies && !cookie.isPersistent()) return;/*from w ww .j ava 2 s.c om*/ String name = cookie.getName() + cookie.getDomain(); // Save cookie into local store, or remove if expired if (!cookie.isExpired(new Date())) { cookies.put(name, cookie); } else { cookies.remove(name); } // Save cookie into persistent store SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie))); prefsWriter.commit(); }
From source file:eu.faircode.netguard.Receiver.java
public static void notifyNewApplication(int uid, Context context) { if (uid < 0) return;//from w ww. j a va 2 s . c o m SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); try { // Get application info String name = TextUtils.join(", ", Util.getApplicationNames(uid, context)); // Get application info PackageManager pm = context.getPackageManager(); String[] packages = pm.getPackagesForUid(uid); if (packages == null || packages.length < 1) throw new PackageManager.NameNotFoundException(Integer.toString(uid)); boolean internet = Util.hasInternet(uid, context); // Build notification Intent main = new Intent(context, ActivityMain.class); main.putExtra(ActivityMain.EXTRA_REFRESH, true); main.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(uid)); PendingIntent pi = PendingIntent.getActivity(context, uid, main, PendingIntent.FLAG_UPDATE_CURRENT); Util.setTheme(context); TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_security_white_24dp).setContentIntent(pi).setColor(tv.data) .setAutoCancel(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) builder.setContentTitle(name).setContentText(context.getString(R.string.msg_installed_n)); else builder.setContentTitle(context.getString(R.string.app_name)) .setContentText(context.getString(R.string.msg_installed, name)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_STATUS).setVisibility(Notification.VISIBILITY_SECRET); } // Get defaults SharedPreferences prefs_wifi = context.getSharedPreferences("wifi", Context.MODE_PRIVATE); SharedPreferences prefs_other = context.getSharedPreferences("other", Context.MODE_PRIVATE); boolean wifi = prefs_wifi.getBoolean(packages[0], prefs.getBoolean("whitelist_wifi", true)); boolean other = prefs_other.getBoolean(packages[0], prefs.getBoolean("whitelist_other", true)); // Build Wi-Fi action Intent riWifi = new Intent(context, ServiceSinkhole.class); riWifi.putExtra(ServiceSinkhole.EXTRA_COMMAND, ServiceSinkhole.Command.set); riWifi.putExtra(ServiceSinkhole.EXTRA_NETWORK, "wifi"); riWifi.putExtra(ServiceSinkhole.EXTRA_UID, uid); riWifi.putExtra(ServiceSinkhole.EXTRA_PACKAGE, packages[0]); riWifi.putExtra(ServiceSinkhole.EXTRA_BLOCKED, !wifi); PendingIntent piWifi = PendingIntent.getService(context, uid, riWifi, PendingIntent.FLAG_UPDATE_CURRENT); builder.addAction(wifi ? R.drawable.wifi_on : R.drawable.wifi_off, context.getString(wifi ? R.string.title_allow : R.string.title_block), piWifi); // Build mobile action Intent riOther = new Intent(context, ServiceSinkhole.class); riOther.putExtra(ServiceSinkhole.EXTRA_COMMAND, ServiceSinkhole.Command.set); riOther.putExtra(ServiceSinkhole.EXTRA_NETWORK, "other"); riOther.putExtra(ServiceSinkhole.EXTRA_UID, uid); riOther.putExtra(ServiceSinkhole.EXTRA_PACKAGE, packages[0]); riOther.putExtra(ServiceSinkhole.EXTRA_BLOCKED, !other); PendingIntent piOther = PendingIntent.getService(context, uid + 10000, riOther, PendingIntent.FLAG_UPDATE_CURRENT); builder.addAction(other ? R.drawable.other_on : R.drawable.other_off, context.getString(other ? R.string.title_allow : R.string.title_block), piOther); // Show notification if (internet) NotificationManagerCompat.from(context).notify(uid, builder.build()); else { NotificationCompat.BigTextStyle expanded = new NotificationCompat.BigTextStyle(builder); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) expanded.bigText(context.getString(R.string.msg_installed_n)); else expanded.bigText(context.getString(R.string.msg_installed, name)); expanded.setSummaryText(context.getString(R.string.title_internet)); NotificationManagerCompat.from(context).notify(uid, expanded.build()); } } catch (PackageManager.NameNotFoundException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } }
From source file:android_network.hetnet.vpn_service.Receiver.java
public static void notifyNewApplication(int uid, Context context) { if (uid < 0) return;/*from w w w . j a va2 s .c om*/ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); try { // Get application info String name = TextUtils.join(", ", Util.getApplicationNames(uid, context)); // Get application info PackageManager pm = context.getPackageManager(); String[] packages = pm.getPackagesForUid(uid); if (packages == null || packages.length < 1) throw new PackageManager.NameNotFoundException(Integer.toString(uid)); boolean internet = Util.hasInternet(uid, context); // Build notification Intent main = new Intent(context, MainActivity.class); main.putExtra(MainActivity.EXTRA_REFRESH, true); main.putExtra(MainActivity.EXTRA_SEARCH, Integer.toString(uid)); PendingIntent pi = PendingIntent.getActivity(context, uid, main, PendingIntent.FLAG_UPDATE_CURRENT); Util.setTheme(context); TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_security_white_24dp).setContentIntent(pi).setColor(tv.data) .setAutoCancel(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) builder.setContentTitle(name).setContentText(context.getString(R.string.msg_installed_n)); else builder.setContentTitle(context.getString(R.string.app_name)) .setContentText(context.getString(R.string.msg_installed, name)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_STATUS).setVisibility(Notification.VISIBILITY_SECRET); } // Get defaults SharedPreferences prefs_wifi = context.getSharedPreferences("wifi", Context.MODE_PRIVATE); SharedPreferences prefs_other = context.getSharedPreferences("other", Context.MODE_PRIVATE); boolean wifi = prefs_wifi.getBoolean(packages[0], prefs.getBoolean("whitelist_wifi", true)); boolean other = prefs_other.getBoolean(packages[0], prefs.getBoolean("whitelist_other", true)); // Build Wi-Fi action Intent riWifi = new Intent(context, ServiceSinkhole.class); riWifi.putExtra(ServiceSinkhole.EXTRA_COMMAND, ServiceSinkhole.Command.set); riWifi.putExtra(ServiceSinkhole.EXTRA_NETWORK, "wifi"); riWifi.putExtra(ServiceSinkhole.EXTRA_UID, uid); riWifi.putExtra(ServiceSinkhole.EXTRA_PACKAGE, packages[0]); riWifi.putExtra(ServiceSinkhole.EXTRA_BLOCKED, !wifi); PendingIntent piWifi = PendingIntent.getService(context, uid, riWifi, PendingIntent.FLAG_UPDATE_CURRENT); builder.addAction(wifi ? R.drawable.wifi_on : R.drawable.wifi_off, context.getString(wifi ? R.string.title_allow : R.string.title_block), piWifi); // Build mobile action Intent riOther = new Intent(context, ServiceSinkhole.class); riOther.putExtra(ServiceSinkhole.EXTRA_COMMAND, ServiceSinkhole.Command.set); riOther.putExtra(ServiceSinkhole.EXTRA_NETWORK, "other"); riOther.putExtra(ServiceSinkhole.EXTRA_UID, uid); riOther.putExtra(ServiceSinkhole.EXTRA_PACKAGE, packages[0]); riOther.putExtra(ServiceSinkhole.EXTRA_BLOCKED, !other); PendingIntent piOther = PendingIntent.getService(context, uid + 10000, riOther, PendingIntent.FLAG_UPDATE_CURRENT); builder.addAction(other ? R.drawable.other_on : R.drawable.other_off, context.getString(other ? R.string.title_allow : R.string.title_block), piOther); // Show notification if (internet) NotificationManagerCompat.from(context).notify(uid, builder.build()); else { NotificationCompat.BigTextStyle expanded = new NotificationCompat.BigTextStyle(builder); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) expanded.bigText(context.getString(R.string.msg_installed_n)); else expanded.bigText(context.getString(R.string.msg_installed, name)); expanded.setSummaryText(context.getString(R.string.title_internet)); NotificationManagerCompat.from(context).notify(uid, expanded.build()); } } catch (PackageManager.NameNotFoundException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } }
From source file:com.blazeroni.reddit.http.PersistentCookieStore.java
@Override public void addCookie(Cookie cookie) { String name = cookie.getName(); Date expiryDate = cookie.getExpiryDate(); if (Log.DEBUG) { Log.debug("cookie value: " + cookie.getValue()); Log.debug("Expiry date: " + (expiryDate == null ? "no expiry date" : expiryDate.toLocaleString())); Log.debug("persistent: " + cookie.isPersistent()); Log.debug("Cookie class: " + cookie.getClass().getCanonicalName()); }// ww w . j a va 2 s . c o m // Save cookie into local store this.cookies.put(name, cookie); // Save cookie into persistent store SharedPreferences.Editor prefsWriter = this.cookiePrefs.edit(); prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", this.cookies.keySet())); prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie))); prefsWriter.commit(); }
From source file:com.android.messaging.FakeContentProvider.java
@Override public Cursor query(final Uri uri, final String[] projection, final String selection, final String[] selectionArgs, final String sortOrder) { LogUtil.w(LogUtil.BUGLE_TAG,/*from w ww. java 2 s . co m*/ "FakeContentProvider: query " + uri.toString() + " for " + (projection == null ? null : TextUtils.join(",", projection)) + " where " + selection + " with " + (selectionArgs == null ? null : TextUtils.join(";", selectionArgs))); for (final ContentOverride content : mOverrides) { if (content.match(uri.toString(), selection, selectionArgs)) { return new FakeCursor(projection, content.columns, content.data); } } if (mProvider != null) { try { LogUtil.w(LogUtil.BUGLE_TAG, "FakeContentProvider: delgating"); final Cursor cursor = mProvider.query(uri, projection, selection, selectionArgs, sortOrder); LogUtil.w(LogUtil.BUGLE_TAG, "FakeContentProvider: response size " + cursor.getCount() + " contains " + TextUtils.join(",", cursor.getColumnNames()) + " type(0) " + cursor.getType(0)); return cursor; } catch (final RemoteException e) { e.printStackTrace(); } } return null; }
From source file:com.android.yijiang.kzx.http.PersistentCookieStore.java
@Override public void addCookie(Cookie cookie) { if (omitNonPersistentCookies && !cookie.isPersistent()) return;/*from w w w . j a v a 2 s. c o m*/ // String name = cookie.getName() + cookie.getDomain(); String name = cookie.getName(); // Save cookie into local store, or remove if expired if (!cookie.isExpired(new Date())) { cookies.put(name, cookie); } else { cookies.remove(name); } // Save cookie into persistent store SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie))); prefsWriter.commit(); }
From source file:net.kjmaster.cookiemom.settings.SettingsFragment.java
private void createHooks() { setting_custom_cookie_check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override//w w w .j a v a 2s.c o m public void onCheckedChanged(CompoundButton compoundButton, boolean b) { iSettings.useCustomCookies().put(b); setting_cookie_list.setEnabled(b); settings_edit_cookie.setEnabled(b); setting_save_cookie.setEnabled(b); if (!b) { String[] cookies = getResources().getStringArray(R.array.cookie_names_array); if (!TextUtils.join(",", cookies).equals(iSettings.CookieList().get())) { for (int i = 0; i < Constants.CookieTypes.length; i++) { String cookieType = Constants.CookieTypes[i]; SettingsActivity settingsActivity = (SettingsActivity) getActivity(); settingsActivity.SaveCookie(cookieType, cookies[i]); } } } } }); settings_auot_fill_cases_check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { iSettings.useAutoFillCases().put(b); } }); setting_cookie_list.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { settings_edit_cookie.setEnabled(true); if (adapterView.getSelectedItem() != null) { itemSelected = adapterView.getSelectedItem().toString(); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { settings_edit_cookie.setEnabled(false); } }); }
From source file:com.coffeecups.testproject.FriendPickerSampleActivity.java
private void displaySelectedFriends(int resultCode) { String results = ""; FriendPickerApplication application = (FriendPickerApplication) getApplication(); Collection<GraphUser> selection = application.getSelectedUsers(); if (selection != null && selection.size() > 0) { ArrayList<String> names = new ArrayList<String>(); for (GraphUser user : selection) { names.add(user.getName());//from w w w . j a va2s . c o m } results = TextUtils.join(", ", names); } else { results = "<No friends selected>"; } resultsTextView.setText(results); }
From source file:com.ab.http.PersistentCookieStore.java
/** * ??TODO/*from w ww . j a v a 2s . com*/ * @see org.apache.http.client.CookieStore#addCookie(org.apache.http.cookie.Cookie) * @author: zhaoqp * @date2013-10-22 ?4:23:15 * @version v1.0 */ @Override public void addCookie(Cookie cookie) { String name = cookie.getName() + cookie.getDomain(); // Save cookie into local store, or remove if expired if (!cookie.isExpired(new Date())) { cookies.put(name, cookie); } else { cookies.remove(name); } // Save cookie into persistent store SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie))); prefsWriter.commit(); }
From source file:org.totschnig.myexpenses.dialog.SelectFromMappedTableDialogFragment.java
@Override public void onClick(DialogInterface dialog, int which) { if (getActivity() == null || mCursor == null) { return;//from w w w.ja v a 2 s . c o m } ListView listView = ((AlertDialog) dialog).getListView(); SparseBooleanArray positions = listView.getCheckedItemPositions(); long[] itemIds = listView.getCheckedItemIds(); if (itemIds.length > 0) { ArrayList<String> labelList = new ArrayList<>(); for (int i = 0; i < positions.size(); i++) { if (positions.valueAt(i)) { mCursor.moveToPosition(positions.keyAt(i)); labelList.add(mCursor.getString(mCursor.getColumnIndex(KEY_LABEL))); } } ((MyExpenses) getActivity()).addFilterCriteria(getCommand(), makeCriteria(TextUtils.join(",", labelList), itemIds)); } dismiss(); }