Skip to content

Commit ffb9840

Browse files
committed
Merge branch 'trunk' into bump_android_lint
2 parents 94773c7 + 0d67ee1 commit ffb9840

File tree

13 files changed

+152
-174
lines changed

13 files changed

+152
-174
lines changed

WordPress/build.gradle

-29
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import io.sentry.android.gradle.extensions.InstrumentationFeature
2-
import se.bjurr.violations.comments.github.plugin.gradle.ViolationCommentsToGitHubTask
3-
import se.bjurr.violations.lib.model.SEVERITY
42

53
plugins {
64
alias(libs.plugins.android.application)
75
alias(libs.plugins.kotlin.android)
86
alias(libs.plugins.kotlin.parcelize)
97
alias(libs.plugins.kotlin.allopen)
108
alias(libs.plugins.sentry)
11-
alias(libs.plugins.violation.comments)
129
alias(libs.plugins.google.services)
1310
alias(libs.plugins.google.dagger.hilt)
1411
alias(libs.plugins.kotlinx.kover)
@@ -592,32 +589,6 @@ if ((file('google-services.json').text) == (file('google-services.json-example')
592589
println("WARNING: You're using the example google-services.json file. Google login will fail.")
593590
}
594591

595-
tasks.register("violationCommentsToGitHub", ViolationCommentsToGitHubTask) {
596-
repositoryOwner = "wordpress-mobile"
597-
repositoryName = "WordPress-Android"
598-
pullRequestId = System.properties['GITHUB_PULLREQUESTID']
599-
username = System.properties['GITHUB_USERNAME']
600-
password = System.properties['GITHUB_PASSWORD']
601-
oAuth2Token = System.properties['GITHUB_OAUTH2TOKEN']
602-
gitHubUrl = "https://api.github.com/"
603-
createCommentWithAllSingleFileComments = false
604-
createSingleFileComments = true
605-
commentOnlyChangedContent = true
606-
minSeverity = SEVERITY.INFO //ERROR, INFO, WARN
607-
commentTemplate = """
608-
**Reporter**: {{violation.reporter}}{{#violation.rule}}\n
609-
**Rule**: {{violation.rule}}{{/violation.rule}}
610-
**Severity**: {{violation.severity}}
611-
**File**: {{violation.file}}:{{violation.startLine}}{{#violation.source}}
612-
**Source**: {{violation.source}}{{/violation.source}}
613-
{{violation.message}}
614-
"""
615-
violations = [
616-
["CHECKSTYLE", ".", ".*/build/.*/checkstyle/.*\\.xml\$", "CheckStyle"],
617-
["CHECKSTYLE", ".", ".*/build/.*/detekt/.*\\.xml\$", "Detekt"]
618-
]
619-
}
620-
621592
tasks.register("printVersionName") {
622593
doLast {
623594
println android.defaultConfig.versionName

WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt

+90-71
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,24 @@ import androidx.compose.foundation.layout.fillMaxSize
1818
import androidx.compose.foundation.layout.fillMaxWidth
1919
import androidx.compose.foundation.layout.padding
2020
import androidx.compose.foundation.lazy.LazyColumn
21-
import androidx.compose.material.Button
22-
import androidx.compose.material.ExperimentalMaterialApi
23-
import androidx.compose.material.MaterialTheme
24-
import androidx.compose.material.Scaffold
25-
import androidx.compose.material.Text
26-
import androidx.compose.material.pullrefresh.PullRefreshIndicator
27-
import androidx.compose.material.pullrefresh.pullRefresh
28-
import androidx.compose.material.pullrefresh.rememberPullRefreshState
21+
import androidx.compose.material.icons.Icons
22+
import androidx.compose.material.icons.automirrored.filled.ArrowBack
23+
import androidx.compose.material3.Button
2924
import androidx.compose.material3.CircularProgressIndicator
25+
import androidx.compose.material3.ExperimentalMaterial3Api
26+
import androidx.compose.material3.Icon
27+
import androidx.compose.material3.IconButton
28+
import androidx.compose.material3.MaterialTheme
29+
import androidx.compose.material3.PrimaryTabRow
30+
import androidx.compose.material3.Scaffold
3031
import androidx.compose.material3.Surface
3132
import androidx.compose.material3.Tab
32-
import androidx.compose.material3.TabRow
3333
import androidx.compose.material3.TabRowDefaults
34-
import androidx.compose.material3.TabRowDefaults.tabIndicatorOffset
34+
import androidx.compose.material3.Text
35+
import androidx.compose.material3.TopAppBar
36+
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
37+
import androidx.compose.material3.pulltorefresh.PullToRefreshDefaults
38+
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
3539
import androidx.compose.runtime.Composable
3640
import androidx.compose.runtime.LaunchedEffect
3741
import androidx.compose.runtime.getValue
@@ -41,6 +45,7 @@ import androidx.compose.runtime.setValue
4145
import androidx.compose.ui.Alignment
4246
import androidx.compose.ui.Modifier
4347
import androidx.compose.ui.res.stringResource
48+
import androidx.compose.ui.text.font.FontWeight
4449
import androidx.compose.ui.text.style.TextAlign
4550
import androidx.compose.ui.text.style.TextOverflow
4651
import androidx.compose.ui.unit.dp
@@ -51,9 +56,7 @@ import org.wordpress.android.R
5156
import org.wordpress.android.WordPress
5257
import org.wordpress.android.fluxc.model.SiteModel
5358
import org.wordpress.android.ui.WPWebViewActivity
54-
import org.wordpress.android.ui.compose.components.MainTopAppBar
55-
import org.wordpress.android.ui.compose.components.NavigationIcons
56-
import org.wordpress.android.ui.compose.theme.AppThemeM2
59+
import org.wordpress.android.ui.compose.theme.AppThemeM3
5760
import org.wordpress.android.ui.compose.utils.uiStringText
5861
import org.wordpress.android.util.extensions.getSerializableExtraCompat
5962
import javax.inject.Inject
@@ -114,8 +117,9 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient.
114117
siteMonitorParentViewModel.start(getSite())
115118
currentSelectItemId = getInitialTab()
116119
}
120+
117121
setContent {
118-
AppThemeM2 {
122+
AppThemeM3 {
119123
Surface(
120124
modifier = Modifier.fillMaxSize(),
121125
) {
@@ -145,64 +149,65 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient.
145149
}
146150
}
147151

148-
companion object {
149-
const val ARG_SITE_MONITOR_TYPE_KEY = "ARG_SITE_MONITOR_TYPE_KEY"
150-
const val SAVED_STATE_CONTAINER_KEY = "ContainerKey"
151-
const val SAVED_STATE_CURRENT_TAB_KEY = "CurrentTabKey"
152-
}
153-
152+
@OptIn(ExperimentalMaterial3Api::class)
154153
@Composable
155-
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
156-
fun SiteMonitorScreen(initialTab: Int, modifier: Modifier = Modifier) {
154+
fun SiteMonitorScreen(initialTab: Int) {
157155
Scaffold(
158156
topBar = {
159-
MainTopAppBar(
160-
title = stringResource(id = R.string.site_monitoring),
161-
navigationIcon = NavigationIcons.BackIcon,
162-
onNavigationIconClick = onBackPressedDispatcher::onBackPressed,
157+
TopAppBar(
158+
title = {
159+
Text(
160+
text = stringResource(id = R.string.site_monitoring)
161+
)
162+
},
163+
navigationIcon = {
164+
IconButton(onClick = onBackPressedDispatcher::onBackPressed) {
165+
Icon(
166+
Icons.AutoMirrored.Filled.ArrowBack,
167+
stringResource(R.string.back)
168+
)
169+
}
170+
},
163171
)
164172
},
165-
content = {
166-
SiteMonitorHeader(initialTab, modifier = modifier)
167-
}
168-
)
173+
) { contentPadding ->
174+
SiteMonitorHeader(initialTab, modifier = Modifier.padding(contentPadding))
175+
}
169176
}
170177

178+
@OptIn(ExperimentalMaterial3Api::class)
171179
@Composable
172180
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
173181
fun SiteMonitorHeader(initialTab: Int, modifier: Modifier = Modifier) {
174182
var tabIndex by remember { mutableIntStateOf(initialTab) }
175-
176183
val tabs = SiteMonitorTabItem.entries
177184

178185
LaunchedEffect(true) {
179186
siteMonitorUtils.trackTabLoaded(tabs[initialTab].siteMonitorType)
180187
}
181188

182189
Column(modifier = modifier.fillMaxWidth()) {
183-
TabRow(
190+
PrimaryTabRow(
184191
selectedTabIndex = tabIndex,
185-
containerColor = MaterialTheme.colors.surface,
186-
contentColor = MaterialTheme.colors.onSurface,
187-
indicator = { tabPositions ->
188-
// Customizing the indicator color and style
192+
containerColor = MaterialTheme.colorScheme.surface,
193+
contentColor = MaterialTheme.colorScheme.onSurface,
194+
indicator = {
189195
TabRowDefaults.SecondaryIndicator(
190-
Modifier.tabIndicatorOffset(tabPositions[tabIndex]),
191-
color = MaterialTheme.colors.onSurface,
192-
height = 2.0.dp
196+
color = MaterialTheme.colorScheme.onSurface,
197+
height = 2.0.dp,
198+
modifier = Modifier.tabIndicatorOffset(tabIndex)
193199
)
194200
}
195201
) {
196202
tabs.forEachIndexed { index, item ->
197203
Tab(
198204
text = {
199-
Column(horizontalAlignment = Alignment.CenterHorizontally) {
200-
Text(
201-
text = stringResource(item.title).uppercase(),
202-
maxLines = 1,
203-
overflow = TextOverflow.Ellipsis
204-
)
205-
}
205+
Text(
206+
text = stringResource(item.title).uppercase(),
207+
maxLines = 1,
208+
overflow = TextOverflow.Ellipsis,
209+
fontWeight = FontWeight.Normal
210+
)
206211
},
207212
selected = tabIndex == index,
208213
onClick = {
@@ -226,11 +231,14 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient.
226231
siteMonitorParentViewModel.getUiState(tabType)
227232
}
228233
when (uiState) {
229-
is SiteMonitorUiState.Preparing -> LoadingState(modifier)
234+
is SiteMonitorUiState.Preparing ->
235+
LoadingState(modifier)
236+
230237
is SiteMonitorUiState.Prepared, is SiteMonitorUiState.Loaded ->
231238
SiteMonitorWebViewContent(uiState, tabType, modifier)
232239

233-
is SiteMonitorUiState.Error -> SiteMonitorError(uiState as SiteMonitorUiState.Error, modifier)
240+
is SiteMonitorUiState.Error ->
241+
SiteMonitorError(uiState as SiteMonitorUiState.Error, modifier)
234242
}
235243
}
236244

@@ -241,7 +249,7 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient.
241249
modifier = modifier.fillMaxSize()
242250
) {
243251
CircularProgressIndicator(
244-
color = MaterialTheme.colors.onSurface
252+
color = MaterialTheme.colorScheme.onSurface
245253
)
246254
}
247255
}
@@ -256,14 +264,14 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient.
256264
.fillMaxWidth()
257265
.fillMaxHeight(),
258266
) {
259-
androidx.compose.material.Text(
267+
Text(
260268
text = uiStringText(uiString = error.title),
261-
style = androidx.compose.material.MaterialTheme.typography.h5,
269+
style = MaterialTheme.typography.headlineSmall,
262270
textAlign = TextAlign.Center
263271
)
264-
androidx.compose.material.Text(
272+
Text(
265273
text = uiStringText(uiString = error.description),
266-
style = androidx.compose.material.MaterialTheme.typography.body1,
274+
style = MaterialTheme.typography.bodyLarge,
267275
textAlign = TextAlign.Center,
268276
modifier = Modifier.padding(top = 8.dp)
269277
)
@@ -285,43 +293,54 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient.
285293
tabType: SiteMonitorType,
286294
modifier: Modifier = Modifier
287295
) {
288-
// retrieve the webview from the actvity
289296
val webView = when (tabType) {
290297
SiteMonitorType.METRICS -> metricsWebView
291298
SiteMonitorType.PHP_LOGS -> phpLogsWebView
292299
SiteMonitorType.WEB_SERVER_LOGS -> webServerLogsWebView
293300
}
294301

295-
when(uiState) {
302+
when (uiState) {
296303
is SiteMonitorUiState.Prepared -> {
297304
webView.postUrl(WPWebViewActivity.WPCOM_LOGIN_URL, uiState.model.addressToLoad.toByteArray())
298305
LoadingState()
299306
}
307+
300308
is SiteMonitorUiState.Loaded -> {
301309
SiteMonitorWebView(webView, tabType, modifier)
302310
}
311+
303312
else -> {}
304313
}
305314
}
306315

307-
@OptIn(ExperimentalMaterialApi::class)
316+
@OptIn(ExperimentalMaterial3Api::class)
308317
@Composable
309-
private fun SiteMonitorWebView(tabWebView: WebView, tabType: SiteMonitorType, modifier: Modifier = Modifier) {
318+
private fun SiteMonitorWebView(
319+
tabWebView: WebView,
320+
tabType: SiteMonitorType,
321+
modifier: Modifier = Modifier
322+
) {
310323
// the webview is retrieved from the activity, so we need to use a mutable variable
311324
// to assign to android view
312325
var webView = tabWebView
313326

314327
val refreshState = siteMonitorParentViewModel.getRefreshState(tabType)
328+
val pullToRefreshState = rememberPullToRefreshState()
315329

316-
val pullRefreshState = rememberPullRefreshState(
317-
refreshing = refreshState.value,
318-
onRefresh = { siteMonitorParentViewModel.refreshData(tabType) }
319-
)
320-
321-
Box(
330+
PullToRefreshBox(
322331
modifier = modifier
323-
.fillMaxSize()
324-
.pullRefresh(pullRefreshState)
332+
.fillMaxSize(),
333+
isRefreshing = refreshState.value,
334+
state = pullToRefreshState,
335+
onRefresh = { siteMonitorParentViewModel.refreshData(tabType) },
336+
indicator = {
337+
PullToRefreshDefaults.Indicator(
338+
state = pullToRefreshState,
339+
isRefreshing = refreshState.value,
340+
color = MaterialTheme.colorScheme.secondary,
341+
modifier = Modifier.align(Alignment.TopCenter),
342+
)
343+
}
325344
) {
326345
LazyColumn(modifier = Modifier.fillMaxHeight()) {
327346
item {
@@ -332,12 +351,6 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient.
332351
)
333352
}
334353
}
335-
PullRefreshIndicator(
336-
refreshing = refreshState.value,
337-
state = pullRefreshState,
338-
modifier = Modifier.align(Alignment.TopCenter),
339-
contentColor = MaterialTheme.colors.primaryVariant,
340-
)
341354
}
342355
}
343356

@@ -355,4 +368,10 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient.
355368
siteMonitorParentViewModel.onWebViewError(tabType)
356369
siteMonitorUtils.trackTabLoadingError(tabType)
357370
}
371+
372+
companion object {
373+
const val ARG_SITE_MONITOR_TYPE_KEY = "ARG_SITE_MONITOR_TYPE_KEY"
374+
const val SAVED_STATE_CONTAINER_KEY = "ContainerKey"
375+
const val SAVED_STATE_CURRENT_TAB_KEY = "CurrentTabKey"
376+
}
358377
}

WordPress/src/main/java/org/wordpress/android/ui/voicetocontent/MicToStopIcon.kt

+6-7
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import androidx.compose.foundation.isSystemInDarkTheme
1515
import androidx.compose.foundation.layout.Box
1616
import androidx.compose.foundation.layout.size
1717
import androidx.compose.foundation.shape.CircleShape
18-
import androidx.compose.material.ContentAlpha
19-
import androidx.compose.material.MaterialTheme
18+
import androidx.compose.material3.MaterialTheme
2019
import androidx.compose.runtime.Composable
2120
import androidx.compose.runtime.getValue
2221
import androidx.compose.runtime.rememberUpdatedState
@@ -30,7 +29,7 @@ import androidx.compose.ui.tooling.preview.Devices
3029
import androidx.compose.ui.tooling.preview.Preview
3130
import androidx.compose.ui.unit.dp
3231
import org.wordpress.android.R
33-
import org.wordpress.android.ui.compose.theme.AppThemeM2
32+
import org.wordpress.android.ui.compose.theme.AppThemeM3
3433

3534
@OptIn(ExperimentalAnimationApi::class)
3635
@Suppress("DEPRECATION")
@@ -41,14 +40,14 @@ fun MicToStopIcon(model: RecordingPanelUIModel, isRecording: Boolean) {
4140
val isLight = !isSystemInDarkTheme()
4241

4342
val circleColor by animateColorAsState(
44-
targetValue = if (!isEnabled) MaterialTheme.colors.onSurface.copy(alpha = 0.3f)
45-
else if (isMic) MaterialTheme.colors.primary
43+
targetValue = if (!isEnabled) MaterialTheme.colorScheme.onSurface.copy(alpha = 0.3f)
44+
else if (isMic) MaterialTheme.colorScheme.primary
4645
else if (isLight) Color.Black
4746
else Color.White, label = ""
4847
)
4948

5049
val iconColor by animateColorAsState(
51-
targetValue = if (!isEnabled) MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.disabled)
50+
targetValue = if (!isEnabled) MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f)
5251
else if (isMic) Color.White
5352
else if (isLight) Color.White
5453
else Color.Black, label = ""
@@ -115,7 +114,7 @@ fun MicToStopIcon(model: RecordingPanelUIModel, isRecording: Boolean) {
115114
@Preview(showBackground = true, device = Devices.PIXEL_4_XL, uiMode = Configuration.UI_MODE_NIGHT_YES)
116115
@Composable
117116
fun ExistingLayoutPreview() {
118-
AppThemeM2 {
117+
AppThemeM3 {
119118
MicToStopIcon(
120119
RecordingPanelUIModel(
121120
isEligibleForFeature = true,

0 commit comments

Comments
 (0)