Java Code Examples for android.net.Uri#equals()
The following examples show how to use
android.net.Uri#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CropImageActivity.java From Android-Image-Cropper with Apache License 2.0 | 6 votes |
/** * Get Android uri to save the cropped image into.<br> * Use the given in options or create a temp file. */ protected Uri getOutputUri() { Uri outputUri = mOptions.outputUri; if (outputUri == null || outputUri.equals(Uri.EMPTY)) { try { String ext = mOptions.outputCompressFormat == Bitmap.CompressFormat.JPEG ? ".jpg" : mOptions.outputCompressFormat == Bitmap.CompressFormat.PNG ? ".png" : ".webp"; outputUri = Uri.fromFile(File.createTempFile("cropped", ext, getCacheDir())); } catch (IOException e) { throw new RuntimeException("Failed to create temp file for output image", e); } } return outputUri; }
Example 2
Source File: ContactsBinaryDictionary.java From openboard with GNU General Public License v3.0 | 6 votes |
/** * Loads data within content providers to the dictionary. */ private void loadDictionaryForUriLocked(final Uri uri) { if (!PermissionsUtil.checkAllPermissionsGranted( mContext, Manifest.permission.READ_CONTACTS)) { Log.i(TAG, "No permission to read contacts. Not loading the Dictionary."); } final ArrayList<String> validNames = mContactsManager.getValidNames(uri); for (final String name : validNames) { addNameLocked(name); } if (uri.equals(Contacts.CONTENT_URI)) { // Since we were able to add content successfully, update the local // state of the manager. mContactsManager.updateLocalState(validNames); } }
Example 3
Source File: HlsChunkSource.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Called when a playlist load encounters an error. * * @param playlistUrl The {@link Uri} of the playlist whose load encountered an error. * @param blacklistDurationMs The duration for which the playlist should be blacklisted. Or {@link * C#TIME_UNSET} if the playlist should not be blacklisted. * @return True if blacklisting did not encounter errors. False otherwise. */ public boolean onPlaylistError(Uri playlistUrl, long blacklistDurationMs) { int trackGroupIndex = C.INDEX_UNSET; for (int i = 0; i < playlistUrls.length; i++) { if (playlistUrls[i].equals(playlistUrl)) { trackGroupIndex = i; break; } } if (trackGroupIndex == C.INDEX_UNSET) { return true; } int trackSelectionIndex = trackSelection.indexOf(trackGroupIndex); if (trackSelectionIndex == C.INDEX_UNSET) { return true; } seenExpectedPlaylistError |= playlistUrl.equals(expectedPlaylistUrl); return blacklistDurationMs == C.TIME_UNSET || trackSelection.blacklist(trackSelectionIndex, blacklistDurationMs); }
Example 4
Source File: MediaUrlResolver.java From 365browser with Apache License 2.0 | 5 votes |
private boolean canPlayMedia(Uri uri, Map<String, List<String>> headers) { if (uri == null || uri.equals(Uri.EMPTY)) { recordResultHistogram(RESOLVE_RESULT_MALFORMED_URL); return false; } if (headers != null && headers.containsKey(CORS_HEADER_NAME)) { // Check that the CORS data is valid for Chromecast List<String> corsData = headers.get(CORS_HEADER_NAME); if (corsData.isEmpty() || (!corsData.get(0).equals("*") && !corsData.get(0).equals(CHROMECAST_ORIGIN))) { recordResultHistogram(RESOLVE_RESULT_INCOMPATIBLE_CORS); return false; } } else if (isEnhancedMedia(uri)) { // HLS media requires CORS headers. // TODO(avayvod): it actually requires CORS on the final video URLs vs the manifest. // Clank assumes that if CORS is set for the manifest it's set for everything but // it not necessary always true. See b/19138712 Log.d(TAG, "HLS stream without CORS header: %s", uri); recordResultHistogram(RESOLVE_RESULT_NO_CORS); return false; } if (getMediaType(uri) == MEDIA_TYPE_UNKNOWN) { Log.d(TAG, "Unsupported media container format: %s", uri); recordResultHistogram(RESOLVE_RESULT_UNSUPPORTED_MEDIA); return false; } recordResultHistogram(RESOLVE_RESULT_SUCCESS); return true; }
Example 5
Source File: MessageQueueManager.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Finds the location of procedure is in the queue * * @param queue the queue to check * @param uri the procedure look for * @return index of the procedure in the queue or -1 */ public static int indexOf(Uri uri) { if (contains(uri)) { int index = 0; for (Uri u : queue) { if (uri.equals(u)) { return index; } index++; } } return -1; }
Example 6
Source File: X5WebViewClient.java From x5webview-cordova-plugin with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { try { // Check the against the whitelist and lock out access to the WebView directory // Changing this will cause problems for your application if (!parentEngine.pluginManager.shouldAllowRequest(url)) { LOG.w(TAG, "URL blocked by whitelist: " + url); // Results in a 404. return new WebResourceResponse("text/plain", "UTF-8", null); } CordovaResourceApi resourceApi = parentEngine.resourceApi; Uri origUri = Uri.parse(url); // Allow plugins to intercept WebView requests. Uri remappedUri = resourceApi.remapUri(origUri); if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) { CordovaResourceApi.OpenForReadResult result = resourceApi.openForRead(remappedUri, true); return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream); } // If we don't need to special-case the request, let the browser load it. return null; } catch (IOException e) { if (!(e instanceof FileNotFoundException)) { LOG.e(TAG, "Error occurred while loading a file (returning a 404).", e); } // Results in a 404. return new WebResourceResponse("text/plain", "UTF-8", null); } }
Example 7
Source File: X5WebViewClient.java From cordova-plugin-x5-webview with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { try { // Check the against the whitelist and lock out access to the WebView directory // Changing this will cause problems for your application if (!parentEngine.pluginManager.shouldAllowRequest(url)) { LOG.w(TAG, "URL blocked by whitelist: " + url); // Results in a 404. return new WebResourceResponse("text/plain", "UTF-8", null); } CordovaResourceApi resourceApi = parentEngine.resourceApi; Uri origUri = Uri.parse(url); // Allow plugins to intercept WebView requests. Uri remappedUri = resourceApi.remapUri(origUri); if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) { CordovaResourceApi.OpenForReadResult result = resourceApi.openForRead(remappedUri, true); return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream); } // If we don't need to special-case the request, let the browser load it. return null; } catch (IOException e) { if (!(e instanceof FileNotFoundException)) { LOG.e(TAG, "Error occurred while loading a file (returning a 404).", e); } // Results in a 404. return new WebResourceResponse("text/plain", "UTF-8", null); } }
Example 8
Source File: InputMethodService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void onChange(boolean selfChange, Uri uri) { final Uri showImeWithHardKeyboardUri = Settings.Secure.getUriFor(Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD); if (showImeWithHardKeyboardUri.equals(uri)) { mShowImeWithHardKeyboard = Settings.Secure.getInt(mService.getContentResolver(), Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD, 0) != 0 ? ShowImeWithHardKeyboardType.TRUE : ShowImeWithHardKeyboardType.FALSE; // In Android M and prior, state change of // Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD has triggered // #onConfigurationChanged(). For compatibility reasons, we reset the internal // state as if configuration was changed. mService.resetStateForNewConfiguration(); } }
Example 9
Source File: IceCreamCordovaWebViewClient.java From phonegap-plugin-loading-spinner with Apache License 2.0 | 5 votes |
@Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { try { // Check the against the white-list. if ((url.startsWith("http:") || url.startsWith("https:")) && !Config.isUrlWhiteListed(url)) { LOG.w(TAG, "URL blocked by whitelist: " + url); // Results in a 404. return new WebResourceResponse("text/plain", "UTF-8", null); } CordovaResourceApi resourceApi = appView.getResourceApi(); Uri origUri = Uri.parse(url); // Allow plugins to intercept WebView requests. Uri remappedUri = resourceApi.remapUri(origUri); if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri)) { OpenForReadResult result = resourceApi.openForRead(remappedUri, true); return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream); } // If we don't need to special-case the request, let the browser load it. return null; } catch (IOException e) { if (!(e instanceof FileNotFoundException)) { LOG.e("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e); } // Results in a 404. return new WebResourceResponse("text/plain", "UTF-8", null); } }
Example 10
Source File: SystemWebViewClient.java From countly-sdk-cordova with MIT License | 5 votes |
@Override @SuppressWarnings("deprecation") public WebResourceResponse shouldInterceptRequest(WebView view, String url) { try { // Check the against the whitelist and lock out access to the WebView directory // Changing this will cause problems for your application if (!parentEngine.pluginManager.shouldAllowRequest(url)) { LOG.w(TAG, "URL blocked by whitelist: " + url); // Results in a 404. return new WebResourceResponse("text/plain", "UTF-8", null); } CordovaResourceApi resourceApi = parentEngine.resourceApi; Uri origUri = Uri.parse(url); // Allow plugins to intercept WebView requests. Uri remappedUri = resourceApi.remapUri(origUri); if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) { CordovaResourceApi.OpenForReadResult result = resourceApi.openForRead(remappedUri, true); return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream); } // If we don't need to special-case the request, let the browser load it. return null; } catch (IOException e) { if (!(e instanceof FileNotFoundException)) { LOG.e(TAG, "Error occurred while loading a file (returning a 404).", e); } // Results in a 404. return new WebResourceResponse("text/plain", "UTF-8", null); } }
Example 11
Source File: IceCreamCordovaWebViewClient.java From wildfly-samples with MIT License | 5 votes |
@Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { try { // Check the against the white-list. if ((url.startsWith("http:") || url.startsWith("https:")) && !Config.isUrlWhiteListed(url)) { LOG.w(TAG, "URL blocked by whitelist: " + url); // Results in a 404. return new WebResourceResponse("text/plain", "UTF-8", null); } CordovaResourceApi resourceApi = appView.getResourceApi(); Uri origUri = Uri.parse(url); // Allow plugins to intercept WebView requests. Uri remappedUri = resourceApi.remapUri(origUri); if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri)) { OpenForReadResult result = resourceApi.openForRead(remappedUri, true); return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream); } // If we don't need to special-case the request, let the browser load it. return null; } catch (IOException e) { if (!(e instanceof FileNotFoundException)) { LOG.e("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e); } // Results in a 404. return new WebResourceResponse("text/plain", "UTF-8", null); } }
Example 12
Source File: UriUtils.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
/** Checks whether two URI are equal, taking care of the case where either is null. */ public static boolean areEqual(Uri uri1, Uri uri2) { if (uri1 == null && uri2 == null) { return true; } if (uri1 == null || uri2 == null) { return false; } return uri1.equals(uri2); }
Example 13
Source File: IceCreamCordovaWebViewClient.java From bluemix-parking-meter with MIT License | 5 votes |
@Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { try { // Check the against the whitelist and lock out access to the WebView directory // Changing this will cause problems for your application if (isUrlHarmful(url)) { LOG.w(TAG, "URL blocked by whitelist: " + url); // Results in a 404. return new WebResourceResponse("text/plain", "UTF-8", null); } CordovaResourceApi resourceApi = appView.getResourceApi(); Uri origUri = Uri.parse(url); // Allow plugins to intercept WebView requests. Uri remappedUri = resourceApi.remapUri(origUri); if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) { OpenForReadResult result = resourceApi.openForRead(remappedUri, true); return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream); } // If we don't need to special-case the request, let the browser load it. return null; } catch (IOException e) { if (!(e instanceof FileNotFoundException)) { LOG.e("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e); } // Results in a 404. return new WebResourceResponse("text/plain", "UTF-8", null); } }
Example 14
Source File: MediaUrlResolver.java From AndroidChromium with Apache License 2.0 | 5 votes |
private boolean canPlayMedia(Uri uri, Map<String, List<String>> headers) { if (uri == null || uri.equals(Uri.EMPTY)) { recordResultHistogram(RESOLVE_RESULT_MALFORMED_URL); return false; } if (headers != null && headers.containsKey(CORS_HEADER_NAME)) { // Check that the CORS data is valid for Chromecast List<String> corsData = headers.get(CORS_HEADER_NAME); if (corsData.isEmpty() || (!corsData.get(0).equals("*") && !corsData.get(0).equals(CHROMECAST_ORIGIN))) { recordResultHistogram(RESOLVE_RESULT_INCOMPATIBLE_CORS); return false; } } else if (isEnhancedMedia(uri)) { // HLS media requires CORS headers. // TODO(avayvod): it actually requires CORS on the final video URLs vs the manifest. // Clank assumes that if CORS is set for the manifest it's set for everything but // it not necessary always true. See b/19138712 Log.d(TAG, "HLS stream without CORS header: %s", uri); recordResultHistogram(RESOLVE_RESULT_NO_CORS); return false; } if (getMediaType(uri) == MEDIA_TYPE_UNKNOWN) { Log.d(TAG, "Unsupported media container format: %s", uri); recordResultHistogram(RESOLVE_RESULT_UNSUPPORTED_MEDIA); return false; } recordResultHistogram(RESOLVE_RESULT_SUCCESS); return true; }
Example 15
Source File: SystemWebViewClient.java From chappiecast with Mozilla Public License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { try { // Check the against the whitelist and lock out access to the WebView directory // Changing this will cause problems for your application if (!parentEngine.pluginManager.shouldAllowRequest(url)) { LOG.w(TAG, "URL blocked by whitelist: " + url); // Results in a 404. return new WebResourceResponse("text/plain", "UTF-8", null); } CordovaResourceApi resourceApi = parentEngine.resourceApi; Uri origUri = Uri.parse(url); // Allow plugins to intercept WebView requests. Uri remappedUri = resourceApi.remapUri(origUri); if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) { CordovaResourceApi.OpenForReadResult result = resourceApi.openForRead(remappedUri, true); return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream); } // If we don't need to special-case the request, let the browser load it. return null; } catch (IOException e) { if (!(e instanceof FileNotFoundException)) { LOG.e(TAG, "Error occurred while loading a file (returning a 404).", e); } // Results in a 404. return new WebResourceResponse("text/plain", "UTF-8", null); } }
Example 16
Source File: ImageView.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * Sets the content of this ImageView to the specified Uri. * Note that you use this method to load images from a local Uri only. * <p/> * To learn how to display images from a remote Uri see: <a href="https://developer.android.com/topic/performance/graphics/index.html">Handling Bitmaps</a> * <p/> * <p class="note">This does Bitmap reading and decoding on the UI * thread, which can cause a latency hiccup. If that's a concern, * consider using {@link #setImageDrawable(Drawable)} or * {@link #setImageBitmap(android.graphics.Bitmap)} and * {@link android.graphics.BitmapFactory} instead.</p> * * <p class="note">On devices running SDK < 24, this method will fail to * apply correct density scaling to images loaded from * {@link ContentResolver#SCHEME_CONTENT content} and * {@link ContentResolver#SCHEME_FILE file} schemes. Applications running * on devices with SDK >= 24 <strong>MUST</strong> specify the * {@code targetSdkVersion} in their manifest as 24 or above for density * scaling to be applied to images loaded from these schemes.</p> * * @param uri the Uri of an image, or {@code null} to clear the content */ @android.view.RemotableViewMethod(asyncImpl="setImageURIAsync") public void setImageURI(@Nullable Uri uri) { if (mResource != 0 || (mUri != uri && (uri == null || mUri == null || !uri.equals(mUri)))) { updateDrawable(null); mResource = 0; mUri = uri; final int oldWidth = mDrawableWidth; final int oldHeight = mDrawableHeight; resolveUri(); if (oldWidth != mDrawableWidth || oldHeight != mDrawableHeight) { requestLayout(); } invalidate(); } }
Example 17
Source File: ProfileNotificationsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (data == null) { return; } Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); String name = null; if (ringtone != null) { Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone); if (rng != null) { if (requestCode == 13) { if (ringtone.equals(Settings.System.DEFAULT_RINGTONE_URI)) { name = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone); } else { name = rng.getTitle(getParentActivity()); } } else { if (ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { name = LocaleController.getString("SoundDefault", R.string.SoundDefault); } else { name = rng.getTitle(getParentActivity()); } } rng.stop(); } } SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount); SharedPreferences.Editor editor = preferences.edit(); if (requestCode == 12) { if (name != null) { editor.putString("sound_" + dialog_id, name); editor.putString("sound_path_" + dialog_id, ringtone.toString()); } else { editor.putString("sound_" + dialog_id, "NoSound"); editor.putString("sound_path_" + dialog_id, "NoSound"); } } else if (requestCode == 13) { if (name != null) { editor.putString("ringtone_" + dialog_id, name); editor.putString("ringtone_path_" + dialog_id, ringtone.toString()); } else { editor.putString("ringtone_" + dialog_id, "NoSound"); editor.putString("ringtone_path_" + dialog_id, "NoSound"); } } editor.commit(); if (adapter != null) { adapter.notifyItemChanged(requestCode == 13 ? ringtoneRow : soundRow); } } }
Example 18
Source File: ContactListFilterView.java From zom-android-matrix with Apache License 2.0 | 4 votes |
public void doFilter(Uri uri, String filterString) { if (uri != null && !uri.equals(mUri)) { mUri = uri; } doFilter(filterString); }
Example 19
Source File: NotificationsSettingsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); String name = null; if (ringtone != null) { Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone); if (rng != null) { if (requestCode == callsRingtoneRow) { if (ringtone.equals(Settings.System.DEFAULT_RINGTONE_URI)) { name = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone); } else { name = rng.getTitle(getParentActivity()); } } else { if (ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { name = LocaleController.getString("SoundDefault", R.string.SoundDefault); } else { name = rng.getTitle(getParentActivity()); } } rng.stop(); } } SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount); SharedPreferences.Editor editor = preferences.edit(); if (requestCode == messageSoundRow) { if (name != null && ringtone != null) { editor.putString("GlobalSound", name); editor.putString("GlobalSoundPath", ringtone.toString()); } else { editor.putString("GlobalSound", "NoSound"); editor.putString("GlobalSoundPath", "NoSound"); } } else if (requestCode == groupSoundRow) { if (name != null && ringtone != null) { editor.putString("GroupSound", name); editor.putString("GroupSoundPath", ringtone.toString()); } else { editor.putString("GroupSound", "NoSound"); editor.putString("GroupSoundPath", "NoSound"); } } else if (requestCode == callsRingtoneRow) { if (name != null && ringtone != null) { editor.putString("CallsRingtone", name); editor.putString("CallsRingtonePath", ringtone.toString()); } else { editor.putString("CallsRingtone", "NoSound"); editor.putString("CallsRingtonePath", "NoSound"); } } editor.commit(); if (requestCode == messageSoundRow || requestCode == groupSoundRow) { updateServerNotificationsSettings(requestCode == groupSoundRow); } adapter.notifyItemChanged(requestCode); } }
Example 20
Source File: Uris.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Returns true if the Uri is null or equal to Uri.EMPTY * @param uri * @return */ public static boolean isEmpty(Uri uri) { return (uri != null && !uri.equals(Uri.EMPTY)) ? false : true; }