mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-18 19:19:33 +01:00
improvements
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
61d0e323b3
commit
0b6ed3bcc1
@ -23,6 +23,7 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.colorResource
|
||||
@ -88,6 +89,7 @@ class DiagnoseActivity : BaseActivity() {
|
||||
)[DiagnoseViewModel::class.java]
|
||||
|
||||
val colorScheme = viewThemeUtils.getColorScheme(this)
|
||||
isGooglePlayServicesAvailable = ClosedInterfaceImpl().isGooglePlayServicesAvailable
|
||||
|
||||
setContent {
|
||||
val backgroundColor = colorResource(id = R.color.bg_default)
|
||||
@ -115,6 +117,7 @@ class DiagnoseActivity : BaseActivity() {
|
||||
)
|
||||
},
|
||||
content = {
|
||||
val viewState = diagnoseViewModel.notificationViewState.collectAsState().value
|
||||
Column(
|
||||
Modifier
|
||||
.padding(it)
|
||||
@ -125,9 +128,10 @@ class DiagnoseActivity : BaseActivity() {
|
||||
diagnoseDataState,
|
||||
isLoading = diagnoseViewModel.isLoading.value,
|
||||
showDialog = diagnoseViewModel.showDialog.value,
|
||||
message = diagnoseViewModel.notificationMessage.value,
|
||||
viewState = viewState,
|
||||
onTestPushClick = { diagnoseViewModel.fetchTestPushResult() },
|
||||
onDismissDialog = { diagnoseViewModel.dismissDialog() }
|
||||
onDismissDialog = { diagnoseViewModel.dismissDialog() },
|
||||
isGooglePlayServicesAvailable = isGooglePlayServicesAvailable
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -141,8 +145,6 @@ class DiagnoseActivity : BaseActivity() {
|
||||
super.onResume()
|
||||
supportActionBar?.show()
|
||||
|
||||
isGooglePlayServicesAvailable = ClosedInterfaceImpl().isGooglePlayServicesAvailable
|
||||
|
||||
diagnoseData.clear()
|
||||
setupMetaValues()
|
||||
setupPhoneValues()
|
||||
|
@ -56,9 +56,10 @@ fun DiagnoseContentComposable(
|
||||
data: State<List<DiagnoseActivity.DiagnoseElement>>,
|
||||
isLoading: Boolean,
|
||||
showDialog: Boolean,
|
||||
message: String,
|
||||
viewState: NotificationUiState,
|
||||
onTestPushClick: () -> Unit,
|
||||
onDismissDialog: () -> Unit
|
||||
onDismissDialog: () -> Unit,
|
||||
isGooglePlayServicesAvailable: Boolean
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
Column(
|
||||
@ -95,8 +96,10 @@ fun DiagnoseContentComposable(
|
||||
}
|
||||
}
|
||||
}
|
||||
ShowTestPushButton(onTestPushClick)
|
||||
ShowNotificationData(isLoading, showDialog, context, message, onDismissDialog)
|
||||
if (isGooglePlayServicesAvailable) {
|
||||
ShowTestPushButton(onTestPushClick)
|
||||
}
|
||||
ShowNotificationData(isLoading, showDialog, context, viewState, onDismissDialog)
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,9 +167,20 @@ fun ShowNotificationData(
|
||||
isLoading: Boolean,
|
||||
showDialog: Boolean,
|
||||
context: Context,
|
||||
message: String,
|
||||
viewState: NotificationUiState,
|
||||
onDismissDialog: () -> Unit
|
||||
) {
|
||||
val message = when (viewState) {
|
||||
is NotificationUiState.Success -> viewState.testNotification ?: context.getString(
|
||||
R.string.nc_push_notification_fetch_error
|
||||
)
|
||||
is NotificationUiState.Error -> String.format(
|
||||
context.getString(R.string.nc_push_notification_error),
|
||||
viewState.message
|
||||
)
|
||||
else -> context.getString(R.string.nc_common_error_sorry)
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
LoadingIndicator()
|
||||
}
|
||||
@ -198,10 +212,12 @@ fun ShowNotificationData(
|
||||
.verticalScroll(rememberScrollState())
|
||||
) {
|
||||
Column(modifier = Modifier.padding(top = 12.dp)) {
|
||||
Text(
|
||||
text = stringResource(R.string.nc_push_notification_message),
|
||||
color = colorResource(R.color.colorPrimary)
|
||||
)
|
||||
if (viewState is NotificationUiState.Success) {
|
||||
Text(
|
||||
text = stringResource(R.string.nc_push_notification_message),
|
||||
color = colorResource(R.color.colorPrimary)
|
||||
)
|
||||
}
|
||||
Text(
|
||||
modifier = Modifier.padding(top = 12.dp),
|
||||
text = message
|
||||
@ -231,8 +247,9 @@ fun DiagnoseContentPreview() {
|
||||
state,
|
||||
false,
|
||||
true,
|
||||
"Testing Push Messages",
|
||||
NotificationUiState.Success("Test notification successful"),
|
||||
{},
|
||||
{}
|
||||
{},
|
||||
true
|
||||
)
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import com.nextcloud.talk.api.NcApiCoroutines
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -26,8 +28,8 @@ class DiagnoseViewModel @Inject constructor(
|
||||
val currentUser: User = _currentUser
|
||||
val credentials = ApiUtils.getCredentials(_currentUser.username, _currentUser.token) ?: ""
|
||||
|
||||
private val _notificationMessage = mutableStateOf("")
|
||||
val notificationMessage = _notificationMessage
|
||||
private val _notificationViewState = MutableStateFlow<NotificationUiState>(NotificationUiState.None)
|
||||
val notificationViewState: StateFlow<NotificationUiState> = _notificationViewState
|
||||
|
||||
private val _isLoading = mutableStateOf(false)
|
||||
val isLoading = _isLoading
|
||||
@ -44,9 +46,10 @@ class DiagnoseViewModel @Inject constructor(
|
||||
ApiUtils
|
||||
.getUrlForTestPushNotifications(_currentUser.baseUrl ?: "")
|
||||
)
|
||||
_notificationMessage.value = response.ocs?.data?.message ?: "Error while fetching test push message"
|
||||
val notificationMessage = response.ocs?.data?.message
|
||||
_notificationViewState.value = NotificationUiState.Success(notificationMessage)
|
||||
} catch (e: Exception) {
|
||||
_notificationMessage.value = "Exception: ${e.localizedMessage}"
|
||||
_notificationViewState.value = NotificationUiState.Error(e.message ?: "")
|
||||
} finally {
|
||||
_isLoading.value = false
|
||||
_showDialog.value = true
|
||||
@ -58,3 +61,9 @@ class DiagnoseViewModel @Inject constructor(
|
||||
_showDialog.value = false
|
||||
}
|
||||
}
|
||||
|
||||
sealed class NotificationUiState {
|
||||
data object None : NotificationUiState()
|
||||
data class Success(val testNotification: String?) : NotificationUiState()
|
||||
data class Error(val message: String) : NotificationUiState()
|
||||
}
|
||||
|
@ -67,6 +67,8 @@ How to translate with transifex:
|
||||
<string name="nc_display_name_not_fetched">Display name couldn\'t be fetched, aborting</string>
|
||||
<string name="nc_nextcloud_talk_app_not_installed">%1$s not available (not installed or restricted by admin)</string>
|
||||
<string name="nc_display_name_not_stored">Could not store display name, aborting</string>
|
||||
<string name="nc_push_notification_error"> Sorry something went wrong, error is %1$s</string>
|
||||
<string name="nc_push_notification_fetch_error">Sorry something went wrong, cannot fetch test push message</string>
|
||||
|
||||
<string name="nc_search">Search</string>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user