..
This commit is contained in:
@@ -838,11 +838,14 @@ open class LauncherActivity : CommonActivity() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
val widgets = WorkersDb.getRealm().query<WidgetData>().find()
|
val widgets = WorkersDb.getRealm().query<WidgetData>().find()
|
||||||
widgets.forEach { widgetData ->
|
widgets.forEach { widgetData ->
|
||||||
createWidget(null, widgetData)
|
createWidget(null, widgetData)
|
||||||
}
|
}
|
||||||
|
}catch (e : Exception) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lateinit var scaleDetector: android.view.ScaleGestureDetector
|
lateinit var scaleDetector: android.view.ScaleGestureDetector
|
||||||
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
|
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
|
||||||
|
|||||||
@@ -499,6 +499,29 @@ class CompletedFilesFragment : Fragment() {
|
|||||||
FileViewMode.GRID_SMALL -> "apps"
|
FileViewMode.GRID_SMALL -> "apps"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun saveFolderSortSetting(folderPath: String, sortType: FileSortType, isDesc: Boolean) {
|
||||||
|
val prefs = requireContext().getSharedPreferences("FolderSortPrefs", Context.MODE_PRIVATE)
|
||||||
|
prefs.edit()
|
||||||
|
.putString("${folderPath}_sort", sortType.name)
|
||||||
|
.putBoolean("${folderPath}_desc", isDesc)
|
||||||
|
.apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 💡 폴더별로 저장된 정렬 방식 불러오기 (기본값은 최신순 / 내림차순)
|
||||||
|
private fun loadFolderSortSetting(folderPath: String) {
|
||||||
|
val prefs = requireContext().getSharedPreferences("FolderSortPrefs", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
|
val savedSortName = prefs.getString("${folderPath}_sort", FileSortType.LAST_USED.name)
|
||||||
|
currentSort = try {
|
||||||
|
FileSortType.valueOf(savedSortName ?: FileSortType.LAST_USED.name)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
FileSortType.LAST_USED
|
||||||
|
}
|
||||||
|
|
||||||
|
isDescending = prefs.getBoolean("${folderPath}_desc", true)
|
||||||
|
}
|
||||||
|
|
||||||
val MAX_COUNT = 9
|
val MAX_COUNT = 9
|
||||||
private fun setupControls(view: View) {
|
private fun setupControls(view: View) {
|
||||||
val layoutTitleDefault = view.findViewById<View>(R.id.layoutTitleDefault)
|
val layoutTitleDefault = view.findViewById<View>(R.id.layoutTitleDefault)
|
||||||
@@ -660,6 +683,7 @@ class CompletedFilesFragment : Fragment() {
|
|||||||
spinnerSort.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
spinnerSort.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, position: Int, p3: Long) {
|
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, position: Int, p3: Long) {
|
||||||
currentSort = FileSortType.values()[position]
|
currentSort = FileSortType.values()[position]
|
||||||
|
saveFolderSortSetting(currentDir.absolutePath, currentSort, isDescending)
|
||||||
applyFilterAndSort()
|
applyFilterAndSort()
|
||||||
}
|
}
|
||||||
override fun onNothingSelected(p0: AdapterView<*>?) {}
|
override fun onNothingSelected(p0: AdapterView<*>?) {}
|
||||||
@@ -669,6 +693,7 @@ class CompletedFilesFragment : Fragment() {
|
|||||||
tvSortOrder.setOnClickListener {
|
tvSortOrder.setOnClickListener {
|
||||||
isDescending = !isDescending
|
isDescending = !isDescending
|
||||||
tvSortOrder.text = if (isDescending) "arrow_downward" else "arrow_upward"
|
tvSortOrder.text = if (isDescending) "arrow_downward" else "arrow_upward"
|
||||||
|
saveFolderSortSetting(currentDir.absolutePath, currentSort, isDescending)
|
||||||
applyFilterAndSort()
|
applyFilterAndSort()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -954,6 +979,20 @@ class CompletedFilesFragment : Fragment() {
|
|||||||
private fun loadFiles() {
|
private fun loadFiles() {
|
||||||
allFiles = if (currentDir.exists()) currentDir.listFiles()?.toList() ?: emptyList() else emptyList()
|
allFiles = if (currentDir.exists()) currentDir.listFiles()?.toList() ?: emptyList() else emptyList()
|
||||||
backPressedCallback.isEnabled = isSelectionMode || currentDir.absolutePath != rootDir.absolutePath
|
backPressedCallback.isEnabled = isSelectionMode || currentDir.absolutePath != rootDir.absolutePath
|
||||||
|
|
||||||
|
// 💡 1. 현재 진입한 폴더의 정렬 설정을 로드합니다.
|
||||||
|
loadFolderSortSetting(currentDir.absolutePath)
|
||||||
|
|
||||||
|
// 💡 2. 불러온 설정에 맞게 UI 컴포넌트(스피너, 화살표) 상태를 동기화합니다.
|
||||||
|
view?.let { root ->
|
||||||
|
val spinnerSort = root.findViewById<Spinner>(R.id.spinnerSort)
|
||||||
|
val tvSortOrder = root.findViewById<TextView>(R.id.tvSortOrder)
|
||||||
|
|
||||||
|
// 정렬타입 스피너 인덱스 찾아 바꾸기 (선택 시 이벤트 발생으로 applyFilterAndSort 자동 호출 차단 처리 포함)
|
||||||
|
spinnerSort.setSelection(currentSort.ordinal, false)
|
||||||
|
tvSortOrder.text = if (isDescending) "arrow_downward" else "arrow_upward"
|
||||||
|
}
|
||||||
|
|
||||||
applyFilterAndSort()
|
applyFilterAndSort()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ import bums.lunatic.launcher.home.tokiz.TouchArea
|
|||||||
import bums.lunatic.launcher.home.tokiz.view.PagedTextLayout
|
import bums.lunatic.launcher.home.tokiz.view.PagedTextLayout
|
||||||
import bums.lunatic.launcher.home.tokiz.view.PagedTextViewInterface
|
import bums.lunatic.launcher.home.tokiz.view.PagedTextViewInterface
|
||||||
import bums.lunatic.launcher.utils.FileUtils.detectFileEncoding
|
import bums.lunatic.launcher.utils.FileUtils.detectFileEncoding
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.RandomAccessFile
|
import java.io.RandomAccessFile
|
||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
@@ -212,11 +214,12 @@ class DocumentViewerActivity : AppCompatActivity(), PagedTextViewInterface {
|
|||||||
if (!::pageIndexer.isInitialized || pageIndex !in pageIndexer.pageOffsets.indices) return
|
if (!::pageIndexer.isInitialized || pageIndex !in pageIndexer.pageOffsets.indices) return
|
||||||
currentPageIndex = pageIndex
|
currentPageIndex = pageIndex
|
||||||
|
|
||||||
// 페이지가 정상적으로 변경될 때마다 최종 페이지 인덱스를 SharedPreferences에 저장
|
|
||||||
currentFile?.let { file ->
|
currentFile?.let { file ->
|
||||||
sharedPreferences.edit().putInt(file.absolutePath, currentPageIndex).apply()
|
sharedPreferences.edit().putInt(file.absolutePath, currentPageIndex).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lifecycleScope.launch {
|
||||||
|
val pageText = withContext(Dispatchers.IO) {
|
||||||
val startOffset = pageIndexer.pageOffsets[pageIndex]
|
val startOffset = pageIndexer.pageOffsets[pageIndex]
|
||||||
val endOffset = if (pageIndex + 1 < pageIndexer.pageOffsets.size) {
|
val endOffset = if (pageIndex + 1 < pageIndexer.pageOffsets.size) {
|
||||||
pageIndexer.pageOffsets[pageIndex + 1]
|
pageIndexer.pageOffsets[pageIndex + 1]
|
||||||
@@ -229,16 +232,20 @@ class DocumentViewerActivity : AppCompatActivity(), PagedTextViewInterface {
|
|||||||
|
|
||||||
raf.seek(startOffset)
|
raf.seek(startOffset)
|
||||||
raf.read(buffer)
|
raf.read(buffer)
|
||||||
|
String(buffer, Charset.forName(encoding))
|
||||||
|
}
|
||||||
|
|
||||||
val pageText = String(buffer, Charset.forName(encoding))
|
// 메인 스레드에서 UI 업데이트
|
||||||
pagedLayout.text = pageText
|
pagedLayout.text = pageText
|
||||||
pagedLayout.currentPageTextView?.text = "${currentPageIndex + 1} / ${pageIndexer.pageOffsets.size}"
|
pagedLayout.currentPageTextView?.text = "${currentPageIndex + 1} / ${pageIndexer.pageOffsets.size}"
|
||||||
pagedLayout.currentChapter?.text = pageIndexer.getChapterForPage(currentPageIndex)?.title
|
pagedLayout.currentChapter?.text = pageIndexer.getChapterForPage(currentPageIndex)?.title
|
||||||
|
|
||||||
pagedLayout.currentChapter?.setOnClickListener {
|
pagedLayout.currentChapter?.setOnClickListener {
|
||||||
if (!::pageIndexer.isInitialized || pageIndexer.pageOffsets.isEmpty()) return@setOnClickListener
|
if (!::pageIndexer.isInitialized || pageIndexer.pageOffsets.isEmpty()) return@setOnClickListener
|
||||||
showChapterListDialog()
|
showChapterListDialog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onTouch(touchArea: TouchArea) {
|
override fun onTouch(touchArea: TouchArea) {
|
||||||
// if (!::pageIndexer.isInitialized || pageIndexer.pageOffsets.isEmpty()) return
|
// if (!::pageIndexer.isInitialized || pageIndexer.pageOffsets.isEmpty()) return
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class PageIndexer(
|
|||||||
val raf = RandomAccessFile(file, "r")
|
val raf = RandomAccessFile(file, "r")
|
||||||
val fileLength = raf.length()
|
val fileLength = raf.length()
|
||||||
var currentOffset = 0L
|
var currentOffset = 0L
|
||||||
|
var lastProgress = -1
|
||||||
pageOffsets.add(currentOffset)
|
pageOffsets.add(currentOffset)
|
||||||
|
|
||||||
val bufferSize = 40000
|
val bufferSize = 40000
|
||||||
@@ -137,7 +137,10 @@ class PageIndexer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val progress = ((currentOffset * 100) / fileLength).toInt()
|
val progress = ((currentOffset * 100) / fileLength).toInt()
|
||||||
|
if (progress != lastProgress) {
|
||||||
onProgress(progress)
|
onProgress(progress)
|
||||||
|
lastProgress = progress
|
||||||
|
}
|
||||||
|
|
||||||
startLine = endLine + 1
|
startLine = endLine + 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,13 +36,13 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/current_chapter"
|
android:id="@+id/current_chapter"
|
||||||
android:layout_marginLeft="30dp"
|
android:layout_marginLeft="10dp"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_marginRight="30dp"
|
android:layout_marginRight="10dp"
|
||||||
android:id="@+id/current_page"
|
android:id="@+id/current_page"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
|||||||
Reference in New Issue
Block a user