diff --git a/app/build.gradle b/app/build.gradle index d76ebdf20e..8154927e5b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -230,7 +230,7 @@ dependencies { implementation "io.noties.markwon:image:$markwon_version" implementation "io.noties.markwon:html:$markwon_version" implementation "io.noties.markwon:ext-tables:$markwon_version" - implementation(platform("org.jetbrains.kotlin:kotlin-bom:2.0.21")) + implementation(platform("org.jetbrains.kotlin:kotlin-bom:2.1.0")) implementation 'com.github.chrisbanes:PhotoView:2.3.0' } diff --git a/app/src/main/java/org/ole/planet/myplanet/MainApplication.kt b/app/src/main/java/org/ole/planet/myplanet/MainApplication.kt index 2ff8e10bde..a14ce8359e 100644 --- a/app/src/main/java/org/ole/planet/myplanet/MainApplication.kt +++ b/app/src/main/java/org/ole/planet/myplanet/MainApplication.kt @@ -121,7 +121,15 @@ class MainApplication : Application(), Application.ActivityLifecycleCallbacks { suspend fun isServerReachable(urlString: String): Boolean { return try { - val url = URL(urlString) + if (urlString.isBlank()) return false + + val formattedUrl = if (!urlString.startsWith("http://") && !urlString.startsWith("https://")) { + "http://$urlString" + } else { + urlString + } + + val url = URL(formattedUrl) val connection = withContext(Dispatchers.IO) { url.openConnection() } as HttpURLConnection diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/exam/TakeExamFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/exam/TakeExamFragment.kt index 20bb49b0a6..af0183729a 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/exam/TakeExamFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/exam/TakeExamFragment.kt @@ -189,7 +189,7 @@ class TakeExamFragment : BaseExamFragment(), View.OnClickListener, CompoundButto if (isRadio) { fragmentTakeExamBinding.groupChoices.addView(rdBtn) } else { - rdBtn.setTextColor(resources.getColor(R.color.daynight_textColor)) + rdBtn.setTextColor(ContextCompat.getColor(requireContext(), R.color.daynight_textColor)) rdBtn.buttonTintList = ContextCompat.getColorStateList(requireContext(), R.color.daynight_textColor) fragmentTakeExamBinding.llCheckbox.addView(rdBtn) } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/mylife/AdapterMyLife.kt b/app/src/main/java/org/ole/planet/myplanet/ui/mylife/AdapterMyLife.kt index 39234cecff..b47c19adb6 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/mylife/AdapterMyLife.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/mylife/AdapterMyLife.kt @@ -13,6 +13,7 @@ import android.widget.ImageView import android.widget.LinearLayout import android.widget.TextView import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import androidx.recyclerview.widget.RecyclerView import io.realm.Realm @@ -81,10 +82,10 @@ class AdapterMyLife(private val context: Context, private val myLifeList: List diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/team/teamMember/AdapterJoinedMember.kt b/app/src/main/java/org/ole/planet/myplanet/ui/team/teamMember/AdapterJoinedMember.kt index bdd392837e..3fec35d920 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/team/teamMember/AdapterJoinedMember.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/team/teamMember/AdapterJoinedMember.kt @@ -19,6 +19,7 @@ import org.ole.planet.myplanet.model.RealmTeamLog import org.ole.planet.myplanet.model.RealmUserModel import org.ole.planet.myplanet.service.UserProfileDbHandler import io.realm.Realm +import io.realm.Sort import org.ole.planet.myplanet.utilities.Utilities class AdapterJoinedMember(private val context: Context, private val list: List, private val mRealm: Realm, private val teamId: String) : RecyclerView.Adapter() { @@ -78,7 +79,7 @@ class AdapterJoinedMember(private val context: Context, private val list: List, isLoggedInUserTeamLeader: Boolean ) { - if (isLoggedInUserTeamLeader) { + if (isLoggedInUserTeamLeader && list.size>1) { rowJoinedUserBinding.icMore.visibility = View.VISIBLE rowJoinedUserBinding.icMore.setOnClickListener { val builder = AlertDialog.Builder(context, R.style.AlertDialogTheme) @@ -95,14 +96,20 @@ class AdapterJoinedMember(private val context: Context, private val list: List - if (position >= 0 && position < list.size) { when (i) { 0 -> { if (currentUser.id != list[position].id) { reject(list[position], position) } else { - Toast.makeText(context, R.string.cannot_remove_user, Toast.LENGTH_SHORT).show() + val nextOfKin= getNextOfKin() + if(nextOfKin!=null){ + makeLeader(nextOfKin) + reject(list[position], position) + } + else { + Toast.makeText(context, R.string.cannot_remove_user, Toast.LENGTH_SHORT).show() + } } } 1 -> { @@ -122,7 +129,29 @@ class AdapterJoinedMember(private val context: Context, private val list: List = mRealm.where(RealmMyTeam::class.java) + .equalTo("teamId", teamId) + .equalTo("isLeader", false) + .notEqualTo("status","archived") + .sort("createdDate", Sort.DESCENDING) + .findAll() + val successor = if (members.isNotEmpty()) members?.first() else null + if(successor==null){ + return null + } + else{ + val user= mRealm.where(RealmUserModel::class.java).equalTo("id", successor.userId).findFirst() + return user + } + return null + } + private fun makeLeader(userModel: RealmUserModel) { + if(userModel==null){ + Utilities.toast(context, context.getString(R.string.cannot_remove_user)) + return + } mRealm.executeTransaction { realm -> val team = realm.where(RealmMyTeam::class.java) .equalTo("teamId", teamId) @@ -134,6 +163,7 @@ class AdapterJoinedMember(private val context: Context, private val list: List diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index acd0f2004a..bdc706d8c1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -180,7 +180,7 @@ Showing reply of: Open Date mySurvey - User couldnot be removed + User could not be removed No Team members present to assign tasks No member selected. Please try again diff --git a/build.gradle b/build.gradle index da7baf0208..57419d3624 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { - kotlin_version = '2.0.21' + kotlin_version = '2.1.0' setup = [ compileSdk : 34, buildTools : "28.0.0",