Skip to content

Commit

Permalink
merged branch update-android-skd
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayaryin committed Dec 19, 2024
2 parents c8b9fbd + f7eb793 commit 03e1eb1
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 20 deletions.
3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.1013.0)
aws-sdk-core (3.213.0)
aws-partitions (1.1021.0)
aws-sdk-core (3.214.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.96.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.173.0)
aws-sdk-s3 (1.176.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
Expand Down Expand Up @@ -68,7 +68,7 @@ GEM
faraday_middleware (1.2.1)
faraday (~> 1.0)
fastimage (2.3.1)
fastlane (2.225.0)
fastlane (2.226.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -108,7 +108,7 @@ GEM
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty (~> 0.4.0)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-plugin-appicon (0.16.0)
json
Expand Down Expand Up @@ -157,11 +157,11 @@ GEM
signet (>= 0.16, < 2.a)
highline (2.0.3)
http-accept (1.7.0)
http-cookie (1.0.7)
http-cookie (1.0.8)
domain_name (~> 0.5)
httpclient (2.8.3)
jmespath (1.6.2)
json (2.8.2)
json (2.9.0)
jwt (2.9.3)
base64
logger (1.6.1)
Expand Down Expand Up @@ -198,7 +198,7 @@ GEM
netrc (~> 0.8)
retriable (3.1.2)
rexml (3.3.9)
rouge (2.0.7)
rouge (3.28.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
security (0.1.5)
Expand Down Expand Up @@ -229,8 +229,8 @@ GEM
colored2 (~> 3.1)
nanaimo (~> 0.4.0)
rexml (>= 3.3.6, < 4.0)
xcpretty (0.3.0)
rouge (~> 2.0.7)
xcpretty (0.4.0)
rouge (~> 3.28.0)
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)

Expand Down
1 change: 0 additions & 1 deletion android/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId System.env.ANDROID_PROJECT_APP_ID ? "$System.env.ANDROID_PROJECT_APP_ID" : 'org.wheelmap.pwawrapper'
minSdkVersion 21
targetSdkVersion 35
versionCode 500032
versionName "5.3"
versionCode 500041
versionName "5.4"

buildConfigField 'String', 'PROJECT_APP_NAME', "\"$System.env.PROJECT_APP_NAME\""
buildConfigField 'String', 'PROJECT_HOST_NAME', "\"$System.env.PROJECT_HOST_NAME\""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.wheelmap.pwawrapper

import android.graphics.Color
import android.os.Build
import android.view.View
import android.widget.RelativeLayout
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat

class EdgeToEdgeHandler(private val activity: AppCompatActivity) {

@RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM) // Android 15
fun adjustLayout(){
val rootView = activity.findViewById<RelativeLayout>(R.id.coordinatorLayout)

ViewCompat.setOnApplyWindowInsetsListener(rootView) { _, windowInsets ->
// Handle Status Bar Background
val statusBarHeight = windowInsets.stableInsetTop
if (statusBarHeight > 0) {
val statusBarBackgroundView = View(activity).apply {
setBackgroundColor(ContextCompat.getColor(activity, R.color.primary))
}
rootView.addView(
statusBarBackgroundView,
RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
statusBarHeight
).apply {
addRule(RelativeLayout.ALIGN_PARENT_TOP)
}
)
}

// Handle Bottom Bar Background
val bottomBarHeight = windowInsets.stableInsetBottom
if (bottomBarHeight > 0) {
val bottomBarBackgroundView = View(activity).apply {
setBackgroundColor(Color.BLACK)
}
rootView.addView(
bottomBarBackgroundView,
RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
bottomBarHeight
).apply {
addRule(RelativeLayout.ALIGN_PARENT_BOTTOM)
}
)
}
windowInsets
}

applyMarginsToView(R.id.offlineContainer)
applyMarginsToView(R.id.loadingContainer)
applyMarginsToView(R.id.webView)
applyMarginsToView(R.id.progressBarBottom)
}

@RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM)
fun applyMarginsToView(viewId: Int) {
val view = activity.findViewById<View>(viewId)

ViewCompat.setOnApplyWindowInsetsListener(view) { v, windowInsets ->
val layoutParams = view.layoutParams as RelativeLayout.LayoutParams
layoutParams.setMargins(0, windowInsets.stableInsetTop, 0, windowInsets.stableInsetBottom)
view.layoutParams = layoutParams
windowInsets
}
}
}
19 changes: 15 additions & 4 deletions android/app/src/main/java/org/wheelmap/pwawrapper/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package org.wheelmap.pwawrapper

import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.Resources
import android.os.Build
import android.os.Bundle
import android.view.Window
import androidx.appcompat.app.AppCompatActivity
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.widget.Toast
import org.wheelmap.pwawrapper.ui.UIManager
import org.wheelmap.pwawrapper.webview.WebViewHelper

Expand All @@ -19,10 +18,22 @@ class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
// Setup Theme
setTheme(R.style.AppTheme_NoActionBar)
if (Build.VERSION.SDK_INT >= 35) { // Android 15 (Vanilla Ice Cream)
setTheme(R.style.AppTheme_NoActionBar_OptOut)
} else {
setTheme(R.style.AppTheme_NoActionBar)
}

super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

// It was possible to opt out of edge-to-edge enforcement this time, but the
// following code might be useful in future version updates
/*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) { // Android 15
val edgeToEdgeHandler = EdgeToEdgeHandler(this)
edgeToEdgeHandler.adjustLayout()
}*/

Configuration.init(applicationContext)

// allow app automation in browserstack
Expand Down
6 changes: 6 additions & 0 deletions android/app/src/main/res/values-v35/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="AppTheme.NoActionBar.OptOut" parent="AppTheme.NoActionBar">
<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
</style>
</resources>
3 changes: 3 additions & 0 deletions android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
<item name="android:windowBackground">@xml/launcher</item>
</style>

<style name="OptOutEdgeToEdgeEnforcement">
</style>

</resources>
1 change: 0 additions & 1 deletion fastlane/Pluginfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# Ensure this file is checked in to source control!

# gem 'fastlane-plugin-xml_editor', "~> 0.2.0"
gem 'fastlane-plugin-appicon'
gem 'fastlane-plugin-browserstack'
gem 'fastlane-plugin-increment_version_code'

0 comments on commit 03e1eb1

Please sign in to comment.