Skip to content

Commit

Permalink
v1.13.0-beta14
Browse files Browse the repository at this point in the history
  • Loading branch information
AndraxDev committed Mar 28, 2023
1 parent 2862d15 commit c45c8c4
Show file tree
Hide file tree
Showing 27 changed files with 393 additions and 70 deletions.

This file was deleted.

This file was deleted.

Empty file.

This file was deleted.

Empty file.
Empty file.
12 changes: 0 additions & 12 deletions .idea/sonarlint/issuestore/index.pb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
14 changes: 1 addition & 13 deletions .idea/sonarlint/securityhotspotstore/index.pb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 29 additions & 9 deletions app/src/main/java/org/teslasoft/assistant/adapters/ChatAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,22 @@ class ChatAdapter(data: ArrayList<HashMap<String, Any>>?, context: FragmentActiv
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
val inflater = mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater

val settings: SharedPreferences = mContext.getSharedPreferences("settings",
FragmentActivity.MODE_PRIVATE
)

val layout = settings.getString("layout", "classic").toString()

var mView: View? = convertView

if (mView == null) {
mView = inflater.inflate(R.layout.view_message, null)
mView = if (layout == "bubbles") {
if (dataArray?.get(position)?.get("isBot") == true) {
inflater.inflate(R.layout.view_assistant_bot_message, null)
} else {
inflater.inflate(R.layout.view_assistant_user_message, null)
}
} else {
inflater.inflate(R.layout.view_message, null)
}

val ui: ConstraintLayout = mView!!.findViewById(R.id.ui)
Expand All @@ -59,14 +71,22 @@ class ChatAdapter(data: ArrayList<HashMap<String, Any>>?, context: FragmentActiv

message.setTextIsSelectable(true)

if (dataArray?.get(position)?.get("isBot") == true) {
icon.setImageResource(R.drawable.assistant)
username.text = mContext.resources.getString(R.string.app_name)
ui.setBackgroundColor(getSurfaceColor(mContext))
if (layout == "bubbles") {
if (dataArray?.get(position)?.get("isBot") == true) {
icon.setImageResource(R.drawable.assistant)
} else {
icon.setImageResource(R.drawable.ic_user)
}
} else {
icon.setImageResource(R.drawable.ic_user)
username.text = "User"
ui.setBackgroundResource(R.color.window_background)
if (dataArray?.get(position)?.get("isBot") == true) {
icon.setImageResource(R.drawable.assistant)
username.text = mContext.resources.getString(R.string.app_name)
ui.setBackgroundColor(getSurfaceColor(mContext))
} else {
icon.setImageResource(R.drawable.ic_user)
username.text = "User"
ui.setBackgroundResource(R.color.window_background)
}
}

if (dataArray?.get(position)?.get("message").toString().contains("data:image")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.aallam.openai.api.image.ImageCreation
import com.aallam.openai.api.image.ImageSize
import com.aallam.openai.api.model.ModelId
import com.aallam.openai.client.OpenAI
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.elevation.SurfaceColors
import com.google.gson.Gson
Expand Down Expand Up @@ -433,6 +434,8 @@ class AssistantFragment : BottomSheetDialogFragment() {

@OptIn(BetaOpenAI::class)
private suspend fun generateResponse(request: String, shouldPronounce: Boolean) {
assistantConversation?.visibility = View.VISIBLE

putMessage("", true)
var response = ""

Expand Down Expand Up @@ -521,6 +524,8 @@ class AssistantFragment : BottomSheetDialogFragment() {

@OptIn(BetaOpenAI::class)
private suspend fun generateImage(p: String) {
assistantConversation?.visibility = View.VISIBLE

try {
val images = ai?.imageURL(
creation = ImageCreation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class SettingsActivity : FragmentActivity() {
private var r1024: MaterialButton? = null
private var promptDesc: TextView? = null
private var modelDesc: TextView? = null
private var btnClassicView: LinearLayout? = null
private var btnBubblesView: LinearLayout? = null

private var chatId = ""

Expand Down Expand Up @@ -93,10 +95,33 @@ class SettingsActivity : FragmentActivity() {
promptDesc = findViewById(R.id.prompt_desc)
modelDesc = findViewById(R.id.model_desc)
btnAbout = findViewById(R.id.btn_about)
btnClassicView = findViewById(R.id.btn_classic_chat)
btnBubblesView = findViewById(R.id.btn_bubbles_chat)


val settings: SharedPreferences = getSharedPreferences("settings", MODE_PRIVATE)
activationPrompt = settings.getString("prompt", "").toString()

if (settings.getString("layout", "classic").toString() == "bubbles") {
btnBubblesView?.setBackgroundResource(R.drawable.btn_accent_tonal_selector_v2)
btnClassicView?.setBackgroundResource(R.drawable.btn_accent_tonal_selector_v3)
} else {
btnBubblesView?.setBackgroundResource(R.drawable.btn_accent_tonal_selector_v3)
btnClassicView?.setBackgroundResource(R.drawable.btn_accent_tonal_selector_v2)
}

btnClassicView?.setOnClickListener {
settings.edit().putString("layout", "classic").apply()
btnBubblesView?.setBackgroundResource(R.drawable.btn_accent_tonal_selector_v3)
btnClassicView?.setBackgroundResource(R.drawable.btn_accent_tonal_selector_v2)
}

btnBubblesView?.setOnClickListener {
settings.edit().putString("layout", "bubbles").apply()
btnBubblesView?.setBackgroundResource(R.drawable.btn_accent_tonal_selector_v2)
btnClassicView?.setBackgroundResource(R.drawable.btn_accent_tonal_selector_v3)
}

if (activationPrompt != "") {
promptDesc?.text = activationPrompt
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class BottomSheetListView(context: Context?, p_attrs: AttributeSet?) :
canScroll = true
}
}

return canScroll
}
}
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/btn_accent_tonal_selector_v2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple android:color="@color/accent_500"
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners android:radius="24dp" />
<solid android:color="@color/accent_200" />
</shape>
</item>
</ripple>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/btn_accent_tonal_selector_v3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple android:color="@color/accent_500"
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners android:radius="24dp" />
<solid android:color="@color/accent_100" />
</shape>
</item>
</ripple>
31 changes: 31 additions & 0 deletions app/src/main/res/drawable/chat_layout_bubbles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="500dp"
android:height="500dp"
android:viewportWidth="500"
android:viewportHeight="500">

<path
android:pathData="M-0.66,-0.66L500.66,-0.66L500.66,500.66L-0.66,500.66z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/window_background"
android:fillType="nonZero"/>

<path
android:name="path"
android:pathData="M 45.64 95.497 C 55.87 95.497 64.173 103.8 64.173 114.03 C 64.173 124.26 55.87 132.563 45.64 132.563 C 35.41 132.563 27.107 124.26 27.107 114.03 C 27.107 103.8 35.41 95.497 45.64 95.497 Z M 45.64 256.337 C 55.87 256.337 64.173 264.64 64.173 274.87 C 64.173 285.1 55.87 293.403 45.64 293.403 C 35.41 293.403 27.107 285.1 27.107 274.87 C 27.107 264.64 35.41 256.337 45.64 256.337 Z M 45.64 390.777 C 55.87 390.777 64.173 399.08 64.173 409.31 C 64.173 419.54 55.87 427.843 45.64 427.843 C 35.41 427.843 27.107 419.54 27.107 409.31 C 27.107 399.08 35.41 390.777 45.64 390.777 Z"
android:fillColor="@color/accent_500"
android:strokeWidth="1"/>
<path
android:name="path_1"
android:pathData="M 152.95 46.679 C 152.95 33.628 163.49 23.048 176.492 23.048 L 454.208 23.048 C 467.21 23.048 477.75 33.628 477.75 46.679 C 477.75 59.057 467.753 69.092 455.421 69.092 L 175.279 69.092 C 162.947 69.092 152.95 59.057 152.95 46.679 Z M 260.741 212.178 C 260.741 199.161 271.313 188.608 284.353 188.608 L 454.907 188.608 C 467.947 188.608 478.519 199.161 478.519 212.178 L 478.519 212.297 C 478.519 224.643 468.492 234.652 456.124 234.652 L 283.136 234.652 C 270.768 234.652 260.741 224.643 260.741 212.297 Z M 186.6 348.838 C 186.6 335.821 197.142 325.268 210.146 325.268 L 454.254 325.268 C 467.258 325.268 477.8 335.821 477.8 348.838 L 477.8 348.957 C 477.8 361.303 467.801 371.312 455.467 371.312 L 208.933 371.312 C 196.599 371.312 186.6 361.303 186.6 348.957 Z"
android:fillColor="@color/accent_900"
android:strokeWidth="1"/>
<path
android:name="path_2"
android:pathData="M 82.424 279.908 C 82.424 266.891 92.958 256.338 105.951 256.338 L 291.609 256.338 C 304.602 256.338 315.136 266.891 315.136 279.908 L 315.136 280.027 C 315.136 292.373 305.145 302.382 292.821 302.382 L 104.739 302.382 C 92.415 302.382 82.424 292.373 82.424 280.027 Z M 81.99 414.348 C 81.99 401.331 92.541 390.778 105.557 390.778 L 226.423 390.778 C 239.439 390.778 249.99 401.331 249.99 414.348 L 249.99 414.467 C 249.99 426.813 239.982 436.822 227.638 436.822 L 104.342 436.822 C 91.998 436.822 81.99 426.813 81.99 414.467 Z M 82.092 118.191 C 82.092 105.17 92.653 94.614 105.681 94.614 L 359.659 94.614 C 372.687 94.614 383.248 105.17 383.248 118.191 L 383.248 148.164 C 383.248 160.514 373.231 170.526 360.875 170.526 L 104.465 170.526 C 92.109 170.526 82.092 160.514 82.092 148.164 Z"
android:fillColor="@color/accent_100"
android:strokeWidth="1"/>
</vector>
114 changes: 114 additions & 0 deletions app/src/main/res/drawable/chat_layout_classic.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="500dp"
android:height="500dp"
android:viewportWidth="500"
android:viewportHeight="500">
<path
android:pathData="M-0.66,-0.66L500.66,-0.66L500.66,500.66L-0.66,500.66z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_100"
android:fillType="nonZero"/>
<path
android:pathData="M0.35,-0.1L499.65,-0.1L499.65,127.54L0.35,127.54z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/window_background"
android:fillType="nonZero"/>
<path
android:pathData="M0.41,245.97L499.71,245.97L499.71,373.61L0.41,373.61z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/window_background"
android:fillType="nonZero"/>
<path
android:pathData="M36.62,22.55C46.85,22.55 55.15,30.85 55.15,41.08C55.15,51.31 46.85,59.61 36.62,59.61C26.39,59.61 18.09,51.31 18.09,41.08C18.09,30.85 26.39,22.55 36.62,22.55z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_200"
android:fillType="nonZero"/>
<path
android:pathData="M36.62,143.21C46.85,143.21 55.15,151.51 55.15,161.74C55.15,171.97 46.85,180.27 36.62,180.27C26.39,180.27 18.09,171.97 18.09,161.74C18.09,151.51 26.39,143.21 36.62,143.21z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_500"
android:fillType="nonZero"/>
<path
android:pathData="M36.62,263.05C46.85,263.05 55.15,271.35 55.15,281.58C55.15,291.81 46.85,300.11 36.62,300.11C26.39,300.11 18.09,291.81 18.09,281.58C18.09,271.35 26.39,263.05 36.62,263.05z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_200"
android:fillType="nonZero"/>
<path
android:pathData="M36.62,389.44C46.85,389.44 55.15,397.74 55.15,407.97C55.15,418.2 46.85,426.5 36.62,426.5C26.39,426.5 18.09,418.2 18.09,407.97C18.09,397.74 26.39,389.44 36.62,389.44z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_500"
android:fillType="nonZero"/>
<path
android:pathData="M72.78,22.42L474.46,22.42L474.46,41.2L72.78,41.2z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_900"
android:fillType="nonZero"/>
<path
android:pathData="M72.39,143.2L447.79,143.2L447.79,161.98L72.39,161.98z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_500"
android:fillType="nonZero"/>
<path
android:pathData="M73.01,174.53L256.97,174.53L256.97,193.31L73.01,193.31z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_500"
android:fillType="nonZero"/>
<path
android:pathData="M73.16,206.65L345.34,206.65L345.34,225.43L73.16,225.43z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_500"
android:fillType="nonZero"/>
<path
android:pathData="M73.27,263.04L298.51,263.04L298.51,281.82L73.27,281.82z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_900"
android:fillType="nonZero"/>
<path
android:pathData="M72.71,296.33L397.43,296.33L397.43,315.11L72.71,315.11z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_900"
android:fillType="nonZero"/>
<path
android:pathData="M72.33,389.2L231.87,389.2L231.87,407.98L72.33,407.98z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_500"
android:fillType="nonZero"/>
<path
android:pathData="M72.17,421.24L438.19,421.24L438.19,440.02L72.17,440.02z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_500"
android:fillType="nonZero"/>
<path
android:pathData="M72.39,453.37L318.29,453.37L318.29,472.15L72.39,472.15z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_500"
android:fillType="nonZero"/>
<path
android:pathData="M72.39,54.33L474.07,54.33L474.07,73.11L72.39,73.11z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_900"
android:fillType="nonZero"/>
<path
android:pathData="M72.27,84.82L391.37,84.82L391.37,103.6L72.27,103.6z"
android:strokeLineJoin="miter"
android:strokeWidth="0"
android:fillColor="@color/accent_900"
android:fillType="nonZero"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:topLeftRadius="8dp" android:topRightRadius="8dp" android:bottomRightRadius="8dp" android:bottomLeftRadius="8dp"/>
<gradient android:type="linear" android:angle="315" android:startColor="@color/accent_100" android:centerColor="@color/accent_100" android:endColor="@color/accent_100" android:useLevel="true"/>
</shape>
Loading

0 comments on commit c45c8c4

Please sign in to comment.