Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit f8bb4725 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

refactor: implement UI logic to show/hide nsfw rating

Improved app text color and icon color in dark mode in app details screen.
parent 278ddf85
Loading
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
package foundation.e.apps.data

class ParentalControlRepository {
}
 No newline at end of file
+15 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ data class Application(
    val isFDroidApp: Boolean = false,
    val contentRating: ContentRating = ContentRating(),
    @SerializedName(value = "antifeature")
    val antiFeatures: Map<String, Map<String,String>> = emptyMap(),
    val antiFeatures: AntiFeatures? = null, // FIXME: Update the model to match backend response structure
) {
    fun updateType() {
        this.type = if (this.is_pwa) PWA else NATIVE
@@ -119,6 +119,20 @@ data class Application(
    }
}

data class AntiFeatures(
    @SerializedName("NSFW")
    val nsfw: String?,

    @SerializedName("NonFreeAssets")
    val nonFreeAssets: String?,

    @SerializedName("NonFreeNet")
    val nonFreeNet: String?,

    @SerializedName("Tracking")
    val tracking: String?
)

val Application.shareUri: Uri
    get() = when (type) {
        PWA -> Uri.parse(url)
+33 −8
Original line number Diff line number Diff line
@@ -234,13 +234,6 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {

        collectState()

        binding.titleInclude.nsfwMessage.setOnClickListener {
            ApplicationDialogFragment(
                title = getString(R.string.nsfw_dialog_title),
                message = getString(R.string.nsfw_dialog_message),
                drawableResId = R.drawable.visibility_off
            ).show(childFragmentManager, TAG)
        }
    }

    private fun collectState() {
@@ -440,6 +433,35 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
                appIcon.load(it.icon_image_path)
            }
        }

        updateAntiFeaturesUi(it)
    }

    private fun updateAntiFeaturesUi(app: Application) {
        val isNsfwApp =
            app.antiFeatures?.nsfw != null // nsfw can have empty value, so check only for null

        Timber.tag("Anti-features").i("${app.name} has anti-features?: $isNsfwApp")

        if (isNsfwApp) {
            with(binding.titleInclude) {
                antiFeature.apply {
                    isVisible = true
                    text = getString(R.string.nsfw)
                }

                antiFeatureInfoLayout.apply {
                    isVisible = true
                    setOnClickListener {
                        ApplicationDialogFragment(
                            title = getString(R.string.nsfw_dialog_title),
                            message = getString(R.string.nsfw_dialog_message),
                            drawableResId = R.drawable.ic_visibility_off
                        ).show(childFragmentManager, TAG)
                    }
                }
            }
        }
    }

    private fun updateCategoryTitle(app: Application) {
@@ -451,11 +473,14 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
                catText == "web_games" -> catText = getString(R.string.games) // PWA games
            }

            catText = catText.replace("_", " ")
            catText = formatCategoryText(catText)
            categoryTitle.text = catText
        }
    }

    private fun formatCategoryText(catText: String) = catText.replace("_", " ")
        .replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }

    private fun setupScreenshotRVAdapter() {
        screenshotsRVAdapter = ApplicationScreenshotsRVAdapter(origin)
        binding.recyclerView.apply {
+27 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2024 MURENA SAS
  ~
  ~ This program is free software: you can redistribute it and/or modify
  ~ it under the terms of the GNU General Public License as published by
  ~ the Free Software Foundation, either version 3 of the License, or
  ~ (at your option) any later version.
  ~
  ~ This program is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~ GNU General Public License for more details.
  ~
  ~ You should have received a copy of the GNU General Public License
  ~ along with this program.  If not, see <https://www.gnu.org/licenses/>.
  ~
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="25dp"
    android:viewportWidth="24"
    android:viewportHeight="25">
  <path
      android:pathData="M12,6.475C15.79,6.475 19.17,8.605 20.82,11.975C20.23,13.195 19.4,14.245 18.41,15.095L19.82,16.505C21.21,15.275 22.31,13.735 23,11.975C21.27,7.585 17,4.475 12,4.475C10.73,4.475 9.51,4.675 8.36,5.045L10.01,6.695C10.66,6.565 11.32,6.475 12,6.475ZM10.93,7.615L13,9.685C13.57,9.935 14.03,10.395 14.28,10.965L16.35,13.035C16.43,12.695 16.49,12.335 16.49,11.965C16.5,9.485 14.48,7.475 12,7.475C11.63,7.475 11.28,7.525 10.93,7.615ZM2.01,4.345L4.69,7.025C3.06,8.305 1.77,10.005 1,11.975C2.73,16.365 7,19.475 12,19.475C13.52,19.475 14.98,19.185 16.32,18.655L19.74,22.075L21.15,20.665L3.42,2.925L2.01,4.345ZM9.51,11.845L12.12,14.455C12.08,14.465 12.04,14.475 12,14.475C10.62,14.475 9.5,13.355 9.5,11.975C9.5,11.925 9.51,11.895 9.51,11.845ZM6.11,8.445L7.86,10.195C7.63,10.745 7.5,11.345 7.5,11.975C7.5,14.455 9.52,16.475 12,16.475C12.63,16.475 13.23,16.345 13.77,16.115L14.75,17.095C13.87,17.335 12.95,17.475 12,17.475C8.21,17.475 4.83,15.345 3.18,11.975C3.88,10.545 4.9,9.365 6.11,8.445Z"
      android:fillColor="@color/color_icon_app_details"/>
</vector>
−313 B
Loading image diff...
Loading