diff --git a/.gitignore b/.gitignore
index 4e68788..f7415cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,12 +1,15 @@
*.iml
.gradle
/local.properties
-.idea
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
.DS_Store
-/build/*
+/build
/captures
.externalNativeBuild
.cxx
-local.properties
-.idea/misc.xml
-/.idea/*
+local.properties
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 26d3352..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index fb7f4a8..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index a0de2a1..0000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index f96f21c..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,95 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
deleted file mode 100644
index 17ea014..0000000
--- a/app/build.gradle
+++ /dev/null
@@ -1,66 +0,0 @@
-plugins {
- id("com.android.application")
- id("kotlin-android")
- id("kotlin-android-extensions")
- id("kotlin-kapt")
- id("dagger.hilt.android.plugin")
- id("androidx.navigation.safeargs.kotlin")
-}
-
-android {
- compileSdk(AppConfig.compileSdk)
-// buildToolsVersion(AppConfig.buildToolsVersion)
-
- defaultConfig {
- applicationId = AppConfig.applicationId
- minSdkVersion(AppConfig.minSdk)
- targetSdkVersion(AppConfig.targetSdk)
- versionCode = AppConfig.versionCode
- versionName = AppConfig.versionName
-
- testInstrumentationRunner = AppConfig.androidTestInstrumentation
- }
-
- buildTypes {
- release {
- minifyEnabled = false
- proguardFiles(
- getDefaultProguardFile("proguard-android-optimize.txt"),
- "proguard-rules.pro"
- )
- }
- }
-
- flavorDimensions(AppConfig.dimension)
- productFlavors {
- create("staging") {
- applicationIdSuffix = ".staging"
- setDimension(AppConfig.dimension)
- }
-
- create("production") {
- setDimension(AppConfig.dimension)
- }
- }
-
- compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
- }
- kotlinOptions {
- jvmTarget = AppConfig.jvmTarget
- }
- buildFeatures {
- viewBinding = true
- dataBinding = true
- }
-}
-
-dependencies {
-// implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
- implementation(AppDependencies.appLibraries)
- kapt(AppDependencies.kaptLibraries)
- annotationProcessor(AppDependencies.annotationLibraries)
- testImplementation(AppDependencies.testLibraries)
- androidTestImplementation(AppDependencies.androidTestLibraries)
-}
\ No newline at end of file
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
new file mode 100644
index 0000000..e1f4aad
--- /dev/null
+++ b/app/build.gradle.kts
@@ -0,0 +1,88 @@
+plugins {
+ alias(libs.plugins.android.application)
+ alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.kapt)
+ alias(libs.plugins.hilt)
+ alias(libs.plugins.safearges)
+}
+
+android {
+ namespace = "com.milad.githoob"
+ compileSdk = 34
+
+ defaultConfig {
+ applicationId = "com.milad.githoob"
+ minSdk = 21
+ targetSdk = 33
+ versionCode = 1
+ versionName = "1.0"
+
+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
+ }
+
+ buildTypes {
+ release {
+ isMinifyEnabled = false
+// proguardFiles = getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
+ }
+ }
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+ }
+ kotlinOptions {
+ jvmTarget = "1.8"
+ }
+ buildFeatures {
+ buildConfig = true
+ viewBinding = true
+ dataBinding = true
+ }
+}
+
+dependencies {
+ implementation(projects.core.model)
+ implementation(projects.core.network)
+ implementation(projects.core.data)
+ implementation(projects.core.common)
+
+ implementation(projects.feature.splash)
+
+ implementation(libs.coreKtx)
+ implementation(libs.appcompat)
+ implementation(libs.material)
+ implementation(libs.constraintLayout)
+ implementation(libs.navigationFragment)
+ implementation(libs.navigationUi)
+ implementation(libs.coroutinesCore)
+
+ implementation(libs.legacy)
+ implementation(libs.recyclerview)
+ testImplementation(libs.junit)
+ androidTestImplementation(libs.extJUnit)
+ androidTestImplementation(libs.espressoCore)
+
+ implementation(libs.lifecycleViewmodel)
+ implementation(libs.lifecycleRuntime)
+ implementation(libs.lifecycleLivedata)
+ implementation(libs.lifecycleExtensions)
+
+ implementation(libs.activity)
+ implementation(libs.gson)
+ implementation(libs.retrofit)
+ implementation(libs.retrofitGson)
+ implementation(libs.okhttpLogging)
+
+ implementation(libs.hilt.android)
+ kapt(libs.hilt.compiler)
+ kapt(libs.hilt.ext.compiler)
+
+ implementation(libs.glide)
+ implementation(libs.glide.compiler)
+ implementation(libs.glide.transformations)
+ implementation(libs.datastore)
+ implementation(libs.markwon.core)
+ implementation(libs.markwon.html)
+ implementation(libs.markwon.image)
+ implementation(libs.timber)
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c76bd5b..b3d212a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,6 +1,5 @@
-
+
,
- val forks : Int,
- val open_issues : Int,
- val watchers : Int,
- val default_branch : String,
- var language_color: String
-)
\ No newline at end of file
diff --git a/app/src/main/java/com/milad/githoob/data/model/type/EventType.java b/app/src/main/java/com/milad/githoob/data/model/type/EventType.java
deleted file mode 100644
index 91f0b03..0000000
--- a/app/src/main/java/com/milad/githoob/data/model/type/EventType.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.milad.githoob.data.model.type;
-
-
-import android.annotation.SuppressLint;
-
-import androidx.annotation.DrawableRes;
-import androidx.annotation.StringRes;
-
-import com.milad.githoob.R;
-
-public enum EventType {
- WatchEvent(R.string.starred, R.drawable.ic_star),
- CreateEvent(R.string.created_repo, R.drawable.ic_repo),
- ForkEvent(R.string.forked2, R.drawable.ic_fork),
- IssueCommentEvent(R.string.commented_on_issue, R.drawable.ic_comment),
- IssuesEvent(R.string.created_issue, R.drawable.ic_issues),
- MemberEvent(R.string.member, R.drawable.ic_add),
- PublicEvent(R.string.public_event, R.drawable.ic_repo),
- PullRequestEvent(R.string.pull_request, R.drawable.ic_pull_requests),
- PullRequestReviewCommentEvent(R.string.pr_comment_review, R.drawable.ic_comment),
- PushEvent(R.string.pushed, R.drawable.ic_push),
- DeleteEvent(R.string.deleted, R.drawable.ic_trash),
- ReleaseEvent(R.string.released, R.drawable.ic_download),
- UnknownEvent(R.string.unknown, R.drawable.ic_issues),
- CommitCommentEvent(R.string.commented_on_commit, R.drawable.ic_comment),
- DownloadEvent(R.string.downloaded, R.drawable.ic_download),
- FollowEvent(R.string.followed, R.drawable.ic_add),
- GistEvent(R.string.created_gist, R.drawable.ic_gists),
- GollumEvent(R.string.gollum, R.drawable.ic_info_outline),
- PullRequestReviewEvent(R.string.pr_review_event, R.drawable.ic_eye),
- RepositoryEvent(R.string.repo_event, R.drawable.ic_repo),
- TeamAddEvent(R.string.team_event, R.drawable.ic_profile),
- ForkApplyEvent(R.string.forked, R.drawable.ic_fork),
- OrgBlockEvent(R.string.organization_event, R.drawable.ic_profile),
- ProjectCardEvent(R.string.card_event, R.drawable.ic_info_outline),
- ProjectColumnEvent(R.string.project_event, R.drawable.ic_info_outline),
- OrganizationEvent(R.string.organization_event, R.drawable.ic_profile),
- ProjectEvent(R.string.project_event, R.drawable.ic_info_outline);
-
- @StringRes
- int type;
- @DrawableRes
- int drawableRes;
-
-
- EventType(@StringRes int type, @DrawableRes int drawableRes) {
- this.type = type;
- this.drawableRes = drawableRes;
- }
-
- @SuppressLint("ResourceType")
- @DrawableRes
- public int getDrawableRes() {
- return drawableRes > 0 ? drawableRes : R.drawable.ic_info_outline;
- }
-
- @SuppressLint("ResourceType")
- @StringRes
- public int getType() {
- return type > 0 ? type : R.string.unknown;
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/milad/githoob/di/DataRepositoryModule.kt b/app/src/main/java/com/milad/githoob/di/DataRepositoryModule.kt
deleted file mode 100644
index 7c73006..0000000
--- a/app/src/main/java/com/milad/githoob/di/DataRepositoryModule.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.milad.githoob.di
-
-import android.content.Context
-import androidx.datastore.core.DataStore
-import androidx.datastore.preferences.core.PreferenceDataStoreFactory
-import androidx.datastore.preferences.core.Preferences
-import androidx.datastore.preferences.preferencesDataStoreFile
-import com.milad.githoob.data.MainRepository
-import com.milad.githoob.data.api.ApiService
-import com.milad.githoob.utils.AppConstants.PREFERENCES_STORE_NAME
-import dagger.Module
-import dagger.Provides
-import dagger.hilt.InstallIn
-import dagger.hilt.android.qualifiers.ApplicationContext
-import dagger.hilt.components.SingletonComponent
-import javax.inject.Singleton
-
-@Module
-@InstallIn(SingletonComponent::class)
-object DataRepositoryModule {
-
- @Provides
- fun provideDataRepository(apiService: ApiService): MainRepository {
- return MainRepository(apiService)
- }
-
- @Singleton
- @Provides
- fun provideDataStore(@ApplicationContext appContext: Context): DataStore =
- PreferenceDataStoreFactory.create(
- produceFile = {
- appContext.preferencesDataStoreFile(PREFERENCES_STORE_NAME)
- }
- )
-
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/milad/githoob/ui/launch/LaunchActivity.kt b/app/src/main/java/com/milad/githoob/ui/launch/LaunchActivity.kt
index 4d65825..1d10a33 100644
--- a/app/src/main/java/com/milad/githoob/ui/launch/LaunchActivity.kt
+++ b/app/src/main/java/com/milad/githoob/ui/launch/LaunchActivity.kt
@@ -1,5 +1,6 @@
package com.milad.githoob.ui.launch
+import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.view.WindowManager
@@ -8,11 +9,11 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.NavController
import androidx.navigation.Navigation
import com.milad.githoob.R
-import com.milad.githoob.utils.AppConstants.CLIENT_ID
-import com.milad.githoob.utils.AppConstants.CLIENT_SECRET
-import com.milad.githoob.utils.AppConstants.REDIRECT_URI
-import com.milad.githoob.utils.GlobalState
-import com.milad.githoob.utils.mixTwoColors
+import com.milad.common.AppConstants.CLIENT_ID
+import com.milad.common.AppConstants.CLIENT_SECRET
+import com.milad.common.AppConstants.REDIRECT_URI
+import com.milad.common.GlobalState
+import com.milad.common.mixTwoColors
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
@@ -20,6 +21,7 @@ class LaunchActivity : AppCompatActivity() {
private val mainViewModel: LaunchViewModel by viewModels()
+ @SuppressLint("ResourceType")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_launch)
@@ -27,9 +29,11 @@ class LaunchActivity : AppCompatActivity() {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+
+ // color should be dynamic
mixTwoColors(
- R.attr.colorPrimary,
- R.attr.colorSurface,
+ com.google.android.material.R.color.design_default_color_primary,
+ com.google.android.material.R.color.design_default_color_surface,
GlobalState.default_percent_6
).apply {
window.statusBarColor = this
@@ -39,9 +43,9 @@ class LaunchActivity : AppCompatActivity() {
onNewIntent(intent);
}
- override fun onNewIntent(intent: Intent?) {
+ override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
- val uri = intent?.data
+ val uri = intent.data
if (uri != null && uri.toString().startsWith(REDIRECT_URI)) {
val code = uri.getQueryParameter("code")
requestForAccessToken(code!!)
diff --git a/app/src/main/java/com/milad/githoob/ui/launch/LaunchViewModel.kt b/app/src/main/java/com/milad/githoob/ui/launch/LaunchViewModel.kt
index abd10fc..d4e1e95 100644
--- a/app/src/main/java/com/milad/githoob/ui/launch/LaunchViewModel.kt
+++ b/app/src/main/java/com/milad/githoob/ui/launch/LaunchViewModel.kt
@@ -1,18 +1,15 @@
package com.milad.githoob.ui.launch
-import androidx.datastore.core.DataStore
-import androidx.datastore.preferences.core.Preferences
-import androidx.datastore.preferences.core.edit
+import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
-import com.milad.githoob.data.MainRepository
-import com.milad.githoob.utils.AppConstants.KEY_DATA_STORE_TOKEN
-import com.milad.githoob.utils.Status
+import com.milad.data.MainRepository
+import com.milad.data.utils.Status
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.CoroutineDispatcher
-import kotlinx.coroutines.flow.collect
+import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject
@@ -21,10 +18,11 @@ import javax.inject.Inject
@HiltViewModel
class LaunchViewModel @Inject constructor(
private val mainRepository: MainRepository,
- private val dataStore: DataStore,
private val ioDispatcher: CoroutineDispatcher
) : ViewModel() {
+ private val KEY_DATA_STORE_TOKEN = stringPreferencesKey("KEY_DATA_STORE_TOKEN")
+
private var _token = MutableLiveData()
var token: LiveData = _token
@@ -38,13 +36,15 @@ class LaunchViewModel @Inject constructor(
clientId,
clientSecret,
code
- ).collect {
+ ).collectLatest {
when (it.status) {
Status.SUCCESS -> {
- it.data.let {
- if (it?.access_token != null && !it.access_token.equals("")) {
- val token = "token ${it.access_token}"
+ it.data.let {accessToken->
+ if (!accessToken?.access_token.isNullOrBlank()) {
+
+ val token = "token ${accessToken?.access_token}"
_token.postValue(token)
+
saveToken(token)
}
}
@@ -59,9 +59,7 @@ class LaunchViewModel @Inject constructor(
}
}
- suspend fun saveToken(token: String) {
- dataStore.edit {
- it[KEY_DATA_STORE_TOKEN] = token
- }
+ private suspend fun saveToken(token: String) {
+ mainRepository.saveDataStore(KEY_DATA_STORE_TOKEN, token)
}
}
diff --git a/app/src/main/java/com/milad/githoob/ui/login/LoginFragment.kt b/app/src/main/java/com/milad/githoob/ui/login/LoginFragment.kt
index 9216919..f9be359 100644
--- a/app/src/main/java/com/milad/githoob/ui/login/LoginFragment.kt
+++ b/app/src/main/java/com/milad/githoob/ui/login/LoginFragment.kt
@@ -8,10 +8,10 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.Button
import com.milad.githoob.R
-import com.milad.githoob.utils.AppConstants
+import com.milad.common.AppConstants
import dagger.hilt.android.AndroidEntryPoint
-import kotlinx.android.synthetic.main.login_fragment.*
import java.util.concurrent.TimeUnit
@AndroidEntryPoint
@@ -38,7 +38,7 @@ class LoginFragment : Fragment() {
"&state=" + STATE +
"&redirect_uri=" + AppConstants.REDIRECT_URI
- github_login_btn.setOnClickListener {
+ view?.findViewById