Пример #1
0
  private void addExternalBoardImpl(String board_name, String board_uri) {
    board_name = board_name.trim();
    board_uri = board_uri.trim();
    if (board_uri.length() == 0) return;
    Uri uri = Uri.parse(board_uri);
    if (uri == null) return;
    if (uri.getHost() == null || uri.getHost().length() == 0) return;
    if (uri.getPath() == null || uri.getPath().length() == 0) return;

    getAgent()
        .getBoardData(
            uri,
            true,
            new BoardListAgent.BoardFetchedCallback() {
              @Override
              public void onBoardFetched(BoardData newBoardData) {
                runOnUiThread(
                    new Runnable() {
                      @Override
                      public void run() {
                        reloadBoardList(true, false);
                      }
                    });
              }
            });
  }
Пример #2
0
 private boolean isChildImageUri(Uri uri) {
   // Sometimes, the URI of an image contains a query string with key
   // "bucketId" inorder to restore the image list. However, the query
   // string is not part of the mBaseUri. So, we check only other parts
   // of the two Uri to see if they are the same.
   Uri base = mBaseUri;
   return Util.equals(base.getScheme(), uri.getScheme())
       && Util.equals(base.getHost(), uri.getHost())
       && Util.equals(base.getAuthority(), uri.getAuthority())
       && Util.equals(base.getPath(), getPathWithoutId(uri));
 }
Пример #3
0
  // Determine if this URI appears to be for a Google search
  // and does not have an RLZ parameter.
  // Taken largely from Chrome source, src/chrome/browser/google_url_tracker.cc
  private static boolean needsRlzString(Uri uri) {
    String scheme = uri.getScheme();
    if (("http".equals(scheme) || "https".equals(scheme))
        && (uri.getQueryParameter("q") != null)
        && (uri.getQueryParameter("rlz") == null)) {
      String host = uri.getHost();
      if (host == null) {
        return false;
      }
      String[] hostComponents = host.split("\\.");

      if (hostComponents.length < 2) {
        return false;
      }
      int googleComponent = hostComponents.length - 2;
      String component = hostComponents[googleComponent];
      if (!"google".equals(component)) {
        if (hostComponents.length < 3 || (!"co".equals(component) && !"com".equals(component))) {
          return false;
        }
        googleComponent = hostComponents.length - 3;
        if (!"google".equals(hostComponents[googleComponent])) {
          return false;
        }
      }

      // Google corp network handling.
      if (googleComponent > 0 && "corp".equals(hostComponents[googleComponent - 1])) {
        return false;
      }

      return true;
    }
    return false;
  }
Пример #4
0
  private boolean handleNativeBrowserScheme(String url) {
    if (!isNativeBrowserScheme(url)) {
      return false;
    }

    Uri uri = Uri.parse(url);

    String urlToOpenInNativeBrowser;
    try {
      urlToOpenInNativeBrowser = uri.getQueryParameter("url");
    } catch (UnsupportedOperationException e) {
      Log.w("Adcash", "Could not handle url: " + url);
      return false;
    }

    if (!"navigate".equals(uri.getHost()) || urlToOpenInNativeBrowser == null) {
      return false;
    }

    Uri intentUri = Uri.parse(urlToOpenInNativeBrowser);

    Intent intent = new Intent(Intent.ACTION_VIEW, intentUri);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    String errorMessage =
        "Could not handle intent with URI: " + url + ". Is this intent supported on your phone?";

    launchIntentForUserClick(mContext, intent, errorMessage);

    return true;
  }
Пример #5
0
  @Override
  public Drawable getDrawable(final String source) {
    Uri uri = Uri.parse(source);
    if (!"cdn.akamai.steamstatic.com".equals(uri.getHost())) return null;

    final BitmapDrawablePlaceHolder result = new BitmapDrawablePlaceHolder(resources);

    new AsyncTask<Void, Void, Bitmap>() {
      @Override
      protected Bitmap doInBackground(final Void... meh) {
        try {
          return picasso.load(source).get();
        } catch (Exception e) {
          return null;
        }
      }

      @Override
      protected void onPostExecute(final Bitmap bitmap) {
        try {
          final BitmapDrawable drawable = new BitmapDrawable(resources, bitmap);

          drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());

          result.setDrawable(drawable);
          result.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());

          textView.setText(textView.getText());
        } catch (Exception e) {
        }
      }
    }.execute((Void) null);

    return result;
  }
 public String a_(Uri uri, HashMap hashMap) {
   if (c(uri)) {
     String host = uri.getHost();
     if (host == null) {
       b.e("An error occurred while parsing the AMSG parameters.");
       return null;
     } else if (host.equals("launch")) {
       hashMap.put("a", "intent");
       hashMap.put("u", hashMap.get("url"));
       hashMap.remove("url");
       return "/open";
     } else if (host.equals("closecanvas")) {
       return "/close";
     } else {
       if (host.equals("log")) {
         return "/log";
       }
       b.e("An error occurred while parsing the AMSG: " + uri.toString());
       return null;
     }
   } else if (b(uri)) {
     return uri.getPath();
   } else {
     b.e("Message was neither a GMSG nor an AMSG.");
     return null;
   }
 }
Пример #7
0
 public boolean b(Uri object) {
   int n;
   String[] arrstring;
   int n2;
   boolean bl = false;
   if (object == null) {
     throw new NullPointerException();
   }
   try {
     object = object.getHost();
     arrstring = this.kU;
     n2 = arrstring.length;
     n = 0;
   } catch (NullPointerException var1_2) {
     return false;
   }
   do {
     boolean bl2 = bl;
     if (n < n2) {
       bl2 = object.endsWith(arrstring[n]);
       if (bl2) {
         bl2 = true;
       }
     } else {
       return bl2;
     }
     ++n;
   } while (true);
 }
Пример #8
0
 protected void parseLaunchIntentLocation() {
   Intent intent = getIntent();
   if (intent != null && intent.getData() != null) {
     Uri data = intent.getData();
     if ("http".equalsIgnoreCase(data.getScheme())
         && "download.osmand.net".equals(data.getHost())
         && "/go".equals(data.getPath())) {
       String lat = data.getQueryParameter("lat");
       String lon = data.getQueryParameter("lon");
       if (lat != null && lon != null) {
         try {
           double lt = Double.parseDouble(lat);
           double ln = Double.parseDouble(lon);
           String zoom = data.getQueryParameter("z");
           int z = settings.getLastKnownMapZoom();
           if (zoom != null) {
             z = Integer.parseInt(zoom);
           }
           settings.setMapLocationToShow(lt, ln, z, getString(R.string.shared_location));
         } catch (NumberFormatException e) {
         }
       }
     }
   }
 }
Пример #9
0
  public static String getCacheFilenameForUri(Uri uri) {
    StringBuilder filename = new StringBuilder();
    filename.append(uri.getScheme()).append("_").append(uri.getHost()).append("_");
    String encodedPath = uri.getEncodedPath();
    if (!TextUtils.isEmpty(encodedPath)) {
      int length = encodedPath.length();
      if (length > 60) {
        encodedPath = encodedPath.substring(length - 60);
      }
      encodedPath = encodedPath.replace('/', '_');
      filename.append(encodedPath).append("_");
    }
    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      md.update(uri.toString().getBytes("UTF-8"));
      byte[] digest = md.digest();
      for (byte b : digest) {
        if ((0xff & b) < 0x10) {
          filename.append("0").append(Integer.toHexString((0xFF & b)));
        } else {
          filename.append(Integer.toHexString(0xFF & b));
        }
      }
    } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
      filename.append(uri.toString().hashCode());
    }

    return filename.toString();
  }
Пример #10
0
    public PublicURLProcessor(Uri uri)
    {
        mUri = uri;
        mHost = mUri.getHost();
        if (!Util.isEmpty(mHost))
        {
            mHost = mHost.toLowerCase();
        }
        mPathSegments = mUri.getPathSegments();
        mRefmarker = mUri.getQueryParameter("ref");
        mAssociateTag = mUri.getQueryParameter("tag");
        mLocaleName = getLocaleNameFromUri(uri);
        mParams = new HashMap();
        String s;
        boolean flag;
        if (android.os.Build.VERSION.SDK_INT >= 11)
        {
            flag = true;
        } else
        {
            flag = false;
        }
        if (flag)
        {
            uri = mUri.getQueryParameterNames();
        } else
        {
            uri = parseQueryParameterNames(mUri);
        }
        for (uri = uri.iterator(); uri.hasNext(); mParams.put(s, mUri.getQueryParameter(s)))
        {
            s = (String)uri.next();
        }

    }
Пример #11
0
  @Override
  public boolean imageShowSuccess(Uri uri) {
    if (uri != null) {
      if (DEBUG) {
        Log.d(
            "imageShowSuccess",
            "[[imageShowSuccess]] uri : "
                + uri.getScheme()
                + " uri path : "
                + uri.getPath()
                + " uri title : "
                + uri.getHost()
                + " encode path = "
                + uri.getEncodedPath()
                + " toString : "
                + uri.toString());
      }
      String checkUrl = uri.getPath();
      if (!TextUtils.isEmpty(checkUrl) && checkUrl.toLowerCase().startsWith("http")) {
        // do nothing
      } else if (!TextUtils.isEmpty(checkUrl) && checkUrl.toLowerCase().startsWith(FILE_CONTENT)) {
        checkUrl = checkUrl.substring(FILE_CONTENT.length());
      }
      if (!TextUtils.isEmpty(checkUrl) && checkUrl.equals(mUrl)) {
        return mCurrentBtLoadSuccess;
      }
    }

    return false;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // Creates the LayerClient object if it does not exist
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_conversations);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(R.string.recent_chats);

    Intent it = getIntent();
    if (it != null && it.getData() != null) {
      Uri uri = it.getData();
      String host = uri.getHost();
      String path = uri.getPath();
      Log.d("WILL path", path);

      if (host.contains("im")) {
        // Get conversation-id from notif Intent
        String conversationIdStr = path.substring(1);
        Log.d("WILL conversationIdStr", conversationIdStr);
        Uri conversationIdUri = Uri.parse(conversationIdStr);
        Log.d("WILL conversationIdUri", conversationIdUri.toString());

        Intent intent = new Intent(this, MessageActivity.class);
        intent.putExtra("conversation-id", conversationIdUri);
        startActivity(intent);
      }
    }

    //        Button logoutBtn = (Button) findViewById(R.id.logout);
    //        if (logoutBtn != null)
    //            logoutBtn.setOnClickListener(this);
  }
Пример #13
0
 static BitmapHunter forRequest(
     Context context,
     Picasso picasso,
     Dispatcher dispatcher,
     Cache cache,
     Stats stats,
     Action action,
     Downloader downloader) {
   if (action.getData().resourceId != 0) {
     return new ResourceBitmapHunter(context, picasso, dispatcher, cache, stats, action);
   }
   Uri uri = action.getData().uri;
   String scheme = uri.getScheme();
   if (SCHEME_CONTENT.equals(scheme)) {
     if (Contacts.CONTENT_URI.getHost().equals(uri.getHost()) //
         && !uri.getPathSegments().contains(Contacts.Photo.CONTENT_DIRECTORY)) {
       return new ContactsPhotoBitmapHunter(context, picasso, dispatcher, cache, stats, action);
     } else {
       return new ContentProviderBitmapHunter(context, picasso, dispatcher, cache, stats, action);
     }
   } else if (SCHEME_FILE.equals(scheme)) {
     if (!uri.getPathSegments().isEmpty() && ANDROID_ASSET.equals(uri.getPathSegments().get(0))) {
       return new AssetBitmapHunter(context, picasso, dispatcher, cache, stats, action);
     }
     return new FileBitmapHunter(context, picasso, dispatcher, cache, stats, action);
   } else if (SCHEME_ANDROID_RESOURCE.equals(scheme)) {
     return new ResourceBitmapHunter(context, picasso, dispatcher, cache, stats, action);
   } else {
     return new NetworkBitmapHunter(picasso, dispatcher, cache, stats, action, downloader);
   }
 }
 @Override
 public boolean canHandleRequest(Request data) {
   final Uri uri = data.uri;
   return (SCHEME_CONTENT.equals(uri.getScheme())
       && ContactsContract.Contacts.CONTENT_URI.getHost().equals(uri.getHost())
       && !uri.getPathSegments().contains(ContactsContract.Contacts.Photo.CONTENT_DIRECTORY));
 }
  private void fillData(@Nullable Intent intent, @NonNull TextView textView) {
    Uri data = intent == null ? null : intent.getData();
    if (data == null) {
      textView.setText(Printer.EMPTY);
      return;
    }

    Truss truss = new Truss();
    Printer.append(truss, "raw", data);
    Printer.append(truss, "scheme", data.getScheme());
    Printer.append(truss, "host", data.getHost());
    Printer.append(truss, "port", data.getPort());
    Printer.append(truss, "path", data.getPath());
    Printer.appendKey(truss, "query");
    boolean query = false;
    if (data.isHierarchical()) {
      for (String queryParameterName : data.getQueryParameterNames()) {
        Printer.appendSecondary(
            truss, queryParameterName, data.getQueryParameter(queryParameterName));
        query = true;
      }
    }
    if (!query) {
      Printer.appendValue(truss, null);
    }
    Printer.append(truss, "fragment", data.getFragment());
    textView.setText(truss.build());
  }
 /**
  * Constructs a new UriBuilder from the given Uri.
  *
  * @return a new Uri Builder based off the given Uri.
  */
 public static UriBuilder newInstance(Uri uri) {
   return new UriBuilder()
       .scheme(uri.getScheme())
       .host(uri.getHost())
       .path(uri.getPath())
       .query(uri.getQuery());
 }
  /**
   * Check every external resource if it's okay to load it and maybe replace it with our own
   * content. This is used to block loading Niantic resources which aren’t required and to inject
   * IITC early into the site. via http://stackoverflow.com/a/8274881/1684530
   */
  @Override
  public WebResourceResponse shouldInterceptRequest(final WebView view, final String url) {
    // if any tiles are requested, handle it with IITC_TileManager
    if (url.matches(".*tile.*jpg.*") // mapquest tiles | ovi tiles
        || url.matches(".*tile.*png.*") // cloudmade tiles
        || url.matches(".*mts.*googleapis.*") // google tiles
        || url.matches(".*khms.*googleapis.*") // google satellite tiles
        || url.matches(".*tile.*jpeg.*") // bing tiles
        || url.matches(".*maps.*yandex.*tiles.*") // yandex maps
        || url.matches(".*cartocdn.*png.*") // cartoDB tiles
    ) {
      try {
        return mTileManager.getTile(url);
      } catch (final Exception e) {
        Log.w(e);
        return super.shouldInterceptRequest(view, url);
      }
    }

    if (url.contains("/css/common.css")) {
      // return custom stylesheet
      return new WebResourceResponse("text/css", "UTF-8", STYLE);
    }

    if (url.contains("/css/ap_icons.css")
        || url.contains("/css/map_icons.css")
        || url.contains("/css/common.css")
        || url.contains("/css/misc_icons.css")
        || url.contains("/css/style_full.css")
        || url.contains("/css/style_mobile.css")
        || url.contains("/css/portalrender.css")
        || url.contains("/css/portalrender_mobile.css")
        || url.contains("js/analytics.js")
        || url.contains("google-analytics.com/ga.js")) {
      // don't load stylesheets
      return new WebResourceResponse("text/plain", "UTF-8", EMPTY);
    }

    final Uri uri = Uri.parse(url);
    if (uri.getHost() != null
        && uri.getHost().endsWith(DOMAIN)
        && ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())))
      return mIitc.getFileManager().getResponse(uri);

    return super.shouldInterceptRequest(view, url);
  }
Пример #18
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    context = this;

    setContentView(R.layout.main);

    editText = (EditText) findViewById(R.id.input);
    editTextTitlePost = null;
    editTextDescriptionPost = null;

    /** --- From ShareVia Intent */
    if (getIntent().getExtras() != null) {
      String shareVia = (String) getIntent().getExtras().get(Intent.EXTRA_TEXT);
      if (shareVia != null) {
        editText.setText(shareVia);
      }
    }
    if (getIntent().getAction() == Intent.ACTION_VIEW) {
      Uri data = getIntent().getData();
      String scheme = data.getScheme();
      String host = data.getHost();
      List<String> params = data.getPathSegments();
      String builded = scheme + "://" + host + "/";

      for (String string : params) {
        builded += string + "/";
      }

      if (data.getQuery() != null && !data.getQuery().equals("")) {
        builded = builded.substring(0, builded.length() - 1);
        builded += "?" + data.getQuery();
      }

      System.out.println(builded);

      editText.setText(builded);
    }
    /** --- */
    submitButton = (Button) findViewById(R.id.action_go);
    randomButton = (Button) findViewById(R.id.random);
    postButton = (Button) findViewById(R.id.post);

    previewAreaTitle = (TextView) findViewById(R.id.preview_area);
    postAreaTitle = (TextView) findViewById(R.id.post_area);

    /** Where the previews will be dropped */
    dropPreview = (ViewGroup) findViewById(R.id.drop_preview);

    /** Where the previews will be dropped */
    dropPost = (ViewGroup) findViewById(R.id.drop_post);

    textCrawler = new TextCrawler();

    initSubmitButton();
    initRandomButton();
  }
Пример #19
0
  private static boolean isRedditUri(Uri uri) {

    final String[] hostSegments = uri.getHost().toLowerCase().split("\\.");
    if (hostSegments.length < 2) return false;
    if (!hostSegments[hostSegments.length - 1].equals("com")) return false;
    if (!hostSegments[hostSegments.length - 2].equals("reddit")) return false;

    return true;
  }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   String url = getArguments().getString(ARG_IMAGE_URL);
   Uri uri = Uri.parse(url);
   if (uri.getHost() == null) {
     uri = Uri.parse("http://" + ArticleApi.getDomainRoot(mContext) + url);
   }
   mUri = uri;
 }
Пример #21
0
 /*
  * Get the default path and filename for the saved file from content: scheme.
  * As the directory is always used the SD storage.
  * For GMail, the filename is the _display_name in its ContentProvider. Otherwise the file has
  * no name.
  * !IMPORTANT! When you add another "special" intent-filter like the one for GMail, consider,
  * if you could add also the code for finding out the filename.
  */
 private String getPath(Uri uri) {
   Uri sd = Uri.fromFile(Environment.getExternalStorageDirectory());
   if (uri.getHost().equals("gmail-ls")) {
     Cursor cur = managedQuery(uri, new String[] {"_display_name"}, null, null, null);
     int nameColumn = cur.getColumnIndex("_display_name");
     if (cur.moveToFirst()) {
       return sd.buildUpon().appendPath(cur.getString(nameColumn)).toString();
     }
   }
   return sd.getPath();
 }
    @Override
    public boolean shouldTryHandlingUrl(@NonNull final Uri uri) {
      final String scheme = uri.getScheme();
      final String host = uri.getHost();

      return "play.google.com".equals(host)
          || "market.android.com".equals(host)
          || "market".equals(scheme)
          || uri.toString().startsWith("play.google.com/")
          || uri.toString().startsWith("market.android.com/");
    }
Пример #23
0
 public boolean a(Uri uri) {
   if (uri == null) {
     throw new NullPointerException();
   }
   try {
     boolean bl = uri.getHost().equals(this.kT);
     return bl;
   } catch (NullPointerException var1_2) {
     return false;
   }
 }
Пример #24
0
 public boolean matches(Uri uri) {
   try {
     return ((scheme == null || scheme.matcher(uri.getScheme()).matches())
         && (host == null || host.matcher(uri.getHost()).matches())
         && (port == null || port.equals(uri.getPort()))
         && (path == null || path.matcher(uri.getPath()).matches()));
   } catch (Exception e) {
     LOG.d(TAG, e.toString());
     return false;
   }
 }
Пример #25
0
  public boolean isLocal() {
    ServerDB server = getServer();
    Uri uri = Uri.parse(link);

    try {
      return uri.getHost().equals(Uri.parse(server.getLocalUrl()).getHost());
    } catch (Exception e) {
    }

    return false;
  }
Пример #26
0
  public void setImageURI(Uri uri, boolean forceOriginLoad) {
    unRegistehandler();
    mCurrentBtLoadSuccess = false;

    if (uri != null) {
      if (DEBUG) {
        Log.d(
            "setImageURI",
            "[[setImageURI]] uri : "
                + uri.getScheme()
                + " uri path : "
                + uri.getPath()
                + " uri title : "
                + uri.getHost()
                + " encode path = "
                + uri.getEncodedPath()
                + " toString : "
                + uri.toString());
      }
      String path = uri.getPath();
      if (!TextUtils.isEmpty(path) && path.toLowerCase().startsWith("http")) {
        this.setImageUrl(uri.getPath(), forceOriginLoad);
        return;
      } else if (!TextUtils.isEmpty(path) && path.toLowerCase().startsWith(FILE_CONTENT)) {
        String localUri = path.substring(FILE_CONTENT.length());
        if (!TextUtils.isEmpty(localUri)) {
          this.setImageUrlLocal(localUri, forceOriginLoad);
          return;
        }
      }
      mUrl = null;
      setImageDrawable(mDefaultSrc);
    } else {
      mUrl = null;
      if (mCurrentDownloadRequest != null) {
        mCurrentDownloadRequest.cancelDownload();
      }
      if (mHasAnimation) {
        this.clearAnimation();
      }
      // super.setImageURI(uri);
      if (mWebImageViewStatusListener != null) {
        mHandler.post(
            new Runnable() {
              @Override
              public void run() {
                mWebImageViewStatusListener.onLoadImageFailed(WebImageView.this, mUrl);
              }
            });
      }
      setImageDrawable(mDefaultSrc);
    }
  }
Пример #27
0
 private static int findDefaultTrafficStatsTag(String url) {
   if (!TextUtils.isEmpty(url)) {
     Uri uri = Uri.parse(url);
     if (uri != null) {
       String host = uri.getHost();
       if (host != null) {
         return host.hashCode();
       }
     }
   }
   return 0;
 }
  static ICustomNetworkLink getLinkFromIntent(Intent intent) {
    final Uri uri = intent.getData();
    if (uri == null || !intent.hasExtra(ADD_CATALOG_ID_KEY)) {
      return null;
    }

    return new OPDSCustomLink(
        intent.getIntExtra(ADD_CATALOG_ID_KEY, ICustomNetworkLink.INVALID_ID),
        uri.getHost(),
        intent.getStringExtra(ADD_CATALOG_TITLE_KEY),
        intent.getStringExtra(ADD_CATALOG_SUMMARY_KEY),
        (UrlInfoCollection<UrlInfoWithDate>) intent.getSerializableExtra(ADD_CATALOG_URLS_MAP_KEY));
  }
Пример #29
0
 public static String getLocaleNameFromUri(Uri uri)
 {
     if (uri != null)
     {
         if (!Util.isEmpty(uri = uri.getHost()))
         {
             uri = uri.toLowerCase();
             uri = uri.substring(uri.indexOf("amazon.") + "amazon.".length());
             return (String)sLocaleMapping.get(uri);
         }
     }
     return null;
 }
Пример #30
0
 public static boolean isValidUri(String uri) {
   if (TextUtils.isEmpty(uri)) return false;
   Uri parsed = Uri.parse(uri);
   return parsed != null
       && !TextUtils.isEmpty(parsed.getAuthority())
       && !TextUtils.isEmpty(parsed.getHost())
       && !TextUtils.isEmpty(parsed.getScheme())
       && ("imap+ssl+".equalsIgnoreCase(parsed.getScheme())
           || "imap+ssl".equalsIgnoreCase(parsed.getScheme())
           || "imap".equalsIgnoreCase(parsed.getScheme())
           || "imap+tls+".equalsIgnoreCase(parsed.getScheme())
           || "imap+tls".equalsIgnoreCase(parsed.getScheme()));
 }