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());
  }
 private void setPlaceWebsite() {
   final Uri webUri = getArguments().getParcelable(WEBSITE_KEY);
   final String weburl = (webUri != null && webUri.isHierarchical()) ? webUri.toString() : null;
   if (!TextUtils.isEmpty(weburl)) {
     mTvPlaceWebsite.setText(weburl);
     mWebVwebView.getSettings().setJavaScriptEnabled(true);
     mWebVwebView.setWebViewClient(new PlaceWebViewClient());
     mWebVwebView.loadUrl(weburl);
   } else {
     mTvPlaceWebsite.setVisibility(View.INVISIBLE);
     mWebVwebView.setVisibility(View.INVISIBLE);
   }
 }
Example #3
0
  private void handleSearchOrAppViewIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
      String query = intent.getStringExtra(SearchManager.QUERY);
      performSearch(query);
      return;
    }

    final Uri data = intent.getData();
    if (data == null) {
      return;
    }

    final String scheme = data.getScheme();
    final String path = data.getPath();
    String packageName = null;
    String query = null;
    if (data.isHierarchical()) {
      final String host = data.getHost();
      if (host == null) {
        return;
      }
      switch (host) {
        case "f-droid.org":
          if (path.startsWith("/repository/browse")) {
            // http://f-droid.org/repository/browse?fdfilter=search+query
            query = UriCompat.getQueryParameter(data, "fdfilter");

            // http://f-droid.org/repository/browse?fdid=packageName
            packageName = UriCompat.getQueryParameter(data, "fdid");
          } else if (path.startsWith("/app")) {
            // http://f-droid.org/app/packageName
            packageName = data.getLastPathSegment();
            if ("app".equals(packageName)) {
              packageName = null;
            }
          }
          break;
        case "details":
          // market://details?id=app.id
          packageName = UriCompat.getQueryParameter(data, "id");
          break;
        case "search":
          // market://search?q=query
          query = UriCompat.getQueryParameter(data, "q");
          break;
        case "play.google.com":
          if (path.startsWith("/store/apps/details")) {
            // http://play.google.com/store/apps/details?id=app.id
            packageName = UriCompat.getQueryParameter(data, "id");
          } else if (path.startsWith("/store/search")) {
            // http://play.google.com/store/search?q=foo
            query = UriCompat.getQueryParameter(data, "q");
          }
          break;
        case "apps":
        case "amazon.com":
        case "www.amazon.com":
          // amzn://apps/android?p=app.id
          // http://amazon.com/gp/mas/dl/android?s=app.id
          packageName = UriCompat.getQueryParameter(data, "p");
          query = UriCompat.getQueryParameter(data, "s");
          break;
      }
    } else if ("fdroid.app".equals(scheme)) {
      // fdroid.app:app.id
      packageName = data.getSchemeSpecificPart();
    } else if ("fdroid.search".equals(scheme)) {
      // fdroid.search:query
      query = data.getSchemeSpecificPart();
    }

    if (!TextUtils.isEmpty(query)) {
      // an old format for querying via packageName
      if (query.startsWith("pname:")) packageName = query.split(":")[1];

      // sometimes, search URLs include pub: or other things before the query string
      if (query.contains(":")) query = query.split(":")[1];
    }

    if (!TextUtils.isEmpty(packageName)) {
      Utils.debugLog(TAG, "FDroid launched via app link for '" + packageName + "'");
      Intent intentToInvoke = new Intent(this, AppDetails.class);
      intentToInvoke.putExtra(AppDetails.EXTRA_APPID, packageName);
      startActivity(intentToInvoke);
      finish();
    } else if (!TextUtils.isEmpty(query)) {
      Utils.debugLog(TAG, "FDroid launched via search link for '" + query + "'");
      performSearch(query);
    }
  }
 public boolean a_(Uri uri) {
   if (uri == null || !uri.isHierarchical()) {
     return false;
   }
   return b(uri) || c(uri);
 }