Skip to content

Commit 9844cbf

Browse files
authored
Merge pull request #13334 from woocommerce/13270-android-sdk-update-target-sdk-to-35
[Android SDK update] Target SDK to 35
2 parents 079af3d + 6ddb40e commit 9844cbf

File tree

52 files changed

+661
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+661
-182
lines changed

WooCommerce/src/main/AndroidManifest.xml

+20-22
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@
110110
<activity
111111
android:name=".ui.login.MagicLinkInterceptActivity"
112112
android:exported="true"
113-
android:theme="@style/LoginTheme">
113+
android:theme="@style/LoginTheme"
114+
android:windowSoftInputMode="adjustResize">
114115
<intent-filter>
115116
<action android:name="android.intent.action.VIEW" />
116117

@@ -124,49 +125,46 @@
124125
</activity>
125126
<activity
126127
android:name=".ui.prefs.AppSettingsActivity"
127-
android:theme="@style/Theme.Woo.DayNight" />
128+
android:theme="@style/Theme.Woo.DayNight"
129+
android:windowSoftInputMode="adjustResize" />
128130
<activity
129131
android:name=".ui.prefs.UnifiedAboutScreenActivity"
130-
android:theme="@style/Theme.Woo.UnifiedAbout" />
132+
android:theme="@style/Theme.Woo.UnifiedAbout"
133+
android:windowSoftInputMode="adjustResize" />
131134
<activity
132135
android:name=".support.WooLogViewerActivity"
133136
android:label="@string/logviewer_activity_title"
134-
android:theme="@style/Theme.Woo.DayNight" />
137+
android:theme="@style/Theme.Woo.DayNight"
138+
android:windowSoftInputMode="adjustResize" />
135139
<activity
136140
android:name=".support.SSRActivity"
137141
android:label="@string/support_system_status_report"
138-
android:theme="@style/Theme.Woo.DayNight" />
142+
android:theme="@style/Theme.Woo.DayNight"
143+
android:windowSoftInputMode="adjustResize" />
139144
<activity
140145
android:name=".support.requests.SupportRequestFormActivity"
141146
android:label="@string/support_request"
142-
android:theme="@style/Theme.Woo.DayNight" />
147+
android:theme="@style/Theme.Woo.DayNight"
148+
android:windowSoftInputMode="adjustResize" />
143149
<activity
144150
android:name=".support.help.HelpActivity"
145151
android:label="@string/support_help"
146-
android:theme="@style/Theme.Woo.DayNight" />
147-
<activity
148-
android:name="zendesk.support.guide.HelpCenterActivity"
149-
android:theme="@style/Theme.Woo.DayNight.Zendesk" />
150-
<activity
151-
android:name="zendesk.support.guide.ViewArticleActivity"
152-
android:theme="@style/Theme.Woo.DayNight.Zendesk" />
153-
<activity
154-
android:name="zendesk.support.request.RequestActivity"
155-
android:theme="@style/Theme.Woo.DayNight.Zendesk" />
156-
<activity
157-
android:name="zendesk.support.requestlist.RequestListActivity"
158-
android:theme="@style/Theme.Woo.DayNight.Zendesk" />
152+
android:theme="@style/Theme.Woo.DayNight"
153+
android:windowSoftInputMode="adjustResize" />
159154
<activity
160155
android:name="org.wordpress.android.mediapicker.ui.MediaPickerActivity"
161-
android:theme="@style/Theme.Woo.DayNight" />
156+
android:theme="@style/Theme.Woo.DayNight"
157+
android:windowSoftInputMode="adjustResize" />
162158
<!-- Make sure portrait screen orientation is not required for the installation of the app -->
163159
<activity
164160
android:name="com.woocommerce.android.ui.woopos.root.WooPosActivity"
161+
android:exported="false"
165162
android:theme="@style/Theme.WooPos"
166-
android:exported="false" />
163+
android:windowSoftInputMode="adjustResize" />
167164
<activity
168165
android:name="com.woocommerce.android.ui.woopos.cardreader.WooPosCardReaderActivity"
169-
android:theme="@style/Theme.WooPos.Transparent" />
166+
android:theme="@style/Theme.WooPos.Transparent"
167+
android:windowSoftInputMode="adjustResize" />
170168

171169
<!-- Stats today app widget -->
172170
<meta-data

WooCommerce/src/main/kotlin/com/woocommerce/android/AppInitializer.kt

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import com.woocommerce.android.ui.login.AccountRepository
4545
import com.woocommerce.android.ui.main.MainActivity
4646
import com.woocommerce.android.ui.payments.cardreader.onboarding.CardReaderOnboardingChecker
4747
import com.woocommerce.android.util.AppThemeUtils
48+
import com.woocommerce.android.util.ApplicationEdgeToEdgeEnabler
4849
import com.woocommerce.android.util.ApplicationLifecycleMonitor
4950
import com.woocommerce.android.util.ApplicationLifecycleMonitor.ApplicationLifecycleListener
5051
import com.woocommerce.android.util.GetWooCorePluginCachedVersion
@@ -160,6 +161,8 @@ class AppInitializer @Inject constructor() : ApplicationLifecycleListener {
160161

161162
@Inject lateinit var backgroundUpdatesDisabled: BackgroundUpdatesDisabled
162163

164+
@Inject lateinit var edgeToEdgeEnabler: ApplicationEdgeToEdgeEnabler
165+
163166
private var connectionReceiverRegistered = false
164167

165168
private lateinit var application: Application
@@ -219,6 +222,7 @@ class AppInitializer @Inject constructor() : ApplicationLifecycleListener {
219222
val lifecycleMonitor = ApplicationLifecycleMonitor(this)
220223
application.registerActivityLifecycleCallbacks(lifecycleMonitor)
221224
application.registerComponentCallbacks(lifecycleMonitor)
225+
application.registerActivityLifecycleCallbacks(edgeToEdgeEnabler)
222226

223227
trackStartupAnalytics()
224228

WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/ViewExt.kt

+45
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,25 @@ import android.view.animation.Transformation
1313
import android.widget.LinearLayout.LayoutParams
1414
import androidx.constraintlayout.widget.ConstraintLayout
1515
import androidx.constraintlayout.widget.Group
16+
import androidx.core.graphics.Insets
17+
import androidx.core.view.ViewCompat
18+
import androidx.core.view.WindowInsetsCompat
1619
import androidx.core.view.children
1720
import androidx.core.view.isVisible
1821
import androidx.core.view.updateLayoutParams
22+
import androidx.core.view.updatePadding
1923
import androidx.transition.ChangeBounds
2024
import androidx.transition.Transition
2125
import androidx.transition.TransitionListenerAdapter
2226
import androidx.transition.TransitionManager
27+
import com.google.android.material.appbar.AppBarLayout
2328
import kotlinx.coroutines.channels.awaitClose
2429
import kotlinx.coroutines.flow.Flow
2530
import kotlinx.coroutines.flow.callbackFlow
2631
import kotlinx.coroutines.flow.distinctUntilChanged
2732
import kotlinx.coroutines.flow.filter
2833
import kotlinx.coroutines.flow.map
34+
import org.wordpress.android.util.DisplayUtils
2935

3036
const val EXPAND_COLLAPSE_ANIMATION_DURATION_MILLIS = 300L
3137

@@ -182,3 +188,42 @@ fun View.scrollStartEvents(): Flow<Unit> {
182188
.filter { it == MotionEvent.ACTION_MOVE }
183189
.map { }
184190
}
191+
192+
fun View.edgeToEdgeHandlingForNavigationBar() {
193+
doOnApplyWindowInsets {
194+
setPadding(it.left, 0, it.right, it.bottom)
195+
}
196+
}
197+
198+
fun View.edgeToEdgeForInLandscape() {
199+
if (DisplayUtils.isLandscape(context)) {
200+
edgeToEdgeHandlingForNavigationBar()
201+
}
202+
}
203+
204+
fun View.edgeToEdgeHandlingForNavigationAndStatusBar(appBarLayout: AppBarLayout? = null) {
205+
doOnApplyWindowInsets(consumeInsets = true) { insets ->
206+
updatePadding(
207+
left = insets.left,
208+
right = insets.right,
209+
bottom = insets.bottom
210+
)
211+
212+
if (appBarLayout != null) {
213+
appBarLayout.updatePadding(top = insets.top)
214+
} else {
215+
updatePadding(top = insets.top)
216+
}
217+
}
218+
}
219+
220+
inline fun View.doOnApplyWindowInsets(
221+
insetsMask: Int = WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout(),
222+
consumeInsets: Boolean = false,
223+
crossinline action: (Insets) -> Unit
224+
) {
225+
ViewCompat.setOnApplyWindowInsetsListener(this) { v, insets ->
226+
action(insets.getInsets(insetsMask))
227+
if (consumeInsets) WindowInsetsCompat.CONSUMED else insets
228+
}
229+
}

WooCommerce/src/main/kotlin/com/woocommerce/android/support/SSRScreen.kt

+20-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ package com.woocommerce.android.support
33
import androidx.compose.foundation.background
44
import androidx.compose.foundation.layout.Box
55
import androidx.compose.foundation.layout.Column
6+
import androidx.compose.foundation.layout.WindowInsets
7+
import androidx.compose.foundation.layout.WindowInsetsSides
68
import androidx.compose.foundation.layout.fillMaxSize
9+
import androidx.compose.foundation.layout.only
710
import androidx.compose.foundation.layout.padding
11+
import androidx.compose.foundation.layout.safeDrawing
12+
import androidx.compose.foundation.layout.windowInsetsPadding
813
import androidx.compose.foundation.rememberScrollState
914
import androidx.compose.foundation.text.selection.SelectionContainer
1015
import androidx.compose.foundation.verticalScroll
@@ -58,20 +63,28 @@ fun SSRScreen(
5863
IconButton(onClick = onCopyButtonClick, enabled = !isLoading) {
5964
Icon(
6065
painter = painterResource(id = R.drawable.ic_copy_white_24dp),
61-
contentDescription = stringResource(id = R.string.support_system_status_report_copy_label),
66+
contentDescription = stringResource(
67+
id = R.string.support_system_status_report_copy_label
68+
),
6269
tint = colorResource(id = R.color.color_icon_menu),
6370
)
6471
}
6572
IconButton(onClick = onShareButtonClick, enabled = !isLoading) {
6673
Icon(
6774
imageVector = Icons.Filled.Share,
68-
contentDescription = stringResource(id = R.string.support_system_status_report_share_label),
75+
contentDescription = stringResource(
76+
id = R.string.support_system_status_report_share_label
77+
),
6978
tint = colorResource(id = R.color.color_icon_menu)
7079
)
7180
}
72-
}
81+
},
7382
)
74-
}
83+
},
84+
modifier = Modifier
85+
.fillMaxSize()
86+
.background(color = colorResource(id = R.color.color_toolbar))
87+
.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top)),
7588
) { padding ->
7689
val scrollState = rememberScrollState()
7790

@@ -84,6 +97,7 @@ fun SSRScreen(
8497
modifier = Modifier
8598
.background(color = MaterialTheme.colors.surface)
8699
.verticalScroll(scrollState)
100+
.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom))
87101
.padding(padding)
88102
.padding(vertical = dimensionResource(id = R.dimen.major_100))
89103
.fillMaxSize()
@@ -107,7 +121,8 @@ fun SSRContent(isLoading: Boolean, formattedSSR: String, modifier: Modifier) {
107121
SelectionContainer {
108122
Text(
109123
text = formattedSSR,
110-
modifier = Modifier.padding(dimensionResource(R.dimen.major_100))
124+
modifier = Modifier
125+
.padding(dimensionResource(R.dimen.major_100))
111126
)
112127
}
113128
}

WooCommerce/src/main/kotlin/com/woocommerce/android/support/WooLogViewerActivity.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class WooLogViewerActivity : AppCompatActivity() {
3535
intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name) + " " + title)
3636
try {
3737
startActivity(Intent.createChooser(intent, getString(R.string.share)))
38-
} catch (ex: android.content.ActivityNotFoundException) {
38+
} catch (_: android.content.ActivityNotFoundException) {
3939
ToastUtils.showToast(this, R.string.logviewer_share_error)
4040
}
4141
}

WooCommerce/src/main/kotlin/com/woocommerce/android/support/WooLogViewerScreen.kt

+17-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ import androidx.compose.foundation.background
55
import androidx.compose.foundation.layout.Arrangement
66
import androidx.compose.foundation.layout.Column
77
import androidx.compose.foundation.layout.Row
8+
import androidx.compose.foundation.layout.WindowInsets
9+
import androidx.compose.foundation.layout.WindowInsetsSides
10+
import androidx.compose.foundation.layout.asPaddingValues
11+
import androidx.compose.foundation.layout.fillMaxSize
812
import androidx.compose.foundation.layout.fillMaxWidth
13+
import androidx.compose.foundation.layout.only
914
import androidx.compose.foundation.layout.padding
15+
import androidx.compose.foundation.layout.safeDrawing
16+
import androidx.compose.foundation.layout.windowInsetsPadding
1017
import androidx.compose.foundation.lazy.LazyColumn
1118
import androidx.compose.foundation.lazy.itemsIndexed
1219
import androidx.compose.foundation.text.selection.SelectionContainer
@@ -60,9 +67,13 @@ fun WooLogViewerScreen(
6067
tint = colorResource(id = R.color.color_icon_menu)
6168
)
6269
}
63-
}
70+
},
6471
)
65-
}
72+
},
73+
modifier = Modifier
74+
.fillMaxSize()
75+
.background(color = colorResource(id = R.color.color_toolbar))
76+
.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top)),
6677
) { padding ->
6778
LogViewerEntries(
6879
entries,
@@ -76,7 +87,10 @@ fun LogViewerEntries(
7687
entries: RollingLogEntries,
7788
modifier: Modifier = Modifier
7889
) {
79-
LazyColumn(modifier = modifier) {
90+
LazyColumn(
91+
modifier = modifier,
92+
contentPadding = WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom).asPaddingValues(),
93+
) {
8094
itemsIndexed(entries) { index, entry ->
8195
LogViewerEntry(index, entry)
8296
if (index < entries.lastIndex) {

WooCommerce/src/main/kotlin/com/woocommerce/android/support/help/HelpActivity.kt

+13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import android.view.View
88
import androidx.activity.viewModels
99
import androidx.appcompat.app.AppCompatActivity
1010
import androidx.appcompat.widget.Toolbar
11+
import androidx.core.view.updatePadding
1112
import com.woocommerce.android.AppPrefs
1213
import com.woocommerce.android.AppUrls
1314
import com.woocommerce.android.R
@@ -17,6 +18,7 @@ import com.woocommerce.android.analytics.AnalyticsTracker.Companion.KEY_HELP_CON
1718
import com.woocommerce.android.analytics.AnalyticsTracker.Companion.KEY_SOURCE_FLOW
1819
import com.woocommerce.android.analytics.AnalyticsTracker.Companion.KEY_SOURCE_STEP
1920
import com.woocommerce.android.databinding.ActivityHelpBinding
21+
import com.woocommerce.android.extensions.doOnApplyWindowInsets
2022
import com.woocommerce.android.extensions.isNotNullOrEmpty
2123
import com.woocommerce.android.extensions.serializable
2224
import com.woocommerce.android.extensions.show
@@ -69,6 +71,17 @@ class HelpActivity : AppCompatActivity() {
6971
binding = ActivityHelpBinding.inflate(layoutInflater)
7072
setContentView(binding.root)
7173

74+
binding.root.doOnApplyWindowInsets(consumeInsets = true) {
75+
binding.root.updatePadding(
76+
left = it.left,
77+
right = it.right,
78+
bottom = it.bottom
79+
)
80+
binding.appBarLayout.updatePadding(
81+
top = it.top
82+
)
83+
}
84+
7285
setSupportActionBar(binding.toolbar.toolbar as Toolbar)
7386
supportActionBar?.setHomeButtonEnabled(true)
7487
supportActionBar?.setDisplayHomeAsUpEnabled(true)

WooCommerce/src/main/kotlin/com/woocommerce/android/support/requests/SupportRequestFormActivity.kt

+18
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ import android.view.MenuItem
77
import androidx.activity.viewModels
88
import androidx.appcompat.app.AppCompatActivity
99
import androidx.appcompat.widget.Toolbar
10+
import androidx.core.view.WindowInsetsCompat
11+
import androidx.core.view.updatePadding
1012
import androidx.core.widget.doOnTextChanged
1113
import com.woocommerce.android.R
1214
import com.woocommerce.android.analytics.AnalyticsEvent
1315
import com.woocommerce.android.analytics.AnalyticsTracker
1416
import com.woocommerce.android.databinding.ActivitySupportRequestFormBinding
1517
import com.woocommerce.android.extensions.adjustActivityTransition
18+
import com.woocommerce.android.extensions.doOnApplyWindowInsets
1619
import com.woocommerce.android.extensions.serializable
1720
import com.woocommerce.android.support.SupportHelper
1821
import com.woocommerce.android.support.help.HelpOrigin
@@ -50,6 +53,21 @@ class SupportRequestFormActivity : AppCompatActivity() {
5053
zendeskSettings.setup(context = this)
5154

5255
ActivitySupportRequestFormBinding.inflate(layoutInflater).apply {
56+
this.root.doOnApplyWindowInsets(
57+
insetsMask = WindowInsetsCompat.Type.systemBars()
58+
or WindowInsetsCompat.Type.displayCutout()
59+
or WindowInsetsCompat.Type.ime(),
60+
consumeInsets = true
61+
) { insets ->
62+
this.root.updatePadding(
63+
left = insets.left,
64+
right = insets.right,
65+
bottom = insets.bottom
66+
)
67+
this.appBarLayout.updatePadding(
68+
top = insets.top
69+
)
70+
}
5371
setContentView(root)
5472
setupActionBar()
5573
observeViewEvents(this)

0 commit comments

Comments
 (0)