Skip to content

Commit

Permalink
Merge branch 'develop' into feat/deploy-springboot-cd
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisWooyeol committed Nov 28, 2023
2 parents 5636f13 + ba88b1a commit 7d98a33
Show file tree
Hide file tree
Showing 69 changed files with 4,526 additions and 551 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/springboot-on-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ jobs:
distribution: 'temurin'
cache: gradle

- name: Add test account key from secrets
run: |
echo "${{ secrets.FIREBASE_TEST_ACCOUNT_KEY }}" | base64 -d > \
src/test/kotlin/com/goliath/emojihub/springboot/TestServiceAccountKey.json
ls -al src/test/kotlin/com/goliath/emojihub/springboot/
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
Expand Down
22 changes: 22 additions & 0 deletions android/.idea/androidTestResultsUserPreferences.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions android/.idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 38 additions & 8 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ android {
vectorDrawables {
useSupportLibrary = true
}
// testFunctionalTest = true

// get properties from `local.properties`
buildConfigField("String", "API_BASE_URL", getProperty("API_BASE_URL"))
Expand All @@ -42,27 +43,47 @@ android {
}
}

buildFeatures {
compose = true
buildConfig = true
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

composeOptions {
kotlinCompilerExtensionVersion = "1.4.3"
}

kotlinOptions {
jvmTarget = "17"
}

buildFeatures {
compose = true
buildConfig = true
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}

composeOptions {
kotlinCompilerExtensionVersion = "1.4.3"
testOptions {
unitTests {
isIncludeAndroidResources = true
isReturnDefaultValues = true
}
animationsDisabled = true
}

packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
sourceSets {
getByName("main") {
resources.srcDirs("src/main/assets")
}
getByName("test") {
resources.srcDirs("src/main/assets")
}
getByName("androidTest") {
resources.srcDirs("src/main/assets")
}
}

Expand All @@ -76,6 +97,7 @@ dependencies {

implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")

// jetpack compose
implementation("androidx.activity:activity-compose:1.8.0")
Expand All @@ -92,9 +114,15 @@ dependencies {
// jetpack compose extended icons
implementation("androidx.compose.material:material-icons-extended:1.5.4")

// coil
implementation("io.coil-kt:coil-compose:2.5.0")

// test tools
testImplementation("junit:junit:4.13.2")
testImplementation("io.mockk:mockk:1.13.5")
testImplementation("androidx.test.ext:junit:1.1.5")
testImplementation("androidx.paging:paging-testing:3.2.1")
testImplementation ("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
Expand All @@ -105,6 +133,8 @@ dependencies {
// hilt
implementation("com.google.dagger:hilt-android:2.44")
kapt("com.google.dagger:hilt-android-compiler:2.44")
kaptTest("com.google.dagger:hilt-android-compiler:2.44")
kaptAndroidTest("com.google.dagger:hilt-android-compiler:2.44")

// navigation
implementation("androidx.navigation:navigation-compose:2.5.3")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.goliath.emojihub

import android.app.Application
import com.goliath.emojihub.data_sources.LocalStorage
import com.goliath.emojihub.data_sources.SharedLocalStorage
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class EmojiHubApplication: Application() {
companion object {
lateinit var preferences: SharedLocalStorage
lateinit var preferences: LocalStorage
}

override fun onCreate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ object NavigationDestination {
const val TransformVideo = "transform_video"
const val CreatePost = "create_post"
const val PlayEmojiVideo = "play_emoji_video"

const val MyPostList = "my_post_list"
const val MyEmojiList = "my_emoji_list"
const val MySavedEmojiList = "my_saved_emoji_list"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.goliath.emojihub.data_sources

import androidx.paging.PagingSource
import androidx.paging.PagingState
import com.goliath.emojihub.data_sources.api.EmojiApi
import com.goliath.emojihub.models.EmojiDto
import javax.inject.Inject

class EmojiPagingSource @Inject constructor(
private val api: EmojiApi
): PagingSource<Int, EmojiDto>() {
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, EmojiDto> {
val cursor = params.key ?: 1
val count = params.loadSize
return try {
val response = api.fetchEmojiList(1, cursor, count).body()
val data = response ?: listOf()
LoadResult.Page(
data = data,
prevKey = if (cursor == 1) null else cursor - 1,
nextKey = if (data.isEmpty()) null else cursor + 1
)
} catch (exception: Exception) {
LoadResult.Error(exception)
}
}

override fun getRefreshKey(state: PagingState<Int, EmojiDto>): Int? {
return state.anchorPosition?.let { anchorPosition ->
state.closestPageToPosition(anchorPosition)?.prevKey?.plus(1)
?: state.closestPageToPosition(anchorPosition)?.nextKey?.minus(1)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import android.content.SharedPreferences
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Singleton

interface LocalStorage {
var accessToken: String?
}

@Singleton
class SharedLocalStorage(
@ApplicationContext private val context: Context
) {
) : LocalStorage {
private val preferences: SharedPreferences =
context.getSharedPreferences("EMOJI_HUB", MODE_PRIVATE)

var accessToken: String?
override var accessToken: String?
get() = preferences.getString("accessToken", "")
set(value) = preferences.edit().putString("accessToken", value).apply()
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface EmojiApi {
@POST("emoji")
suspend fun uploadEmoji(
@Part file: MultipartBody.Part,
@Part thumbnail: MultipartBody.Part,
@Part("postEmojiRequest") emojiDto: RequestBody
): Response<Unit>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Emoji(
val createdAt: String = dto.createdAt
val savedCount: Int = dto.savedCount
val videoLink: String = dto.videoLink
val thumbnailLink: String = dto.thumbnailLink
val unicode: String = dto.unicode
val label: String = dto.label
val id: String = dto.id
Expand All @@ -20,6 +21,7 @@ data class EmojiDto(
@SerializedName("created_at") val createdAt: String,
@SerializedName("num_saved") val savedCount: Int,
@SerializedName("video_url") val videoLink: String,
@SerializedName("thumbnail_url") val thumbnailLink: String,
@SerializedName("id") val id: String,
@SerializedName("emoji_label") val label: String,
@SerializedName("emoji_unicode") val unicode: String
Expand Down Expand Up @@ -48,6 +50,7 @@ val dummyEmoji = Emoji(
createdAt = "2023.09.16",
savedCount = 1600,
videoLink = "https://firebasestorage.googleapis.com/v0/b/emojihub-e2023.appspot.com/o/sample_videos%2Fthumbs%20up.mp4?alt=media&token=9526818f-6ccb-499f-84b2-e6e1f6924704",
thumbnailLink = "https://storage.googleapis.com/emojihub-e2023.appspot.com/username1_2023-11-22%2008%3A45%3A29.jpeg?GoogleAccessId=firebase-adminsdk-zynbm@emojihub-e2023.iam.gserviceaccount.com&Expires=1709250330&Signature=Mht0X%2BkLsGGzGKq1yT2MmhUOzW8p9FqWd659Ggb8isEG7UkKvVFOdnqd4U6iPvS7JWv%2FhHyPp%2F%2FnZyQ4%2F6smLSAyQtRCUNtuKkbVVN0bTP8a8Wo5BwMjRlj5rFyyyo3hDAAOZIr3Qj6OThGcvxldGXnYVFtc5qWCLkkb%2FYS5QoHa9NYbqx0Hj10T5QfKSHhayi3%2BXEBgN59nzdrmFl7dsJ4RW8043EvXNF20eNw9DFmiRSIFqh7dT9Q3hd21GVgoIBOlXJ%2BsI%2BWu2vy61NXcfKhlZzAwS8eh8jHSxQZ%2FjPHE3itl7fFfgcFvapcJ9d%2BkFjwqhr7j4D2mcBF0yr1tHQ%3D%3D",
unicode = "U+1F44D",
id = "1234",
label = "sample"
Expand All @@ -65,6 +68,7 @@ fun createDummyEmoji(): Emoji {
createdAt = "2023.09.16",
savedCount = dummySavedCounts.random(),
videoLink = "",
thumbnailLink = "",
unicode = dummyUnicodes.random(),
id = dummySavedCounts.random().toString(),
label = "cat"
Expand Down
Loading

0 comments on commit 7d98a33

Please sign in to comment.