Skip to content

Commit eef6a15

Browse files
committed
Allow http for debug builds
1 parent 2eb86bf commit eef6a15

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

app/src/debug/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<application
4+
android:usesCleartextTraffic="true"/>
5+
</manifest>

app/src/main/java/be/mygod/reactmap/ConfigDialogFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class ConfigDialogFragment : AlertDialogFragment<ConfigDialogFragment.Arg, Empty
7575

7676
override val ret get() = try {
7777
val uri = urlEdit.text!!.toString().toUri().let {
78-
require("https".equals(it.scheme, true)) { getText(R.string.error_https_only) }
78+
require(BuildConfig.DEBUG || "https".equals(it.scheme, true)) { getText(R.string.error_https_only) }
7979
it.host!!
8080
it.toString()
8181
}

app/src/main/java/be/mygod/reactmap/webkit/BaseReactMapFragment.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import androidx.core.net.toUri
3030
import androidx.core.os.bundleOf
3131
import androidx.fragment.app.Fragment
3232
import be.mygod.reactmap.App.Companion.app
33+
import be.mygod.reactmap.BuildConfig
3334
import be.mygod.reactmap.R
3435
import be.mygod.reactmap.follower.BackgroundLocationReceiver
3536
import be.mygod.reactmap.util.UnblockCentral
@@ -194,7 +195,9 @@ abstract class BaseReactMapFragment : Fragment(), DownloadListener {
194195
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
195196
glocation.clear()
196197
val uri = url.toUri()
197-
if ("http".equals(uri.scheme, true)) web.loadUrl(uri.buildUpon().scheme("https").build().toString())
198+
if (!BuildConfig.DEBUG && "http".equals(uri.scheme, true)) {
199+
web.loadUrl(uri.buildUpon().scheme("https").build().toString())
200+
}
198201
if (uri.host == hostname) glocation.setupGeolocation()
199202
onPageStarted()
200203
}
@@ -216,15 +219,15 @@ abstract class BaseReactMapFragment : Fragment(), DownloadListener {
216219
}
217220
"http".equals(parsed.scheme, true) -> {
218221
Snackbar.make(view, R.string.error_https_only, Snackbar.LENGTH_SHORT).show()
219-
true
222+
!BuildConfig.DEBUG
220223
}
221224
else -> false
222225
}
223226
}
224227

225228
override fun shouldInterceptRequest(view: WebView?, request: WebResourceRequest): WebResourceResponse? {
226229
val path = request.url.path ?: return null
227-
if ("https".equals(request.url.scheme, true) && request.url.host == hostname) {
230+
if (request.url.host == hostname) {
228231
if (path == "/api/settings") return handleSettings(request)
229232
if (path.startsWith("/locales/") && path.endsWith("/translation.json")) {
230233
return handleTranslation(request)

0 commit comments

Comments
 (0)