List of usage examples for android.net Uri encode
public static String encode(String s)
From source file:com.securecomcode.text.contacts.ContactAccessor.java
public Collection<ContactData> getContactsWithPush(Context context) { final ContentResolver resolver = context.getContentResolver(); final String[] inProjection = new String[] { PhoneLookup._ID, PhoneLookup.DISPLAY_NAME }; List<String> pushNumbers = Directory.getInstance(context).getActiveNumbers(); final Collection<ContactData> lookupData = new ArrayList<ContactData>(pushNumbers.size()); for (String pushNumber : pushNumbers) { Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(pushNumber)); Cursor lookupCursor = resolver.query(uri, inProjection, null, null, null); try {//from w w w . j a va2s .c om if (lookupCursor != null && lookupCursor.moveToFirst()) { final ContactData contactData = new ContactData(lookupCursor.getLong(0), lookupCursor.getString(1)); contactData.numbers.add(new NumberData("TextSecure", pushNumber)); lookupData.add(contactData); } } finally { if (lookupCursor != null) lookupCursor.close(); } } return lookupData; }
From source file:org.yammp.app.AlbumFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { if (mCursor == null) return false; Intent intent;/*from www . j ava 2s. c om*/ switch (item.getItemId()) { case PLAY_SELECTION: int position = mSelectedPosition; long[] list = MusicUtils.getSongListForAlbum(getSherlockActivity(), mSelectedId); MusicUtils.playAll(getSherlockActivity(), list, position); return true; case DELETE_ITEMS: intent = new Intent(INTENT_DELETE_ITEMS); Bundle bundle = new Bundle(); bundle.putString(INTENT_KEY_PATH, Uri.withAppendedPath(Audio.Albums.EXTERNAL_CONTENT_URI, Uri.encode(String.valueOf(mSelectedId))) .toString()); intent.putExtras(bundle); startActivity(intent); return true; case SEARCH: doSearch(); return true; } return super.onContextItemSelected(item); }
From source file:in.risysnetworks.shplayer.fragments.childfragment.ChildFragmentAlbum.java
private Cursor getAlbumCursor(AsyncQueryHandler async, String filter) { String[] cols = new String[] { MediaStore.Audio.Albums._ID, MediaStore.Audio.Albums.ARTIST, MediaStore.Audio.Albums.ALBUM, MediaStore.Audio.Albums.ALBUM_ART }; Cursor ret = null;//from w w w . java 2 s .c o m Uri uri = MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI; if (!TextUtils.isEmpty(filter)) { uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build(); } if (async != null) { System.out.println(" async != null "); async.startQuery(0, null, uri, cols, null, null, MediaStore.Audio.Albums.DEFAULT_SORT_ORDER); } else { System.out.println(" async == null "); ret = SHPlayerUtility.query(getActivity(), uri, cols, null, null, MediaStore.Audio.Albums.DEFAULT_SORT_ORDER); } return ret; }
From source file:com.windigo.RestApiMethodMetadata.java
/** * Convert parameters map to {@link NameValuePair} list * * @param queryParams/*from w w w . j a va2s. co m*/ * @param args * @return {@link List} of {@link NameValuePair} */ private static List<NameValuePair> convertToNameValuePairs(Map<Integer, String> queryParams, Object[] args) { List<NameValuePair> params = new ArrayList<NameValuePair>(); if (queryParams.size() > 0) { for (Entry<Integer, String> queryParamEntry : queryParams.entrySet()) { Object parameterValue = args[queryParamEntry.getKey()]; if (parameterValue != null) { String valueString = Uri.encode(parameterValue.toString()); params.add(new BasicNameValuePair(queryParamEntry.getValue(), valueString)); } } } return params; }
From source file:com.lyraf.oneavatarplease.avatargenerator.AvatarGeneratorFragment.java
@Override public void loadAvatar() { Picasso.with(getActivity())/* w ww . j a v a 2 s . c o m*/ .load(String.format(getResources().getString(R.string.url_avatar), Uri.encode(textAvatarIdentifier.getText().toString()))) .fit().centerCrop().into(imageAvatar, new Callback() { @Override public void onSuccess() { presenter.generatedAvatar(((BitmapDrawable) imageAvatar.getDrawable()).getBitmap(), textAvatarIdentifier.getText().toString()); } @Override public void onError() { imageAvatar.setImageResource(R.drawable.ic_avatar_empty); presenter.checkConnectivity(); } }); }
From source file:com.github.snowdream.android.apps.imageviewer.ImageViewerActivity.java
public void initData() { imageLoader = ImageLoader.getInstance(); imageUrls = new ArrayList<String>(); Intent intent = getIntent();//from ww w . j av a 2 s .c om if (intent != null) { Bundle bundle = intent.getExtras(); if (bundle != null) { imageUrls = bundle.getStringArrayList(Extra.IMAGES); imagePosition = bundle.getInt(Extra.IMAGE_POSITION, 0); imageMode = bundle.getInt(Extra.IMAGE_MODE, 0); Log.i("The snowdream bundle path of the image is: " + imageUri); } Uri uri = (Uri) intent.getData(); if (uri != null) { imageUri = uri.getPath(); fileName = uri.getLastPathSegment(); getSupportActionBar().setSubtitle(fileName); Log.i("The path of the image is: " + imageUri); File file = new File(imageUri); imageUri = "file://" + imageUri; File dir = file.getParentFile(); if (dir != null) { FileFilter fileFilter = new FileFilter() { @Override public boolean accept(File f) { if (f != null) { String extension = MimeTypeMap .getFileExtensionFromUrl(Uri.encode(f.getAbsolutePath())); if (!TextUtils.isEmpty(extension)) { String mimeType = MimeTypeMap.getSingleton() .getMimeTypeFromExtension(extension); if (!TextUtils.isEmpty(mimeType) && mimeType.contains("image")) { return true; } } } return false; } }; File[] files = dir.listFiles(fileFilter); if (files != null && files.length > 0) { int size = files.length; for (int i = 0; i < size; i++) { imageUrls.add("file://" + files[i].getAbsolutePath()); } imagePosition = imageUrls.indexOf(imageUri); imageMode = 1; Log.i("Image Position:" + imagePosition); } } else { imageUrls.add("file://" + imageUri); imagePosition = 0; imageMode = 0; } } } else { Log.w("The intent is null!"); } }
From source file:com.wowza.gocoder.sdk.sampleapp.InfoActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_share: String uriText = "mailto:support@wowza.com" + "?subject=" + Uri.encode("GoCoder SDK Support Information") + "&body=" + Uri.encode(shareContents()); Uri uri = Uri.parse(uriText);/*from w ww . j ava 2s .c o m*/ Intent sendIntent = new Intent(Intent.ACTION_SENDTO); sendIntent.setData(uri); startActivity(Intent.createChooser(sendIntent, "Send to Wowza Support")); return true; case R.id.action_copy: ClipboardManager myClipboard; myClipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); ClipData myClip; myClip = ClipData.newPlainText("text", shareContents()); myClipboard.setPrimaryClip(myClip); Toast.makeText(this, "Copied to clipboard", Toast.LENGTH_SHORT).show(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:net.kourlas.voipms_sms.activities.ConversationQuickReplyActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.conversation_quick_reply); database = Database.getInstance(getApplicationContext()); preferences = Preferences.getInstance(getApplicationContext()); contact = getIntent().getExtras().getString(getString(R.string.conversation_extra_contact)); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/* www.ja v a2 s . co m*/ ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); } NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Integer notificationId = Notifications.getInstance(getApplicationContext()).getNotificationIds() .get(contact); if (notificationId != null) { manager.cancel(notificationId); } TextView replyToText = (TextView) findViewById(R.id.reply_to_edit_text); String contactName = Utils.getContactName(getApplicationContext(), contact); if (contactName == null) { replyToText.setText(getString(R.string.conversation_quick_reply_reply_to) + " " + Utils.getFormattedPhoneNumber(contact)); } else { replyToText.setText(getString(R.string.conversation_quick_reply_reply_to) + " " + contactName); } final EditText messageText = (EditText) findViewById(R.id.message_edit_text); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { messageText.setOutlineProvider(new ViewOutlineProvider() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(View view, Outline outline) { outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 15); } }); messageText.setClipToOutline(true); } messageText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { ViewSwitcher viewSwitcher = (ViewSwitcher) findViewById(R.id.view_switcher); if (s.toString().equals("") && viewSwitcher.getDisplayedChild() == 1) { viewSwitcher.setDisplayedChild(0); } else if (viewSwitcher.getDisplayedChild() == 0) { viewSwitcher.setDisplayedChild(1); } } }); QuickContactBadge photo = (QuickContactBadge) findViewById(R.id.photo); Utils.applyCircularMask(photo); photo.assignContactFromPhone(Preferences.getInstance(getApplicationContext()).getDid(), true); Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(Preferences.getInstance(getApplicationContext()).getDid())); Cursor cursor = getContentResolver().query(uri, new String[] { ContactsContract.PhoneLookup._ID, ContactsContract.PhoneLookup.PHOTO_THUMBNAIL_URI, ContactsContract.PhoneLookup.DISPLAY_NAME }, null, null, null); if (cursor.moveToFirst()) { String photoUri = cursor .getString(cursor.getColumnIndex(ContactsContract.Contacts.PHOTO_THUMBNAIL_URI)); if (photoUri != null) { photo.setImageURI(Uri.parse(photoUri)); } else { photo.setImageToDefault(); } } else { photo.setImageToDefault(); } cursor.close(); final ImageButton sendButton = (ImageButton) findViewById(R.id.send_button); Utils.applyCircularMask(sendButton); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { preSendMessage(); } }); Button openAppButton = (Button) findViewById(R.id.open_app_button); openAppButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); Intent intent = new Intent(activity, ConversationActivity.class); intent.putExtra(getString(R.string.conversation_extra_contact), contact); TaskStackBuilder stackBuilder = TaskStackBuilder.create(getApplicationContext()); stackBuilder.addParentStack(ConversationActivity.class); stackBuilder.addNextIntent(intent); stackBuilder.startActivities(); } }); messageText.requestFocus(); }
From source file:fr.spaz.widget.pedia.SimpleWikipediaHelper.java
/** * Read and return the content for a specific Wiktionary page. This makes a * lightweight API call, and trims out just the page content returned. * Because this call blocks until results are available, it should not be * run from a UI thread.//from ww w .ja va 2 s . com * * @param title * The exact title of the Wiktionary page requested. * @param expandTemplates * If true, expand any wiki templates found. * @return Exact content of page. * @throws ApiException * If any connection or server error occurs. * @throws ParseException * If there are problems parsing the response. */ public static String getPageContent(String title, boolean expandTemplates) throws ApiException, ParseException { // Encode page title and expand templates if requested String lang = Uri.encode("en"); String encodedTitle = Uri.encode(title); String expandClause = expandTemplates ? WIKIPEDIA_EXPAND_TEMPLATES : ""; // Query the API for content final String s = String.format(WIKIPEDIA_PAGE, lang, encodedTitle, expandClause); Log.d("Spaz", s); String content = getUrlContent(s); try { // Drill into the JSON response to find the content body JSONObject response = new JSONObject(content); JSONObject query = response.getJSONObject("query"); JSONObject pages = query.getJSONObject("pages"); JSONObject page = pages.getJSONObject((String) pages.keys().next()); JSONArray revisions = page.getJSONArray("revisions"); JSONObject revision = revisions.getJSONObject(0); return revision.getString("*"); } catch (JSONException e) { throw new ParseException("Problem parsing API response", e); } }
From source file:com.battlelancer.seriesguide.ui.CheckinActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Uri baseUri;//from w w w . j a v a 2s.c om if (mSearchFilter != null) { baseUri = Uri.withAppendedPath(Shows.CONTENT_FILTER_URI, Uri.encode(mSearchFilter)); } else { baseUri = Shows.CONTENT_URI; } // query selects shows with next episodes before this point in time // it does not make sense to check into episodes further in the future String customTimeInOneHour = String.valueOf(TimeTools.getCurrentTime(this) + DateUtils.HOUR_IN_MILLIS); return new CursorLoader(this, baseUri, CheckinQuery.PROJECTION, CheckinQuery.SELECTION, new String[] { customTimeInOneHour }, ShowsDistillationSettings.ShowsSortOrder.EPISODE_REVERSE); }