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

Commit 640652ae authored by Guillaume Jacquart's avatar Guillaume Jacquart
Browse files

Merge branch '1736-update_widget_ux' into 'main'

1736 update widget ux

See merge request !158
parents 5f52c50d f674a6ed
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ object Notifications {
            permissionsPrivacyModule = permissionsPrivacyModule,
            channelId = CHANNEL_TRACKER_FLAG,
            channelName = R.string.notifications_tracker_channel_name,
            channelDescription = R.string.notifications_ipscrambling_channel_description
            channelDescription = R.string.notifications_tracker_channel_description
        )

        getQuickPrivacyStateUseCase.isLocationHidden.onEach {
+0 −23
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 E FOUNDATION
 *
 * 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/>.
 */

package foundation.e.advancedprivacy.common

// Definition of a Factory interface with a function to create objects of a type
interface Factory<T> {
    fun create(): T
}
+0 −61
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 MURENA SAS
 * Copyright (C) 2022 E FOUNDATION
 *
 * 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/>.
 */

package foundation.e.advancedprivacy.domain.entities

import android.graphics.drawable.Drawable

data class AppWithCounts(
    val appDesc: ApplicationDescription,
    val packageName: String,
    val uid: Int,
    var label: CharSequence?,
    var icon: Drawable?,
    val isWhitelisted: Boolean = false,
    val trackersCount: Int = 0,
    val whiteListedTrackersCount: Int = 0,
    val blockedLeaks: Int = 0,
    val leaks: Int = 0
) {
    constructor(
        app: ApplicationDescription,
        isWhitelisted: Boolean,
        trackersCount: Int,
        whiteListedTrackersCount: Int,
        blockedLeaks: Int,
        leaks: Int
    ) :
        this(
            appDesc = app,
            packageName = app.packageName,
            uid = app.uid,
            label = app.label,
            icon = app.icon,
            isWhitelisted = isWhitelisted,
            trackersCount = trackersCount,
            whiteListedTrackersCount = whiteListedTrackersCount,
            blockedLeaks = blockedLeaks,
            leaks = leaks
        )

    val blockedTrackersCount get() = if (isWhitelisted) {
        0
    } else {
        Math.max(trackersCount - whiteListedTrackersCount, 0)
    }
}
+0 −26
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 E FOUNDATION
 *
 * 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/>.
 */

package foundation.e.advancedprivacy.domain.entities

enum class QuickPrivacyState {
    DISABLED,
    ENABLED,
    FULL_ENABLED;

    fun isEnabled(): Boolean = this != DISABLED
}
+0 −26
Original line number Diff line number Diff line
@@ -21,40 +21,16 @@ package foundation.e.advancedprivacy.domain.usecases
import foundation.e.advancedprivacy.domain.entities.ApplicationDescription
import foundation.e.advancedprivacy.domain.entities.FeatureState
import foundation.e.advancedprivacy.domain.entities.LocationMode
import foundation.e.advancedprivacy.domain.entities.QuickPrivacyState
import foundation.e.advancedprivacy.domain.entities.TrackerMode
import foundation.e.advancedprivacy.domain.repositories.LocalStateRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.map

class GetQuickPrivacyStateUseCase(
    private val localStateRepository: LocalStateRepository
) {
    val quickPrivacyState: Flow<QuickPrivacyState> = combine(
        localStateRepository.blockTrackers,
        localStateRepository.areAllTrackersBlocked,
        localStateRepository.locationMode,
        localStateRepository.internetPrivacyMode
    ) { isBlockTrackers, isAllTrackersBlocked, locationMode, internetPrivacyMode ->
        when {
            !isBlockTrackers &&
                locationMode == LocationMode.REAL_LOCATION &&
                internetPrivacyMode == FeatureState.OFF -> QuickPrivacyState.DISABLED

            isAllTrackersBlocked &&
                locationMode != LocationMode.REAL_LOCATION &&
                internetPrivacyMode in listOf(
                    FeatureState.ON,
                    FeatureState.STARTING
                ) -> QuickPrivacyState.FULL_ENABLED

            else -> QuickPrivacyState.ENABLED
        }
    }

    val trackerMode: Flow<TrackerMode> = combine(
        localStateRepository.blockTrackers,
        localStateRepository.areAllTrackersBlocked
@@ -70,8 +46,6 @@ class GetQuickPrivacyStateUseCase(
        locationMode != LocationMode.REAL_LOCATION
    }

    val locationMode: StateFlow<LocationMode> = localStateRepository.locationMode

    val ipScramblingMode: Flow<FeatureState> =
        localStateRepository.internetPrivacyMode

Loading