-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from KaushalVasava/add_multi_image_chat
Add Linkify text and update gemini pro vision to gemini-1.5-flash model
- Loading branch information
Showing
5 changed files
with
42 additions
and
5 deletions.
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
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/lahsuak/apps/geminiai/ui/component/LinkifyText.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,32 @@ | ||
package com.lahsuak.apps.geminiai.ui.component | ||
|
||
import android.text.method.LinkMovementMethod | ||
import android.text.util.Linkify | ||
import android.widget.TextView | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.text.AnnotatedString | ||
import androidx.compose.ui.viewinterop.AndroidView | ||
import androidx.core.text.util.LinkifyCompat | ||
|
||
@Composable | ||
fun LinkifyText( | ||
text: AnnotatedString?, color: Color, | ||
modifier: Modifier = Modifier, | ||
) { | ||
val context = LocalContext.current | ||
val customLinkifyTextView = remember { | ||
TextView(context) | ||
} | ||
AndroidView(modifier = modifier, factory = { customLinkifyTextView }) { textView -> | ||
textView.text = text ?: "" | ||
|
||
textView.setTextColor(color.hashCode()) | ||
textView.setLinkTextColor(Color.Blue.hashCode()) | ||
LinkifyCompat.addLinks(textView, Linkify.ALL) | ||
textView.movementMethod = LinkMovementMethod.getInstance() | ||
} | ||
} |
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