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

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

refactor: update Application data class to map anti-features response

Removed anti-features label from title panel as per the discussion in Figma.
parent f8bb4725
Loading
Loading
Loading
Loading
Loading
+2 −16
Original line number Diff line number Diff line
@@ -103,8 +103,8 @@ data class Application(
    @SerializedName(value = "on_fdroid")
    val isFDroidApp: Boolean = false,
    val contentRating: ContentRating = ContentRating(),
    @SerializedName(value = "antifeature")
    val antiFeatures: AntiFeatures? = null, // FIXME: Update the model to match backend response structure
    @SerializedName(value = "antifeatures")
    val antiFeatures: List<Map<String, String>> = emptyList()
) {
    fun updateType() {
        this.type = if (this.is_pwa) PWA else NATIVE
@@ -119,20 +119,6 @@ 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)
+3 −9
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
        private const val PRIVACY_GUIDELINE_URL = "https://doc.e.foundation/privacy_score"
        private const val REQUEST_EXODUS_REPORT_URL =
            "https://reports.exodus-privacy.eu.org/en/analysis/submit#"
        private const val KEY_ANTI_FEATURES_NSFW = "NSFW"
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -284,7 +285,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
            }
            appTrackers.setOnClickListener {
                val fusedApp = applicationViewModel.getFusedApp()
                var trackers =
                val trackers =
                    buildTrackersString(fusedApp)

                ApplicationDialogFragment(
@@ -439,17 +440,10 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {

    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")
            app.antiFeatures.find { antiFeature -> antiFeature.containsKey(KEY_ANTI_FEATURES_NSFW) } != null

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

                antiFeatureInfoLayout.apply {
                    isVisible = true
                    setOnClickListener {
+2 −21
Original line number Diff line number Diff line
@@ -119,24 +119,6 @@
        android:background="@color/colorBackground"
        android:backgroundTint="@color/colorBackground">

        <TextView
            android:id="@+id/antiFeature"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="10dp"
            android:background="@drawable/bg_tag_rounded"
            android:paddingStart="10dp"
            android:paddingTop="4dp"
            android:paddingEnd="10dp"
            android:paddingBottom="4dp"
            android:textAllCaps="false"
            android:textColor="#626262"
            android:textSize="14sp"
            android:visibility="gone"
            tools:text="NSFW"
            tools:visibility="visible" />


    <TextView
            android:id="@+id/sourceTag"
            android:layout_width="wrap_content"
@@ -173,5 +155,4 @@

    </LinearLayout>


</LinearLayout>
+1 −1
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@
    <string name="notification_channel_desc">Split Install channel</string>
    <string name="sign_in">Sign in</string>
    <string name="ignore">Ignore</string>
    <string name="nsfw">NSFW</string>
    <!-- F-Droid Anti-Features-->
    <string name="nsfw_dialog_title">Content Warning</string>
    <string name="nsfw_dialog_message">The app may contain nudity, profanity, slurs, violence, intense sexuality, political incorrectness, or other potentially disturbing subject matter. This is especially relevant in environments like workplaces, schools, religious and family settings.</string>
</resources>
 No newline at end of file