forked from line/line-sdk-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ActivityResultContract implementation for Login
Fixes line#150
- Loading branch information
1 parent
5ff4957
commit ea83431
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
line-sdk/src/main/java/com/linecorp/linesdk/auth/LineLogin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.linecorp.linesdk.auth | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import androidx.activity.result.contract.ActivityResultContract | ||
|
||
class LineLogin : ActivityResultContract<LineLogin.Input, LineLoginResult>() { | ||
|
||
data class Input( | ||
val channelId: String, | ||
val params: LineAuthenticationParams, | ||
val isBrowserLoginOnly: Boolean = false | ||
) | ||
|
||
override fun createIntent(context: Context, input: Input): Intent { | ||
val (channelId, params, isBrowserLoginOnly) = input | ||
return if (isBrowserLoginOnly) { | ||
LineLoginApi.getLoginIntentWithoutLineAppAuth(context, channelId, params) | ||
} else { | ||
LineLoginApi.getLoginIntent(context, channelId, params) | ||
} | ||
} | ||
|
||
override fun parseResult(resultCode: Int, intent: Intent?): LineLoginResult { | ||
return LineLoginApi.getLoginResultFromIntent(intent) | ||
} | ||
|
||
} |