Embed UUID and SERVER_URL in build types
Browse filesUUID and SERVER_URL is now part of the build process.
For debug, the placeholder default values are set, however if corresponding env values are set, it sets them.
So by default the settings now displays the environment URL and UUID fetched during build.
For Release, the env values are pulled again from env variable. Which is injected in github action.
puppet/app/build.gradle
CHANGED
|
@@ -5,7 +5,7 @@ plugins {
|
|
| 5 |
|
| 6 |
android {
|
| 7 |
namespace 'com.ttt246.puppet'
|
| 8 |
-
|
| 9 |
kotlinOptions {
|
| 10 |
jvmTarget = "1.8"
|
| 11 |
}
|
|
@@ -28,10 +28,27 @@ android {
|
|
| 28 |
}
|
| 29 |
}
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
buildTypes {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
release {
|
| 33 |
minifyEnabled false
|
| 34 |
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
|
|
|
|
|
|
|
|
| 35 |
}
|
| 36 |
}
|
| 37 |
|
|
|
|
| 5 |
|
| 6 |
android {
|
| 7 |
namespace 'com.ttt246.puppet'
|
| 8 |
+
compileSdk 33
|
| 9 |
kotlinOptions {
|
| 10 |
jvmTarget = "1.8"
|
| 11 |
}
|
|
|
|
| 28 |
}
|
| 29 |
}
|
| 30 |
|
| 31 |
+
buildFeatures {
|
| 32 |
+
buildConfig = true
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
buildTypes {
|
| 36 |
+
def DEFAULT_SERVER_URL = '"https://posix4e-puppet.hf.space"'
|
| 37 |
+
// This is a non existent UUID, meant to be a placeholder so that build wont yell
|
| 38 |
+
def DEFAULT_UUID = '"123456789012345"'
|
| 39 |
+
|
| 40 |
+
debug {
|
| 41 |
+
buildConfigField("String", "SERVER_URL", System.getenv("SERVER_URL") ?: DEFAULT_SERVER_URL)
|
| 42 |
+
buildConfigField("String", "UUID", System.getenv("UUID") ?: DEFAULT_UUID)
|
| 43 |
+
applicationIdSuffix ".debug"
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
release {
|
| 47 |
minifyEnabled false
|
| 48 |
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
| 49 |
+
|
| 50 |
+
buildConfigField("String", "SERVER_URL", System.getenv("SERVER_URL") ?: '""')
|
| 51 |
+
buildConfigField("String", "UUID", System.getenv("UUID") ?: '""')
|
| 52 |
}
|
| 53 |
}
|
| 54 |
|
puppet/app/src/main/java/com/ttt246/puppet/ChatterAct.kt
CHANGED
|
@@ -3,6 +3,8 @@ package com.ttt246.puppet
|
|
| 3 |
import android.annotation.SuppressLint
|
| 4 |
import android.content.Context
|
| 5 |
import android.content.Intent
|
|
|
|
|
|
|
| 6 |
import android.os.Bundle
|
| 7 |
import android.preference.PreferenceManager
|
| 8 |
import android.provider.Settings
|
|
@@ -12,6 +14,8 @@ import androidx.appcompat.app.AppCompatActivity
|
|
| 12 |
|
| 13 |
class ChatterAct : AppCompatActivity() {
|
| 14 |
private lateinit var webView: WebView
|
|
|
|
|
|
|
| 15 |
private val TAG = "ChatterActLog"
|
| 16 |
|
| 17 |
override fun onCreate(savedInstanceState: Bundle?) {
|
|
@@ -19,6 +23,12 @@ class ChatterAct : AppCompatActivity() {
|
|
| 19 |
setContentView(R.layout.activity_main)
|
| 20 |
supportActionBar?.hide()
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
val accessibilitySettingsBtn: Button = findViewById(R.id.accessibilitySettings)
|
| 23 |
accessibilitySettingsBtn.setOnClickListener {
|
| 24 |
val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
|
|
|
|
| 3 |
import android.annotation.SuppressLint
|
| 4 |
import android.content.Context
|
| 5 |
import android.content.Intent
|
| 6 |
+
import android.content.SharedPreferences
|
| 7 |
+
import android.os.Build
|
| 8 |
import android.os.Bundle
|
| 9 |
import android.preference.PreferenceManager
|
| 10 |
import android.provider.Settings
|
|
|
|
| 14 |
|
| 15 |
class ChatterAct : AppCompatActivity() {
|
| 16 |
private lateinit var webView: WebView
|
| 17 |
+
private lateinit var sharedPreferences: SharedPreferences
|
| 18 |
+
|
| 19 |
private val TAG = "ChatterActLog"
|
| 20 |
|
| 21 |
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
| 23 |
setContentView(R.layout.activity_main)
|
| 24 |
supportActionBar?.hide()
|
| 25 |
|
| 26 |
+
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
|
| 27 |
+
val editor = sharedPreferences.edit()
|
| 28 |
+
editor.putString("SERVER_URL", BuildConfig.SERVER_URL)
|
| 29 |
+
editor.putString("UUID", BuildConfig.UUID)
|
| 30 |
+
editor.apply()
|
| 31 |
+
|
| 32 |
val accessibilitySettingsBtn: Button = findViewById(R.id.accessibilitySettings)
|
| 33 |
accessibilitySettingsBtn.setOnClickListener {
|
| 34 |
val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
|