Skip to content

Commit

Permalink
community: smoother services info (fixes #5006) (#5016)
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 Jan 16, 2025
1 parent 9aae636 commit 8862598
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 29 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 2208
versionName "0.22.8"
versionCode 2209
versionName "0.22.9"
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 @@ -50,11 +50,19 @@ class ServicesFragment : BaseTeamFragment() {

if (links?.size == 0) {
fragmentServicesBinding.llServices.visibility = View.GONE
fragmentServicesBinding.tvNoLinks.visibility = View.VISIBLE
} else {
fragmentServicesBinding.llServices.visibility = View.VISIBLE
}

val description = team?.description ?: ""
fragmentServicesBinding.llServices.visibility = View.VISIBLE
fragmentServicesBinding.tvDescription.visibility = View.VISIBLE
if (description.isEmpty()) {
fragmentServicesBinding.tvDescription.visibility = View.GONE
fragmentServicesBinding.tvNoDescription.visibility = View.VISIBLE
} else {
fragmentServicesBinding.tvDescription.visibility = View.VISIBLE
fragmentServicesBinding.tvNoDescription.visibility = View.GONE
}
val markdownContentWithLocalPaths = CourseStepFragment.prependBaseUrlToImages(description, "file://${MainApplication.context.getExternalFilesDir(null)}/ole/")
setMarkdownText(fragmentServicesBinding.tvDescription, markdownContentWithLocalPaths)
setRecyclerView(links)
Expand All @@ -75,25 +83,27 @@ class ServicesFragment : BaseTeamFragment() {

private fun setRecyclerView(links: RealmResults<RealmMyTeam>?) {
fragmentServicesBinding.llServices.removeAllViews()
links?.forEach { team ->
val b: TextView = LayoutInflater.from(activity).inflate(R.layout.button_single, fragmentServicesBinding.llServices, false) as TextView
b.setPadding(8, 8, 8, 8)
b.text = team.title
b.setOnClickListener {
val route = team.route?.split("/")
if (route != null) {
if (route.size >= 3) {
val f = TeamDetailFragment()
val c = Bundle()
val teamObject = mRealm.where(RealmMyTeam::class.java)?.equalTo("_id", route[3])?.findFirst()
c.putString("id", route[3])
teamObject?.isMyTeam(user?.id, mRealm)?.let { it1 -> c.putBoolean("isMyTeam", it1) }
f.arguments = c
(context as OnHomeItemClickListener).openCallFragment(f)
if (links != null) {
links.forEach { team ->
val b: TextView = LayoutInflater.from(activity).inflate(R.layout.button_single, fragmentServicesBinding.llServices, false) as TextView
b.setPadding(8, 8, 8, 8)
b.text = team.title
b.setOnClickListener {
val route = team.route?.split("/")
if (route != null) {
if (route.size >= 3) {
val f = TeamDetailFragment()
val c = Bundle()
val teamObject = mRealm.where(RealmMyTeam::class.java)?.equalTo("_id", route[3])?.findFirst()
c.putString("id", route[3])
teamObject?.isMyTeam(user?.id, mRealm)?.let { it1 -> c.putBoolean("isMyTeam", it1) }
f.arguments = c
(context as OnHomeItemClickListener).openCallFragment(f)
}
}
}
fragmentServicesBinding.llServices.addView(b)
}
fragmentServicesBinding.llServices.addView(b)
}
}
}
5 changes: 2 additions & 3 deletions app/src/main/res/layout/button_single.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
android:background="@drawable/border"
android:orientation="vertical"
android:padding="@dimen/padding_large"
android:textColor="@color/md_black_1000"
android:textColor="@color/daynight_textColor"
android:textSize="18sp">

</TextView>
</TextView>
46 changes: 40 additions & 6 deletions app/src/main/res/layout/fragment_services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,63 @@

<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent">

<TextView
android:id="@+id/tv_description"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/padding_normal"
android:gravity="center"
android:textColor="@color/daynight_textColor"
android:textSize="@dimen/text_size_large"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvNoDescription"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:text="No description available"
android:textColor="@color/daynight_textColor"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_description"/>
<TextView
android:id="@+id/tvNoLinks"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:text="No links available"
android:textColor="@color/daynight_textColor"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvNoDescription"/>
<LinearLayout
android:id="@+id/ll_services"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/padding_normal"
android:orientation="vertical"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_description" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvNoLinks"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

Expand All @@ -39,6 +73,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:padding="16dp"
android:layout_margin="16dp"
android:src="@drawable/ic_add" />
</FrameLayout>

0 comments on commit 8862598

Please sign in to comment.