-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Custom server no network dialog #WPB-11627 #3543
Open
m-zagorski
wants to merge
2
commits into
develop
Choose a base branch
from
feat/custom-server-no-network-dialog
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+173
−30
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
app/src/main/kotlin/com/wire/android/ui/common/dialogs/CustomServerNoNetworkDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.android.ui.common.dialogs | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.res.stringResource | ||
import com.wire.android.R | ||
import com.wire.android.ui.common.WireDialog | ||
import com.wire.android.ui.common.WireDialogButtonProperties | ||
import com.wire.android.ui.common.WireDialogButtonType | ||
import com.wire.android.ui.common.button.WireButtonState | ||
import com.wire.android.ui.theme.WireTheme | ||
import com.wire.android.util.ui.PreviewMultipleThemes | ||
|
||
@Composable | ||
internal fun CustomServerNoNetworkDialog( | ||
onTryAgain: () -> Unit, | ||
onDismiss: () -> Unit | ||
) { | ||
WireDialog( | ||
title = stringResource(R.string.custom_backend_error_title), | ||
text = stringResource(R.string.custom_backend_error_no_internet_connection_body), | ||
onDismiss = onDismiss, | ||
buttonsHorizontalAlignment = false, | ||
optionButton1Properties = WireDialogButtonProperties( | ||
onClick = { | ||
onTryAgain() | ||
onDismiss() | ||
}, | ||
text = stringResource(id = R.string.custom_backend_error_no_internet_connection_try_again), | ||
type = WireDialogButtonType.Primary, | ||
state = WireButtonState.Default | ||
), | ||
optionButton2Properties = WireDialogButtonProperties( | ||
onClick = onDismiss, | ||
text = stringResource(id = R.string.label_cancel), | ||
type = WireDialogButtonType.Secondary, | ||
state = WireButtonState.Default | ||
) | ||
) | ||
} | ||
|
||
data class CustomServerNoNetworkDialogState(val customServerUrl: String) : CustomServerDialogState() | ||
|
||
@PreviewMultipleThemes | ||
@Composable | ||
fun PreviewCustomServerNoNetworkDialog() = WireTheme { | ||
CustomServerNoNetworkDialog( | ||
onTryAgain = {}, | ||
onDismiss = {} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is over kill you don't need to check the network state, we can do the request to get the json with custom server meta data and check the error returned it is a network error with something list Io Exception then display this error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is unfortunately not doable:
When we dont have internet connection and the config is valid we're getting:
GenericError(cause=java.net.UnknownHostException: Unable to resolve host "nginz-https.bund-next-column-offline-android.wire.link": No address associated with hostname)
When we have internet connection and the config is invalid we're getting:
GenericError(cause=java.net.UnknownHostException: Unable to resolve host "nginz-https.unreachable.wire.link": No address associated with hostname)
So we're unable to know if the config was wrong or not with the exception we're getting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could slightly change the copy and use this dialog in both cases?
Like: "You don't seem to be connected to the Internet or the config link you used is broken. Please check your Internet connection and try again." 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well yeah we could have only one for malformed json and no internet connection :D that'd solve the issue too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like i am missing something?
this will never happen how was the app able to know that the constant is valid if we are not able to read the content, since there is no internet?