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

Commit 1ca98e6e authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

Merge branch '2112-block_nsfw_app_download' into 'main'

Issue 2112 - block nsfw app download

See merge request !457
parents a5555a3f f66620be
Loading
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import foundation.e.apps.data.login.AuthObject
import foundation.e.apps.data.login.exceptions.GPlayLoginException
import foundation.e.apps.databinding.FragmentApplicationBinding
import foundation.e.apps.di.CommonUtilsModule.LIST_OF_NULL
import foundation.e.apps.domain.ValidateAppAgeLimitUseCase.Companion.KEY_ANTI_FEATURES_NSFW
import foundation.e.apps.install.download.data.DownloadProgress
import foundation.e.apps.install.pkg.AppLoungePackageManager
import foundation.e.apps.install.pkg.PWAManager
@@ -433,6 +434,28 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
                appIcon.load(it.icon_image_path)
            }
        }

        updateAntiFeaturesUi(it)
    }

    private fun updateAntiFeaturesUi(app: Application) {
        val isNsfwApp =
            app.antiFeatures.find { antiFeature -> antiFeature.containsKey(KEY_ANTI_FEATURES_NSFW) } != null

        val isKnownNsfwApp = applicationViewModel.isKnownNsfwApp(app)

        if (!isNsfwApp && !isKnownNsfwApp) return

        binding.titleInclude.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) {
+6 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import foundation.e.apps.R
import foundation.e.apps.data.application.ApplicationRepository
import foundation.e.apps.data.application.data.Application
import foundation.e.apps.data.application.data.shareUri
import foundation.e.apps.data.blockedApps.ContentRatingsRepository
import foundation.e.apps.data.enums.Origin
import foundation.e.apps.data.enums.ResultStatus
import foundation.e.apps.data.enums.Status
@@ -55,6 +56,7 @@ class ApplicationViewModel @Inject constructor(
    private val applicationRepository: ApplicationRepository,
    private val playStoreRepository: PlayStoreRepository,
    private val appManagerWrapper: AppManagerWrapper,
    private val contentRatingsRepository: ContentRatingsRepository,
) : LoadingViewModel() {

    val applicationLiveData: MutableLiveData<Pair<Application, ResultStatus>> = MutableLiveData()
@@ -235,6 +237,10 @@ class ApplicationViewModel @Inject constructor(
    }

    fun isOpenSourceSelected() = applicationRepository.isOpenSourceSelected()

    fun isKnownNsfwApp(app: Application): Boolean {
        return app.package_name in contentRatingsRepository.fDroidNSFWApps
    }
}

sealed class ShareButtonVisibilityState {
+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/e_primary_text_color"/>
</vector>
+43 −6
Original line number Diff line number Diff line
@@ -46,7 +46,8 @@
                android:layout_alignParentStart="true"
                android:layout_centerVertical="true"
                android:contentDescription="@string/app_icon"
                android:scaleType="fitXY" />
                android:scaleType="fitXY"
                tools:src="@tools:sample/avatars" />
        </androidx.cardview.widget.CardView>

        <LinearLayout
@@ -61,7 +62,8 @@
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="?android:textColorPrimary"
                android:textSize="22sp" />
                android:textSize="22sp"
                tools:text="@tools:sample/lorem" />

            <com.google.android.material.textview.MaterialTextView
                android:id="@+id/appAuthor"
@@ -70,11 +72,44 @@
                android:paddingStart="2dp"
                android:paddingEnd="2dp"
                android:textColor="@color/app_info_text_color_grey"
                android:textSize="16sp" />
                android:textSize="16sp"
                tools:text="@tools:sample/lorem" />

        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/antiFeatureInfoLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="16dp"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        android:visibility="gone"
        tools:ignore="UseCompoundDrawables"
        tools:visibility="visible">

        <ImageView
            android:layout_width="16dp"
            android:layout_height="16dp"
            android:layout_gravity="center_vertical"
            android:src="@drawable/ic_visibility_off"
            app:tint="@color/e_primary_text_color"
            tools:ignore="ContentDescription" />

        <TextView
            android:id="@+id/antiFeatureMessage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginStart="8dp"
            android:text="@string/message_inappropriate_content"
            android:textColor="@color/e_primary_text_color"
            android:textSize="14sp"
            app:lineHeight="20dp" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
@@ -98,7 +133,8 @@
            android:textColor="#626262"
            android:textSize="14sp"
            android:visibility="gone"
            tools:text="Open Source" />
            tools:text="Open Source"
            tools:visibility="visible" />

        <TextView
            android:id="@+id/categoryTitle"
@@ -114,7 +150,8 @@
            android:textColor="#626262"
            android:textIsSelectable="false"
            android:textSize="14sp"
            tools:text="Racing" />
            tools:text="Racing"
            tools:visibility="visible" />

    </LinearLayout>

+8 −2
Original line number Diff line number Diff line
@@ -125,8 +125,9 @@
    <string name="troubleshootURL" translatable="false">https://doc.e.foundation/support-topics/app_lounge_troubleshooting</string>
    <string name="share">Share</string>
    <string name="restricted_app">[%1$s] Restricted App</string>
    <string name="age_rate_limit_message">You are too young to be able to install %1$s. Please check with your parent your age group is correct or disable Parental Control to be able to install it.</string>
    <string name="age_rate_limit_message">You are too young to be able to install %1$s. Please check with your parent your age group is correct or disable parental control to be able to install it.</string>

    <string name="message_inappropriate_content">This app may contain inappropriate content.</string>

    <!-- Updates Fragment -->
    <string name="update_all">Update All</string>
@@ -226,4 +227,9 @@
    <string name="notification_channel_desc">Split Install channel</string>
    <string name="sign_in">Sign in</string>
    <string name="ignore">Ignore</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>