Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cwa App Android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felix Foertsch
Cwa App Android
Commits
833b7a80
Unverified
Commit
833b7a80
authored
4 years ago
by
harambasicluka
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
added clickable links to DialogHelper.kt (#646)
Co-authored-by:
marcmuschko
<
marc.muschko@sap.com
>
parent
30fb65ec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/DialogHelper.kt
+26
-1
26 additions, 1 deletion
...p/src/main/java/de/rki/coronawarnapp/util/DialogHelper.kt
with
26 additions
and
1 deletion
Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/DialogHelper.kt
+
26
−
1
View file @
833b7a80
package
de.rki.coronawarnapp.util
package
de.rki.coronawarnapp.util
import
android.app.Activity
import
android.app.Activity
import
android.app.Activity.RESULT_OK
import
android.text.SpannableString
import
android.text.method.LinkMovementMethod
import
android.text.util.Linkify
import
android.widget.TextView
import
androidx.appcompat.app.AlertDialog
import
androidx.appcompat.app.AlertDialog
import
de.rki.coronawarnapp.R
object
DialogHelper
{
object
DialogHelper
{
...
@@ -59,11 +65,12 @@ object DialogHelper {
...
@@ -59,11 +65,12 @@ object DialogHelper {
fun
showDialog
(
fun
showDialog
(
dialogInstance
:
DialogInstance
dialogInstance
:
DialogInstance
):
AlertDialog
{
):
AlertDialog
{
val
message
=
getMessage
(
dialogInstance
.
activity
,
dialogInstance
.
message
)
val
alertDialog
:
AlertDialog
=
dialogInstance
.
activity
.
let
{
val
alertDialog
:
AlertDialog
=
dialogInstance
.
activity
.
let
{
val
builder
=
AlertDialog
.
Builder
(
it
)
val
builder
=
AlertDialog
.
Builder
(
it
)
builder
.
apply
{
builder
.
apply
{
setTitle
(
dialogInstance
.
title
)
setTitle
(
dialogInstance
.
title
)
set
Message
(
dialogInstance
.
message
)
set
View
(
message
)
setCancelable
(
dialogInstance
.
cancelable
?:
true
)
setCancelable
(
dialogInstance
.
cancelable
?:
true
)
setPositiveButton
(
setPositiveButton
(
dialogInstance
.
positiveButton
dialogInstance
.
positiveButton
...
@@ -83,4 +90,22 @@ object DialogHelper {
...
@@ -83,4 +90,22 @@ object DialogHelper {
alertDialog
.
show
()
alertDialog
.
show
()
return
alertDialog
return
alertDialog
}
}
private
fun
getMessage
(
activity
:
Activity
,
message
:
String
?):
TextView
{
// create spannable and add links
val
spannable
=
SpannableString
(
message
)
Linkify
.
addLinks
(
spannable
,
Linkify
.
WEB_URLS
)
// get padding for all sides
val
paddingStartEnd
=
activity
.
resources
.
getDimension
(
R
.
dimen
.
spacing_normal
).
toInt
()
val
paddingLeftRight
=
activity
.
resources
.
getDimension
(
R
.
dimen
.
spacing_small
).
toInt
()
// create a textview with clickable links from the spannable
val
textView
=
TextView
(
activity
)
textView
.
text
=
spannable
textView
.
autoLinkMask
=
RESULT_OK
textView
.
movementMethod
=
LinkMovementMethod
.
getInstance
()
textView
.
setPadding
(
paddingStartEnd
,
paddingLeftRight
,
paddingStartEnd
,
paddingLeftRight
)
textView
.
setTextAppearance
(
R
.
style
.
body1
)
textView
.
setLinkTextColor
(
activity
.
getColorStateList
(
R
.
color
.
button_primary
))
return
textView
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment