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

Add 2nd hidden Google API key #114

Merged
merged 2 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 8 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
tags:
- 'v*'

jobs:
Build:
name: Build/Sign APK
Expand All @@ -17,7 +17,12 @@ jobs:
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1)
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV
echo Last build tool version is: $BUILD_TOOL_VERSION


- name: Access GOOGLE_API_KEY
env:
GOOGLE_API_KEY: $
run: echo GOOGLE_API_KEY=\"$GOOGLE_API_KEY\" >> ./local.properties

- name: set up JDK 17
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -65,7 +70,7 @@ jobs:
keyPassword: ${{ secrets.KEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}

- name: Make artifact
uses: actions/upload-artifact@v2
with:
Expand Down
15 changes: 14 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ plugins {

apply plugin: 'com.mikepenz.aboutlibraries.plugin'

String getGoogleApiKey() {
def propFile = rootProject.file("./local.properties")
def properties = new Properties()
if (propFile.exists()) {
properties.load(new FileInputStream(propFile))
return properties.getProperty('GOOGLE_API_KEY', "null")
} else {
return "null"
}
}

android {
namespace 'com.starry.myne'
compileSdk 34
Expand All @@ -27,6 +38,8 @@ android {
ksp {
arg('room.schemaLocation', "$projectDir/schemas")
}

buildConfigField("String", "GOOGLE_API_KEY", getGoogleApiKey())
}

buildTypes {
Expand Down Expand Up @@ -85,7 +98,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
implementation 'androidx.activity:activity-compose:1.8.2'
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0"
implementation "androidx.navigation:navigation-compose:2.7.6"
implementation "androidx.navigation:navigation-compose:2.7.7"
// Jetpack compose.
implementation "androidx.compose.ui:ui"
implementation "androidx.compose.ui:ui-tooling-preview"
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/starry/myne/repo/BookRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.starry.myne.repo

import com.google.gson.Gson
import com.starry.myne.BuildConfig
import com.starry.myne.repo.models.BookSet
import com.starry.myne.repo.models.ExtraInfo
import com.starry.myne.utils.book.BookLanguage
Expand All @@ -41,7 +42,9 @@ class BookRepository {

private val baseApiUrl = "https://myne.pooloftears.xyz/books"
private val googleBooksUrl = "https://www.googleapis.com/books/v1/volumes"
private val googleApiKey = "AIzaSyBCaXx-U0sbEpGVPWylSggC4RaR4gCGkVE"
private val googleApiKey =
BuildConfig.GOOGLE_API_KEY ?: "AIzaSyBCaXx-U0sbEpGVPWylSggC4RaR4gCGkVE" // Backup API key


private val okHttpClient = OkHttpClient.Builder()
.connectTimeout(60, TimeUnit.SECONDS)
Expand Down
Loading