Example usage for android.net Uri decode

List of usage examples for android.net Uri decode

Introduction

In this page you can find the example usage for android.net Uri decode.

Prototype

public static String decode(String s) 

Source Link

Document

Decodes '%'-escaped octets in the given string using the UTF-8 scheme.

Usage

From source file:org.mobiledeeplinking.android.DeeplinkMatcher.java

static Map<String, String> matchQueryParameters(JSONObject routeOptions, String deeplinkQuery,
        Map<String, String> results) throws JSONException {
    JSONObject routeParameters = null;/*from  w w w.j  a va2  s.c  o  m*/
    if (routeOptions.has(Constants.ROUTE_PARAMS_JSON_NAME)) {
        routeParameters = routeOptions.getJSONObject(Constants.ROUTE_PARAMS_JSON_NAME);
        if (deeplinkQuery != null) {
            List<String> queryPairs = Arrays.asList(deeplinkQuery.split("&"));
            for (String query : queryPairs) {
                List<String> nameAndValue = Arrays.asList(query.split("="));
                if (nameAndValue.size() == 2) {
                    String name = Uri.decode(nameAndValue.get(0));
                    if (!routeParameters.has(name)) {
                        continue;
                    }

                    String value = Uri.decode(nameAndValue.get(1));
                    if (validateRouteComponent(name, value, routeOptions)) {
                        results.put(name, value);
                    } else {
                        MDLLog.e("DeeplinkMatcher", "Query Parameter Regex Checking failed.");
                        return null;
                    }
                }
            }
        }
    }
    return results;
}

From source file:com.vk.sdkweb.api.VKError.java

/**
 * Generate API error from HTTP-query// w  w  w.  j a  va  2  s . com
 *
 * @param queryParams key-value parameters
 */
public VKError(Map<String, String> queryParams) {
    this.errorCode = VK_API_ERROR;
    this.errorReason = queryParams.get("error_reason");
    this.errorMessage = Uri.decode(queryParams.get("error_description"));
}

From source file:com.appnexus.opensdk.ANJAMImplementation.java

private static void callExternalBrowser(WebView webView, Uri uri) {
    String urlParam = uri.getQueryParameter("url");

    if ((webView.getContext() == null) || (urlParam == null) || (!urlParam.startsWith("http"))) {
        return;/*from w  w  w  .j  ava  2s.c o  m*/
    }
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Uri.decode(urlParam)));
        webView.getContext().startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(webView.getContext(), R.string.action_cant_be_completed, Toast.LENGTH_SHORT).show();
    }
}

From source file:com.ubikod.capptain.android.sdk.track.CapptainTrackReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    /* Once the application identifier is known */
    if ("com.ubikod.capptain.intent.action.APPID_GOT".equals(intent.getAction())) {
        /* Init the tracking agent */
        String appId = intent.getStringExtra("appId");
        CapptainTrackAgent.getInstance(context).onAppIdGot(appId);
    }/*from w w w  .  j ava2  s  . c om*/

    /* During installation, an install referrer may be triggered */
    else if ("com.android.vending.INSTALL_REFERRER".equals(intent.getAction())) {
        /* Forward this action to configured receivers */
        String forwardList = CapptainUtils.getMetaData(context)
                .getString("capptain:track:installReferrerForwardList");
        if (forwardList != null)
            for (String component : forwardList.split(","))
                if (!component.equals(getClass().getName())) {
                    Intent clonedIntent = new Intent(intent);
                    clonedIntent.setComponent(new ComponentName(context, component));
                    context.sendBroadcast(clonedIntent);
                }

        /* Guess store from referrer */
        String referrer = Uri.decode(intent.getStringExtra("referrer"));
        String store;

        /* GetJar uses an opaque string always starting with z= */
        if (referrer.startsWith("z="))
            store = "GetJar";

        /* Assume Android Market otherwise */
        else
            store = "Android Market";

        /* Look for a source parameter */
        Uri uri = Uri.parse("a://a?" + referrer);
        String source = uri.getQueryParameter("utm_source");

        /*
         * Skip "androidmarket" source, this is the default one when not set or installed via web
         * Android Market.
         */
        if ("androidmarket".equals(source))
            source = null;

        /* Send app info to register store/source */
        Bundle appInfo = new Bundle();
        appInfo.putString("store", store);
        if (source != null) {
            /* Parse source, if coming from capptain, it may be a JSON complex object */
            try {
                /* Convert JSON to bundle (just flat strings) */
                JSONObject jsonInfo = new JSONObject(source);
                Iterator<?> keyIt = jsonInfo.keys();
                while (keyIt.hasNext()) {
                    String key = keyIt.next().toString();
                    appInfo.putString(key, jsonInfo.getString(key));
                }
            } catch (JSONException jsone) {
                /* Not an object, process as a string */
                appInfo.putString("source", source);
            }
        }

        /* Send app info */
        CapptainAgent.getInstance(context).sendAppInfo(appInfo);
    }
}

From source file:org.videolan.vlc.gui.video.MediaInfoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View v = inflater.inflate(R.layout.media_info, container, false);

    mLengthView = (TextView) v.findViewById(R.id.length);
    mSizeView = (TextView) v.findViewById(R.id.size_value);
    mPathView = (TextView) v.findViewById(R.id.info_path);
    mPlayButton = (FloatingActionButton) v.findViewById(R.id.play);
    mDelete = (ImageButton) v.findViewById(R.id.info_delete);
    mSubtitles = (ImageView) v.findViewById(R.id.info_subtitles);

    mThreadPoolExecutor = Executors.newFixedThreadPool(2);
    mThreadPoolExecutor.submit(mCheckFile);
    mThreadPoolExecutor.submit(mLoadImage);

    mPathView.setText(mItem == null ? "" : Uri.decode(mItem.getLocation().substring(7)));
    mPlayButton.setOnClickListener(new OnClickListener() {
        @Override/*from ww w. ja  v a  2 s  . c  o  m*/
        public void onClick(View v) {
            VideoPlayerActivity.start(getActivity(), mItem.getUri());
        }
    });

    mDelete.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mItem != null) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        boolean deleted = Util.deleteFile(mItem.getLocation());
                        if (deleted) {
                            mHandler.obtainMessage(EXIT).sendToTarget();
                        }
                    }
                }).start();
            }
        }
    });
    mAdapter = new MediaInfoAdapter(getActivity());
    setListAdapter(mAdapter);

    return v;
}

From source file:org.videolan.vlc.gui.PlaylistActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mBinding = DataBindingUtil.setContentView(this, R.layout.playlist_activity);

    initAudioPlayerContainerActivity();//w  w  w .j ava  2  s.  c  om
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mPlaylist = (MediaLibraryItem) (savedInstanceState != null
            ? savedInstanceState.getParcelable(AudioBrowserFragment.TAG_ITEM)
            : getIntent().getParcelableExtra(AudioBrowserFragment.TAG_ITEM));
    mBinding.setPlaylist(mPlaylist);
    mAdapter = new AudioBrowserAdapter(this, MediaLibraryItem.TYPE_MEDIA, this, false);

    mBinding.songs.setLayoutManager(new LinearLayoutManager(this));
    mBinding.songs.setAdapter(mAdapter);
    final int fabVisibility = savedInstanceState != null ? savedInstanceState.getInt(TAG_FAB_VISIBILITY) : -1;

    if (!TextUtils.isEmpty(mPlaylist.getArtworkMrl())) {
        VLCApplication.runBackground(new Runnable() {
            @Override
            public void run() {
                final Bitmap cover = AudioUtil.readCoverBitmap(Uri.decode(mPlaylist.getArtworkMrl()), 0);
                if (cover != null) {
                    mBinding.setCover(new BitmapDrawable(PlaylistActivity.this.getResources(), cover));
                    VLCApplication.runOnMainThread(new Runnable() {
                        @Override
                        public void run() {
                            mBinding.appbar.setExpanded(true, true);
                            if (fabVisibility != -1)
                                mBinding.fab.setVisibility(fabVisibility);
                        }
                    });
                } else
                    fabFallback();
            }
        });
    } else
        fabFallback();
    mBinding.fab.setOnClickListener(this);
}

From source file:com.appnexus.opensdk.ANJAMImplementation.java

@SuppressLint("SetJavaScriptEnabled")
private static void callInternalBrowser(AdWebView webView, Uri uri) {
    String urlParam = uri.getQueryParameter("url");

    if ((webView.getContext() == null) || (urlParam == null) || (!urlParam.startsWith("http"))) {
        return;/*from  w w w . jav  a 2 s .c o m*/
    }

    String url = Uri.decode(urlParam);
    Class<?> activity_clz = AdActivity.getActivityClass();

    Intent intent = new Intent(webView.getContext(), activity_clz);
    intent.putExtra(AdActivity.INTENT_KEY_ACTIVITY_TYPE, AdActivity.ACTIVITY_TYPE_BROWSER);

    WebView browserWebView = new WebView(webView.getContext());
    WebviewUtil.setWebViewSettings(browserWebView);
    BrowserAdActivity.BROWSER_QUEUE.add(browserWebView);
    browserWebView.loadUrl(url);

    if (webView.adView.getBrowserStyle() != null) {
        String i = "" + browserWebView.hashCode();
        intent.putExtra("bridgeid", i);
        AdView.BrowserStyle.bridge
                .add(new Pair<String, AdView.BrowserStyle>(i, webView.adView.getBrowserStyle()));
    }

    try {
        webView.getContext().startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(webView.getContext(), R.string.action_cant_be_completed, Toast.LENGTH_SHORT).show();
        Clog.w(Clog.baseLogTag, Clog.getString(R.string.adactivity_missing, activity_clz.getName()));
        BrowserAdActivity.BROWSER_QUEUE.remove();
    }
}

From source file:com.vk.sdk.api.VKError.java

/**
 * Generate API error from HTTP-query/*  w w w. j  av  a 2 s .  c  o m*/
 *
 * @param queryParams key-value parameters
 */
public VKError(Map<String, String> queryParams) {
    this.errorCode = VK_API_ERROR;
    this.errorReason = queryParams.get(ERROR_REASON);
    this.errorMessage = Uri.decode(queryParams.get(ERROR_DESCRIPTION));
    if (queryParams.containsKey(FAIL)) {
        this.errorReason = "Action failed";
    }
    if (queryParams.containsKey("cancel")) {
        this.errorCode = VK_CANCELED;
        this.errorReason = "User canceled request";
    }
}

From source file:org.videolan.vlc.gui.tv.RecommendationsService.java

private boolean doRecommendations() {
    mNotificationManager.cancelAll();/*from w w  w .j  ava 2  s.  c o  m*/
    String last = Uri.decode(PreferenceManager.getDefaultSharedPreferences(mContext)
            .getString(PreferencesActivity.VIDEO_LAST, null));
    int id = 0;
    if (last != null) {
        buildRecommendation(MediaLibrary.getInstance().getMediaItem(last), id, Notification.PRIORITY_HIGH);
    }
    ArrayList<MediaWrapper> videoList = MediaLibrary.getInstance().getVideoItems();
    if (videoList == null || videoList.isEmpty())
        return false;
    Bitmap pic;
    Collections.shuffle(videoList);
    for (MediaWrapper mediaWrapper : videoList) {
        if (TextUtils.equals(mediaWrapper.getLocation(), last))
            continue;
        pic = mMediaDatabase.getPicture(mediaWrapper.getUri());
        if (pic != null && pic.getByteCount() > 4 && mediaWrapper.getTime() == 0) {
            buildRecommendation(mediaWrapper, ++id, Notification.PRIORITY_DEFAULT);
        }
        if (id == NUM_RECOMMANDATIONS)
            break;
    }
    return true;
}

From source file:org.videolan.vlc.gui.video.MediaInfoFragment.java

private void checkSubtitles(File itemFile) {
    String extension, filename, videoName = Uri.decode(itemFile.getName()),
            parentPath = Uri.decode(itemFile.getParent());
    videoName = videoName.substring(0, videoName.lastIndexOf('.'));
    String[] subFolders = { "/Subtitles", "/subtitles", "/Subs", "/subs" };
    String[] files = itemFile.getParentFile().list();
    int filesLength = files == null ? 0 : files.length;
    for (int i = 0; i < subFolders.length; ++i) {
        File subFolder = new File(parentPath + subFolders[i]);
        if (!subFolder.exists())
            continue;
        String[] subFiles = subFolder.list();
        int subFilesLength = 0;
        String[] newFiles = new String[0];
        if (subFiles != null) {
            subFilesLength = subFiles.length;
            newFiles = new String[filesLength + subFilesLength];
            System.arraycopy(subFiles, 0, newFiles, 0, subFilesLength);
        }/*from ww w.  j  a  v a  2s .  co  m*/
        if (files != null)
            System.arraycopy(files, 0, newFiles, subFilesLength, filesLength);
        files = newFiles;
        filesLength = files.length;
    }
    for (int i = 0; i < filesLength; ++i) {
        filename = Uri.decode(files[i]);
        int index = filename.lastIndexOf('.');
        if (index <= 0)
            continue;
        extension = filename.substring(index);
        if (!Extensions.SUBTITLES.contains(extension))
            continue;
        if (filename.startsWith(videoName)) {
            mHandler.obtainMessage(SHOW_SUBTITLES).sendToTarget();
            return;
        }
    }
}