Skip to content

Commit

Permalink
teams: smoother joining (fixes #4815) (#4826)
Browse files Browse the repository at this point in the history
Co-authored-by: Gideon Okuro <[email protected]>
Co-authored-by: dogi <[email protected]>
  • Loading branch information
3 people authored Dec 2, 2024
1 parent d9f25fd commit ba11826
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 26
targetSdkVersion 34
versionCode 2117
versionName "0.21.17"
versionCode 2118
versionName "0.21.18"
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 @@ -42,8 +42,34 @@ class TeamDetailFragment : BaseTeamFragment() {
fragmentTeamDetailBinding.subtitle.text = team?.type

if (!isMyTeam) {
fragmentTeamDetailBinding.llActionButtons.visibility = View.GONE
fragmentTeamDetailBinding.btnAddDoc.isEnabled = false
fragmentTeamDetailBinding.btnAddDoc.visibility = View.GONE
val currentTeam = team
if (currentTeam != null && !currentTeam._id.isNullOrEmpty()) {

val isUserRequested = currentTeam.requested(user?.id, mRealm)

if (isUserRequested) {
fragmentTeamDetailBinding.btnLeave.text = getString(R.string.requested)
fragmentTeamDetailBinding.btnLeave.isEnabled = false
} else {
fragmentTeamDetailBinding.btnLeave.text = getString(R.string.join)
fragmentTeamDetailBinding.btnLeave.setOnClickListener {
RealmMyTeam.requestToJoin(currentTeam._id!!, user, mRealm)
fragmentTeamDetailBinding.btnLeave.text = getString(R.string.requested)
fragmentTeamDetailBinding.btnLeave.isEnabled = false
}
}
} else {
throw IllegalStateException("Team or team ID is null, cannot proceed.")
}

} else {

fragmentTeamDetailBinding.btnAddDoc.isEnabled = true
fragmentTeamDetailBinding.btnAddDoc.visibility = View.VISIBLE
fragmentTeamDetailBinding.btnLeave.isEnabled = true
fragmentTeamDetailBinding.btnLeave.visibility = View.VISIBLE
fragmentTeamDetailBinding.btnLeave.setOnClickListener {
AlertDialog.Builder(requireContext()).setMessage(R.string.confirm_exit)
.setPositiveButton(R.string.yes) { _: DialogInterface?, _: Int ->
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_team_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<Button
android:id="@+id/btn_leave"
style="@style/YellowButtons"
android:layout_width="59dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/leave" />
Expand Down

0 comments on commit ba11826

Please sign in to comment.