-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from SphericalKat/refactor-welcome-auth
- Loading branch information
Showing
9 changed files
with
284 additions
and
122 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
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,44 @@ | ||
package at.sphericalk.gidget | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import at.sphericalk.gidget.utils.Constants | ||
|
||
class AuthActivity : ComponentActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
val authIntent = Intent(Intent.ACTION_VIEW, Uri.parse(Constants.OAUTH_URL)) | ||
startActivity(authIntent) | ||
return | ||
} | ||
|
||
override fun onNewIntent(intent: Intent?) { | ||
super.onNewIntent(intent) | ||
|
||
if (intent == null) { | ||
setResult(Activity.RESULT_CANCELED) | ||
finish() | ||
return | ||
} | ||
|
||
val uri = intent.data | ||
val returnIntent = Intent().apply { data = intent.data } | ||
|
||
if (uri.toString().startsWith(Constants.REDIRECT_URI)) { | ||
setResult(Activity.RESULT_OK, returnIntent) | ||
} else { | ||
setResult(Activity.RESULT_CANCELED, returnIntent) | ||
} | ||
|
||
finish() | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
app/src/main/java/at/sphericalk/gidget/navigation/Destination.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,17 @@ | ||
package at.sphericalk.gidget.navigation | ||
|
||
import androidx.navigation.NavController | ||
|
||
sealed class Destination(val route: String) { | ||
object Welcome : Destination("welcome") | ||
object Feed : Destination("feed") | ||
object Release : Destination("release") | ||
} | ||
|
||
class AppActions(navController: NavController) { | ||
val navigateToFeed: () -> Unit = { | ||
navController.navigate(Destination.Feed.route) { | ||
popUpTo(Destination.Welcome.route) { inclusive = true } | ||
} | ||
} | ||
} |
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
Oops, something went wrong.