Java Code Examples for android.webkit.URLUtil#isHttpsUrl()
The following examples show how to use
android.webkit.URLUtil#isHttpsUrl() .
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: ConnectActivity.java From Yahala-Messenger with MIT License | 6 votes |
private boolean validateUrl(String url) { if (URLUtil.isHttpsUrl(url) || URLUtil.isHttpUrl(url)) { return true; } FileLog.e(TAG + ": " + getText(R.string.invalid_url_title), getString(R.string.invalid_url_text, url)); /* new AlertDialog.Builder(this) .setTitle(getText(R.string.invalid_url_title)) .setMessage(getString(R.string.invalid_url_text, url)) .setCancelable(false) .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).create().show();*/ return false; }
Example 2
Source File: WebRtcPhone.java From Yahala-Messenger with MIT License | 6 votes |
private boolean validateUrl(String url) { if (URLUtil.isHttpsUrl(url) || URLUtil.isHttpUrl(url)) { return true; } FileLog.e(TAG + ": " + ApplicationLoader.applicationContext.getText(R.string.invalid_url_title), ApplicationLoader.applicationContext.getString(R.string.invalid_url_text, url)); /* new AlertDialog.Builder(this) .setTitle(getText(R.string.invalid_url_title)) .setMessage(getString(R.string.invalid_url_text, url)) .setCancelable(false) .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).create().show();*/ return false; }
Example 3
Source File: SettingsActivity.java From MyOwnNotes with GNU General Public License v3.0 | 6 votes |
/** * checks whether the <code>String</code> passed in the <code>EditText</code> object is a valid https-url * is valid if: * <li>string is not empty</li> * <li>string is a valid URL (according to <code>URLUtil.isValidUrl()</code></li> * <li>string is a https-URL (according to <code>URLUtil.isHttpsUrl()</code>)</li> * <li>string is at least 13 characters long (example for minimum url: https://ab.at)</li> * <p>If String ends with a slash ("/"), it is removed.</p> * * @param toCheck <code>EditText</code> containing the String to be checked * @return <code>true</code> iff the <code>String</code> contains a valid https-url */ public boolean isValidURL(EditText toCheck) { String stringToCheck = toCheck.getText().toString(); if(stringToCheck.isEmpty() || !URLUtil.isValidUrl(stringToCheck) || !URLUtil.isHttpsUrl(stringToCheck) || stringToCheck.length() < 13 ) { return false; } else if(stringToCheck.charAt(stringToCheck.length() - 1 ) == '/') //input url ends with "/" (e.g.: https://example.org/ ) { //remove slash at end String newAddressWithoutSlashAtEnd = stringToCheck.substring(0, stringToCheck.length() - 1 ); toCheck.setText(newAddressWithoutSlashAtEnd); return isValidURL(toCheck); } else { return true; } }
Example 4
Source File: DownloadsManager.java From FirefoxReality with Mozilla Public License 2.0 | 5 votes |
public void startDownload(@NonNull DownloadJob job, @SettingsStore.Storage int storageType) { if (!URLUtil.isHttpUrl(job.getUri()) && !URLUtil.isHttpsUrl(job.getUri())) { notifyDownloadError("Cannot download non http/https files", job.getFilename()); return; } Uri url = Uri.parse(job.getUri()); DownloadManager.Request request = new DownloadManager.Request(url); request.setTitle(job.getTitle()); request.setDescription(job.getDescription()); request.setMimeType(job.getContentType()); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setVisibleInDownloadsUi(false); if (job.getOutputPath() == null) { if (storageType == SettingsStore.EXTERNAL) { request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, job.getFilename()); } else { String outputPath = getOutputPathForJob(job); if (outputPath == null) { notifyDownloadError("Cannot create output file", job.getFilename()); return; } request.setDestinationUri(Uri.parse(outputPath)); } } else { request.setDestinationUri(Uri.parse("file://" + job.getOutputPath())); } if (mDownloadManager != null) { mDownloadManager.enqueue(request); scheduleUpdates(); } }
Example 5
Source File: Utils.java From alpha-wallet-android with MIT License | 5 votes |
public static String formatUrl(String url) { if (URLUtil.isHttpsUrl(url) || URLUtil.isHttpUrl(url)) { return url; } else { if (isValidUrl(url)) { return C.HTTPS_PREFIX + url; } else { return C.GOOGLE_SEARCH_PREFIX + url; } } }
Example 6
Source File: DownloadService.java From AntennaPodSP with MIT License | 5 votes |
private Downloader getDownloader(DownloadRequest request) { if (URLUtil.isHttpUrl(request.getSource()) || URLUtil.isHttpsUrl(request.getSource())) { return new HttpDownloader(request); } Log.e(TAG, "Could not find appropriate downloader for " + request.getSource() ); return null; }
Example 7
Source File: OpenTokConfig.java From opentok-android-sdk-samples with MIT License | 5 votes |
public static boolean isWebServerConfigUrlValid(){ if (OpenTokConfig.CHAT_SERVER_URL == null || OpenTokConfig.CHAT_SERVER_URL.isEmpty()) { webServerConfigErrorMessage = "CHAT_SERVER_URL in OpenTokConfig.java must not be null or empty"; return false; } else if ( !( URLUtil.isHttpsUrl(OpenTokConfig.CHAT_SERVER_URL) || URLUtil.isHttpUrl(OpenTokConfig.CHAT_SERVER_URL)) ) { webServerConfigErrorMessage = "CHAT_SERVER_URL in OpenTokConfig.java must be specified as either http or https"; return false; } else if ( !URLUtil.isValidUrl(OpenTokConfig.CHAT_SERVER_URL) ) { webServerConfigErrorMessage = "CHAT_SERVER_URL in OpenTokConfig.java is not a valid URL"; return false; } else { return true; } }
Example 8
Source File: OpenTokConfig.java From opentok-android-sdk-samples with MIT License | 5 votes |
public static boolean isWebServerConfigUrlValid(){ if (OpenTokConfig.CHAT_SERVER_URL == null || OpenTokConfig.CHAT_SERVER_URL.isEmpty()) { webServerConfigErrorMessage = "CHAT_SERVER_URL in OpenTokConfig.java must not be null or empty"; return false; } else if ( !( URLUtil.isHttpsUrl(OpenTokConfig.CHAT_SERVER_URL) || URLUtil.isHttpUrl(OpenTokConfig.CHAT_SERVER_URL)) ) { webServerConfigErrorMessage = "CHAT_SERVER_URL in OpenTokConfig.java must be specified as either http or https"; return false; } else if ( !URLUtil.isValidUrl(OpenTokConfig.CHAT_SERVER_URL) ) { webServerConfigErrorMessage = "CHAT_SERVER_URL in OpenTokConfig.java is not a valid URL"; return false; } else { return true; } }
Example 9
Source File: OpenTokConfig.java From opentok-android-sdk-samples with MIT License | 5 votes |
public static boolean isConfigUrlValid(){ if (OpenTokConfig.CHAT_SERVER_URL == null) { configErrorMessage = "CHAT_SERVER_URL in OpenTokConfig.java must not be null"; return false; } else if ( !( URLUtil.isHttpsUrl(OpenTokConfig.CHAT_SERVER_URL) || URLUtil.isHttpUrl(OpenTokConfig.CHAT_SERVER_URL)) ) { configErrorMessage = "CHAT_SERVER_URL in OpenTokConfig.java must be specified as either http or https"; return false; } else if ( !URLUtil.isValidUrl(OpenTokConfig.CHAT_SERVER_URL) ) { configErrorMessage = "CHAT_SERVER_URL in OpenTokConfig.java is not a valid URL"; return false; } else { return true; } }
Example 10
Source File: NavigationBarWidget.java From FirefoxReality with Mozilla Public License 2.0 | 4 votes |
private void showMenu() { if (mAttachedWindow.getSession() == null) { return; } if (mHamburgerMenu != null && mHamburgerMenu.isVisible()) { // Release current selection menu to recreate it with different actions. hideMenu(); return; } mHamburgerMenu = new HamburgerMenuWidget(getContext()); mHamburgerMenu.getPlacement().parentHandle = getHandle(); mHamburgerMenu.setMenuDelegate(new HamburgerMenuWidget.MenuDelegate() { @Override public void onSendTab() { hideMenu(); showSendTabDialog(); } @Override public void onResize() { hideMenu(); enterResizeMode(); } @Override public void onSwitchMode() { int uaMode = mAttachedWindow.getSession().getUaMode(); if (uaMode == GeckoSessionSettings.USER_AGENT_MODE_DESKTOP) { final int defaultUaMode = SettingsStore.getInstance(mAppContext).getUaMode(); mHamburgerMenu.setUAMode(defaultUaMode); mAttachedWindow.getSession().setUaMode(defaultUaMode); } else { mHamburgerMenu.setUAMode(GeckoSessionSettings.USER_AGENT_MODE_DESKTOP); mAttachedWindow.getSession().setUaMode(GeckoSessionSettings.USER_AGENT_MODE_DESKTOP); } hideMenu(); } }); boolean isSendTabEnabled = false; if (URLUtil.isHttpUrl(mAttachedWindow.getSession().getCurrentUri()) || URLUtil.isHttpsUrl(mAttachedWindow.getSession().getCurrentUri())) { isSendTabEnabled = true; } mHamburgerMenu.setSendTabEnabled(isSendTabEnabled); mHamburgerMenu.setUAMode(mAttachedWindow.getSession().getUaMode()); mHamburgerMenu.show(UIWidget.KEEP_FOCUS); }
Example 11
Source File: ValidUtils.java From letv with Apache License 2.0 | 4 votes |
public static boolean isUrlValid(String url) { return !TextUtils.empty(url) && (URLUtil.isHttpUrl(url) || URLUtil.isHttpsUrl(url) || url.startsWith("file:")); }
Example 12
Source File: AppIndexingUtil.java From 365browser with Apache License 2.0 | 4 votes |
/** * Extracts entities from document metadata and reports it to on-device App Indexing. * This call can cache entities from recently parsed webpages, in which case, only the url and * title of the page is reported to App Indexing. */ public void extractCopylessPasteMetadata(final Tab tab) { final String url = tab.getUrl(); boolean isHttpOrHttps = URLUtil.isHttpsUrl(url) || URLUtil.isHttpUrl(url); if (!isEnabledForDevice() || tab.isIncognito() || !isHttpOrHttps) { return; } // There are three conditions that can occur with respect to the cache. // 1. Cache hit, and an entity was found previously. Report only the page view to App // Indexing. // 2. Cache hit, but no entity was found. Ignore. // 3. Cache miss, we need to parse the page. if (wasPageVisitedRecently(url)) { if (lastPageVisitContainedEntity(url)) { // Condition 1 RecordHistogram.recordEnumeratedHistogram( "CopylessPaste.CacheHit", CACHE_HIT_WITH_ENTITY, CACHE_HISTOGRAM_BOUNDARY); getAppIndexingReporter().reportWebPageView(url, tab.getTitle()); return; } // Condition 2 RecordHistogram.recordEnumeratedHistogram( "CopylessPaste.CacheHit", CACHE_HIT_WITHOUT_ENTITY, CACHE_HISTOGRAM_BOUNDARY); } else { // Condition 3 RecordHistogram.recordEnumeratedHistogram( "CopylessPaste.CacheHit", CACHE_MISS, CACHE_HISTOGRAM_BOUNDARY); CopylessPaste copylessPaste = getCopylessPasteInterface(tab); if (copylessPaste == null) { return; } copylessPaste.getEntities(new CopylessPaste.GetEntitiesResponse() { @Override public void call(WebPage webpage) { putCacheEntry(url, webpage != null); if (sCallbackForTesting != null) { sCallbackForTesting.onResult(webpage); } if (webpage == null) return; getAppIndexingReporter().reportWebPage(webpage); } }); } }