Skip to content
Snippets Groups Projects
Unverified Commit efdd52d1 authored by Hee Tatt Ooi's avatar Hee Tatt Ooi Committed by GitHub
Browse files

remove app start via scheme and added URL override from environment.properties (#339)

parent 2b87f798
No related branches found
No related tags found
No related merge requests found
......@@ -41,24 +41,36 @@ android {
buildConfigField "String", "VERIFICATION_CDN_URL", "\"$VERIFICATION_CDN_URL\""
buildConfigField "String", "EXPORT_SIGNATURE_ID", "\"de.rki.coronawarnapp-dev\""
//override URLs with local variables
Properties properties = new Properties()
//override URLs. Use local.properties if exist.
// If environment.properties also exist, override local.properties
def propertiesFile = project.rootProject.file('local.properties')
def environmentPropertiesFile = project.rootProject.file('environment.properties')
Properties overridingProperties
if (propertiesFile.exists()) {
properties.load(propertiesFile.newDataInputStream())
def secretFile = project.rootProject.file('secrets.properties')
if (secretFile.exists())
properties.load(secretFile.newDataInputStream())
overridingProperties = new Properties()
overridingProperties.load(propertiesFile.newDataInputStream())
}
if (environmentPropertiesFile.exists()) {
overridingProperties = new Properties()
overridingProperties.load(environmentPropertiesFile.newDataInputStream())
}else if (propertiesFile.exists()) {
overridingProperties = new Properties()
overridingProperties.load(propertiesFile.newDataInputStream())
}
def DOWNLOAD_CDN_URL = properties.getProperty('DOWNLOAD_CDN_URL')
if(overridingProperties){
def DOWNLOAD_CDN_URL = overridingProperties.getProperty('DOWNLOAD_CDN_URL')
if (DOWNLOAD_CDN_URL)
buildConfigField "String", "DOWNLOAD_CDN_URL", "\"$DOWNLOAD_CDN_URL\""
def SUBMISSION_CDN_URL = properties.getProperty('SUBMISSION_CDN_URL')
def SUBMISSION_CDN_URL = overridingProperties.getProperty('SUBMISSION_CDN_URL')
if (SUBMISSION_CDN_URL)
buildConfigField "String", "SUBMISSION_CDN_URL", "\"$SUBMISSION_CDN_URL\""
def VERIFICATION_CDN_URL = properties.getProperty('VERIFICATION_CDN_URL')
def VERIFICATION_CDN_URL = overridingProperties.getProperty('VERIFICATION_CDN_URL')
if (VERIFICATION_CDN_URL)
buildConfigField "String", "VERIFICATION_CDN_URL", "\"$VERIFICATION_CDN_URL\""
}
......
......@@ -42,15 +42,6 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="coronawarnapp" />
</intent-filter>
</activity>
<activity
android:name=".ui.main.MainActivity"
......
......@@ -4,7 +4,6 @@ import android.webkit.URLUtil
import de.rki.coronawarnapp.BuildConfig
import de.rki.coronawarnapp.CoronaWarnApplication
import de.rki.coronawarnapp.exception.http.ServiceFactoryException
import de.rki.coronawarnapp.http.config.DynamicURLs
import de.rki.coronawarnapp.http.config.HTTPVariables
import de.rki.coronawarnapp.http.interceptor.OfflineCacheInterceptor
import de.rki.coronawarnapp.http.interceptor.RetryInterceptor
......@@ -160,7 +159,7 @@ class ServiceFactory {
this.newBuilder().connectionSpecs(specs).build()
private val downloadCdnUrl
get() = getValidUrl(DynamicURLs.DOWNLOAD_CDN_URL)
get() = getValidUrl(BuildConfig.DOWNLOAD_CDN_URL)
fun distributionService(): DistributionService = distributionService
private val distributionService by lazy {
......@@ -173,7 +172,7 @@ class ServiceFactory {
}
private val verificationCdnUrl
get() = getValidUrl(DynamicURLs.VERIFICATION_CDN_URL)
get() = getValidUrl(BuildConfig.VERIFICATION_CDN_URL)
fun verificationService(): VerificationService = verificationService
private val verificationService by lazy {
......@@ -186,7 +185,7 @@ class ServiceFactory {
}
private val submissionCdnUrl
get() = getValidUrl(DynamicURLs.SUBMISSION_CDN_URL)
get() = getValidUrl(BuildConfig.SUBMISSION_CDN_URL)
fun submissionService(): SubmissionService = submissionService
private val submissionService by lazy {
......
package de.rki.coronawarnapp.http.config
import de.rki.coronawarnapp.BuildConfig
object DynamicURLs {
const val PATTERN_PREFIX_HTTPS = "https://"
/** CDN URLs for querying against the Server from the Build Config for downloading keys */
var DOWNLOAD_CDN_URL = BuildConfig.DOWNLOAD_CDN_URL
/** CDN URLs for querying against the Server from the Build Config for submitting keys */
var SUBMISSION_CDN_URL = BuildConfig.SUBMISSION_CDN_URL
var VERIFICATION_CDN_URL = BuildConfig.VERIFICATION_CDN_URL
}
package de.rki.coronawarnapp.ui
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import de.rki.coronawarnapp.http.config.DynamicURLs
import de.rki.coronawarnapp.storage.LocalData
import de.rki.coronawarnapp.ui.main.MainActivity
import de.rki.coronawarnapp.ui.onboarding.OnboardingActivity
......@@ -22,7 +19,6 @@ class LauncherActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
retrieveCustomURLsFromSchema(intent.data)
updateChecker = UpdateChecker(this)
lifecycleScope.launch {
......@@ -30,34 +26,6 @@ class LauncherActivity : AppCompatActivity() {
}
}
/**
* Retrieves the custom server URLs for testing purposes.
* The schema to start the application: coronawarnapp://launch?SUBMISSION_CDN_URL=<custom_url>&DOWNLOAD_CDN_URL=<custom_url>&VERIFICATION_CDN_URL=<custom_url>
*
* @param intentData
*/
private fun retrieveCustomURLsFromSchema(intentData: Uri?) {
if (intentData != null) {
val downloadCDNUrlFromParameter = intentData.getQueryParameter("DOWNLOAD_CDN_URL")
if (!downloadCDNUrlFromParameter.isNullOrEmpty()) {
DynamicURLs.DOWNLOAD_CDN_URL = downloadCDNUrlFromParameter
}
val submissionCDNUrlFromParameter = intentData.getQueryParameter("SUBMISSION_CDN_URL")
if (!submissionCDNUrlFromParameter.isNullOrEmpty()) {
DynamicURLs.SUBMISSION_CDN_URL = submissionCDNUrlFromParameter
}
val verificationCDNUrlFromParameter =
intentData.getQueryParameter("VERIFICATION_CDN_URL")
if (!verificationCDNUrlFromParameter.isNullOrEmpty()) {
DynamicURLs.VERIFICATION_CDN_URL = verificationCDNUrlFromParameter
}
val toast = Toast.makeText(this, "You now using custom server URLs", Toast.LENGTH_LONG)
toast.show()
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment