android.webkit.URLUtil#isHttpsUrl ( )源码实例Demo

下面列出了android.webkit.URLUtil#isHttpsUrl ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Yahala-Messenger   文件: ConnectActivity.java
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;
 }
 
源代码2 项目: Yahala-Messenger   文件: WebRtcPhone.java
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;
    }
 
源代码3 项目: MyOwnNotes   文件: SettingsActivity.java
/**
 * 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;
	}
}
 
源代码4 项目: FirefoxReality   文件: DownloadsManager.java
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();
    }
}
 
源代码5 项目: alpha-wallet-android   文件: Utils.java
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;
        }
    }
}
 
源代码6 项目: AntennaPodSP   文件: DownloadService.java
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;
}
 
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;
        }
    }
 
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;
    }
}
 
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;
    }
}
 
源代码10 项目: FirefoxReality   文件: NavigationBarWidget.java
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);
}
 
源代码11 项目: letv   文件: ValidUtils.java
public static boolean isUrlValid(String url) {
    return !TextUtils.empty(url) && (URLUtil.isHttpUrl(url) || URLUtil.isHttpsUrl(url) || url.startsWith("file:"));
}
 
源代码12 项目: 365browser   文件: AppIndexingUtil.java
/**
 * 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);
            }
        });
    }
}