Skip to content

Commit

Permalink
Merge branch 'master' into 3775-version-code-deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
dogi authored Jul 9, 2024
2 parents 5b8764b + 50195c5 commit a8f78b2
Show file tree
Hide file tree
Showing 30 changed files with 415 additions and 325 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
matrix:
build: [default, lite]
env:
FILES: |
LITES: |
app/src/main/AndroidManifest.xml
app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt
app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt
Expand All @@ -30,9 +30,9 @@ jobs:
- name: check for .lite diffs
if: matrix.build == 'lite'
run: |
echo "${{ env.FILES }}" | xargs -n 1 | while read file; do
echo "${{ env.LITES }}" | xargs -n 1 | while read file; do
ls -al $file*
diff "$file" "$file.lite" || true
diff <(sed 's/^\s*\/\///; s/^\s*<!--//; s/-->\s*$//' "$file") <(sed 's/^\s*\/\///; s/^\s*<!--//; s/-->\s*$//' "$file.lite")
done
- name: setup JDK 17
Expand All @@ -52,12 +52,12 @@ jobs:
- name: diff the code to get lite
if: matrix.build == 'lite'
run: |
echo "${{ env.FILES }}" | xargs -n 1 | while read file; do
ls -al app/build.gradle
sed -i 's/\(versionName "[0-9.]\+\)"/\1-lite"/' app/build.gradle
echo "${{ env.LITES }}" | xargs -n 1 | while read file; do
ls -al $file*
cp "${file}.lite" "$file"
done
ls -al app/build.gradle
sed -i 's/\(versionName "[0-9.]\+\)"/\1-lite"/' app/build.gradle
- name: build debug as test
run: ./gradlew assembleDebug --configuration-cache --no-daemon
31 changes: 17 additions & 14 deletions .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ jobs:
matrix:
build: [default, lite]
env:
FILES: |
LITES: |
app/src/main/AndroidManifest.xml
app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt
app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt
app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt
OUTPUTS: |
.apk
.apk.sha256
.aab
.aab.sha256
steps:
- name: checkout repository code
Expand All @@ -44,13 +49,13 @@ jobs:
- name: diff the code to get lite
if: matrix.build == 'lite'
run: |
echo "${{ env.FILES }}" | xargs -n 1 | while read file; do
echo ANDROID_VERSION_LITE=$(grep -oP 'versionName "\K[^\"]+' app/build.gradle) >> $GITHUB_ENV
ls -al app/build.gradle
sed -i 's/\(versionName "[0-9.]\+\)"/\1-lite"/' app/build.gradle
echo "${{ env.LITES }}" | xargs -n 1 | while read file; do
ls -al $file*
cp "${file}.lite" "$file"
done
ls -al app/build.gradle
echo ANDROID_VERSION_LITE=$(grep -oP 'versionName "\K[^\"]+' app/build.gradle) >> $GITHUB_ENV
sed -i 's/\(versionName "[0-9.]\+\)"/\1-lite"/' app/build.gradle
- name: build release APK and AAB
run: |
Expand Down Expand Up @@ -108,12 +113,11 @@ jobs:
- name: rename APK and AAB with version and branch for artifact
if: github.event_name == 'workflow_dispatch'
run: |
echo "BRANCHNAME=${GITHUB_REF##*/}" >> $GITHUB_ENV
mv output/myPlanet.apk output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.apk
mv output/myPlanet.apk.sha256 output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.apk.sha256
mv output/myPlanet.aab output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.aab
mv output/myPlanet.aab.sha256 output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.aab.sha256
echo "${{ env.OUTPUTS }}" | xargs -n 1 | while read type; do
mv "output/myPlanet${type}" "output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${GITHUB_REF##*/}${type}"
done
ls -alR output
echo "BRANCHNAME=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: upload APK and AAB as build artifact
if: github.event_name == 'workflow_dispatch'
Expand All @@ -126,10 +130,9 @@ jobs:
- name: pre-process files and tag for lite version
if: github.event_name != 'workflow_dispatch' && matrix.build == 'lite'
run: |
mv output/myPlanet.apk output/myPlanet-lite.apk
mv output/myPlanet.apk.sha256 output/myPlanet-lite.apk.sha256
mv output/myPlanet.aab output/myPlanet-lite.aab
mv output/myPlanet.aab.sha256 output/myPlanet-lite.aab.sha256
echo "${{ env.OUTPUTS }}" | xargs -n 1 | while read type; do
mv "output/myPlanet${type}" "output/myPlanet-lite${type}"
done
echo "ANDROID_VERSION_NAME=${ANDROID_VERSION_LITE}" >> $GITHUB_ENV
- name: release APK and AAB on GitHub
Expand Down
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 1655
versionName "0.16.55"
versionCode 1665
versionName "0.16.65"
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 @@ -298,6 +298,7 @@ abstract class BaseRecyclerFragment<LI> : BaseRecyclerParentFragment<Any?>(), On
"submission" -> (v as TextView).setText(R.string.no_submissions)
"teams" -> (v as TextView).setText(R.string.no_teams)
"chatHistory" -> (v as TextView).setText(R.string.no_chats)
"feedback" -> (v as TextView).setText(R.string.no_feedback)
else -> (v as TextView).setText(R.string.no_data_available_please_check_and_try_again)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ open class RealmChatHistory : RealmObject() {
var aiProvider: String? = null
var title: String? = null
var createdDate: String? = null
var updatedDate: String? = null
var conversations: RealmList<Conversation>? = null
companion object {
@JvmStatic
Expand All @@ -33,6 +34,7 @@ open class RealmChatHistory : RealmObject() {
chatHistory._id = JsonUtils.getString("_id", act)
chatHistory.title = JsonUtils.getString("title", act)
chatHistory.createdDate = JsonUtils.getString("createdDate", act)
chatHistory.updatedDate = JsonUtils.getString("updatedDate", act)
chatHistory.user = JsonUtils.getString("user", act)
chatHistory.aiProvider = JsonUtils.getString("aiProvider", act)
chatHistory.conversations = parseConversations(mRealm, JsonUtils.getJsonArray("conversations", act))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ open class RealmUserModel : RealmObject() {
@JvmField
var birthPlace: String? = null
@JvmField
var communityName: String? = null
@JvmField
var userImage: String? = null
@JvmField
var key: String? = null
Expand Down Expand Up @@ -172,7 +170,7 @@ open class RealmUserModel : RealmObject() {
}

override fun toString(): String {
return "$firstName $lastName"
return "$name"
}

companion object {
Expand Down
31 changes: 16 additions & 15 deletions app/src/main/java/org/ole/planet/myplanet/ui/chat/ChatAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import org.ole.planet.myplanet.R
import org.ole.planet.myplanet.databinding.ItemAiResponseMessageBinding
import org.ole.planet.myplanet.databinding.ItemUserMessageBinding

Expand All @@ -16,8 +17,8 @@ class ChatAdapter(private val chatList: ArrayList<String>, val context: Context,
private lateinit var textAiMessageBinding: ItemAiResponseMessageBinding
var responseSource: Int = RESPONSE_SOURCE_UNKNOWN

private val VIEW_TYPE_QUERY = 1
private val VIEW_TYPE_RESPONSE = 2
private val viewTypeQuery = 1
private val viewTypeResponse = 2
companion object {
const val RESPONSE_SOURCE_SHARED_VIEW_MODEL = 1
const val RESPONSE_SOURCE_NETWORK = 2
Expand All @@ -29,36 +30,36 @@ class ChatAdapter(private val chatList: ArrayList<String>, val context: Context,
}
}

class ResponseViewHolder(private val textAiMessageBinding: ItemAiResponseMessageBinding) : RecyclerView.ViewHolder(textAiMessageBinding.root) {
class ResponseViewHolder(private val textAiMessageBinding: ItemAiResponseMessageBinding, val context: Context) : RecyclerView.ViewHolder(textAiMessageBinding.root) {
fun bind(response: String, responseSource: Int) {
if(responseSource == RESPONSE_SOURCE_NETWORK){
val typingDelayMillis = 10L
val typingAnimationDurationMillis = response.length * typingDelayMillis
textAiMessageBinding.textGchatMessageOther.text = ""
textAiMessageBinding.textGchatMessageOther.text = context.getString(R.string.empty_text)
Handler(Looper.getMainLooper()).postDelayed({
animateTyping(response, typingDelayMillis)
animateTyping(response)
}, typingAnimationDurationMillis)
} else if(responseSource == RESPONSE_SOURCE_SHARED_VIEW_MODEL){
if (response != "") {
if (response.isNotEmpty()) {
textAiMessageBinding.textGchatMessageOther.text = response
} else{
textAiMessageBinding.textGchatMessageOther.visibility = View.GONE
}
}
}

private fun animateTyping(response: String, typingDelayMillis: Long) {
private fun animateTyping(response: String) {
var currentIndex = 0
val typingRunnable = object : Runnable {
override fun run() {
if (currentIndex < response.length) {
textAiMessageBinding.textGchatMessageOther.text = response.substring(0, currentIndex + 1)
currentIndex++
Handler(Looper.getMainLooper()).postDelayed(this, typingDelayMillis)
Handler(Looper.getMainLooper()).postDelayed(this, 10L)
}
}
}
Handler(Looper.getMainLooper()).postDelayed(typingRunnable, typingDelayMillis)
Handler(Looper.getMainLooper()).postDelayed(typingRunnable, 10L)
}
}

Expand Down Expand Up @@ -90,18 +91,18 @@ class ChatAdapter(private val chatList: ArrayList<String>, val context: Context,
}

override fun getItemViewType(position: Int): Int {
return if (position % 2 == 0) VIEW_TYPE_QUERY else VIEW_TYPE_RESPONSE
return if (position % 2 == 0) viewTypeQuery else viewTypeResponse
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return when (viewType) {
VIEW_TYPE_QUERY -> {
viewTypeQuery -> {
textUserMessageBinding = ItemUserMessageBinding.inflate(LayoutInflater.from(context), parent, false)
QueryViewHolder(textUserMessageBinding)
}
VIEW_TYPE_RESPONSE -> {
viewTypeResponse -> {
textAiMessageBinding = ItemAiResponseMessageBinding.inflate(LayoutInflater.from(context), parent, false)
ResponseViewHolder(textAiMessageBinding)
ResponseViewHolder(textAiMessageBinding, context)
}
else -> throw IllegalArgumentException("Invalid view type")
}
Expand All @@ -111,11 +112,11 @@ class ChatAdapter(private val chatList: ArrayList<String>, val context: Context,
val chatItem = chatList[position]
Log.d("ChatAdapter", "chatList: $chatList")
when (holder.itemViewType) {
VIEW_TYPE_QUERY -> {
viewTypeQuery -> {
val queryViewHolder = holder as QueryViewHolder
queryViewHolder.bind(chatItem)
}
VIEW_TYPE_RESPONSE -> {
viewTypeResponse -> {
val responseViewHolder = holder as ResponseViewHolder
responseViewHolder.bind(chatItem, responseSource)
}
Expand Down
Loading

0 comments on commit a8f78b2

Please sign in to comment.