mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 03:29:28 +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.foundation.layout.padding
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.colorResource
|
import androidx.compose.ui.res.colorResource
|
||||||
@ -88,6 +89,7 @@ class DiagnoseActivity : BaseActivity() {
|
|||||||
)[DiagnoseViewModel::class.java]
|
)[DiagnoseViewModel::class.java]
|
||||||
|
|
||||||
val colorScheme = viewThemeUtils.getColorScheme(this)
|
val colorScheme = viewThemeUtils.getColorScheme(this)
|
||||||
|
isGooglePlayServicesAvailable = ClosedInterfaceImpl().isGooglePlayServicesAvailable
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
val backgroundColor = colorResource(id = R.color.bg_default)
|
val backgroundColor = colorResource(id = R.color.bg_default)
|
||||||
@ -115,6 +117,7 @@ class DiagnoseActivity : BaseActivity() {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
content = {
|
content = {
|
||||||
|
val viewState = diagnoseViewModel.notificationViewState.collectAsState().value
|
||||||
Column(
|
Column(
|
||||||
Modifier
|
Modifier
|
||||||
.padding(it)
|
.padding(it)
|
||||||
@ -125,9 +128,10 @@ class DiagnoseActivity : BaseActivity() {
|
|||||||
diagnoseDataState,
|
diagnoseDataState,
|
||||||
isLoading = diagnoseViewModel.isLoading.value,
|
isLoading = diagnoseViewModel.isLoading.value,
|
||||||
showDialog = diagnoseViewModel.showDialog.value,
|
showDialog = diagnoseViewModel.showDialog.value,
|
||||||
message = diagnoseViewModel.notificationMessage.value,
|
viewState = viewState,
|
||||||
onTestPushClick = { diagnoseViewModel.fetchTestPushResult() },
|
onTestPushClick = { diagnoseViewModel.fetchTestPushResult() },
|
||||||
onDismissDialog = { diagnoseViewModel.dismissDialog() }
|
onDismissDialog = { diagnoseViewModel.dismissDialog() },
|
||||||
|
isGooglePlayServicesAvailable = isGooglePlayServicesAvailable
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,8 +145,6 @@ class DiagnoseActivity : BaseActivity() {
|
|||||||
super.onResume()
|
super.onResume()
|
||||||
supportActionBar?.show()
|
supportActionBar?.show()
|
||||||
|
|
||||||
isGooglePlayServicesAvailable = ClosedInterfaceImpl().isGooglePlayServicesAvailable
|
|
||||||
|
|
||||||
diagnoseData.clear()
|
diagnoseData.clear()
|
||||||
setupMetaValues()
|
setupMetaValues()
|
||||||
setupPhoneValues()
|
setupPhoneValues()
|
||||||
|
@ -56,9 +56,10 @@ fun DiagnoseContentComposable(
|
|||||||
data: State<List<DiagnoseActivity.DiagnoseElement>>,
|
data: State<List<DiagnoseActivity.DiagnoseElement>>,
|
||||||
isLoading: Boolean,
|
isLoading: Boolean,
|
||||||
showDialog: Boolean,
|
showDialog: Boolean,
|
||||||
message: String,
|
viewState: NotificationUiState,
|
||||||
onTestPushClick: () -> Unit,
|
onTestPushClick: () -> Unit,
|
||||||
onDismissDialog: () -> Unit
|
onDismissDialog: () -> Unit,
|
||||||
|
isGooglePlayServicesAvailable: Boolean
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
Column(
|
Column(
|
||||||
@ -95,8 +96,10 @@ fun DiagnoseContentComposable(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ShowTestPushButton(onTestPushClick)
|
if (isGooglePlayServicesAvailable) {
|
||||||
ShowNotificationData(isLoading, showDialog, context, message, onDismissDialog)
|
ShowTestPushButton(onTestPushClick)
|
||||||
|
}
|
||||||
|
ShowNotificationData(isLoading, showDialog, context, viewState, onDismissDialog)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,9 +167,20 @@ fun ShowNotificationData(
|
|||||||
isLoading: Boolean,
|
isLoading: Boolean,
|
||||||
showDialog: Boolean,
|
showDialog: Boolean,
|
||||||
context: Context,
|
context: Context,
|
||||||
message: String,
|
viewState: NotificationUiState,
|
||||||
onDismissDialog: () -> Unit
|
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) {
|
if (isLoading) {
|
||||||
LoadingIndicator()
|
LoadingIndicator()
|
||||||
}
|
}
|
||||||
@ -198,10 +212,12 @@ fun ShowNotificationData(
|
|||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
) {
|
) {
|
||||||
Column(modifier = Modifier.padding(top = 12.dp)) {
|
Column(modifier = Modifier.padding(top = 12.dp)) {
|
||||||
Text(
|
if (viewState is NotificationUiState.Success) {
|
||||||
text = stringResource(R.string.nc_push_notification_message),
|
Text(
|
||||||
color = colorResource(R.color.colorPrimary)
|
text = stringResource(R.string.nc_push_notification_message),
|
||||||
)
|
color = colorResource(R.color.colorPrimary)
|
||||||
|
)
|
||||||
|
}
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.padding(top = 12.dp),
|
modifier = Modifier.padding(top = 12.dp),
|
||||||
text = message
|
text = message
|
||||||
@ -231,8 +247,9 @@ fun DiagnoseContentPreview() {
|
|||||||
state,
|
state,
|
||||||
false,
|
false,
|
||||||
true,
|
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.utils.ApiUtils
|
||||||
import com.nextcloud.talk.data.user.model.User
|
import com.nextcloud.talk.data.user.model.User
|
||||||
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -26,8 +28,8 @@ class DiagnoseViewModel @Inject constructor(
|
|||||||
val currentUser: User = _currentUser
|
val currentUser: User = _currentUser
|
||||||
val credentials = ApiUtils.getCredentials(_currentUser.username, _currentUser.token) ?: ""
|
val credentials = ApiUtils.getCredentials(_currentUser.username, _currentUser.token) ?: ""
|
||||||
|
|
||||||
private val _notificationMessage = mutableStateOf("")
|
private val _notificationViewState = MutableStateFlow<NotificationUiState>(NotificationUiState.None)
|
||||||
val notificationMessage = _notificationMessage
|
val notificationViewState: StateFlow<NotificationUiState> = _notificationViewState
|
||||||
|
|
||||||
private val _isLoading = mutableStateOf(false)
|
private val _isLoading = mutableStateOf(false)
|
||||||
val isLoading = _isLoading
|
val isLoading = _isLoading
|
||||||
@ -44,9 +46,10 @@ class DiagnoseViewModel @Inject constructor(
|
|||||||
ApiUtils
|
ApiUtils
|
||||||
.getUrlForTestPushNotifications(_currentUser.baseUrl ?: "")
|
.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) {
|
} catch (e: Exception) {
|
||||||
_notificationMessage.value = "Exception: ${e.localizedMessage}"
|
_notificationViewState.value = NotificationUiState.Error(e.message ?: "")
|
||||||
} finally {
|
} finally {
|
||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
_showDialog.value = true
|
_showDialog.value = true
|
||||||
@ -58,3 +61,9 @@ class DiagnoseViewModel @Inject constructor(
|
|||||||
_showDialog.value = false
|
_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_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_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_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>
|
<string name="nc_search">Search</string>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user