Android Open Source - adkintun-mobile-browser Url Utils






From Project

Back to project page adkintun-mobile-browser.

License

The source code is released under:

Apache License

If you think the Android project adkintun-mobile-browser listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
* Copyright 2013 NIC Chile Research Labs
* /*from  w ww .  jav  a  2  s.c o  m*/
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cl.niclabs.adkintunmobile.browser;

import android.content.Context;

/**
 * Manejo de Urls.
 */
public class UrlUtils {

  /**
   * Revisa si el string es una url
   * @param url La url a revisar.
   * @return True si el string es una url.
   */
  public static boolean isUrl(String url) {
    return url.equals(C.URL_ABOUT_BLANK) ||
      url.equals(C.URL_ABOUT_START) ||
      url.contains(".");
  }
  
  /**
   * Devuelve la url de bsqueda
   * @param context Context actual.
   * @param searchTerms Trminos a buscar.
   * @return La url de bsqueda.
   */
  public static String getSearchUrl(Context context, String searchTerms) {
    String currentSearchUrl = C.URL_SEARCH_GOOGLE;
    return String.format(currentSearchUrl, searchTerms);
  }
  
  /**
   * Revisa una url. Agrega 'http://' si es que falta.
   * @param url La url a revisar.
   * @return La url modificada (si fue necesario).
   */
  public static String checkUrl(String url) {
    if ((url != null) &&
          (url.length() > 0)) {
      
        if ((!url.startsWith("http://")) &&
            (!url.startsWith("https://")) &&
            (!url.startsWith("file://")) &&
            (!url.startsWith(C.URL_ABOUT_BLANK)) &&
            (!url.startsWith(C.URL_ABOUT_START))) {
          url = "http://" + url;          
        }
    }
    
    return url;
  }  
  
  /**
   * Revisa si la url corresponde a un archivo local.
   * @param url La url a revisar.
   * @return True si la url es local.
   */
  public static boolean isLocal(String url) {
    if ((url != null) && (url.length() > 0)) {
        if (url.startsWith("file://") ||
          url.startsWith(C.URL_ABOUT_BLANK) ||
          url.startsWith(C.URL_ABOUT_START)) {
          return true;
        }
    }
    return false;
  }
}




Java Source Code List

cl.niclabs.adkintunmobile.browser.C.java
cl.niclabs.adkintunmobile.browser.Client.java
cl.niclabs.adkintunmobile.browser.CustomWebView.java
cl.niclabs.adkintunmobile.browser.DropDownAnim.java
cl.niclabs.adkintunmobile.browser.FileHandler.java
cl.niclabs.adkintunmobile.browser.MainActivity.java
cl.niclabs.adkintunmobile.browser.PreferencesActivity.java
cl.niclabs.adkintunmobile.browser.Register.java
cl.niclabs.adkintunmobile.browser.UrlUtils.java
cl.niclabs.adkintunmobile.crypto.AESEncrypter.java
cl.niclabs.adkintunmobile.crypto.Encrypter.java
cl.niclabs.adkintunmobile.crypto.RSAEncrypter.java