-
-
Notifications
You must be signed in to change notification settings - Fork 509
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
refactor(ui): Use AutoMirrored icons and migrated deprecated components #1631
Closed
Closed
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b0c7174
refactor(ui): Use AutoMirrored icons
BobbyESP 38be352
refactor(ui): Migrated deprecated components
BobbyESP 3a9c070
Merge branch 'main' into update_icons
BobbyESP cea4778
Merge branch 'main' into update_icons
BobbyESP 37cc4c2
refactor(ui): modified link annotation in auto-update not available d…
BobbyESP 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
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
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package com.junkfood.seal.ui.page.settings.about | ||
|
||
import android.util.Log | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.text.ClickableText | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.outlined.ContactSupport | ||
import androidx.compose.material.icons.outlined.AutoAwesome | ||
import androidx.compose.material.icons.outlined.ContactSupport | ||
import androidx.compose.material.icons.outlined.Description | ||
import androidx.compose.material.icons.outlined.Info | ||
import androidx.compose.material.icons.outlined.NewReleases | ||
|
@@ -38,11 +38,13 @@ import androidx.compose.ui.res.painterResource | |
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.AnnotatedString | ||
import androidx.compose.ui.text.ExperimentalTextApi | ||
import androidx.compose.ui.text.LinkAnnotation | ||
import androidx.compose.ui.text.SpanStyle | ||
import androidx.compose.ui.text.UrlAnnotation | ||
import androidx.compose.ui.text.TextLinkStyles | ||
import androidx.compose.ui.text.buildAnnotatedString | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.text.style.TextDecoration | ||
import androidx.compose.ui.text.withLink | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.junkfood.seal.App | ||
import com.junkfood.seal.App.Companion.packageInfo | ||
|
@@ -131,7 +133,7 @@ fun AboutPage( | |
PreferenceItem( | ||
title = stringResource(R.string.github_issue), | ||
description = stringResource(R.string.github_issue_desc), | ||
icon = Icons.Outlined.ContactSupport, | ||
icon = Icons.AutoMirrored.Outlined.ContactSupport, | ||
) { openUrl(githubIssueUrl) } | ||
} | ||
item { | ||
|
@@ -199,7 +201,6 @@ fun AboutPage( | |
}) | ||
} | ||
|
||
@OptIn(ExperimentalTextApi::class) | ||
@Composable | ||
@Preview | ||
fun AutoUpdateUnavailableDialog(onDismissRequest: () -> Unit = {}) { | ||
|
@@ -212,22 +213,27 @@ fun AutoUpdateUnavailableDialog(onDismissRequest: () -> Unit = {}) { | |
) | ||
|
||
val annotatedString = buildAnnotatedString { | ||
append(text) | ||
append(text.substring(0, text.indexOf(hyperLinkText))) | ||
val startIndex = text.indexOf(hyperLinkText) | ||
val endIndex = startIndex + hyperLinkText.length | ||
addUrlAnnotation( | ||
UrlAnnotation("https://github.com/JunkFood02/Seal/releases/latest"), | ||
start = startIndex, | ||
end = endIndex | ||
) | ||
addStyle( | ||
SpanStyle( | ||
color = MaterialTheme.colorScheme.tertiary, | ||
textDecoration = TextDecoration.Underline, | ||
), start = startIndex, | ||
end = endIndex | ||
) | ||
|
||
withLink( | ||
LinkAnnotation.Clickable( | ||
tag = "Link to the latest app release in GitHub", | ||
styles = TextLinkStyles( | ||
SpanStyle( | ||
color = MaterialTheme.colorScheme.tertiary, | ||
textDecoration = TextDecoration.Underline, | ||
) | ||
), | ||
linkInteractionListener = { _ -> | ||
uriHandler.openUri("https://github.com/JunkFood02/Seal/releases/latest") | ||
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress) | ||
} | ||
) | ||
) { | ||
append(text.substring(startIndex, endIndex)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
} | ||
} | ||
AlertDialog( | ||
onDismissRequest = onDismissRequest, | ||
|
@@ -244,16 +250,11 @@ fun AutoUpdateUnavailableDialog(onDismissRequest: () -> Unit = {}) { | |
) | ||
}, | ||
text = { | ||
ClickableText( | ||
Text( | ||
text = annotatedString, | ||
onClick = { index -> | ||
annotatedString.getUrlAnnotations(index, index).firstOrNull()?.let { | ||
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress) | ||
uriHandler.openUri(it.item.url) | ||
} | ||
}, | ||
style = MaterialTheme.typography.bodyMedium.copy(MaterialTheme.colorScheme.onSurfaceVariant) | ||
) | ||
}) | ||
} | ||
) | ||
} | ||
|
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.
what if the
hyperLinkText
is not at the end of thetext
?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.
Since the
hyperLinkText
is being a parameter for another string there is no other way than doing a substring for putting the style and click listening in the new implementation.In this case I believe that the current implementation is well done. Modifying the string resource is not viable. Any ideas are welcome.
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 the only thing I think that might be okay, but tell me some other options If you are not comfortable with the changes and I'll do them. Thanks!
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.
not really understand what you meant on this:
addLink()
which is a drop-in replacement of theaddUrlAnnotation
herewithLink()
, you should append the rest of thetext
which is after thehyperLinkText
(if exist)