This repository has been archived by the owner on Jun 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
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 #26 from ttt246/feature/asset_popup_dialog_17
feature(#22): update chat ui
- Loading branch information
Showing
37 changed files
with
446 additions
and
306 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
46 changes: 46 additions & 0 deletions
46
app/src/main/java/com/matthaigh27/chatgptwrapper/widgets/ChatToolItem.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,46 @@ | ||
package com.matthaigh27.chatgptwrapper.widgets | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import android.widget.ImageView | ||
import android.widget.LinearLayout | ||
import android.widget.TextView | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import com.matthaigh27.chatgptwrapper.R | ||
import com.matthaigh27.chatgptwrapper.R.styleable.ChatToolLayout | ||
|
||
class ChatToolItem(context: Context, attrs: AttributeSet? = null) : LinearLayout(context, attrs) { | ||
private lateinit var mContext:Context | ||
private lateinit var mIvToolIcon: ImageView | ||
private lateinit var mTvToolName: TextView | ||
private lateinit var mClToolIcon: ConstraintLayout | ||
|
||
init { | ||
initView(context, attrs) | ||
} | ||
|
||
private fun initView(context: Context, attrs: AttributeSet?) { | ||
LayoutInflater.from(context).inflate(R.layout.item_chat_tool, this, true) | ||
|
||
val layoutParams = LayoutParams( | ||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT | ||
) | ||
val itemMargin = context.resources.getDimensionPixelSize(R.dimen.item_chat_tool_margin) | ||
layoutParams.setMargins(itemMargin, itemMargin, itemMargin, itemMargin) | ||
this.layoutParams = layoutParams | ||
|
||
mContext = context | ||
mIvToolIcon = findViewById(R.id.iv_chat_tool) | ||
mClToolIcon = findViewById(R.id.cl_chat_tool) | ||
mTvToolName = findViewById(R.id.tv_chat_tool_description) | ||
|
||
} | ||
|
||
fun setTool(drawableId: Int, size: Int, name: String) { | ||
mIvToolIcon.setImageResource(drawableId) | ||
mClToolIcon.layoutParams = LayoutParams(size, size) | ||
mTvToolName.text = name | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
app/src/main/java/com/matthaigh27/chatgptwrapper/widgets/ChatToolsWidget.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,85 @@ | ||
package com.matthaigh27.chatgptwrapper.widgets | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.View.OnClickListener | ||
import android.view.ViewGroup | ||
import android.widget.GridLayout | ||
import android.widget.LinearLayout | ||
import com.matthaigh27.chatgptwrapper.R | ||
|
||
|
||
class ChatToolsWidget(context: Context) : LinearLayout(context), OnClickListener { | ||
|
||
private lateinit var mClickListener: OnPositiveButtonClickListener | ||
private lateinit var mGlTools: GridLayout | ||
private var isInitFlag = true | ||
|
||
val TOOL_ICONS = arrayOf( | ||
R.drawable.ic_camera, | ||
R.drawable.ic_gallery, | ||
) | ||
|
||
val TOOL_NAMES = arrayOf( | ||
"Camera", | ||
"Gallery" | ||
) | ||
|
||
val TOOL_COUNT = 2 | ||
|
||
init { | ||
initView() | ||
} | ||
|
||
fun setOnClickListener(listener: OnPositiveButtonClickListener) { | ||
mClickListener = listener | ||
} | ||
|
||
private fun initView() { | ||
LayoutInflater.from(context).inflate(R.layout.view_chat_tools, this, true) | ||
|
||
layoutParams = LayoutParams( | ||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT | ||
) | ||
|
||
mGlTools = findViewById(R.id.gl_tools) | ||
|
||
this.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> | ||
if (!isInitFlag) return@addOnLayoutChangeListener | ||
isInitFlag = false | ||
|
||
val width: Int = this.width | ||
|
||
for (i in 0 until TOOL_COUNT) { | ||
val cameraTool = ChatToolItem(context) | ||
val itemMargin = | ||
context.resources.getDimensionPixelSize(R.dimen.item_chat_tool_margin) | ||
cameraTool.setTool(TOOL_ICONS[i], width / 4 - itemMargin * 2, TOOL_NAMES[i]) | ||
mGlTools.addView(cameraTool) | ||
|
||
cameraTool.setTag(TOOL_NAMES[i]) | ||
cameraTool.setOnClickListener(this@ChatToolsWidget) | ||
} | ||
} | ||
} | ||
|
||
override fun onClick(view: View?) { | ||
when (view?.tag) { | ||
"Camera" -> { | ||
mClickListener.onPositiveBtnClick(true) | ||
} | ||
|
||
"Gallery" -> { | ||
mClickListener.onPositiveBtnClick(false) | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* callback function invoked when filepickerdialog buttons are pressed | ||
*/ | ||
interface OnPositiveButtonClickListener { | ||
fun onPositiveBtnClick(isCamera: Boolean?) | ||
} | ||
} |
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
53 changes: 0 additions & 53 deletions
53
app/src/main/java/com/matthaigh27/chatgptwrapper/widgets/ImagePickerWidget.kt
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...rawable/background_sms_rounded_button.xml → ...rawable/background_chat_widget_button.xml
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,8 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<solid | ||
android:width="@dimen/sms_button_stroke_width" | ||
android:color="@color/sms_button_bgcolor" /> | ||
<corners android:radius="@dimen/sms_button_radius" /> | ||
</shape> |
3 changes: 2 additions & 1 deletion
3
.../res/drawable/background_sms_edittext.xml → ...wable/background_chat_widget_edittext.xml
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,8 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<solid android:color="@color/view_help_prompt_edittext_bgcolor" /> | ||
<stroke | ||
android:width="@dimen/view_help_prompt_edittext_stroke_width" | ||
android:color="@color/view_help_prompt_edittext_stroke_color" /> | ||
<corners android:radius="@dimen/view_help_prompt_edittext_round_size" /> | ||
</shape> | ||
</shape> |
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,8 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<solid android:color="@color/chat_content_top_bgcolor" /> | ||
<solid android:color="@color/chat_main_content_top_bgcolor" /> | ||
<corners | ||
android:bottomLeftRadius="@dimen/chat_content_top_radius" | ||
android:bottomRightRadius="@dimen/chat_content_top_radius" /> | ||
android:bottomLeftRadius="@dimen/chat_main_content_top_radius" | ||
android:bottomRightRadius="@dimen/chat_main_content_top_radius" /> | ||
</shape> |
6 changes: 0 additions & 6 deletions
6
app/src/main/res/drawable/background_control_button_common.xml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.