Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
463e490
Add LoginButton composable and integrate it into MainActivity
theMr17 Apr 27, 2025
d084a29
Add CLIENT_ID and CLIENT_SECRET to buildConfig in debug and release b…
theMr17 Apr 27, 2025
ed82b5a
Add GitHub OAuth integration with LoginButton and createGitHubAuthIntent
theMr17 Apr 27, 2025
7058ed3
Add LoginScreen composable and update MainActivity to use it
theMr17 Apr 27, 2025
bbedd44
Add authentication feature with ViewModel, data sources, and error ha…
theMr17 Apr 28, 2025
1b7b3b5
Add ConnectingToGitHubScreen and navigation setup in MainActivity
theMr17 Apr 28, 2025
9c6c7ac
Update build.gradle.kts to handle missing local.properties gracefully…
theMr17 Apr 28, 2025
2cda0cc
Add GitHub connection handling with state management and navigation s…
theMr17 Apr 29, 2025
2bb8b02
Rename authentication-related classes and update references to improv…
theMr17 Apr 29, 2025
b710a5e
Update SetupStep enum documentation to clarify token retrieval proces…
theMr17 Apr 29, 2025
99577cd
Merge branch 'main' into feat/setup-authentication-flow
theMr17 May 1, 2025
6e396b2
Fix daggerHilt variable name
theMr17 May 1, 2025
bbb0150
Refactor error handling in DataStore operations and update related cl…
theMr17 May 1, 2025
0d604e8
Update test script to include verbose output for connectedAndroidTest
theMr17 May 1, 2025
de4f862
Enhance test script to handle emulator termination on test failure
theMr17 May 1, 2025
a34fa01
Revert changes to test.yml
theMr17 May 1, 2025
fb5a0cd
Refactor DataStoreManager tests to assert Result type and improve cla…
theMr17 May 1, 2025
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add GitHub OAuth integration with LoginButton and createGitHubAuthIntent
  • Loading branch information
theMr17 committed Apr 27, 2025
commit ed82b5a4438e5ef0d5e311f5d340d02e04e02848
7 changes: 2 additions & 5 deletions app/src/main/java/com/notifier/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.ui.Modifier
import com.notifier.app.auth.presentation.LoginButton
import com.notifier.app.auth.presentation.components.LoginButton
import com.notifier.app.ui.theme.GitHubNotifierTheme
import dagger.hilt.android.AndroidEntryPoint

Expand All @@ -20,10 +20,7 @@ class MainActivity : ComponentActivity() {
setContent {
GitHubNotifierTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
LoginButton(
modifier = Modifier.padding(innerPadding),
onClick = {}
)
LoginButton(modifier = Modifier.padding(innerPadding))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
package com.notifier.app.auth.presentation
package com.notifier.app.auth.presentation.components

import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import com.notifier.app.auth.presentation.util.createGitHubAuthIntent
import com.notifier.app.ui.theme.GitHubNotifierTheme

@Composable
fun LoginButton(onClick: () -> Unit, modifier: Modifier = Modifier) {
fun LoginButton(modifier: Modifier = Modifier) {
val context = LocalContext.current
Button(
modifier = modifier,
onClick = onClick,
onClick = {
context.startActivity(createGitHubAuthIntent())
},
) {
Text("Login with GitHub")
}
Expand All @@ -21,6 +26,6 @@ fun LoginButton(onClick: () -> Unit, modifier: Modifier = Modifier) {
@Composable
private fun LoginButtonPreview() {
GitHubNotifierTheme {
LoginButton(onClick = {})
LoginButton()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.notifier.app.auth.presentation.util

import android.content.Intent
import androidx.core.net.toUri
import com.notifier.app.BuildConfig
import java.util.UUID

private const val GITHUB_AUTH_BASE_URL = "https://github.com/login/oauth/authorize"

/**
* Creates an [Intent] to launch the GitHub OAuth authorization page in a browser.
*
* @return [Intent] configured with the GitHub OAuth URL and required parameters.
*/
fun createGitHubAuthIntent(): Intent {
val clientId = BuildConfig.CLIENT_ID
val state = UUID.randomUUID().toString()

val authUrl = "$GITHUB_AUTH_BASE_URL?client_id=$clientId&state=$state"

return Intent(Intent.ACTION_VIEW, authUrl.toUri())
}