mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-22 14:11:00 +00:00
Added custom scheme redirect
This commit is contained in:
parent
1dc56ae41c
commit
0737a88ea2
5 changed files with 59 additions and 13 deletions
|
@ -242,6 +242,15 @@
|
|||
android:path="/oauth/"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="eu.faircode.email" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
|
|
|
@ -79,7 +79,8 @@ import net.openid.appauth.ClientSecretPost;
|
|||
import net.openid.appauth.NoClientAuthentication;
|
||||
import net.openid.appauth.ResponseTypeValues;
|
||||
import net.openid.appauth.TokenResponse;
|
||||
import net.openid.appauth.browser.BrowserBlacklist;
|
||||
import net.openid.appauth.browser.BrowserDescriptor;
|
||||
import net.openid.appauth.browser.BrowserMatcher;
|
||||
import net.openid.appauth.browser.Browsers;
|
||||
import net.openid.appauth.browser.VersionRange;
|
||||
import net.openid.appauth.browser.VersionedBrowserMatcher;
|
||||
|
@ -1157,13 +1158,17 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
|
||||
private AuthorizationService getAuthorizationService() {
|
||||
AppAuthConfiguration appAuthConfig = new AppAuthConfiguration.Builder()
|
||||
.setBrowserMatcher(new BrowserBlacklist(
|
||||
new VersionedBrowserMatcher(
|
||||
.setBrowserMatcher(new BrowserMatcher() {
|
||||
@Override
|
||||
public boolean matches(@NonNull BrowserDescriptor descriptor) {
|
||||
BrowserMatcher sbrowser = new VersionedBrowserMatcher(
|
||||
Browsers.SBrowser.PACKAGE_NAME,
|
||||
Browsers.SBrowser.SIGNATURE_SET,
|
||||
true,
|
||||
VersionRange.atMost("5.3")
|
||||
)))
|
||||
VersionRange.atMost("5.3"));
|
||||
return descriptor.useCustomTab && !sbrowser.matches(descriptor);
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
return new AuthorizationService(this, appAuthConfig);
|
||||
|
@ -1237,7 +1242,8 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
|
||||
Log.i("OAuth token provider=" + provider.name);
|
||||
|
||||
if ("Outlook/Office365".equals(provider.name)) {
|
||||
if ("Gmail".equals(provider.name)) {
|
||||
} else if ("Outlook/Office365".equals(provider.name)) {
|
||||
authState.performActionWithFreshTokens(getAuthorizationService(), new AuthState.AuthStateAction() {
|
||||
@Override
|
||||
public void execute(String accessToken, String idToken, AuthorizationException error) {
|
||||
|
|
|
@ -169,13 +169,12 @@ public class FragmentSetup extends FragmentBase {
|
|||
int order = 1;
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_setup_gmail, order++, R.string.title_setup_gmail);
|
||||
|
||||
// Android 5 Lollipop does not support app links
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
for (EmailProvider provider : EmailProvider.loadProfiles(getContext()))
|
||||
if (provider.oauth != null && (provider.oauth.enabled || BuildConfig.DEBUG))
|
||||
popupMenu.getMenu()
|
||||
.add(Menu.NONE, -1, order++, getString(R.string.title_setup_oauth, provider.name))
|
||||
.setIntent(new Intent(ActivitySetup.ACTION_QUICK_OAUTH).putExtra("name", provider.name));
|
||||
.setIntent(new Intent(ActivitySetup.ACTION_QUICK_OAUTH)
|
||||
.putExtra("name", provider.name));
|
||||
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_setup_activesync, order++, R.string.title_setup_activesync);
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_setup_other, order++, R.string.title_setup_other);
|
||||
|
|
14
tools/assetlinks.json
Normal file
14
tools/assetlinks.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
[{
|
||||
"relation": ["delegate_permission/common.handle_all_urls"],
|
||||
"target" : { "namespace": "android_app", "package_name": "eu.faircode.email",
|
||||
"sha256_cert_fingerprints": ["E0:20:67:24:9F:5A:35:0E:0E:C7:03:FE:9D:F4:DD:68:2E:02:91:A0:9F:0C:2E:04:10:50:BB:E7:C0:64:F5:C9"] }
|
||||
},
|
||||
{
|
||||
"relation": ["delegate_permission/common.handle_all_urls"],
|
||||
"target" : { "namespace": "android_app", "package_name": "eu.faircode.email.debug",
|
||||
"sha256_cert_fingerprints": ["83:9E:69:DC:B7:B6:28:EF:38:AE:C7:3E:03:1D:D4:8C:15:BC:8A:BC:F9:12:39:32:EF:FE:10:62:60:FD:7C:73"] }
|
||||
},
|
||||
{
|
||||
"relation": ["delegate_permission/common.handle_all_urls"],
|
||||
"target": { "namespace": "web", "site": "https://email.faircode.eu" }
|
||||
}]
|
18
tools/oauth.html
Normal file
18
tools/oauth.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>FairEmail - OAuth</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>FairEmail OAuth</h1>
|
||||
<script>
|
||||
function oauth() {
|
||||
document.location = 'eu.faircode.email://oauth' + window.location.search;
|
||||
}
|
||||
</script>
|
||||
<button onclick="oauth()">Continue</button>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue