Skip to content

Commit

Permalink
teams: smoother members removal (fixes #4802) (#4805)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
deeppp15 and dogi authored Nov 27, 2024
1 parent 0f80a0e commit c71bedc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 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 2111
versionName "0.21.11"
versionCode 2112
versionName "0.21.12"
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 @@ -82,7 +82,11 @@ class AdapterJoinedMember(private val context: Context, private val list: List<R
rowJoinedUserBinding.icMore.visibility = View.VISIBLE
rowJoinedUserBinding.icMore.setOnClickListener {
val builder = AlertDialog.Builder(context, R.style.AlertDialogTheme)
val adapter = object : ArrayAdapter<CharSequence>(context, android.R.layout.simple_list_item_1, overflowMenuOptions) {
val adapter = object : ArrayAdapter<CharSequence>(
context,
android.R.layout.simple_list_item_1,
overflowMenuOptions
) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
val view = super.getView(position, convertView, parent) as TextView
val color = ContextCompat.getColor(context, R.color.daynight_textColor)
Expand All @@ -91,11 +95,22 @@ class AdapterJoinedMember(private val context: Context, private val list: List<R
}
}
builder.setAdapter(adapter) { _, i ->
if (i >= 0 && i < list.size) {
if (i == 0) {
reject(list[i], i)
} else {
makeLeader(list[i])

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()
}
}
1 -> {
makeLeader(list[position])
}
else -> {
Toast.makeText(context, R.string.cannot_remove_user, Toast.LENGTH_SHORT).show()
}
}
} else {
Toast.makeText(context, R.string.cannot_remove_user, Toast.LENGTH_SHORT).show()
Expand Down

0 comments on commit c71bedc

Please sign in to comment.