peterluo3131 commited on
Commit
a94ee60
·
1 Parent(s): 1f154fd

feature(#105): update setting page with uuid

Browse files
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/ApiService.kt CHANGED
@@ -7,6 +7,7 @@ import com.matthaigh27.chatgptwrapper.data.remote.requests.TrainContactsApiReque
7
  import com.matthaigh27.chatgptwrapper.data.remote.requests.TrainImageApiRequest
8
  import com.matthaigh27.chatgptwrapper.data.remote.responses.ApiResponse
9
  import com.matthaigh27.chatgptwrapper.data.remote.responses.EmptyResultApiResponse
 
10
  import com.matthaigh27.chatgptwrapper.data.remote.responses.TrainImageApiResponse
11
  import retrofit2.Call
12
  import retrofit2.http.Body
@@ -20,7 +21,7 @@ interface ApiService {
20
  @POST("train/contacts")
21
  fun trainContacts(@Body request: TrainContactsApiRequest) : Call<EmptyResultApiResponse>
22
  @POST("image_relatedness")
23
- fun getImageRelatedness(@Body request: ImageRelatednessApiRequest) : Call<ApiResponse>
24
  @POST("uploadImage")
25
  fun trainImage(@Body request: TrainImageApiRequest) : Call<TrainImageApiResponse>
26
  }
 
7
  import com.matthaigh27.chatgptwrapper.data.remote.requests.TrainImageApiRequest
8
  import com.matthaigh27.chatgptwrapper.data.remote.responses.ApiResponse
9
  import com.matthaigh27.chatgptwrapper.data.remote.responses.EmptyResultApiResponse
10
+ import com.matthaigh27.chatgptwrapper.data.remote.responses.ImageRelatenessApiResponse
11
  import com.matthaigh27.chatgptwrapper.data.remote.responses.TrainImageApiResponse
12
  import retrofit2.Call
13
  import retrofit2.http.Body
 
21
  @POST("train/contacts")
22
  fun trainContacts(@Body request: TrainContactsApiRequest) : Call<EmptyResultApiResponse>
23
  @POST("image_relatedness")
24
+ fun getImageRelatedness(@Body request: ImageRelatednessApiRequest) : Call<ImageRelatenessApiResponse>
25
  @POST("uploadImage")
26
  fun trainImage(@Body request: TrainImageApiRequest) : Call<TrainImageApiResponse>
27
  }
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/responses/ImageRelatenessApiResponse.kt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package com.matthaigh27.chatgptwrapper.data.remote.responses
2
+
3
+ data class ImageRelatenessApiResponse(
4
+ val status_code: Int,
5
+ val message: List<String>,
6
+ val result: RelatenessResult
7
+ )
8
+
9
+ data class RelatenessResult(
10
+ val program: String,
11
+ val content: RelatenessContent
12
+ )
13
+
14
+ data class RelatenessContent (
15
+ val image_name: String,
16
+ val image_desc: String
17
+ )
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/repository/RemoteRepository.kt CHANGED
@@ -8,6 +8,7 @@ import com.matthaigh27.chatgptwrapper.data.remote.requests.TrainContactsApiReque
8
  import com.matthaigh27.chatgptwrapper.data.remote.requests.TrainImageApiRequest
9
  import com.matthaigh27.chatgptwrapper.data.remote.responses.ApiResponse
10
  import com.matthaigh27.chatgptwrapper.data.remote.responses.EmptyResultApiResponse
 
11
  import com.matthaigh27.chatgptwrapper.data.remote.responses.TrainImageApiResponse
12
  import com.matthaigh27.chatgptwrapper.utils.helpers.OnFailure
13
  import com.matthaigh27.chatgptwrapper.utils.helpers.OnSuccess
@@ -111,14 +112,14 @@ object RemoteRepository {
111
 
112
  fun getImageRelatedness(
113
  request: ImageRelatednessApiRequest,
114
- onSuccess: OnSuccess<ApiResponse>,
115
  onFailure: OnFailure<String>
116
  ) {
117
  val call = apiService.getImageRelatedness(request)
118
 
119
- call.enqueue(object : Callback<ApiResponse> {
120
  override fun onResponse(
121
- call: Call<ApiResponse>, response: Response<ApiResponse>
122
  ) {
123
  response.body()?.let { data ->
124
  onSuccess(data)
@@ -127,7 +128,7 @@ object RemoteRepository {
127
  }
128
  }
129
 
130
- override fun onFailure(call: Call<ApiResponse>, t: Throwable) {
131
  onFailure(t.message.toString())
132
  }
133
  })
 
8
  import com.matthaigh27.chatgptwrapper.data.remote.requests.TrainImageApiRequest
9
  import com.matthaigh27.chatgptwrapper.data.remote.responses.ApiResponse
10
  import com.matthaigh27.chatgptwrapper.data.remote.responses.EmptyResultApiResponse
11
+ import com.matthaigh27.chatgptwrapper.data.remote.responses.ImageRelatenessApiResponse
12
  import com.matthaigh27.chatgptwrapper.data.remote.responses.TrainImageApiResponse
13
  import com.matthaigh27.chatgptwrapper.utils.helpers.OnFailure
14
  import com.matthaigh27.chatgptwrapper.utils.helpers.OnSuccess
 
112
 
113
  fun getImageRelatedness(
114
  request: ImageRelatednessApiRequest,
115
+ onSuccess: OnSuccess<ImageRelatenessApiResponse>,
116
  onFailure: OnFailure<String>
117
  ) {
118
  val call = apiService.getImageRelatedness(request)
119
 
120
+ call.enqueue(object : Callback<ImageRelatenessApiResponse> {
121
  override fun onResponse(
122
+ call: Call<ImageRelatenessApiResponse>, response: Response<ImageRelatenessApiResponse>
123
  ) {
124
  response.body()?.let { data ->
125
  onSuccess(data)
 
128
  }
129
  }
130
 
131
+ override fun onFailure(call: Call<ImageRelatenessApiResponse>, t: Throwable) {
132
  onFailure(t.message.toString())
133
  }
134
  })
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/ui/chat/view/adapters/ChatMainAdapter.kt CHANGED
@@ -121,6 +121,8 @@ class ChatMainAdapter(
121
 
122
  data.content?.let { message ->
123
  holder.txtMessage.text = message
 
 
124
  } ?: run {
125
  holder.txtMessage.visibility = View.GONE
126
  }
@@ -138,6 +140,7 @@ class ChatMainAdapter(
138
 
139
  private fun setMessageData(holder: ChatWidgetViewHolder, data: ChatMessageModel) {
140
  holder.itemLayout.visibility = View.VISIBLE
 
141
  val index = holder.adapterPosition
142
 
143
  when (data.content) {
@@ -197,11 +200,8 @@ class ChatMainAdapter(
197
  }
198
 
199
  TYPE_WIDGET_SCHEDULE_ALARM -> {
200
- var props = ScheduleAlarmProps()
201
- data.data?.run {
202
- val widgetDesc = data.data.asJsonObject[PROPS_WIDGET_DESC].asString
203
- props = ScheduleAlarmProps.init(widgetDesc)
204
- }
205
  val scheduleAlarmWidget =
206
  ScheduleAlarmWidget(context, props.time, props.label, props.repeat).apply {
207
  this.callback = callbacks
 
121
 
122
  data.content?.let { message ->
123
  holder.txtMessage.text = message
124
+ if(message.isEmpty())
125
+ holder.txtMessage.visibility = View.GONE
126
  } ?: run {
127
  holder.txtMessage.visibility = View.GONE
128
  }
 
140
 
141
  private fun setMessageData(holder: ChatWidgetViewHolder, data: ChatMessageModel) {
142
  holder.itemLayout.visibility = View.VISIBLE
143
+ holder.itemLayout.removeAllViews()
144
  val index = holder.adapterPosition
145
 
146
  when (data.content) {
 
200
  }
201
 
202
  TYPE_WIDGET_SCHEDULE_ALARM -> {
203
+ val widgetDesc = data.data!!.asJsonObject[PROPS_WIDGET_DESC].asString
204
+ val props = ScheduleAlarmProps.init(widgetDesc)
 
 
 
205
  val scheduleAlarmWidget =
206
  ScheduleAlarmWidget(context, props.time, props.label, props.repeat).apply {
207
  this.callback = callbacks
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/ui/chat/view/fragments/ChatMainFragment.kt CHANGED
@@ -36,7 +36,6 @@ import com.matthaigh27.chatgptwrapper.utils.Constants.ERROR_MSG_NOEXIST_COMMAND
36
  import com.matthaigh27.chatgptwrapper.utils.Constants.HELP_COMMAND_ALL
37
  import com.matthaigh27.chatgptwrapper.utils.Constants.PROPS_WIDGET_DESC
38
  import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_RESPONSE_ALARM
39
- import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_RESPONSE_ALERT
40
  import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_RESPONSE_BROWSER
41
  import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_RESPONSE_CONTACT
42
  import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_RESPONSE_IMAGE
@@ -53,7 +52,6 @@ import com.matthaigh27.chatgptwrapper.utils.helpers.chat.CommandHelper.makePromp
53
  import com.matthaigh27.chatgptwrapper.utils.helpers.chat.CommandHelper.makePromptUsage
54
  import com.matthaigh27.chatgptwrapper.utils.helpers.ui.NoNewLineInputFilter
55
  import org.json.JSONArray
56
- import java.util.Calendar
57
 
58
  class ChatMainFragment : Fragment(), OnClickListener {
59
 
@@ -102,7 +100,6 @@ class ChatMainFragment : Fragment(), OnClickListener {
102
  }
103
 
104
 
105
-
106
  private fun initViewModel() {
107
  viewModel = ViewModelProvider(this)[ChatViewModel::class.java]
108
  }
@@ -168,7 +165,7 @@ class ChatMainFragment : Fragment(), OnClickListener {
168
  showloadingCount++
169
  } else {
170
  showloadingCount--
171
- if(showloadingCount == 0) {
172
  imgLoading.clearAnimation()
173
  imgLoading.visibility = View.GONE
174
  edtMessageInput?.isEnabled = true
@@ -200,6 +197,58 @@ class ChatMainFragment : Fragment(), OnClickListener {
200
  )
201
  )
202
  isImagePicked = false
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  } else {
204
  addChatItemToList(ChatMessageModel(type, content, data, hasImage, image))
205
  sendNotification(content)
@@ -216,8 +265,7 @@ class ChatMainFragment : Fragment(), OnClickListener {
216
  message: String
217
  ) {
218
  addMessage(
219
- type = TYPE_CHAT_RECEIVE,
220
- content = message
221
  )
222
  }
223
 
@@ -331,7 +379,10 @@ class ChatMainFragment : Fragment(), OnClickListener {
331
  showLoading(false)
332
  val apiResponse = resource.data
333
  when (apiResponse?.result?.program) {
334
- TYPE_RESPONSE_MESSAGE -> addMessage(TYPE_CHAT_RECEIVE, apiResponse.result.content.toString())
 
 
 
335
  TYPE_RESPONSE_BROWSER -> fetchResponseBrowser(apiResponse)
336
  TYPE_RESPONSE_CONTACT -> fetchResponseContact(apiResponse)
337
  TYPE_RESPONSE_IMAGE -> fetchResponseImage(apiResponse)
@@ -399,7 +450,8 @@ class ChatMainFragment : Fragment(), OnClickListener {
399
  }
400
 
401
  private fun fetchResponseAlarm(apiResponse: ApiResponse) {
402
- val time: Time = Converter.stringToTime(apiResponse.result.content.asJsonObject.get("time").asString)
 
403
  val label = apiResponse.result.content.asJsonObject.get("label").asString
404
  val props = ScheduleAlarmProps(time, label)
405
  val widgetDesc = JsonObject().apply {
@@ -426,29 +478,25 @@ class ChatMainFragment : Fragment(), OnClickListener {
426
 
427
  override fun sentHelpPrompt(prompt: String) {
428
  addMessage(
429
- type = TYPE_CHAT_SENT,
430
- content = prompt
431
  )
432
  }
433
 
434
  override fun canceledHelpPrompt() {
435
  addMessage(
436
- type = TYPE_CHAT_RECEIVE,
437
- content = "You canceled Help prompt."
438
  )
439
  }
440
 
441
  override fun doVoiceCall(phoneNumber: String) {
442
  addMessage(
443
- type = TYPE_CHAT_RECEIVE,
444
- content = "You made a voice call to $phoneNumber"
445
  )
446
  }
447
 
448
  override fun doVideoCall(phoneNumber: String) {
449
  addMessage(
450
- type = TYPE_CHAT_RECEIVE,
451
- content = "You made a video call to $phoneNumber"
452
  )
453
  }
454
 
@@ -457,15 +505,15 @@ class ChatMainFragment : Fragment(), OnClickListener {
457
  this.addProperty(PROPS_WIDGET_DESC, phoneNumber)
458
  }
459
  addMessage(
460
- type = TYPE_CHAT_WIDGET,
461
- content = TYPE_WIDGET_SMS,
462
- data = widgetDesc
463
  )
464
  }
465
 
466
  override fun pickImage(isSuccess: Boolean, data: ByteArray?) {
467
- if (!isSuccess)
468
  addErrorMessage("Fail to pick image")
 
 
469
  viewModel.uploadImageToFirebase(data!!)
470
  .observe(viewLifecycleOwner, Observer { resource ->
471
  when (resource) {
@@ -497,8 +545,7 @@ class ChatMainFragment : Fragment(), OnClickListener {
497
 
498
  override fun cancelAlarm() {
499
  addMessage(
500
- type = TYPE_CHAT_RECEIVE,
501
- content = "You canceled setting an alarm."
502
  )
503
  }
504
  }
 
36
  import com.matthaigh27.chatgptwrapper.utils.Constants.HELP_COMMAND_ALL
37
  import com.matthaigh27.chatgptwrapper.utils.Constants.PROPS_WIDGET_DESC
38
  import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_RESPONSE_ALARM
 
39
  import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_RESPONSE_BROWSER
40
  import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_RESPONSE_CONTACT
41
  import com.matthaigh27.chatgptwrapper.utils.Constants.TYPE_RESPONSE_IMAGE
 
52
  import com.matthaigh27.chatgptwrapper.utils.helpers.chat.CommandHelper.makePromptUsage
53
  import com.matthaigh27.chatgptwrapper.utils.helpers.ui.NoNewLineInputFilter
54
  import org.json.JSONArray
 
55
 
56
  class ChatMainFragment : Fragment(), OnClickListener {
57
 
 
100
  }
101
 
102
 
 
103
  private fun initViewModel() {
104
  viewModel = ViewModelProvider(this)[ChatViewModel::class.java]
105
  }
 
165
  showloadingCount++
166
  } else {
167
  showloadingCount--
168
+ if (showloadingCount == 0) {
169
  imgLoading.clearAnimation()
170
  imgLoading.visibility = View.GONE
171
  edtMessageInput?.isEnabled = true
 
197
  )
198
  )
199
  isImagePicked = false
200
+ currentUploadedImageName?.let {
201
+ viewModel.getImageRelatedness(it, content)
202
+ .observe(viewLifecycleOwner, Observer { relatenessResource ->
203
+ when (relatenessResource) {
204
+ is ApiResource.Loading -> {
205
+ showLoading(true)
206
+ }
207
+
208
+ is ApiResource.Success -> {
209
+ showLoading(false)
210
+ relatenessResource.data?.result?.content?.image_name?.let { imageName ->
211
+ viewModel.downloadImageFromFirebase(
212
+ imageName
213
+ ).observe(viewLifecycleOwner, Observer { resource ->
214
+ when (resource) {
215
+ is ApiResource.Loading -> {
216
+ showLoading(true)
217
+ }
218
+
219
+ is ApiResource.Success -> {
220
+ addMessage(
221
+ type = TYPE_CHAT_RECEIVE,
222
+ content = relatenessResource.data.result.content.image_desc,
223
+ data = null,
224
+ hasImage = true,
225
+ image = resource.data
226
+ )
227
+ showLoading(false)
228
+ }
229
+ is ApiResource.Error -> {
230
+ addErrorMessage(resource.message!!)
231
+ showLoading(false)
232
+ }
233
+ }
234
+ })
235
+ } ?: run {
236
+ addMessage(
237
+ type = TYPE_CHAT_RECEIVE,
238
+ content = relatenessResource.data?.result?.content?.image_desc,
239
+ )
240
+ }
241
+ }
242
+
243
+ is ApiResource.Error -> {
244
+ showLoading(false)
245
+ addErrorMessage(relatenessResource.message!!)
246
+ }
247
+ }
248
+ })
249
+ }
250
+ currentUploadedImageName = null
251
+ currentSelectedImage = null
252
  } else {
253
  addChatItemToList(ChatMessageModel(type, content, data, hasImage, image))
254
  sendNotification(content)
 
265
  message: String
266
  ) {
267
  addMessage(
268
+ type = TYPE_CHAT_RECEIVE, content = message
 
269
  )
270
  }
271
 
 
379
  showLoading(false)
380
  val apiResponse = resource.data
381
  when (apiResponse?.result?.program) {
382
+ TYPE_RESPONSE_MESSAGE -> addMessage(
383
+ TYPE_CHAT_RECEIVE, apiResponse.result.content.toString()
384
+ )
385
+
386
  TYPE_RESPONSE_BROWSER -> fetchResponseBrowser(apiResponse)
387
  TYPE_RESPONSE_CONTACT -> fetchResponseContact(apiResponse)
388
  TYPE_RESPONSE_IMAGE -> fetchResponseImage(apiResponse)
 
450
  }
451
 
452
  private fun fetchResponseAlarm(apiResponse: ApiResponse) {
453
+ val time: Time =
454
+ Converter.stringToTime(apiResponse.result.content.asJsonObject.get("time").asString)
455
  val label = apiResponse.result.content.asJsonObject.get("label").asString
456
  val props = ScheduleAlarmProps(time, label)
457
  val widgetDesc = JsonObject().apply {
 
478
 
479
  override fun sentHelpPrompt(prompt: String) {
480
  addMessage(
481
+ type = TYPE_CHAT_SENT, content = prompt
 
482
  )
483
  }
484
 
485
  override fun canceledHelpPrompt() {
486
  addMessage(
487
+ type = TYPE_CHAT_RECEIVE, content = "You canceled Help prompt."
 
488
  )
489
  }
490
 
491
  override fun doVoiceCall(phoneNumber: String) {
492
  addMessage(
493
+ type = TYPE_CHAT_RECEIVE, content = "You made a voice call to $phoneNumber"
 
494
  )
495
  }
496
 
497
  override fun doVideoCall(phoneNumber: String) {
498
  addMessage(
499
+ type = TYPE_CHAT_RECEIVE, content = "You made a video call to $phoneNumber"
 
500
  )
501
  }
502
 
 
505
  this.addProperty(PROPS_WIDGET_DESC, phoneNumber)
506
  }
507
  addMessage(
508
+ type = TYPE_CHAT_WIDGET, content = TYPE_WIDGET_SMS, data = widgetDesc
 
 
509
  )
510
  }
511
 
512
  override fun pickImage(isSuccess: Boolean, data: ByteArray?) {
513
+ if (!isSuccess) {
514
  addErrorMessage("Fail to pick image")
515
+ return
516
+ }
517
  viewModel.uploadImageToFirebase(data!!)
518
  .observe(viewLifecycleOwner, Observer { resource ->
519
  when (resource) {
 
545
 
546
  override fun cancelAlarm() {
547
  addMessage(
548
+ type = TYPE_CHAT_RECEIVE, content = "You canceled setting an alarm."
 
549
  )
550
  }
551
  }
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/ui/chat/viewmodel/ChatViewModel.kt CHANGED
@@ -12,6 +12,7 @@ import com.matthaigh27.chatgptwrapper.data.remote.requests.TrainContactsApiReque
12
  import com.matthaigh27.chatgptwrapper.data.remote.requests.TrainImageApiRequest
13
  import com.matthaigh27.chatgptwrapper.data.remote.responses.ApiResponse
14
  import com.matthaigh27.chatgptwrapper.data.remote.responses.EmptyResultApiResponse
 
15
  import com.matthaigh27.chatgptwrapper.data.repository.FirebaseRepository
16
  import com.matthaigh27.chatgptwrapper.data.repository.RemoteRepository
17
  import com.matthaigh27.chatgptwrapper.data.repository.RoomRepository
@@ -205,8 +206,8 @@ class ChatViewModel : ViewModel() {
205
  return state
206
  }
207
 
208
- fun getImageRelatedness(imageName: String, message: String): MutableLiveData<ApiResource<ApiResponse>> {
209
- val resource: MutableLiveData<ApiResource<ApiResponse>> = MutableLiveData()
210
  val request = ImageRelatednessApiRequest(
211
  image_name = imageName, message = message, confs = buildApiKeys()
212
  )
 
12
  import com.matthaigh27.chatgptwrapper.data.remote.requests.TrainImageApiRequest
13
  import com.matthaigh27.chatgptwrapper.data.remote.responses.ApiResponse
14
  import com.matthaigh27.chatgptwrapper.data.remote.responses.EmptyResultApiResponse
15
+ import com.matthaigh27.chatgptwrapper.data.remote.responses.ImageRelatenessApiResponse
16
  import com.matthaigh27.chatgptwrapper.data.repository.FirebaseRepository
17
  import com.matthaigh27.chatgptwrapper.data.repository.RemoteRepository
18
  import com.matthaigh27.chatgptwrapper.data.repository.RoomRepository
 
206
  return state
207
  }
208
 
209
+ fun getImageRelatedness(imageName: String, message: String): MutableLiveData<ApiResource<ImageRelatenessApiResponse>> {
210
+ val resource: MutableLiveData<ApiResource<ImageRelatenessApiResponse>> = MutableLiveData()
211
  val request = ImageRelatednessApiRequest(
212
  image_name = imageName, message = message, confs = buildApiKeys()
213
  )
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/ui/setting/view/SettingActivity.kt CHANGED
@@ -6,6 +6,7 @@ import android.view.View
6
  import android.view.View.OnClickListener
7
  import com.google.android.material.textfield.TextInputLayout
8
  import com.matthaigh27.chatgptwrapper.R
 
9
  import com.matthaigh27.chatgptwrapper.ui.base.BaseActivity
10
  import com.matthaigh27.chatgptwrapper.ui.chat.view.ChatActivity
11
 
@@ -15,6 +16,8 @@ class SettingActivity : BaseActivity() {
15
  private lateinit var txtPineconeEnv: TextInputLayout
16
  private lateinit var txtFirebaseKey: TextInputLayout
17
  private lateinit var txtTemperature: TextInputLayout
 
 
18
 
19
  override fun onCreate(savedInstanceState: Bundle?) {
20
  super.onCreate(savedInstanceState)
@@ -28,9 +31,14 @@ class SettingActivity : BaseActivity() {
28
  txtPineconeEnv = findViewById(R.id.txt_pinecone_env)
29
  txtFirebaseKey = findViewById(R.id.txt_firebase_key)
30
  txtTemperature = findViewById(R.id.txt_temperature)
 
 
31
 
32
  findViewById<View>(R.id.btn_setting_save).setOnClickListener { saveSettingData() }
33
  findViewById<View>(R.id.btn_back_chat).setOnClickListener { backToChatMain() }
 
 
 
34
  }
35
 
36
  private fun saveSettingData() {
@@ -38,6 +46,7 @@ class SettingActivity : BaseActivity() {
38
  val pineconeEnv = txtPineconeEnv.editText?.text.toString()
39
  val firebaseKey = txtFirebaseKey.editText?.text.toString()
40
  val temperature = txtTemperature.editText?.text.toString()
 
41
  }
42
 
43
  private fun backToChatMain() {
 
6
  import android.view.View.OnClickListener
7
  import com.google.android.material.textfield.TextInputLayout
8
  import com.matthaigh27.chatgptwrapper.R
9
+ import com.matthaigh27.chatgptwrapper.RisingApplication.Companion.appContext
10
  import com.matthaigh27.chatgptwrapper.ui.base.BaseActivity
11
  import com.matthaigh27.chatgptwrapper.ui.chat.view.ChatActivity
12
 
 
16
  private lateinit var txtPineconeEnv: TextInputLayout
17
  private lateinit var txtFirebaseKey: TextInputLayout
18
  private lateinit var txtTemperature: TextInputLayout
19
+ private lateinit var txtUUID: TextInputLayout
20
+ private lateinit var txtOpenAIKey: TextInputLayout
21
 
22
  override fun onCreate(savedInstanceState: Bundle?) {
23
  super.onCreate(savedInstanceState)
 
31
  txtPineconeEnv = findViewById(R.id.txt_pinecone_env)
32
  txtFirebaseKey = findViewById(R.id.txt_firebase_key)
33
  txtTemperature = findViewById(R.id.txt_temperature)
34
+ txtUUID = findViewById(R.id.txt_uuid)
35
+ txtOpenAIKey = findViewById(R.id.txt_openai_key)
36
 
37
  findViewById<View>(R.id.btn_setting_save).setOnClickListener { saveSettingData() }
38
  findViewById<View>(R.id.btn_back_chat).setOnClickListener { backToChatMain() }
39
+
40
+ val uuid = appContext.getUUID()
41
+ txtUUID.editText?.setText(uuid)
42
  }
43
 
44
  private fun saveSettingData() {
 
46
  val pineconeEnv = txtPineconeEnv.editText?.text.toString()
47
  val firebaseKey = txtFirebaseKey.editText?.text.toString()
48
  val temperature = txtTemperature.editText?.text.toString()
49
+ val openai = txtTemperature.editText?.text.toString()
50
  }
51
 
52
  private fun backToChatMain() {
Android/app/src/main/res/layout/activity_setting.xml CHANGED
@@ -47,10 +47,35 @@
47
  android:layout_width="match_parent"
48
  android:layout_height="0dp"
49
  android:orientation="vertical"
50
- android:padding="@dimen/spacing_tiny"
51
  app:layout_constraintBottom_toTopOf="@+id/ll_action"
52
  app:layout_constraintTop_toBottomOf="@+id/cl_header">
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  <com.google.android.material.textfield.TextInputLayout
55
  android:id="@+id/txt_pinecone_key"
56
  style="@style/SettingEditText"
 
47
  android:layout_width="match_parent"
48
  android:layout_height="0dp"
49
  android:orientation="vertical"
50
+ android:padding="@dimen/spacing_small"
51
  app:layout_constraintBottom_toTopOf="@+id/ll_action"
52
  app:layout_constraintTop_toBottomOf="@+id/cl_header">
53
 
54
+ <com.google.android.material.textfield.TextInputLayout
55
+ android:id="@+id/txt_uuid"
56
+ style="@style/SettingEditText"
57
+ android:layout_marginBottom="@dimen/spacing_tiny"
58
+ android:enabled="false"
59
+ android:hint="@string/label_setting_uuid">
60
+
61
+ <com.google.android.material.textfield.TextInputEditText
62
+ android:layout_width="match_parent"
63
+ android:layout_height="wrap_content"/>
64
+
65
+ </com.google.android.material.textfield.TextInputLayout>
66
+
67
+ <com.google.android.material.textfield.TextInputLayout
68
+ android:id="@+id/txt_openai_key"
69
+ style="@style/SettingEditText"
70
+ android:layout_marginBottom="@dimen/spacing_tiny"
71
+ android:hint="@string/label_setting_openai_key">
72
+
73
+ <com.google.android.material.textfield.TextInputEditText
74
+ android:layout_width="match_parent"
75
+ android:layout_height="wrap_content" />
76
+
77
+ </com.google.android.material.textfield.TextInputLayout>
78
+
79
  <com.google.android.material.textfield.TextInputLayout
80
  android:id="@+id/txt_pinecone_key"
81
  style="@style/SettingEditText"
Android/app/src/main/res/values/colors.xml CHANGED
@@ -3,9 +3,9 @@
3
  <color name="white">#ffffff</color>
4
  <color name="transparent">#00000000</color>
5
 
6
- <color name="color_primary_light">#f0f0f0</color>
7
- <color name="color_primary">#ebebeb</color>
8
- <color name="color_primary_dark">#707070</color>
9
  <color name="color_accent">#222222</color>
10
 
11
  <color name="bg_color_message_receive">#99DBA7</color>
 
3
  <color name="white">#ffffff</color>
4
  <color name="transparent">#00000000</color>
5
 
6
+ <color name="color_primary_light">#eeeeee</color>
7
+ <color name="color_primary">#e9e9e9</color>
8
+ <color name="color_primary_dark">#505050</color>
9
  <color name="color_accent">#222222</color>
10
 
11
  <color name="bg_color_message_receive">#99DBA7</color>
Android/app/src/main/res/values/strings.xml CHANGED
@@ -17,6 +17,8 @@
17
  <string name="title_chat_widget">widget title</string>
18
  <string name="title_chat_widget_sms">SMS</string>
19
 
 
 
20
  <string name="label_setting_pinecone_key">Pinecone Key</string>
21
  <string name="label_setting_pinecone_env">Pinecone Env</string>
22
  <string name="label_setting_firebase_key">Firebase Key</string>
 
17
  <string name="title_chat_widget">widget title</string>
18
  <string name="title_chat_widget_sms">SMS</string>
19
 
20
+ <string name="label_setting_uuid">uuid</string>
21
+ <string name="label_setting_openai_key">OpenAI Key</string>
22
  <string name="label_setting_pinecone_key">Pinecone Key</string>
23
  <string name="label_setting_pinecone_env">Pinecone Env</string>
24
  <string name="label_setting_firebase_key">Firebase Key</string>
Android/app/src/main/res/values/styles.xml CHANGED
@@ -10,6 +10,7 @@
10
  <item name="android:layout_width">match_parent</item>
11
  <item name="android:layout_height">wrap_content</item>
12
  <item name="boxStrokeWidth">@dimen/width_stroke_thin</item>
 
13
  </style>
14
 
15
 
 
10
  <item name="android:layout_width">match_parent</item>
11
  <item name="android:layout_height">wrap_content</item>
12
  <item name="boxStrokeWidth">@dimen/width_stroke_thin</item>
13
+ <item name="android:disabledAlpha">0.1</item>
14
  </style>
15
 
16