Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ val keystoreProperties = Properties().apply {

android {
namespace = "com.jk.gogit"
compileSdk = 34
compileSdk = 36

defaultConfig {
applicationId = "com.jk.gogit"
minSdk = 29
targetSdk = 34
targetSdk = 36 // Updated from 34
versionCode = 8
versionName = "1.0"

Expand Down Expand Up @@ -61,9 +61,6 @@ android {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
}
Expand All @@ -75,7 +72,7 @@ android {
}

dependencies {

implementation(libs.javax.inject)
implementation(libs.androidx.core.splashscreen)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
Expand Down Expand Up @@ -130,6 +127,8 @@ dependencies {
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
}


tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8)
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/jk/gogit/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import com.jk.gogit.search.SearchExecutor
import com.jk.gogit.search.SearchViewModel
import com.jk.gogit.users.services.UserListExecutor
import com.jk.gogit.users.viewmodel.UserListViewModel
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.core.module.dsl.viewModel
import org.koin.dsl.module

val appModule = module {
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/jk/gogit/GoGitApplication.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package com.jk.gogit

import android.app.Application
import android.content.Context
import android.widget.Toast
import com.google.firebase.auth.FirebaseAuth
import com.hoppers.networkmodule.AuthManager
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.GlobalContext.startKoin
import androidx.core.content.edit

class GoGitApplication : Application() {
override fun onCreate() {
super.onCreate()
val context = applicationContext
val sharedPreferences = getSharedPreferences("auth", Context.MODE_PRIVATE)
applicationContext
val sharedPreferences = getSharedPreferences("auth", MODE_PRIVATE)
AuthManager.initialize(sharedPreferences, onLogout = {
sharedPreferences.edit().clear().apply()
val firebaseAuth = FirebaseAuth.getInstance()
sharedPreferences.edit { clear() }
FirebaseAuth.getInstance()
// firebaseAuth.signOut()
showToast()
})
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/java/com/jk/gogit/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.jk.gogit

import Start
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
Expand All @@ -10,8 +9,8 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.jk.gogit.components.ComposeLocalWrapper
import com.jk.gogit.login.screen.LoginScreen
import com.jk.gogit.navigation.Start
import com.jk.gogit.ui.theme.GoGitTheme
import org.koin.androidx.compose.KoinAndroidContext
import org.koin.core.annotation.KoinExperimentalAPI

class MainActivity : ComponentActivity() {
Expand All @@ -23,9 +22,7 @@ class MainActivity : ComponentActivity() {
setContent {
GoGitTheme {
ComposeLocalWrapper {
KoinAndroidContext() {
Start()
}
}
}
}
Expand Down
60 changes: 34 additions & 26 deletions app/src/main/java/com/jk/gogit/components/HyperLinkText.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.jk.gogit.components

import androidx.compose.foundation.text.ClickableText
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.Text // Changed from ClickableText
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.LinkAnnotation
import androidx.compose.ui.text.LinkInteractionListener // Ensure this is imported
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.buildAnnotatedString
Expand All @@ -13,45 +15,51 @@ import androidx.compose.ui.text.withStyle

@Composable
fun HyperLinkText(
hyperLink: String,
hyperLink: String, // Data for the link action, also part of displayed text
modifier: Modifier,
localString: String,
startIndex: Int,
endIndex: Int,
hyperLinkStyle: SpanStyle = SpanStyle(),
localStringStyle: TextStyle = LocalTextStyle.current,
action: (String) -> Unit
localString: String, // Text following the hyperLink part
startIndex: Int, // Start index of the clickable link segment
endIndex: Int, // End index of the clickable link segment
hyperLinkStyle: SpanStyle = SpanStyle(), // Style for the link segment
localStringStyle: TextStyle = LocalTextStyle.current, // Base style for the entire text
action: (String) -> Unit // Lambda to execute on link click
) {

val annotatedString = buildAnnotatedString {
// 1. Append text content
withStyle(style = SpanStyle(fontWeight = FontWeight.Bold)) {
append(hyperLink)
}
append(localString)

// 2. Apply visual style to the link segment
addStyle(
end = endIndex,
style = hyperLinkStyle,
start = startIndex,
style = hyperLinkStyle
end = endIndex
)
addStringAnnotation(
annotation = hyperLink,
end = endIndex,
start = startIndex,
tag = "URL"

// 3. Create and add the LinkAnnotation
val clickableAnnotation = LinkAnnotation.Clickable(
tag = "URL", // Semantic tag for the link
linkInteractionListener = object : LinkInteractionListener {
override fun onClick(link: LinkAnnotation) { // Renamed parameter here
// When the link is clicked, this listener is invoked.
// We use the 'hyperLink' value captured from the HyperLinkText function's parameters.
action(hyperLink)
}
}
)

// Apply the clickable annotation to the specified range.
// Ensure addLink is called correctly (no named argument for clickableAnnotation itself)
addLink(clickableAnnotation, start = startIndex, end = endIndex)
}

ClickableText(
Text(
modifier = modifier,
style = localStringStyle.copy(color = LocalContentColor.current),
text = annotatedString,
onClick = {
annotatedString
.getStringAnnotations("URL", it, it)
.firstOrNull()?.let { stringAnnotation ->
action(stringAnnotation.item)
}
},

)
text = annotatedString
// Click handling is managed by the LinkAnnotation.Clickable's LinkInteractionListener
)
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/jk/gogit/components/OrgItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.jk.gogit.navigation.AppScreens

@Composable
fun OrgItem(org: Org) {
val localNavController = LocalNavController.current
LocalNavController.current
val navController = LocalNavController.current
Row(
modifier = Modifier
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/jk/gogit/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ fun HomeScreen() {
val owner = a[4]
val repo = a[5]
navController.currentBackStackEntry
?.savedStateHandle?.let {
it[AppScreens.USERPROFILE.route] = owner
it[AppScreens.REPODETAIL.route] = repo
?.savedStateHandle?.let { s ->
s[AppScreens.USERPROFILE.route] = owner
s[AppScreens.REPODETAIL.route] = repo
}

navController.navigate(AppScreens.REPODETAIL.route)
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/jk/gogit/home/services/HomeExecutor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class HomeExecutor

val userResponse = client.query(GetUserQuery(login)).execute()
Log.d( "execute:" ,"${userResponse.extensions.keys}")
val user = userResponse.data?.user ?: throw userResponse.exception ?: IllegalStateException(
val user = userResponse.data?.user ?: throw IllegalStateException(
"Sorry, the user you're looking for was not found"
)

Expand Down Expand Up @@ -78,13 +78,13 @@ class HomeExecutor
}
suspend fun followUser(userId: String): FollowUserMutation.Data
{
return client.mutation(FollowUserMutation(user = userId)).execute().dataOrThrow()
return client.mutation(FollowUserMutation(user = userId)).execute().dataAssertNoErrors


}
suspend fun unFollowUser(userId: String): UnfollowUserMutation.Data
{
return client.mutation(UnfollowUserMutation(user = userId)).execute().dataOrThrow()
return client.mutation(UnfollowUserMutation(user = userId)).execute().dataAssertNoErrors


}
Expand Down
76 changes: 44 additions & 32 deletions app/src/main/java/com/jk/gogit/login/screen/LoginScreen.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.jk.gogit.login.screen

import android.content.Intent
import android.net.Uri
import androidx.activity.compose.LocalActivity
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.ClickableText
import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.LocalTextStyle
Expand All @@ -19,19 +18,20 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.LinkAnnotation
import androidx.compose.ui.text.LinkInteractionListener
import androidx.compose.ui.text.ParagraphStyle
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.withStyle
// import androidx.compose.ui.text.withStyle // Removed unused import
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.content.ContextCompat.startActivity
import androidx.core.net.toUri
import androidx.lifecycle.lifecycleScope
import com.google.firebase.auth.OAuthProvider
import com.jk.gogit.MainActivity
Expand All @@ -49,9 +49,9 @@ import org.koin.androidx.compose.koinViewModel

@Composable
fun LoginScreen() {
val activity = LocalContext.current as MainActivity
val activity = LocalActivity.current as MainActivity
val provider = OAuthProvider.newBuilder("github.com")
provider.setScopes(AuthRequestModel().generate().scopes)
provider.scopes = AuthRequestModel().generate().scopes

val localNavController = LocalNavController.current

Expand Down Expand Up @@ -94,38 +94,50 @@ fun LoginScreen() {
) {
Text(text = stringResource(id = R.string.sign_in))
}

val privacyPolicyUrl = "https://jk2pr.github.io"
val preLinkText = "Your login indicates acceptance of our "
val linkText = "\nPrivacy Policy"

val annotatedString = buildAnnotatedString {
pushStyle(style = ParagraphStyle(textAlign = TextAlign.Center))
append("Your login indicates acceptance of our ")
pushStringAnnotation(
tag = "PrivacyPolicy",
annotation = "https://jk2pr.github.io"
) // Replace the URL with your actual Privacy Policy URL
withStyle(style = SpanStyle(textDecoration = TextDecoration.Underline)) {
append("\n")
append("Privacy Policy")
}
pop()
append(preLinkText)

val startIndex = length
append(linkText)
val endIndex = length

// Apply visual style to the link text
addStyle(
style = SpanStyle(textDecoration = TextDecoration.Underline),
start = startIndex,
end = endIndex
)

// Create and add the LinkAnnotation
val clickableAnnotation = LinkAnnotation.Clickable(
tag = "PrivacyPolicyURL", // Semantic tag for the link
linkInteractionListener = object : LinkInteractionListener {
override fun onClick(link: LinkAnnotation) {
val uri = privacyPolicyUrl.toUri()
val intent = Intent(Intent.ACTION_VIEW, uri)
activity.startActivity(intent)
}
}
)
addLink(
clickableAnnotation, // Corrected: pass annotation directly
start = startIndex,
end = endIndex
)
pop() // Pop the ParagraphStyle
}


ClickableText(
Text(
modifier = Modifier
// .widthIn(max = 250.dp)
.align(Alignment.CenterHorizontally),
text = annotatedString,
onClick = { offset ->
annotatedString.getStringAnnotations(
tag = "PrivacyPolicy",
start = offset,
end = offset
)
.firstOrNull()?.let { annotation ->
val uri = Uri.parse(annotation.item)
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(activity, intent, null)
}
},
style = LocalTextStyle.current.copy(
color = MaterialTheme.colorScheme.outline,
fontSize = 14.sp
Expand Down Expand Up @@ -166,4 +178,4 @@ private fun LoginScreenPreview() {
ComposeLocalWrapper {
LoginScreen()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.jk.gogit.navigation
import androidx.compose.runtime.Composable
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import com.hoppers.networkmodule.AuthManager
import com.jk.gogit.components.localproviders.LocalNavController
import com.jk.gogit.home.HomeScreen
import com.jk.gogit.login.screen.LoginScreen
import com.jk.gogit.navigation.AppScreens
import com.jk.gogit.organisation.OrgListScreen
import com.jk.gogit.orgdetails.OrgDetailsScreen
import com.jk.gogit.profile.UserProfileScreen
Expand Down
Loading