Skip to content

Commit

Permalink
chat: smoother context flow (fixes #3411) (#3413)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Apr 29, 2024
1 parent 9ca61bf commit 9a5a635
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 41 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1499
versionName "0.14.99"
versionCode 1500
versionName "0.15.0"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,27 @@ class ChatDetailFragment : Fragment() {
fragmentChatDetailBinding.tvOpenai.visibility = View.VISIBLE
fragmentChatDetailBinding.view1.visibility = View.VISIBLE

aiName = getString(R.string.openai)
aiModel = "gpt-3.5-turbo"
fragmentChatDetailBinding.tvOpenai.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
fragmentChatDetailBinding.tvOpenai.setTextColor(ContextCompat.getColor(requireContext(), R.color.textColorPrimary))

fragmentChatDetailBinding.tvOpenai.setOnClickListener {
if (isAdded) {
aiName = getString(R.string.openai)
aiModel = "gpt-3.5-turbo"
fragmentChatDetailBinding.tvOpenai.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
fragmentChatDetailBinding.tvOpenai.setTextColor(ContextCompat.getColor(requireContext(), R.color.textColorPrimary))

fragmentChatDetailBinding.tvPerplexity.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.disable_color))
fragmentChatDetailBinding.tvPerplexity.setTextColor(ContextCompat.getColor(requireContext(), R.color.md_black_1000))
fragmentChatDetailBinding.tvOpenai.setOnClickListener {
fragmentChatDetailBinding.tvOpenai.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
fragmentChatDetailBinding.tvOpenai.setTextColor(ContextCompat.getColor(requireContext(), R.color.textColorPrimary))

fragmentChatDetailBinding.tvGemini.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.disable_color))
fragmentChatDetailBinding.tvGemini.setTextColor(ContextCompat.getColor(requireContext(), R.color.md_black_1000))
fragmentChatDetailBinding.tvPerplexity.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.disable_color))
fragmentChatDetailBinding.tvPerplexity.setTextColor(ContextCompat.getColor(requireContext(), R.color.md_black_1000))

clearChatDetail()
fragmentChatDetailBinding.textGchatIndicator.visibility = View.GONE
aiName = getString(R.string.openai)
aiModel = "gpt-3.5-turbo"
fragmentChatDetailBinding.tvGemini.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.disable_color))
fragmentChatDetailBinding.tvGemini.setTextColor(ContextCompat.getColor(requireContext(), R.color.md_black_1000))

clearChatDetail()
fragmentChatDetailBinding.textGchatIndicator.visibility = View.GONE
aiName = getString(R.string.openai)
aiModel = "gpt-3.5-turbo"
}
}
} else {
fragmentChatDetailBinding.tvOpenai.visibility = View.GONE
Expand All @@ -177,27 +179,29 @@ class ChatDetailFragment : Fragment() {
fragmentChatDetailBinding.tvPerplexity.visibility = View.VISIBLE
fragmentChatDetailBinding.view2.visibility = View.VISIBLE

if (!aiProvidersResponse.openai) {
aiName = getString(R.string.perplexity)
aiModel = "pplx-7b-online"
fragmentChatDetailBinding.tvPerplexity.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
fragmentChatDetailBinding.tvPerplexity.setTextColor(ContextCompat.getColor(requireContext(), R.color.textColorPrimary))
}

fragmentChatDetailBinding.tvPerplexity.setOnClickListener {
fragmentChatDetailBinding.tvPerplexity.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
fragmentChatDetailBinding.tvPerplexity.setTextColor(ContextCompat.getColor(requireContext(), R.color.textColorPrimary))

fragmentChatDetailBinding.tvOpenai.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.disable_color))
fragmentChatDetailBinding.tvOpenai.setTextColor(ContextCompat.getColor(requireContext(), R.color.md_black_1000))

fragmentChatDetailBinding.tvGemini.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.disable_color))
fragmentChatDetailBinding.tvGemini.setTextColor(ContextCompat.getColor(requireContext(), R.color.md_black_1000))

clearChatDetail()
fragmentChatDetailBinding.textGchatIndicator.visibility = View.GONE
aiName = getString(R.string.perplexity)
aiModel = "pplx-7b-online"
if (isAdded) {
if (!aiProvidersResponse.openai) {
aiName = getString(R.string.perplexity)
aiModel = "pplx-7b-online"
fragmentChatDetailBinding.tvPerplexity.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
fragmentChatDetailBinding.tvPerplexity.setTextColor(ContextCompat.getColor(requireContext(), R.color.textColorPrimary))
}

fragmentChatDetailBinding.tvPerplexity.setOnClickListener {
fragmentChatDetailBinding.tvPerplexity.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
fragmentChatDetailBinding.tvPerplexity.setTextColor(ContextCompat.getColor(requireContext(), R.color.textColorPrimary))

fragmentChatDetailBinding.tvOpenai.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.disable_color))
fragmentChatDetailBinding.tvOpenai.setTextColor(ContextCompat.getColor(requireContext(), R.color.md_black_1000))

fragmentChatDetailBinding.tvGemini.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.disable_color))
fragmentChatDetailBinding.tvGemini.setTextColor(ContextCompat.getColor(requireContext(), R.color.md_black_1000))

clearChatDetail()
fragmentChatDetailBinding.textGchatIndicator.visibility = View.GONE
aiName = getString(R.string.perplexity)
aiModel = "pplx-7b-online"
}
}
} else {
fragmentChatDetailBinding.tvPerplexity.visibility = View.GONE
Expand All @@ -206,10 +210,12 @@ class ChatDetailFragment : Fragment() {

if (aiProvidersResponse.gemini) {
if (!aiProvidersResponse.openai && !aiProvidersResponse.perplexity) {
aiName = getString(R.string.gemini)
aiModel = "gemini-pro"
fragmentChatDetailBinding.tvGemini.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
fragmentChatDetailBinding.tvGemini.setTextColor(ContextCompat.getColor(requireContext(), R.color.textColorPrimary))
if (isAdded) {
aiName = getString(R.string.gemini)
aiModel = "gemini-pro"
fragmentChatDetailBinding.tvGemini.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
fragmentChatDetailBinding.tvGemini.setTextColor(ContextCompat.getColor(requireContext(), R.color.textColorPrimary))
}
}

fragmentChatDetailBinding.tvGemini.visibility = View.VISIBLE
Expand Down

0 comments on commit 9a5a635

Please sign in to comment.