Skip to content

Commit

Permalink
dependency injection and file structure rearranged
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatozcelik committed Sep 18, 2023
1 parent 1de9ac3 commit 0dbfcc4
Show file tree
Hide file tree
Showing 38 changed files with 430 additions and 262 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
.externalNativeBuild
.cxx
local.properties
.idea
4 changes: 0 additions & 4 deletions .idea/.gitignore

This file was deleted.

124 changes: 0 additions & 124 deletions .idea/codeStyles/Project.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

20 changes: 0 additions & 20 deletions .idea/gradle.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/kotlinc.xml

This file was deleted.

14 changes: 0 additions & 14 deletions .idea/misc.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

19 changes: 12 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ plugins {
id 'com.google.dagger.hilt.android'
}

kapt {
correctErrorTypes true
useBuildCache true
}

android {
namespace 'com.ferhatozcelik.androidmvvmtemplate'
compileSdk 33
Expand All @@ -16,14 +21,13 @@ android {
dataBinding true
}


defaultConfig {
applicationId "com.ferhatozcelik.androidmvvmtemplate"
minSdk 24
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0"

multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand All @@ -43,7 +47,6 @@ android {
}

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.10"
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.0'
Expand All @@ -52,6 +55,9 @@ dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'

// Core
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5")

// Local Unit Tests
implementation "androidx.test:core:1.5.0"
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
Expand Down Expand Up @@ -97,13 +103,12 @@ dependencies {
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation "com.squareup.okhttp3:logging-interceptor:4.7.2"

// navigation
implementation 'androidx.navigation:navigation-fragment:2.4.2'
implementation 'androidx.navigation:navigation-ui:2.4.2'
// Navigation
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.2'

// Glide
implementation 'com.github.bumptech.glide:glide:4.13.0'
kapt 'com.github.bumptech.glide:compiler:4.12.0'

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.ferhatozcelik.androidmvvmtemplate.common.data.preferences

import android.content.Context
import javax.inject.Inject

class PreferenceManager @Inject constructor(
context: Context
) : SharedPreferences(context), Preferences {

override fun getPrefName() = "WiseriaPrefs"

override fun getAccessToken() = preferences.getString(PreferencesConstants.KEY_ACCESS_TOKEN, "")


override fun setAccessToken(token: String) {
preferences.edit().putString(PreferencesConstants.KEY_ACCESS_TOKEN, token).apply()
}

override fun deleteAccessToken() {
preferences.edit().remove(PreferencesConstants.KEY_ACCESS_TOKEN).apply()
}

override fun getRefreshToken() =
preferences.getString(PreferencesConstants.KEY_REFRESH_TOKEN, "")

override fun setRefreshToken(token: String) {
preferences.edit().putString(PreferencesConstants.KEY_REFRESH_TOKEN, token).apply()
}

override fun deleteRefreshToken() {
preferences.edit().remove(PreferencesConstants.KEY_REFRESH_TOKEN).apply()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.ferhatozcelik.androidmvvmtemplate.common.data.preferences

interface Preferences {

fun getAccessToken(): String?

fun setAccessToken(token: String)
fun deleteAccessToken()

fun getRefreshToken(): String?

fun setRefreshToken(token: String)

fun deleteRefreshToken()

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.ferhatozcelik.androidmvvmtemplate.common.data.preferences

object PreferencesConstants {

const val KEYSTORE_NAME = "X1kp5vI3oySeyXOqftOS"
const val KEY_ACCESS_TOKEN = "userAccessToken"
const val KEY_REFRESH_TOKEN = "userRefreshToken"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.ferhatozcelik.androidmvvmtemplate.common.data.preferences

import android.content.Context
import android.content.Context.MODE_PRIVATE
import android.content.SharedPreferences

abstract class SharedPreferences(context: Context) {

abstract fun getPrefName(): String

protected val preferences: SharedPreferences by lazy {
context.getSharedPreferences(PreferencesConstants.KEYSTORE_NAME,MODE_PRIVATE)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.wiseria.common.domain.session

interface SessionManager {

fun getAccessToken(): String?

fun setAccessToken(token: String)

fun saveAccessToken()

fun deleteAccessToken()

fun getRefreshToken(): String?

fun setRefreshToken(token: String)

fun saveRefreshToken()

fun deleteRefreshToken()

fun logOut()

fun saveTokens(accessToken: String, refreshToken: String)

}
Loading

0 comments on commit 0dbfcc4

Please sign in to comment.