Skip to content

Commit

Permalink
Apply 2023C01 changes on main
Browse files Browse the repository at this point in the history
  • Loading branch information
louischan-oursky committed Nov 21, 2023
1 parent ec8f663 commit d8a9a62
Show file tree
Hide file tree
Showing 32 changed files with 1,520 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
app:
runs-on: macos-12
needs: ["test"]
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/2023C01'
env:
# The version depends on the Android Gradle Plugin version in /build.gradle.kts
BUILD_TOOLS_VERSION: "33.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ protected void onCreate(Bundle savedInstanceState) {

String[] uiVariants = {
UIVariant.CUSTOM_TABS.name(),
UIVariant.WEB_VIEW.name(),
UIVariant.WEB_VIEW_FULL_SCREEN.name(),
};
mUIVariant = findViewById(R.id.uiVariantSpinner);
ArrayAdapter<String> mUIVariantAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, uiVariants);
Expand Down Expand Up @@ -205,6 +207,10 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
String value = (String) parent.getItemAtPosition(position);
if (UIVariant.CUSTOM_TABS.name().equals(value)) {
viewModel.setUIVariant(UIVariant.CUSTOM_TABS);
} else if (UIVariant.WEB_VIEW.name().equals(value)) {
viewModel.setUIVariant(UIVariant.WEB_VIEW);
} else if (UIVariant.WEB_VIEW_FULL_SCREEN.name().equals(value)) {
viewModel.setUIVariant(UIVariant.WEB_VIEW_FULL_SCREEN);
}
}

Expand Down
13 changes: 13 additions & 0 deletions sdk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,18 @@
<activity android:name=".CustomTabActivity"
android:exported="false"
android:launchMode="singleTask" />
<activity
android:name=".OAuthWebViewActivity"
android:exported="false" />
<activity
android:name=".OAuthWebViewFullScreenActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:exported="false" />
</application>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="mailto"/>
</intent>
</queries>
</manifest>
34 changes: 27 additions & 7 deletions sdk/src/main/java/com/oursky/authgear/AuthgearCore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -737,14 +737,34 @@ internal class AuthgearCore(
}
application.registerReceiver(br, intentFilter)
val redirectUri = Uri.parse(redirectUrl)
application.startActivity(
OAuthActivity.createAuthorizationIntent(
application,
action,
redirectUrl,
authorizeUri.toString()
if (uiVariant == UIVariant.WEB_VIEW) {
application.startActivity(
OAuthWebViewActivity.createIntent(
application,
action,
authorizeUri,
redirectUri
)
)
)
} else if (uiVariant == UIVariant.WEB_VIEW_FULL_SCREEN) {
application.startActivity(
OAuthWebViewFullScreenActivity.createIntent(
application,
action,
authorizeUri,
redirectUri
)
)
} else {
application.startActivity(
OAuthActivity.createAuthorizationIntent(
application,
action,
redirectUrl,
authorizeUri.toString()
)
)
}
}
}

Expand Down
19 changes: 19 additions & 0 deletions sdk/src/main/java/com/oursky/authgear/OAuthWebViewActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.oursky.authgear

import android.content.Context
import android.content.Intent
import android.net.Uri

internal class OAuthWebViewActivity : OAuthWebViewBaseActivity() {

companion object {
fun createIntent(ctx: Context?, broadcastAction: String, uri: Uri?, redirectUri: Uri?): Intent {
val intent = Intent(ctx, OAuthWebViewActivity::class.java)
intent.data = uri
intent.putExtra(OAuthWebViewBaseActivity.KEY_BROADCAST_ACTION, broadcastAction)
intent.putExtra(OAuthWebViewBaseActivity.KEY_REDIRECT_URI, redirectUri)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
return intent
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.oursky.authgear

import android.content.Context
import android.content.Intent
import android.net.Uri

internal class OAuthWebViewFullScreenActivity : OAuthWebViewBaseActivity() {

companion object {
fun createIntent(ctx: Context?, broadcastAction: String, uri: Uri?, redirectUri: Uri?): Intent {
val intent = Intent(ctx, OAuthWebViewFullScreenActivity::class.java)
intent.data = uri
intent.putExtra(OAuthWebViewBaseActivity.KEY_BROADCAST_ACTION, broadcastAction)
intent.putExtra(OAuthWebViewBaseActivity.KEY_REDIRECT_URI, redirectUri)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
return intent
}
}
}
4 changes: 3 additions & 1 deletion sdk/src/main/java/com/oursky/authgear/UIVariant.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.oursky.authgear

enum class UIVariant {
CUSTOM_TABS
CUSTOM_TABS,
WEB_VIEW,
WEB_VIEW_FULL_SCREEN
}
16 changes: 16 additions & 0 deletions sdk/src/main/java/com/oursky/authgear/latte/AuthenticateOptions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.oursky.authgear.latte

import com.oursky.authgear.ColorScheme
import com.oursky.authgear.PromptOption

data class AuthenticateOptions @JvmOverloads constructor(
var xSecrets: Map<String, String> = mapOf(),
var xState: Map<String, String> = mapOf(),
var responseType: String? = "code",
var prompt: List<PromptOption>? = null,
var loginHint: String? = null,
var uiLocales: List<String>? = null,
var colorScheme: ColorScheme? = null,
var wechatRedirectURI: String? = null,
var page: String? = null
)
12 changes: 12 additions & 0 deletions sdk/src/main/java/com/oursky/authgear/latte/BiometricOptions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.oursky.authgear.latte

import androidx.fragment.app.FragmentActivity

data class BiometricOptions constructor(
var activity: FragmentActivity,
var title: String,
var subtitle: String? = null,
var description: String? = null,
var negativeButtonText: String? = null,
var allowedAuthenticators: Int = androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_WEAK
)
5 changes: 5 additions & 0 deletions sdk/src/main/java/com/oursky/authgear/latte/Capability.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.oursky.authgear.latte

enum class Capability(val raw: String) {
BIOMETRIC("biometric")
}
45 changes: 45 additions & 0 deletions sdk/src/main/java/com/oursky/authgear/latte/EmailClient.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.oursky.authgear.latte

import android.content.Context
import android.content.Intent
import android.content.pm.LabeledIntent
import android.content.pm.PackageManager

data class EmailClient(val packageName: String) {
companion object {
@JvmField
val GMAIL = EmailClient("com.google.android.gm")
@JvmField
val OUTLOOK = EmailClient("com.microsoft.office.outlook")

@JvmStatic
fun makeEmailClientIntentChooser(
ctx: Context,
title: String,
clients: List<EmailClient>
): Intent? {
val launchIntents: MutableList<Intent> = mutableListOf()
val pm: PackageManager = ctx.packageManager
for (client in clients) {
val intent = pm.getLaunchIntentForPackage(client.packageName) ?: continue
val info = pm.resolveActivity(intent, 0) ?: continue
launchIntents.add(
LabeledIntent(
intent,
client.packageName,
info.loadLabel(pm),
info.icon
)
)
}
if (launchIntents.size == 0) {
return null
}
val firstIntent = launchIntents[0]
val chooser = Intent.createChooser(firstIntent, title)
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, launchIntents.toTypedArray())
chooser.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
return chooser
}
}
}
Loading

0 comments on commit d8a9a62

Please sign in to comment.