List of usage examples for android.net Uri getUserInfo
@Nullable public abstract String getUserInfo();
From source file:com.oakesville.mythling.util.MediaStreamProxy.java
/** * Returns ProxyInfo if proxy is needed, null otherwise. */// w ww . ja v a 2s.c om public static ProxyInfo needsAuthProxy(Uri mediaUri) throws MalformedURLException { ProxyInfo proxyInfo = null; String userInfo = mediaUri.getUserInfo(); int colon = userInfo == null ? -1 : userInfo.indexOf(':'); if (colon > 0) { proxyInfo = new ProxyInfo(); proxyInfo.user = userInfo.substring(0, colon); proxyInfo.password = userInfo.substring(colon + 1); proxyInfo.netUrl = getNetUrl(mediaUri); } return proxyInfo; }
From source file:org.brandroid.openmanager.util.FileManager.java
public static OpenPath getOpenCache(String path, Boolean bGetNetworkedFiles, SortType sort) throws IOException //, SmbAuthException, SmbException { if (path == null) return null; //Logger.LogDebug("Checking cache for " + path); if (mOpenCache == null) mOpenCache = new Hashtable<String, OpenPath>(); OpenPath ret = mOpenCache.get(path); if (ret == null) { if (path.startsWith("ftp:/") && OpenServers.DefaultServers != null) { Logger.LogDebug("Checking cache for " + path); FTPManager man = new FTPManager(path); FTPFile file = new FTPFile(); file.setName(path.substring(path.lastIndexOf("/") + 1)); Uri uri = Uri.parse(path); OpenServer server = OpenServers.DefaultServers.findByHost("ftp", uri.getHost()); man.setUser(server.getUser()); man.setPassword(server.getPassword()); ret = new OpenFTP(null, file, man); } else if (path.startsWith("scp:/")) { Uri uri = Uri.parse(path);//from w w w . j a va2s . c o m ret = new OpenSCP(uri.getHost(), uri.getUserInfo(), uri.getPath(), null); } else if (path.startsWith("sftp:/") && OpenServers.DefaultServers != null) { Uri uri = Uri.parse(path); OpenServer server = OpenServers.DefaultServers.findByHost("sftp", uri.getHost()); ret = new OpenSFTP(uri); SimpleUserInfo info = new SimpleUserInfo(); if (server != null) info.setPassword(server.getPassword()); ((OpenSFTP) ret).setUserInfo(info); } else if (path.startsWith("smb:/") && OpenServers.DefaultServers != null) { try { Uri uri = Uri.parse(path); String user = uri.getUserInfo(); if (user != null && user.indexOf(":") > -1) user = user.substring(0, user.indexOf(":")); else user = ""; OpenServer server = OpenServers.DefaultServers.findByPath("smb", uri.getHost(), user, uri.getPath()); if (server == null) server = OpenServers.DefaultServers.findByUser("smb", uri.getHost(), user); if (server == null) server = OpenServers.DefaultServers.findByHost("smb", uri.getHost()); if (user == "") user = server.getUser(); if (server != null && server.getPassword() != null && server.getPassword() != "") user += ":" + server.getPassword(); if (!user.equals("")) user += "@"; ret = new OpenSMB(uri.getScheme() + "://" + user + uri.getHost() + uri.getPath()); } catch (Exception e) { Logger.LogError("Couldn't get samba from cache.", e); } } else if (path.startsWith("/data") || path.startsWith("/system")) ret = new OpenFileRoot(new OpenFile(path)); else if (path.startsWith("/")) ret = new OpenFile(path); else if (path.startsWith("file://")) ret = new OpenFile(path.replace("file://", "")); else if (path.equals("Videos")) ret = OpenExplorer.getVideoParent(); else if (path.equals("Photos")) ret = OpenExplorer.getPhotoParent(); else if (path.equals("Music")) ret = OpenExplorer.getMusicParent(); else if (path.equals("Downloads")) ret = OpenExplorer.getDownloadParent(); if (ret == null) return ret; if (ret instanceof OpenFile && ret.isArchive() && Preferences.Pref_Zip_Internal) ret = new OpenZip((OpenFile) ret); if (ret.requiresThread() && bGetNetworkedFiles) { if (ret.listFiles() != null) setOpenCache(path, ret); } else if (ret instanceof OpenNetworkPath) { if (ret.listFromDb(sort)) setOpenCache(path, ret); } } //if(ret == null) // ret = setOpenCache(path, new OpenFile(path)); //else setOpenCache(path, ret); return ret; }
From source file:com.deliciousdroid.fragment.BrowseBookmarksFragment.java
@Override public void onResume() { super.onResume(); if (query != null) { if (unread) { base.setTitle(getString(R.string.unread_search_results_title, query)); } else//from w w w.j av a 2s .c om base.setTitle(getString(R.string.bookmark_search_results_title, query)); } else { if (unread && tagname != null && tagname != "") { base.setTitle(getString(R.string.browse_my_unread_bookmarks_tagged_title, tagname)); } else if (unread && (tagname == null || tagname.equals(""))) { base.setTitle(getString(R.string.browse_my_unread_bookmarks_title)); } else if (tagname != null && tagname != "") { base.setTitle(getString(R.string.browse_my_bookmarks_tagged_title, tagname)); } else { base.setTitle(getString(R.string.browse_my_bookmarks_title)); } } Uri data = base.getIntent().getData(); if (data != null && data.getUserInfo() != null && data.getUserInfo() != "") { username = data.getUserInfo(); } else if (base.getIntent().hasExtra("username")) { username = base.getIntent().getStringExtra("username"); } else username = base.mAccount.name; }
From source file:com.deliciousdroid.fragment.BrowseBookmarkFeedFragment.java
@Override public void onResume() { super.onResume(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); base.setTitle(getString(R.string.search_results_global_tag_title, query)); } else if (username.equals("recent")) { base.setTitle(getString(R.string.browse_recent_bookmarks_title)); } else if (username.equals("network")) { base.setTitle(getString(R.string.browse_network_bookmarks_title)); } else {/*from w w w.j av a 2 s.co m*/ if (tagname != null && tagname != "") { base.setTitle(getString(R.string.browse_user_bookmarks_tagged_title, username, tagname)); } else { base.setTitle(getString(R.string.browse_user_bookmarks_title, username)); } } Uri data = base.getIntent().getData(); if (data != null && data.getUserInfo() != null && data.getUserInfo() != "") { username = data.getUserInfo(); } else if (base.getIntent().hasExtra("username")) { username = base.getIntent().getStringExtra("username"); } else username = base.mAccount.name; }
From source file:com.freerdp.freerdpcore.services.LibFreeRDP.java
public static boolean setConnectionInfo(Context context, long inst, Uri openUri) { ArrayList<String> args = new ArrayList<>(); // Parse URI from query string. Same key overwrite previous one // freerdp://user@ip:port/connect?sound=&rfx=&p=password&clipboard=%2b&themes=- // Now we only support Software GDI args.add(TAG);/*ww w.j a va 2s . c o m*/ args.add("/gdi:sw"); final String clientName = ApplicationSettingsActivity.getClientName(context); if (!clientName.isEmpty()) { args.add("/client-hostname:" + clientName); } // Parse hostname and port. Set to 'v' argument String hostname = openUri.getHost(); int port = openUri.getPort(); if (hostname != null) { hostname = hostname + ((port == -1) ? "" : (":" + String.valueOf(port))); args.add("/v:" + hostname); } String user = openUri.getUserInfo(); if (user != null) { args.add("/u:" + user); } for (String key : openUri.getQueryParameterNames()) { String value = openUri.getQueryParameter(key); if (value.isEmpty()) { // Query: key= // To freerdp argument: /key args.add("/" + key); } else if (value.equals("-") || value.equals("+")) { // Query: key=- or key=+ // To freerdp argument: -key or +key args.add(value + key); } else { // Query: key=value // To freerdp argument: /key:value if (key.equals("drive") && value.equals("sdcard")) { // Special for sdcard redirect String path = android.os.Environment.getExternalStorageDirectory().getPath(); value = "sdcard," + path; } args.add("/" + key + ":" + value); } } String[] arrayArgs = args.toArray(new String[args.size()]); return freerdp_parse_arguments(inst, arrayArgs); }
From source file:com.deliciousdroid.activity.BrowseBookmarks.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.browse_bookmarks); Intent intent = getIntent();/*from w ww. j a v a2 s.c o m*/ Uri data = intent.getData(); FragmentManager fm = getSupportFragmentManager(); FragmentTransaction t = fm.beginTransaction(); Fragment bookmarkFrag; if (fm.findFragmentById(R.id.listcontent) == null) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { Bundle searchData = intent.getBundleExtra(SearchManager.APP_DATA); if (searchData != null) { tagname = searchData.getString("tagname"); username = searchData.getString("username"); unread = searchData.getBoolean("unread"); } query = intent.getStringExtra(SearchManager.QUERY); if (intent.hasExtra("username")) { username = intent.getStringExtra("username"); } if (data != null && data.getUserInfo() != null) { username = data.getUserInfo(); } } else { if (data != null) { if (data.getUserInfo() != "") { username = data.getUserInfo(); } else username = mAccount.name; tagname = data.getQueryParameter("tagname"); unread = data.getQueryParameter("unread") != null; path = data.getPath(); } } if (isMyself()) { bookmarkFrag = new BrowseBookmarksFragment(); } else { bookmarkFrag = new BrowseBookmarkFeedFragment(); } t.add(R.id.listcontent, bookmarkFrag); } else { if (savedInstanceState != null) { username = savedInstanceState.getString(STATE_USERNAME); tagname = savedInstanceState.getString(STATE_TAGNAME); unread = savedInstanceState.getBoolean(STATE_UNREAD); query = savedInstanceState.getString(STATE_QUERY); path = savedInstanceState.getString(STATE_PATH); } bookmarkFrag = fm.findFragmentById(R.id.listcontent); } if (isMyself()) { if (query != null && !query.equals("")) { ((BrowseBookmarksFragment) bookmarkFrag).setSearchQuery(query, username, tagname, unread); } else { ((BrowseBookmarksFragment) bookmarkFrag).setQuery(username, tagname, unread); } } else { if (query != null && !query.equals("")) { ((BrowseBookmarkFeedFragment) bookmarkFrag).setQuery(username, tagname); } else { ((BrowseBookmarkFeedFragment) bookmarkFrag).setQuery(username, query); } } BrowseTagsFragment tagFrag = (BrowseTagsFragment) fm.findFragmentById(R.id.tagcontent); if (tagFrag != null) { tagFrag.setAccount(username); } if (path != null && path.contains("tags")) { t.hide(fm.findFragmentById(R.id.maincontent)); findViewById(R.id.panel_collapse_button).setVisibility(View.GONE); } else { if (tagFrag != null) { t.hide(tagFrag); } } Fragment addFrag = fm.findFragmentById(R.id.addcontent); if (addFrag != null) { t.hide(addFrag); } t.commit(); }
From source file:com.pindroid.activity.BrowseBookmarks.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.browse_bookmarks); Intent intent = getIntent();/*from w ww. j a v a2s . c o m*/ Uri data = intent.getData(); FragmentManager fm = getSupportFragmentManager(); FragmentTransaction t = fm.beginTransaction(); if (fm.findFragmentById(R.id.listcontent) == null) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { Bundle searchData = intent.getBundleExtra(SearchManager.APP_DATA); if (searchData != null) { tagname = searchData.getString("tagname"); app.setUsername(searchData.getString("username")); unread = searchData.getBoolean("unread"); } query = intent.getStringExtra(SearchManager.QUERY); if (intent.hasExtra("username")) { app.setUsername(intent.getStringExtra("username")); } if (data != null) { feed = data.getQueryParameter("feed"); if (data.getUserInfo() != null) { app.setUsername(data.getUserInfo()); } } } else { if (data != null) { tagname = data.getQueryParameter("tagname"); feed = data.getQueryParameter("feed"); unread = data.getQueryParameter("unread") != null; path = data.getPath(); } } if (feed == null || feed.equals("")) { bookmarkFrag = new BrowseBookmarksFragment(); } else { bookmarkFrag = new BrowseBookmarkFeedFragment(); } t.add(R.id.listcontent, bookmarkFrag); } else { if (savedInstanceState != null) { tagname = savedInstanceState.getString(STATE_TAGNAME); unread = savedInstanceState.getBoolean(STATE_UNREAD); query = savedInstanceState.getString(STATE_QUERY); path = savedInstanceState.getString(STATE_PATH); feed = savedInstanceState.getString(STATE_FEED); } bookmarkFrag = fm.findFragmentById(R.id.listcontent); } if (feed == null || feed.equals("")) { if (query != null && !query.equals("")) { ((BrowseBookmarksFragment) bookmarkFrag).setSearchQuery(query, app.getUsername(), tagname, unread); } else { ((BookmarkBrowser) bookmarkFrag).setQuery(app.getUsername(), tagname, unread ? "unread" : null); } ((BrowseBookmarksFragment) bookmarkFrag).refresh(); } else { if (query == null || query.equals("")) { ((BookmarkBrowser) bookmarkFrag).setQuery(app.getUsername(), tagname, feed); } else { ((BookmarkBrowser) bookmarkFrag).setQuery(app.getUsername(), query, feed); } } BrowseTagsFragment tagFrag = (BrowseTagsFragment) fm.findFragmentById(R.id.tagcontent); if (tagFrag != null) { tagFrag.setAccount(app.getUsername()); } if (path != null && path.contains("tags")) { t.hide(fm.findFragmentById(R.id.maincontent)); findViewById(R.id.panel_collapse_button).setVisibility(View.GONE); } else { if (tagFrag != null) { t.hide(tagFrag); } } Fragment addFrag = fm.findFragmentById(R.id.addcontent); if (addFrag != null) { t.hide(addFrag); } t.commit(); }
From source file:info.guardianproject.otr.app.im.app.NewChatActivity.java
private void doResolveIntent(Intent intent) { if (requireOpenDashboardOnStart(intent)) { long providerId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID, -1L); mLastAccountId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID, -1L); if (providerId == -1L || mLastAccountId == -1L) { finish();/*from w w w .j a v a 2 s . com*/ } else { // mChatSwitcher.open(); } return; } if (ImServiceConstants.ACTION_MANAGE_SUBSCRIPTION.equals(intent.getAction())) { long providerId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID, -1); mLastAccountId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID, -1L); String from = intent.getStringExtra(ImServiceConstants.EXTRA_INTENT_FROM_ADDRESS); if ((providerId == -1) || (from == null)) { finish(); } else { showSubscriptionDialog(providerId, from); } } else if (intent != null) { Uri data = intent.getData(); if (intent.getBooleanExtra("showaccounts", false)) mDrawer.openDrawer(GravityCompat.START); if (data != null) { if (data.getScheme() != null && data.getScheme().equals("immu")) { String user = data.getUserInfo(); String host = data.getHost(); String path = null; if (data.getPathSegments().size() > 0) path = data.getPathSegments().get(0); if (host != null && path != null) { IImConnection connMUC = findConnectionForGroupChat(user, host); if (connMUC != null) { startGroupChat(path, host, user, connMUC); setResult(RESULT_OK); } else { mHandler.showAlert("Connection Error", "Unable to find a connection to join a group chat from. Please sign in and try again."); setResult(Activity.RESULT_CANCELED); finish(); } } } else { String type = getContentResolver().getType(data); if (Imps.Chats.CONTENT_ITEM_TYPE.equals(type)) { long requestedContactId = ContentUris.parseId(data); Cursor cursorChats = mChatPagerAdapter.getCursor(); if (cursorChats != null) { cursorChats.moveToPosition(-1); int posIdx = 1; boolean foundChatView = false; while (cursorChats.moveToNext()) { long chatId = cursorChats.getLong(ChatView.CONTACT_ID_COLUMN); if (chatId == requestedContactId) { mChatPager.setCurrentItem(posIdx); foundChatView = true; break; } posIdx++; } if (!foundChatView) { Uri.Builder builder = Imps.Contacts.CONTENT_URI.buildUpon(); ContentUris.appendId(builder, requestedContactId); Cursor cursor = getContentResolver().query(builder.build(), ChatView.CHAT_PROJECTION, null, null, null); try { if (cursor.getCount() > 0) { cursor.moveToFirst(); openExistingChat(cursor); } } finally { cursor.close(); } } } } else if (Imps.Invitation.CONTENT_ITEM_TYPE.equals(type)) { //chatView.bindInvitation(ContentUris.parseId(data)); } } } else if (intent.hasExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID)) { //set the current account id mLastAccountId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID, -1L); //move the pager back to the first page if (mChatPager != null) mChatPager.setCurrentItem(0); } else { // refreshConnections(); } } }