This commit is contained in:
RyanMaulana23 2026-01-02 22:28:31 +07:00
parent 6d21baa3f3
commit d0b773b6ef
2 changed files with 17 additions and 2 deletions

View File

@ -1,3 +1,6 @@
import java.util.Properties
import java.io.FileInputStream
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
@ -5,6 +8,13 @@ plugins {
alias(libs.plugins.google.services)
}
// Load properties from local.properties file
val localProperties = Properties()
val localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
localProperties.load(FileInputStream(localPropertiesFile))
}
android {
namespace = "com.example.ppb_kelompok2"
compileSdk {
@ -19,6 +29,9 @@ android {
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// Expose the API key as a BuildConfig field
buildConfigField("String", "HF_API_KEY", "\"${localProperties.getProperty("HF_API_KEY") ?: ""}\"")
}
buildTypes {
@ -39,6 +52,7 @@ android {
}
buildFeatures {
compose = true
buildConfig = true // Ensure this is enabled
}
}

View File

@ -1,5 +1,5 @@
package com.example.ppb_kelompok2
// Kelompok2
// Yoseph & Team - Final Version with Secure API Key
import android.Manifest
import android.app.AlarmManager
import android.app.PendingIntent
@ -71,7 +71,8 @@ import java.util.Locale
import kotlin.math.roundToInt
import kotlin.random.Random
const val HF_API_TOKEN = "Bearer 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"
// Kunci API sekarang diambil dari BuildConfig, bukan hardcoded
const val HF_API_TOKEN = "Bearer ${BuildConfig.HF_API_KEY}"
data class JournalEntry(
val id: String = "",