diff --git a/app/build.gradle.kts b/app/build.gradle.kts index dcf0c60..30b5cf0 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -68,7 +68,7 @@ dependencies { debugImplementation(libs.ui.tooling) debugImplementation(libs.ui.test.manifest) - // Room Database + // Room Database - TAMBAHKAN INI SEMUA val roomVersion = "2.6.1" implementation("androidx.room:room-runtime:$roomVersion") implementation("androidx.room:room-ktx:$roomVersion") @@ -91,7 +91,4 @@ dependencies { // Gson implementation("com.google.code.gson:gson:2.10.1") - - // PDF Support - implementation("com.tom-roush:pdfbox-android:2.0.27.0") } \ No newline at end of file diff --git a/app/src/main/java/com/example/notebook/api/GeminiApiService.kt b/app/src/main/java/com/example/notebook/api/GeminiApiService.kt index 824688a..1e57b01 100644 --- a/app/src/main/java/com/example/notebook/api/GeminiApiService.kt +++ b/app/src/main/java/com/example/notebook/api/GeminiApiService.kt @@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit */ interface GeminiApiService { - @POST("v1beta/models/gemini-2.0-flash:generateContent") + @POST("v1beta/models/gemini-1.5-flash:generateContent") suspend fun generateContent( @Query("key") apiKey: String, @Body request: GeminiRequest diff --git a/app/src/main/java/com/example/notebook/utils/FileHelper.kt b/app/src/main/java/com/example/notebook/utils/FileHelper.kt index 413b657..1c97023 100644 --- a/app/src/main/java/com/example/notebook/utils/FileHelper.kt +++ b/app/src/main/java/com/example/notebook/utils/FileHelper.kt @@ -76,27 +76,11 @@ object FileHelper { } /** - * Baca text dari file (support Text, Markdown, dan PDF) + * Baca text dari file */ fun readTextFromFile(filePath: String): String? { return try { - val file = File(filePath) - val extension = file.extension.lowercase() - - when (extension) { - "pdf" -> { - // Extract text dari PDF - PdfHelper.extractTextFromPdf(filePath) - } - "txt", "md", "markdown" -> { - // Baca text biasa - file.readText() - } - else -> { - println("⚠️ Format file tidak didukung untuk ekstraksi teks: $extension") - null - } - } + File(filePath).readText() } catch (e: Exception) { e.printStackTrace() null diff --git a/app/src/main/java/com/example/notebook/utils/PdfHelper.kt b/app/src/main/java/com/example/notebook/utils/PdfHelper.kt deleted file mode 100644 index c2fc1bf..0000000 --- a/app/src/main/java/com/example/notebook/utils/PdfHelper.kt +++ /dev/null @@ -1,93 +0,0 @@ -package com.example.notebook.utils - -import android.content.Context -import android.net.Uri -import com.tom_roush.pdfbox.android.PDFBoxResourceLoader -import com.tom_roush.pdfbox.pdmodel.PDDocument -import com.tom_roush.pdfbox.text.PDFTextStripper -import java.io.File - -/** - * Helper untuk extract text dari PDF - */ -object PdfHelper { - - /** - * Initialize PDFBox (panggil sekali saat app start) - */ - fun initialize(context: Context) { - PDFBoxResourceLoader.init(context) - } - - /** - * Extract text dari PDF file - * Return: Text content atau null jika error - */ - fun extractTextFromPdf(filePath: String): String? { - return try { - val file = File(filePath) - val document = PDDocument.load(file) - - val stripper = PDFTextStripper() - val text = stripper.getText(document) - - document.close() - - // Cleanup whitespace - text.trim() - } catch (e: Exception) { - println("❌ Error extract PDF: ${e.message}") - e.printStackTrace() - null - } - } - - /** - * Extract text dari PDF URI (sebelum disimpan) - */ - fun extractTextFromPdfUri(context: Context, uri: Uri): String? { - return try { - val inputStream = context.contentResolver.openInputStream(uri) - val document = PDDocument.load(inputStream) - - val stripper = PDFTextStripper() - val text = stripper.getText(document) - - document.close() - inputStream?.close() - - text.trim() - } catch (e: Exception) { - println("❌ Error extract PDF from URI: ${e.message}") - e.printStackTrace() - null - } - } - - /** - * Get info PDF (jumlah halaman, dll) - */ - fun getPdfInfo(filePath: String): PdfInfo? { - return try { - val file = File(filePath) - val document = PDDocument.load(file) - - val info = PdfInfo( - pageCount = document.numberOfPages, - title = document.documentInformation.title ?: "Unknown", - author = document.documentInformation.author ?: "Unknown" - ) - - document.close() - info - } catch (e: Exception) { - null - } - } -} - -data class PdfInfo( - val pageCount: Int, - val title: String, - val author: String -) \ No newline at end of file