mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
minor fixes - show meaningful message + add previews
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
ce385556a3
commit
c57bd90ee5
@ -121,7 +121,14 @@ class DiagnoseActivity : BaseActivity() {
|
|||||||
.background(backgroundColor)
|
.background(backgroundColor)
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
DiagnoseContentComposable(diagnoseDataState, diagnoseViewModel)
|
DiagnoseContentComposable(
|
||||||
|
diagnoseDataState,
|
||||||
|
isLoading = diagnoseViewModel.isLoading.value,
|
||||||
|
showDialog = diagnoseViewModel.showDialog.value,
|
||||||
|
message = diagnoseViewModel.notificationMessage.value,
|
||||||
|
onTestPushClick = { diagnoseViewModel.fetchTestPushResult() },
|
||||||
|
onDismissDialog = { diagnoseViewModel.dismissDialog() }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -141,7 +148,6 @@ class DiagnoseActivity : BaseActivity() {
|
|||||||
setupPhoneValues()
|
setupPhoneValues()
|
||||||
setupAppValues()
|
setupAppValues()
|
||||||
setupAccountValues()
|
setupAccountValues()
|
||||||
testPushNotification()
|
|
||||||
|
|
||||||
diagnoseDataState.value = diagnoseData.toList()
|
diagnoseDataState.value = diagnoseData.toList()
|
||||||
}
|
}
|
||||||
@ -196,10 +202,6 @@ class DiagnoseActivity : BaseActivity() {
|
|||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun testPushNotification() {
|
|
||||||
addHeadline(context.resources.getString(R.string.nc_test_push_button))
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupMetaValues() {
|
private fun setupMetaValues() {
|
||||||
addHeadline(context.resources.getString(R.string.nc_diagnose_meta_category_title))
|
addHeadline(context.resources.getString(R.string.nc_diagnose_meta_category_title))
|
||||||
addDiagnosisEntry(
|
addDiagnosisEntry(
|
||||||
|
@ -33,6 +33,8 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
@ -42,21 +44,22 @@ import androidx.compose.ui.res.dimensionResource
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
|
|
||||||
@Suppress("LongMethod")
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DiagnoseContentComposable(
|
fun DiagnoseContentComposable(
|
||||||
data: State<List<DiagnoseActivity.DiagnoseElement>>,
|
data: State<List<DiagnoseActivity.DiagnoseElement>>,
|
||||||
diagnoseViewModel: DiagnoseViewModel
|
isLoading: Boolean,
|
||||||
|
showDialog: Boolean,
|
||||||
|
message: String,
|
||||||
|
onTestPushClick: () -> Unit,
|
||||||
|
onDismissDialog: () -> Unit
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val message = diagnoseViewModel.notificationMessage
|
|
||||||
val isLoading = diagnoseViewModel.isLoading
|
|
||||||
val showDialog = diagnoseViewModel.showDialog
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
@ -66,39 +69,15 @@ fun DiagnoseContentComposable(
|
|||||||
data.value.forEach { element ->
|
data.value.forEach { element ->
|
||||||
when (element) {
|
when (element) {
|
||||||
is DiagnoseActivity.DiagnoseElement.DiagnoseHeadline -> {
|
is DiagnoseActivity.DiagnoseElement.DiagnoseHeadline -> {
|
||||||
if (element.headline == "Test push notifications") {
|
Text(
|
||||||
Button(
|
modifier = Modifier.fillMaxWidth().padding(vertical = 16.dp),
|
||||||
modifier = Modifier
|
text = element.headline,
|
||||||
.wrapContentSize()
|
color = MaterialTheme.colorScheme.primary,
|
||||||
.padding(vertical = 8.dp),
|
fontSize = LocalDensity.current.run {
|
||||||
onClick = {
|
dimensionResource(R.dimen.headline_text_size).toPx().toSp()
|
||||||
diagnoseViewModel.fetchTestPushResult()
|
},
|
||||||
}
|
fontWeight = FontWeight.Bold
|
||||||
) {
|
)
|
||||||
Text(
|
|
||||||
text = element.headline,
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(vertical = 8.dp),
|
|
||||||
color = colorResource(R.color.high_emphasis_text),
|
|
||||||
fontSize = LocalDensity.current.run {
|
|
||||||
dimensionResource(R.dimen.headline_text_size).toPx().toSp()
|
|
||||||
},
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
textAlign = TextAlign.Center
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Text(
|
|
||||||
modifier = Modifier.fillMaxWidth().padding(vertical = 16.dp),
|
|
||||||
text = element.headline,
|
|
||||||
color = MaterialTheme.colorScheme.primary,
|
|
||||||
fontSize = LocalDensity.current.run {
|
|
||||||
dimensionResource(R.dimen.headline_text_size).toPx().toSp()
|
|
||||||
},
|
|
||||||
fontWeight = FontWeight.Bold
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is DiagnoseActivity.DiagnoseElement.DiagnoseEntry -> {
|
is DiagnoseActivity.DiagnoseElement.DiagnoseEntry -> {
|
||||||
@ -115,30 +94,84 @@ fun DiagnoseContentComposable(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ShowNotificationData(isLoading.value, showDialog.value, context, message.value, diagnoseViewModel)
|
ShowTestPushButton(onTestPushClick)
|
||||||
|
ShowNotificationData(isLoading, showDialog, context, message, onDismissDialog)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ShowTestPushButton(onTestPushClick: () -> Unit) {
|
||||||
|
Button(
|
||||||
|
modifier = Modifier
|
||||||
|
.wrapContentSize()
|
||||||
|
.padding(vertical = 8.dp),
|
||||||
|
onClick = {
|
||||||
|
onTestPushClick()
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.nc_test_push_button),
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(vertical = 8.dp),
|
||||||
|
fontSize = LocalDensity.current.run {
|
||||||
|
dimensionResource(R.dimen.headline_text_size).toPx().toSp()
|
||||||
|
},
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ShowOptions(onDismissDialog: () -> Unit, message: String, context: Context) {
|
||||||
|
Row(
|
||||||
|
horizontalArrangement = Arrangement.SpaceEvenly,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
TextButton(onClick = { onDismissDialog() }) {
|
||||||
|
Text(text = stringResource(R.string.nc_cancel))
|
||||||
|
}
|
||||||
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
|
TextButton(onClick = {
|
||||||
|
val clipboard =
|
||||||
|
context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
val clip = ClipData.newPlainText("Push Message", message)
|
||||||
|
clipboard.setPrimaryClip(clip)
|
||||||
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2) {
|
||||||
|
Toast.makeText(context, R.string.message_copied, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
onDismissDialog()
|
||||||
|
}) {
|
||||||
|
Text(text = stringResource(R.string.nc_common_copy))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun LoadingIndicator() {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
CircularProgressIndicator()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Suppress("LongMethod")
|
|
||||||
fun ShowNotificationData(
|
fun ShowNotificationData(
|
||||||
isLoading: Boolean,
|
isLoading: Boolean,
|
||||||
showDialog: Boolean,
|
showDialog: Boolean,
|
||||||
context: Context,
|
context: Context,
|
||||||
message: String,
|
message: String,
|
||||||
diagnoseViewModel: DiagnoseViewModel
|
onDismissDialog: () -> Unit
|
||||||
) {
|
) {
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
Box(
|
LoadingIndicator()
|
||||||
modifier = Modifier.fillMaxSize(),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
CircularProgressIndicator()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (showDialog) {
|
if (showDialog) {
|
||||||
Dialog(
|
Dialog(
|
||||||
onDismissRequest = { diagnoseViewModel.dismissDialog() },
|
onDismissRequest = { onDismissDialog() },
|
||||||
properties = DialogProperties(
|
properties = DialogProperties(
|
||||||
dismissOnClickOutside = true,
|
dismissOnClickOutside = true,
|
||||||
usePlatformDefaultWidth = false
|
usePlatformDefaultWidth = false
|
||||||
@ -157,42 +190,48 @@ fun ShowNotificationData(
|
|||||||
style = MaterialTheme.typography
|
style = MaterialTheme.typography
|
||||||
.titleMedium
|
.titleMedium
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(12.dp))
|
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.weight(1f, fill = false)
|
.weight(1f, fill = false)
|
||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
) {
|
) {
|
||||||
Text(
|
Column(modifier = Modifier.padding(top = 12.dp)) {
|
||||||
modifier = Modifier.padding(top = 8.dp),
|
Text(
|
||||||
text = message
|
text = stringResource(R.string.nc_push_notification_message),
|
||||||
)
|
color = colorResource(R.color.colorPrimary)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(top = 12.dp),
|
||||||
|
text = message
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
Row(
|
ShowOptions(onDismissDialog, message, context)
|
||||||
horizontalArrangement = Arrangement.SpaceEvenly,
|
|
||||||
modifier = Modifier.fillMaxWidth()
|
|
||||||
) {
|
|
||||||
TextButton(onClick = { diagnoseViewModel.dismissDialog() }) {
|
|
||||||
Text(text = stringResource(R.string.nc_cancel))
|
|
||||||
}
|
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
|
||||||
TextButton(onClick = {
|
|
||||||
val clipboard =
|
|
||||||
context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
|
||||||
val clip = ClipData.newPlainText("Push Message", message)
|
|
||||||
clipboard.setPrimaryClip(clip)
|
|
||||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2) {
|
|
||||||
Toast.makeText(context, R.string.message_copied, Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
diagnoseViewModel.dismissDialog()
|
|
||||||
}) {
|
|
||||||
Text(text = stringResource(R.string.nc_common_copy))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Preview(showBackground = true)
|
||||||
|
@Composable
|
||||||
|
fun DiagnoseContentPreview() {
|
||||||
|
val state = remember {
|
||||||
|
mutableStateOf(
|
||||||
|
listOf(
|
||||||
|
DiagnoseActivity.DiagnoseElement.DiagnoseHeadline("Headline"),
|
||||||
|
DiagnoseActivity.DiagnoseElement.DiagnoseEntry("Key", "Value")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
DiagnoseContentComposable(
|
||||||
|
state,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
"Testing Push Messages",
|
||||||
|
{},
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@ -231,6 +231,8 @@ How to translate with transifex:
|
|||||||
<string name="nc_test_push_button">"Test push notifications</string>
|
<string name="nc_test_push_button">"Test push notifications</string>
|
||||||
<string name="nc_test_results">Test results</string>
|
<string name="nc_test_results">Test results</string>
|
||||||
<string name="message_copied">Message copied</string>
|
<string name="message_copied">Message copied</string>
|
||||||
|
<string name="nc_push_notification_message">Push notification is sent successfully. You should now receive
|
||||||
|
a notification on this device with the title \'Testing push notifications\' </string>
|
||||||
|
|
||||||
<!-- Conversation menu -->
|
<!-- Conversation menu -->
|
||||||
<string name="nc_leave">Leave conversation</string>
|
<string name="nc_leave">Leave conversation</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user