Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF 화면 구성 및 PDF 렌더링 #27

Merged
merged 30 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bdff90f
Feat: PDF 렌더링
Guri999 Dec 5, 2024
e95c491
Feat: PDF Zoom & drag
Guri999 Dec 6, 2024
cf10836
Feat: PDF 해상도 증가
Guri999 Dec 6, 2024
0785726
Feat: PDF Topbar
Guri999 Dec 7, 2024
2d70b89
Feat: PDF TopBar Page calculation
Guri999 Dec 7, 2024
4b66946
Feat: Domain 모듈 제거
Guri999 Dec 7, 2024
58596a1
Feat: Domain 모듈 제거
Guri999 Dec 7, 2024
c4aa77c
Feat: File Model 생성, 파일 찾기 로직 분리
Guri999 Dec 7, 2024
e65341e
Feat: Room 생성
Guri999 Dec 8, 2024
809743a
Refactor: 파일 탐색 백그라운드 스레드로 변경
Guri999 Dec 31, 2024
0de159f
Refactor: Uri remember로 처리
Guri999 Jan 3, 2025
21a6a33
Refactor: 매직넘버 상수로 관리
Guri999 Jan 3, 2025
308e067
Refactor: page,onPageChange -> page, onPageChange
Guri999 Jan 3, 2025
830538f
Refactor: 빈 프리뷰 제거
Guri999 Jan 3, 2025
b7e491a
Refactor: TopBar 관리 캡슐화
Guri999 Jan 6, 2025
1a1ed20
Refactor: Permission 관리 변경
Guri999 Jan 6, 2025
641f6de
Chore: onTopBarVisibleChange -> onPdfBodyPressed 이름 변경
Guri999 Jan 6, 2025
6020dd8
Refactor: PdfToBitmap class 생성하여 pdf 렌더링 관리
Guri999 Jan 6, 2025
3bd4b0d
Chore: if문 괄호
Guri999 Jan 6, 2025
91e5fa5
Feat: Koin 설정
Guri999 Jan 7, 2025
003c38d
Refactor: PDF화면 MVI refactor
Guri999 Jan 7, 2025
a7f951d
Revert "Refactor: PDF화면 MVI refactor"
Guri999 Jan 7, 2025
39ab182
Revert "Feat: Koin 설정"
Guri999 Jan 7, 2025
ea25198
Refactor: TopBarState currentScope -> currentJob
Guri999 Jan 7, 2025
514b612
Refactor: TopBarState onBodyPress -> show
Guri999 Jan 7, 2025
1b8822a
Refactor: TopBarState 생성자 제한
Guri999 Jan 7, 2025
04c1ab7
Chore: bitmap 줄내림 수정
Guri999 Jan 7, 2025
6345800
Chore: if문 중괄호 표시
Guri999 Jan 7, 2025
9a39999
Chore: line 제거
Guri999 Jan 7, 2025
7afa071
Chore: ignore .idea 추가
Guri999 Jan 7, 2025
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
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
8 changes: 8 additions & 0 deletions .idea/deploymentTargetSelector.xml

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

3 changes: 1 addition & 2 deletions .idea/gradle.xml

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

1 change: 0 additions & 1 deletion .idea/misc.xml

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

1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ android {

dependencies {
implementation(projects.core.ui)
implementation(projects.core.domain)
implementation(projects.core.data)
implementation(projects.core.navigation)
implementation(projects.feature.main)
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/java/kr/co/seedocs/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import androidx.activity.enableEdgeToEdge
import kr.co.main.Main
import kr.co.ui.theme.SeeDocsTheme

class MainActivity : PermissionActivity() {
class MainActivity : ComponentActivity() {

private val permissionManager = PermissionManager()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -23,7 +25,9 @@ class MainActivity : PermissionActivity() {
override fun onResume() {
super.onResume()

if (!checkStoragePermission())
requestStoragePermission()
permissionManager.run {
if (!checkStoragePermission())
requestStoragePermission()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import androidx.annotation.RequiresApi
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat

abstract class PermissionActivity : ComponentActivity() {
internal class PermissionManager {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 리팩토링은 이 브랜치에 어울리지 않는 커밋인 것 같습니다.


internal fun ComponentActivity.checkStoragePermission(): Boolean =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SeeDocsFeatureConventionPlugin : Plugin<Project> {
implementations(
project(":core:ui"),
project(":core:common"),
project(":core:domain"),
project(":core:data"),
project(":core:navigation"),
project(":core:model"),
)
Expand Down
1 change: 0 additions & 1 deletion core/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ android {

dependencies {
implementation(projects.core.common)
implementation(projects.core.domain)
implementation(projects.core.model)
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ room {
}

android {
setNamespace("core.local")
setNamespace("core.database")

buildFeatures {
buildConfig = true
Expand All @@ -27,6 +27,7 @@ android {
dependencies {
implementation(projects.core.common)
implementation(projects.core.data)
implementation(projects.core.model)

Local()
}
19 changes: 19 additions & 0 deletions core/database/src/main/java/kr/co/database/SeeDocsDatabase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package kr.co.database

import androidx.room.Database
import androidx.room.RoomDatabase
import kr.co.database.dao.RecentFileDao
import kr.co.database.model.RecentFile

@Database(
entities = [
RecentFile::class
],
version = 1,
exportSchema = true
)

abstract class SeeDocsDatabase : RoomDatabase() {

abstract fun recentFileDao(): RecentFileDao

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재의 PR에서 SeeDocsDatabase가 사용되는 곳은 없는데, 이 PR에 포함된 이유가 있을까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

잘못 포함된 커밋입니다,, revert해서 도려낼까요?

Copy link

@f-lab-dean f-lab-dean Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

가급적 PR에 포함되지 않아야할 내용은 포함되지 않도록 하는것이 좋습니다.
다음 PR부터 잘 챙겨주세요.
개발 계획을 좀 더 명확히 하고 진행하면 이런일이 줄어들 것 같습니다.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package kr.co.database.converter

import androidx.room.ProvidedTypeConverter
import androidx.room.TypeConverter

@ProvidedTypeConverter
internal class EnumConverter {

@TypeConverter
fun <T: Enum<T>> fromEnum(value: T): String =
value.name

@TypeConverter
fun <T: Enum<T>> toEnum(value: String, enumClass: Class<T>): T? =
enumClass.enumConstants?.firstOrNull { it.name == value }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package kr.co.database.converter

import androidx.room.ProvidedTypeConverter
import androidx.room.TypeConverter
import java.time.LocalDateTime

@ProvidedTypeConverter
internal class LocalDateTimeConverter {

@TypeConverter
fun fromString(value: String): LocalDateTime =
LocalDateTime.parse(value)

@TypeConverter
fun toString(value: LocalDateTime): String =
value.toString()
}
23 changes: 23 additions & 0 deletions core/database/src/main/java/kr/co/database/dao/RecentFileDao.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package kr.co.database.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import kotlinx.coroutines.flow.Flow
import kr.co.database.model.RecentFile

@Dao
interface RecentFileDao {

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(recentFile: RecentFile)

@Query("SELECT * FROM recent_file ORDER BY updatedAt DESC LIMIT 10")
fun get(): Flow<List<RecentFile>>

@Delete
suspend fun delete(recentFile: RecentFile)

}
15 changes: 15 additions & 0 deletions core/database/src/main/java/kr/co/database/model/RecentFile.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package kr.co.database.model

import androidx.room.Entity
import androidx.room.PrimaryKey
import kr.co.model.FileInfo.Type
import java.time.LocalDateTime

@Entity(tableName = "recent_file")
data class RecentFile(
val name: String,
@PrimaryKey val path: String,
val type: Type,
val size: Long,
val updatedAt: LocalDateTime = LocalDateTime.now(),
)
13 changes: 0 additions & 13 deletions core/domain/build.gradle.kts

This file was deleted.

4 changes: 0 additions & 4 deletions core/domain/src/main/java/kr/co/domain/MyClass.kt

This file was deleted.

1 change: 0 additions & 1 deletion core/local/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions core/local/src/main/java/kr/co/local/MyClass.kt

This file was deleted.

26 changes: 26 additions & 0 deletions core/model/src/main/java/kr/co/model/FileInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package kr.co.model

data class FileInfo(
val name: String,
val path: String,
val type: Type,
val isDirectory: Boolean,
val isHidden: Boolean,
val size: Long,
) {
enum class Type {
PDF,
IMAGE,
FOLDER
;

companion object {
fun from(extension: String): Type =
when(extension) {
"pdf" -> PDF
"jpg", "jpeg", "png", "gif" -> IMAGE
else -> IMAGE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이외의 확장자를 IMAGE로 했을 때 문제가 되는 부분은 없을까요?

}
}
}
}
4 changes: 0 additions & 4 deletions core/model/src/main/java/kr/co/model/MyClass.kt

This file was deleted.

4 changes: 2 additions & 2 deletions core/navigation/src/main/java/kr/co/navigation/Route.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ sealed interface Route {
data class View(val channel: String) : Route

@Serializable
data object Pdf : Route
data class Pdf(val path: String) : Route
}

sealed interface MainNavigation {

@Serializable
data object Explore : MainNavigation
data class Explore(val path: String? = null) : MainNavigation

@Serializable
data object Recent : MainNavigation
Expand Down
48 changes: 48 additions & 0 deletions core/ui/src/main/java/kr/co/ui/util/TopBarState.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package kr.co.ui.util

import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.MainCoroutineDispatcher
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.coroutines.ContinuationInterceptor

class TopBarState private constructor(
private val scope: CoroutineScope
) {
var topBarVisible by mutableStateOf(false)
private set

private var currentJob: Job? = null

fun show() {
currentJob?.cancel()

currentJob = scope.launch {
topBarVisible = true
delay(3000)
topBarVisible = false
}
}

companion object {
fun create(scope: CoroutineScope): TopBarState {
require(scope.coroutineContext[ContinuationInterceptor] is MainCoroutineDispatcher) {
"TopBar state should be created in main thread"
}
return TopBarState(scope)
}
}
}

@Composable
fun rememberTopBarState(
scope: CoroutineScope = rememberCoroutineScope()
) : TopBarState =
remember { TopBarState.create(scope) }
Loading
Loading