From d0b773b6ef8aec91096beb9e336e6eba05487962 Mon Sep 17 00:00:00 2001 From: RyanMaulana23 Date: Fri, 2 Jan 2026 22:28:31 +0700 Subject: [PATCH] fixing --- app/build.gradle.kts | 14 ++++++++++++++ .../java/com/example/ppb_kelompok2/MainActivity.kt | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 09b33cc..1a37c96 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -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 } } diff --git a/app/src/main/java/com/example/ppb_kelompok2/MainActivity.kt b/app/src/main/java/com/example/ppb_kelompok2/MainActivity.kt index dff7573..4f618d5 100644 --- a/app/src/main/java/com/example/ppb_kelompok2/MainActivity.kt +++ b/app/src/main/java/com/example/ppb_kelompok2/MainActivity.kt @@ -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 = "",