Java Code Examples for android.net.Uri#getFragment()
The following examples show how to use
android.net.Uri#getFragment() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IceCreamCordovaWebViewClient.java From phonegapbootcampsite with MIT License | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 2
Source File: IceCreamCordovaWebViewClient.java From crosswalk-cordova-android with Apache License 2.0 | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 3
Source File: SystemWebViewClient.java From a2cardboard with Apache License 2.0 | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 4
Source File: IceCreamCordovaWebViewClient.java From cordova-amazon-fireos with Apache License 2.0 | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 5
Source File: CustomMatchers.java From OpenYOLO-Android with Apache License 2.0 | 6 votes |
@Override protected boolean matchesSafely(Uri item) { if (!item.isAbsolute() || !item.isHierarchical() || TextUtils.isEmpty(item.getScheme()) || TextUtils.isEmpty(item.getAuthority())) { return false; } if (!mPermittedSchemes.isEmpty() && !mPermittedSchemes.contains(item.getScheme())) { return false; } if (mAllowPathQueryOrFragment) { return true; } return TextUtils.isEmpty(item.getPath()) && item.getQuery() == null && item.getFragment() == null; }
Example 6
Source File: X5WebViewClient.java From cordova-plugin-x5-tbs with Apache License 2.0 | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch (android.os.Build.VERSION.SDK_INT) { case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 7
Source File: InstagramLoginActivity.java From InstagramPhotoPicker-Android with MIT License | 6 votes |
public boolean shouldOverrideUrlLoading(WebView view, String url) { if ( DEBUGGING_ENABLED ) Log.d( LOG_TAG, "shouldOverrideUrlLoading( view, url = " + url.toString() + " )" ); if (url != null && url.startsWith(redirectUri)) { Uri uri = Uri.parse(url); String error = uri.getQueryParameter("error"); if (error != null) { String errorMessage = getLoginErrorMessage(uri); webview.stopLoading(); loadLoginPage(); showErrorDialog(errorMessage); } else { String fragment = uri.getFragment(); String accessToken = fragment.substring("access_token=".length()); gotAccessToken(accessToken); } return true; } return false; }
Example 8
Source File: BlobDescriptor.java From aard2-android with GNU General Public License v3.0 | 6 votes |
static BlobDescriptor fromUri(Uri uri) { BlobDescriptor bd = new BlobDescriptor(); bd.id = UUID.randomUUID().toString(); bd.createdAt = System.currentTimeMillis(); bd.lastAccess = bd.createdAt; List<String> pathSegments = uri.getPathSegments(); int segmentCount = pathSegments.size(); if (segmentCount < 3) { return null; } bd.slobId = pathSegments.get(1); StringBuilder key = new StringBuilder(); for (int i = 2; i < segmentCount; i++) { if (key.length() > 0) { key.append("/"); } key.append(pathSegments.get(i)); } bd.key = key.toString(); bd.blobId = uri.getQueryParameter("blob"); bd.fragment = uri.getFragment(); return bd; }
Example 9
Source File: IceCreamCordovaWebViewClient.java From reader with MIT License | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 10
Source File: SystemWebViewClient.java From ultimate-cordova-webview-app with MIT License | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 11
Source File: IceCreamCordovaWebViewClient.java From phonegap-plugin-loading-spinner with Apache License 2.0 | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 12
Source File: IceCreamCordovaWebViewClient.java From CordovaYoutubeVideoPlayer with MIT License | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 13
Source File: SystemWebViewClient.java From countly-sdk-cordova with MIT License | 5 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } return false; }
Example 14
Source File: OtpParser.java From yubikit-android with Apache License 2.0 | 5 votes |
/** * Check the length of code prefix (usually it's * @param ndefUri message uri of ndef tag * @return type of uri */ private static UriFormat getFormat(Uri ndefUri) { if (ndefUri != null && YUBICO_HOST_NAME.equalsIgnoreCase(ndefUri.getHost()) && ndefUri.getPath() != null) { if("/yk/".equals(ndefUri.getPath()) && ndefUri.getFragment() != null) { // Generally uri format is https://my.yubico.com/yk/#<payload> return UriFormat.YK_5; } else if (ndefUri.getPath().startsWith("/neo")) { // YubiKey NEO uses https://my.yubico.com/neo/<payload> return UriFormat.YK_NEO; } } return null; }
Example 15
Source File: OAuthManagerDialogFragment.java From react-native-oauth with MIT License | 5 votes |
static boolean isCallbackUri(String uri, String callbackUrl) { Uri u = null; Uri r = null; try { u = Uri.parse(uri); r = Uri.parse(callbackUrl); } catch (NullPointerException e) { return false; } if (u == null || r == null) return false; boolean rOpaque = r.isOpaque(); boolean uOpaque = u.isOpaque(); if (uOpaque != rOpaque) return false; if (rOpaque) return TextUtils.equals(uri, callbackUrl); if (!TextUtils.equals(r.getScheme(), u.getScheme())) return false; if (u.getPort() != r.getPort()) return false; if (!TextUtils.isEmpty(r.getPath()) && !TextUtils.equals(r.getPath(), u.getPath())) return false; Set<String> paramKeys = r.getQueryParameterNames(); for (String key : paramKeys) { if (!TextUtils.equals(r.getQueryParameter(key), u.getQueryParameter(key))) return false; } String frag = r.getFragment(); if (!TextUtils.isEmpty(frag) && !TextUtils.equals(frag, u.getFragment())) return false; return true; }
Example 16
Source File: AppManagerSchema.java From AppManager-for-Android with Apache License 2.0 | 4 votes |
/** * "https://{basicAuthUser}:{basicAuthPassword}@import-to-appmanager/github.com/app-manager/AppManager-for-Android/blob/master/tests/apk/dummy.apk?raw=true#{name}" * to * "https://github.com/app-manager/AppManager-for-Android/blob/master/tests/apk/dummy.apk?raw=true" * * @param uri * @return decoded FileEntry, or null if it was not able to decode uri. */ public static FileEntry decode(String uri) { FileEntry entry; // validate url try { Uri encodedUri = Uri.parse(uri); String specialHost = encodedUri.getHost(); if (!matchesSpecialHosts(specialHost)) { throw new UnsupportedOperationException("host is not '" + getSpecialHostsList() + "'"); } entry = new FileEntry(); entry.name = encodedUri.getFragment(); // null if not include String userInfo = encodedUri.getUserInfo(); if (null != userInfo) { String[] parts = userInfo.split(":"); String basicAuthUser = parts[0]; String basicAuthPassword = parts[1]; if (!TextUtils.isEmpty(basicAuthUser) && !TextUtils.isEmpty(basicAuthPassword)) { entry.basicAuthUser = basicAuthUser; entry.basicAuthPassword = basicAuthPassword; } } String schema = encodedUri.getScheme(); String encodedPath = encodedUri.getPath(); int separatePoint = encodedPath.indexOf("/"); String host = encodedPath.substring(0, separatePoint); String path = encodedPath.substring(separatePoint + 1); String query = encodedUri.getQuery(); if (TextUtils.isEmpty(query)) { entry.url = schema + "://" + host + path; } else { entry.url = schema + "://" + host + path + "?" + query; } return entry; } catch (Exception e) { LogUtils.e(TAG, e.getMessage(), e); return null; } }
Example 17
Source File: LoadingActivity.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_loading); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) actionBar.hide(); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); new Handler().postDelayed(() -> { finished = true; if (goTo != null) startActivity(goTo); }, 1000); if (Prefs.getBoolean(PK.FIRST_RUN, true)) { startActivity(new Intent(this, TutorialActivity.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)); return; } Button preferences = findViewById(R.id.loading_preferences); preferences.setOnClickListener(v -> startActivity(new Intent(LoadingActivity.this, PreferenceActivity.class))); tutorialManager = new TutorialManager(this, Discovery.LOGIN); loading = findViewById(R.id.loading_loading); loading.getIndeterminateDrawable().setColorFilter(CommonUtils.resolveAttrAsColor(this, android.R.attr.textColorPrimary), PorterDuff.Mode.SRC_IN); currentServer = findViewById(R.id.loading_currentServer); register = findViewById(R.id.loading_register); registerNickname = findViewById(R.id.loading_registerNickname); registerSubmit = findViewById(R.id.loading_registerSubmit); registerIdCode = findViewById(R.id.loading_registerIdCode); welcomeMessage = findViewById(R.id.loading_welcomeMsg); changeServer = findViewById(R.id.loading_changeServer); changeServer.setOnClickListener(v -> changeServerDialog(true)); registerIdCode.setEndIconOnClickListener(v -> CommonUtils.setText(registerIdCode, CommonUtils.randomString(100, new SecureRandom()))); CommonUtils.clearErrorOnEdit(registerIdCode); if (Objects.equals(getIntent().getAction(), Intent.ACTION_VIEW) || Objects.equals(getIntent().getAction(), Intent.ACTION_SEND)) { Uri url = getIntent().getData(); if (url != null) { Pyx.Server server = Pyx.Server.fromUrl(url); if (server != null) setServer(server); String fragment = url.getFragment(); if (fragment != null) { List<NameValuePair> params = Utils.splitQuery(fragment); for (NameValuePair pair : params) { if (Objects.equals(pair.key(), "game")) { try { launchGame = new GamePermalink(Integer.parseInt(pair.value("")), new JSONObject()); // A bit hacky } catch (NumberFormatException ignored) { } } else if (Objects.equals(pair.key(), "password")) { launchGamePassword = pair.value(""); } } launchGameShouldRequest = true; } } } discoveryApi = PyxDiscoveryApi.get(); discoveryApi.getWelcomeMessage(this, new Pyx.OnResult<String>() { @Override public void onDone(@NonNull String result) { if (result.isEmpty()) { welcomeMessage.setVisibility(View.GONE); } else { welcomeMessage.setVisibility(View.VISIBLE); welcomeMessage.setHtml(result); } } @Override public void onException(@NonNull Exception ex) { Log.e(TAG, "Failed loading welcome message.", ex); welcomeMessage.setVisibility(View.GONE); } }); discoveryApi.firstLoad(this, null, this); signInSilently(); }
Example 18
Source File: LoadingActivity.java From DNSHero with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_loading); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) actionBar.hide(); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); Button preferences = findViewById(R.id.loading_preferences); preferences.setOnClickListener(v -> startActivity(new Intent(LoadingActivity.this, PreferenceActivity.class))); favoritesLabel = findViewById(R.id.loading_favoritesLabel); favorites = findViewById(R.id.loading_favorites); favorites.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false)); loadFavorites(); form = findViewById(R.id.loading_form); loading = findViewById(R.id.loading_loading); domain = findViewById(R.id.loading_domain); CommonUtils.clearErrorOnEdit(domain); CommonUtils.getEditText(domain).setOnKeyListener((v, keyCode, event) -> { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { search(); return true; } return false; }); domain.setEndIconOnClickListener(view -> search()); Uri sharedUri = getIntent().getData(); if (sharedUri != null) { String fragment = sharedUri.getFragment(); if (fragment != null) { loading.setVisibility(View.VISIBLE); form.setVisibility(View.GONE); ZoneVisionAPI.get().search(fragment.substring(1), null, this); ThisApplication.sendAnalytics(Utils.ACTION_SEARCH_INTENT); } } }
Example 19
Source File: OAuthDialogFragment.java From android-oauth-client with Apache License 2.0 | 4 votes |
static boolean isRedirectUriFound(String uri, String redirectUri) { Uri u = null; Uri r = null; try { u = Uri.parse(uri); r = Uri.parse(redirectUri); } catch (NullPointerException e) { return false; } if (u == null || r == null) { return false; } boolean rOpaque = r.isOpaque(); boolean uOpaque = u.isOpaque(); if (rOpaque != uOpaque) { return false; } if (rOpaque) { return TextUtils.equals(uri, redirectUri); } if (!TextUtils.equals(r.getScheme(), u.getScheme())) { return false; } if (!TextUtils.equals(r.getAuthority(), u.getAuthority())) { return false; } if (r.getPort() != u.getPort()) { return false; } if (!TextUtils.isEmpty(r.getPath()) && !TextUtils.equals(r.getPath(), u.getPath())) { return false; } Set<String> paramKeys = CompatUri.getQueryParameterNames(r); for (String key : paramKeys) { if (!TextUtils.equals(r.getQueryParameter(key), u.getQueryParameter(key))) { return false; } } String frag = r.getFragment(); if (!TextUtils.isEmpty(frag) && !TextUtils.equals(frag, u.getFragment())) { return false; } return true; }
Example 20
Source File: IdToken.java From AppAuth-Android with Apache License 2.0 | 4 votes |
void validate(@NonNull TokenRequest tokenRequest, Clock clock) throws AuthorizationException { // OpenID Connect Core Section 3.1.3.7. rule #1 // Not enforced: AppAuth does not support JWT encryption. // OpenID Connect Core Section 3.1.3.7. rule #2 // Validates that the issuer in the ID Token matches that of the discovery document. AuthorizationServiceDiscovery discoveryDoc = tokenRequest.configuration.discoveryDoc; if (discoveryDoc != null) { String expectedIssuer = discoveryDoc.getIssuer(); if (!this.issuer.equals(expectedIssuer)) { throw AuthorizationException.fromTemplate(GeneralErrors.ID_TOKEN_VALIDATION_ERROR, new IdTokenException("Issuer mismatch")); } // OpenID Connect Core Section 2. // The iss value is a case sensitive URL using the https scheme that contains scheme, // host, and optionally, port number and path components and no query or fragment // components. Uri issuerUri = Uri.parse(this.issuer); if (!issuerUri.getScheme().equals("https")) { throw AuthorizationException.fromTemplate(GeneralErrors.ID_TOKEN_VALIDATION_ERROR, new IdTokenException("Issuer must be an https URL")); } if (TextUtils.isEmpty(issuerUri.getHost())) { throw AuthorizationException.fromTemplate(GeneralErrors.ID_TOKEN_VALIDATION_ERROR, new IdTokenException("Issuer host can not be empty")); } if (issuerUri.getFragment() != null || issuerUri.getQueryParameterNames().size() > 0) { throw AuthorizationException.fromTemplate(GeneralErrors.ID_TOKEN_VALIDATION_ERROR, new IdTokenException( "Issuer URL should not containt query parameters or fragment components")); } } // OpenID Connect Core Section 3.1.3.7. rule #3 // Validates that the audience of the ID Token matches the client ID. String clientId = tokenRequest.clientId; if (!this.audience.contains(clientId)) { throw AuthorizationException.fromTemplate(GeneralErrors.ID_TOKEN_VALIDATION_ERROR, new IdTokenException("Audience mismatch")); } // OpenID Connect Core Section 3.1.3.7. rules #4 & #5 // Not enforced. // OpenID Connect Core Section 3.1.3.7. rule #6 // As noted above, AppAuth only supports the code flow which results in direct // communication of the ID Token from the Token Endpoint to the Client, and we are // exercising the option to use TLS server validation instead of checking the token // signature. Users may additionally check the token signature should they wish. // OpenID Connect Core Section 3.1.3.7. rules #7 & #8 // Not enforced. See rule #6. // OpenID Connect Core Section 3.1.3.7. rule #9 // Validates that the current time is before the expiry time. Long nowInSeconds = clock.getCurrentTimeMillis() / MILLIS_PER_SECOND; if (nowInSeconds > this.expiration) { throw AuthorizationException.fromTemplate(GeneralErrors.ID_TOKEN_VALIDATION_ERROR, new IdTokenException("ID Token expired")); } // OpenID Connect Core Section 3.1.3.7. rule #10 // Validates that the issued at time is not more than +/- 10 minutes on the current // time. if (Math.abs(nowInSeconds - this.issuedAt) > TEN_MINUTES_IN_SECONDS) { throw AuthorizationException.fromTemplate(GeneralErrors.ID_TOKEN_VALIDATION_ERROR, new IdTokenException("Issued at time is more than 10 minutes " + "before or after the current time")); } // Only relevant for the authorization_code response type if (GrantTypeValues.AUTHORIZATION_CODE.equals(tokenRequest.grantType)) { // OpenID Connect Core Section 3.1.3.7. rule #11 // Validates the nonce. String expectedNonce = tokenRequest.nonce; if (!TextUtils.equals(this.nonce, expectedNonce)) { throw AuthorizationException.fromTemplate(GeneralErrors.ID_TOKEN_VALIDATION_ERROR, new IdTokenException("Nonce mismatch")); } } // OpenID Connect Core Section 3.1.3.7. rules #12 // ACR is not directly supported by AppAuth. // OpenID Connect Core Section 3.1.3.7. rules #12 // max_age is not directly supported by AppAuth. }