forked from github/wulkanowy-mirror
Add User Messaging Platform SDK for ads agreements (#2375)
This commit is contained in:
parent
d811cdb919
commit
7dfa48bbe3
@ -250,14 +250,16 @@ dependencies {
|
|||||||
implementation 'org.apache.commons:commons-text:1.11.0'
|
implementation 'org.apache.commons:commons-text:1.11.0'
|
||||||
|
|
||||||
playImplementation platform('com.google.firebase:firebase-bom:32.7.0')
|
playImplementation platform('com.google.firebase:firebase-bom:32.7.0')
|
||||||
playImplementation 'com.google.firebase:firebase-analytics-ktx'
|
playImplementation 'com.google.firebase:firebase-analytics'
|
||||||
playImplementation 'com.google.firebase:firebase-messaging'
|
playImplementation 'com.google.firebase:firebase-messaging'
|
||||||
playImplementation 'com.google.firebase:firebase-crashlytics:'
|
playImplementation 'com.google.firebase:firebase-crashlytics:'
|
||||||
playImplementation 'com.google.firebase:firebase-config-ktx'
|
playImplementation 'com.google.firebase:firebase-config'
|
||||||
|
|
||||||
playImplementation 'com.google.android.gms:play-services-ads:22.6.0'
|
playImplementation 'com.google.android.gms:play-services-ads:22.6.0'
|
||||||
playImplementation "com.google.android.play:integrity:1.3.0"
|
playImplementation "com.google.android.play:integrity:1.3.0"
|
||||||
playImplementation 'com.google.android.play:app-update-ktx:2.1.0'
|
playImplementation 'com.google.android.play:app-update-ktx:2.1.0'
|
||||||
playImplementation 'com.google.android.play:review-ktx:2.0.1'
|
playImplementation 'com.google.android.play:review-ktx:2.0.1'
|
||||||
|
playImplementation "com.google.android.ump:user-messaging-platform:2.1.0"
|
||||||
|
|
||||||
hmsImplementation 'com.huawei.hms:hianalytics:6.12.0.300'
|
hmsImplementation 'com.huawei.hms:hianalytics:6.12.0.300'
|
||||||
hmsImplementation 'com.huawei.agconnect:agconnect-crash:1.9.1.303'
|
hmsImplementation 'com.huawei.agconnect:agconnect-crash:1.9.1.303'
|
||||||
|
@ -5,6 +5,7 @@ import android.view.View
|
|||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@ -13,9 +14,11 @@ class AdsHelper @Inject constructor(
|
|||||||
private val preferencesRepository: PreferencesRepository
|
private val preferencesRepository: PreferencesRepository
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
val isMobileAdsSdkInitialized = MutableStateFlow(false)
|
||||||
|
val canShowAd = false
|
||||||
|
|
||||||
fun initialize() {
|
fun initialize() {
|
||||||
preferencesRepository.isAdsEnabled = false
|
preferencesRepository.isAdsEnabled = false
|
||||||
preferencesRepository.isAgreeToProcessData = false
|
|
||||||
preferencesRepository.selectedDashboardTiles -= DashboardItem.Tile.ADS
|
preferencesRepository.selectedDashboardTiles -= DashboardItem.Tile.ADS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import android.view.View
|
|||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@ -12,10 +13,11 @@ class AdsHelper @Inject constructor(
|
|||||||
@ApplicationContext private val context: Context,
|
@ApplicationContext private val context: Context,
|
||||||
private val preferencesRepository: PreferencesRepository
|
private val preferencesRepository: PreferencesRepository
|
||||||
) {
|
) {
|
||||||
|
val isMobileAdsSdkInitialized = MutableStateFlow(false)
|
||||||
|
val canShowAd = false
|
||||||
|
|
||||||
fun initialize() {
|
fun initialize() {
|
||||||
preferencesRepository.isAdsEnabled = false
|
preferencesRepository.isAdsEnabled = false
|
||||||
preferencesRepository.isAgreeToProcessData = false
|
|
||||||
preferencesRepository.selectedDashboardTiles -= DashboardItem.Tile.ADS
|
preferencesRepository.selectedDashboardTiles -= DashboardItem.Tile.ADS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import fr.bipi.treessence.file.FileLoggerTree
|
|||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
import io.github.wulkanowy.ui.base.ThemeManager
|
import io.github.wulkanowy.ui.base.ThemeManager
|
||||||
import io.github.wulkanowy.utils.ActivityLifecycleLogger
|
import io.github.wulkanowy.utils.ActivityLifecycleLogger
|
||||||
import io.github.wulkanowy.utils.AdsHelper
|
|
||||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
import io.github.wulkanowy.utils.CrashLogExceptionTree
|
import io.github.wulkanowy.utils.CrashLogExceptionTree
|
||||||
@ -37,9 +36,6 @@ class WulkanowyApp : Application(), Configuration.Provider {
|
|||||||
@Inject
|
@Inject
|
||||||
lateinit var analyticsHelper: AnalyticsHelper
|
lateinit var analyticsHelper: AnalyticsHelper
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var adsHelper: AdsHelper
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var remoteConfigHelper: RemoteConfigHelper
|
lateinit var remoteConfigHelper: RemoteConfigHelper
|
||||||
|
|
||||||
@ -56,7 +52,6 @@ class WulkanowyApp : Application(), Configuration.Provider {
|
|||||||
super.onCreate()
|
super.onCreate()
|
||||||
initializeAppLanguage()
|
initializeAppLanguage()
|
||||||
themeManager.applyDefaultTheme()
|
themeManager.applyDefaultTheme()
|
||||||
adsHelper.initialize()
|
|
||||||
remoteConfigHelper.initialize()
|
remoteConfigHelper.initialize()
|
||||||
initLogging()
|
initLogging()
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,12 @@ import com.fredporciuncula.flow.preferences.Preference
|
|||||||
import com.fredporciuncula.flow.preferences.Serializer
|
import com.fredporciuncula.flow.preferences.Serializer
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.enums.*
|
import io.github.wulkanowy.data.enums.AppTheme
|
||||||
|
import io.github.wulkanowy.data.enums.GradeColorTheme
|
||||||
|
import io.github.wulkanowy.data.enums.GradeExpandMode
|
||||||
|
import io.github.wulkanowy.data.enums.GradeSortingMode
|
||||||
|
import io.github.wulkanowy.data.enums.TimetableGapsMode
|
||||||
|
import io.github.wulkanowy.data.enums.TimetableMode
|
||||||
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
||||||
import io.github.wulkanowy.ui.modules.grade.GradeAverageMode
|
import io.github.wulkanowy.ui.modules.grade.GradeAverageMode
|
||||||
import io.github.wulkanowy.ui.modules.settings.appearance.menuorder.AppMenuItem
|
import io.github.wulkanowy.ui.modules.settings.appearance.menuorder.AppMenuItem
|
||||||
@ -18,7 +23,7 @@ import kotlinx.coroutines.flow.map
|
|||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.util.*
|
import java.util.UUID
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@ -303,19 +308,6 @@ class PreferencesRepository @Inject constructor(
|
|||||||
get() = sharedPref.getBoolean(PREF_KEY_APP_SUPPORT_SHOWN, false)
|
get() = sharedPref.getBoolean(PREF_KEY_APP_SUPPORT_SHOWN, false)
|
||||||
set(value) = sharedPref.edit { putBoolean(PREF_KEY_APP_SUPPORT_SHOWN, value) }
|
set(value) = sharedPref.edit { putBoolean(PREF_KEY_APP_SUPPORT_SHOWN, value) }
|
||||||
|
|
||||||
var isAgreeToProcessData: Boolean
|
|
||||||
get() = getBoolean(
|
|
||||||
R.string.pref_key_ads_consent_data_processing,
|
|
||||||
R.bool.pref_default_ads_consent_data_processing
|
|
||||||
)
|
|
||||||
set(value) = sharedPref.edit {
|
|
||||||
putBoolean(context.getString(R.string.pref_key_ads_consent_data_processing), value)
|
|
||||||
}
|
|
||||||
|
|
||||||
var isPersonalizedAdsEnabled: Boolean
|
|
||||||
get() = sharedPref.getBoolean(PREF_KEY_PERSONALIZED_ADS_ENABLED, false)
|
|
||||||
set(value) = sharedPref.edit { putBoolean(PREF_KEY_PERSONALIZED_ADS_ENABLED, value) }
|
|
||||||
|
|
||||||
val isAdsEnabledFlow = flowSharedPref.getBoolean(
|
val isAdsEnabledFlow = flowSharedPref.getBoolean(
|
||||||
context.getString(R.string.pref_key_ads_enabled),
|
context.getString(R.string.pref_key_ads_enabled),
|
||||||
context.resources.getBoolean(R.bool.pref_default_ads_enabled)
|
context.resources.getBoolean(R.bool.pref_default_ads_enabled)
|
||||||
@ -398,7 +390,6 @@ class PreferencesRepository @Inject constructor(
|
|||||||
private const val PREF_KEY_IN_APP_REVIEW_DATE = "in_app_review_date"
|
private const val PREF_KEY_IN_APP_REVIEW_DATE = "in_app_review_date"
|
||||||
private const val PREF_KEY_IN_APP_REVIEW_DONE = "in_app_review_done"
|
private const val PREF_KEY_IN_APP_REVIEW_DONE = "in_app_review_done"
|
||||||
private const val PREF_KEY_APP_SUPPORT_SHOWN = "app_support_shown"
|
private const val PREF_KEY_APP_SUPPORT_SHOWN = "app_support_shown"
|
||||||
private const val PREF_KEY_PERSONALIZED_ADS_ENABLED = "personalized_ads_enabled"
|
|
||||||
private const val PREF_KEY_ADMIN_DISMISSED_MESSAGE_IDS = "admin_message_dismissed_ids"
|
private const val PREF_KEY_ADMIN_DISMISSED_MESSAGE_IDS = "admin_message_dismissed_ids"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,46 @@
|
|||||||
package io.github.wulkanowy.ui.modules.dashboard
|
package io.github.wulkanowy.ui.modules.dashboard
|
||||||
|
|
||||||
import io.github.wulkanowy.data.*
|
import io.github.wulkanowy.data.Resource
|
||||||
|
import io.github.wulkanowy.data.dataOrNull
|
||||||
import io.github.wulkanowy.data.db.entities.AdminMessage
|
import io.github.wulkanowy.data.db.entities.AdminMessage
|
||||||
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
||||||
import io.github.wulkanowy.data.db.entities.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
import io.github.wulkanowy.data.enums.MessageFolder
|
import io.github.wulkanowy.data.enums.MessageFolder
|
||||||
import io.github.wulkanowy.data.enums.MessageType
|
import io.github.wulkanowy.data.enums.MessageType
|
||||||
import io.github.wulkanowy.data.repositories.*
|
import io.github.wulkanowy.data.errorOrNull
|
||||||
|
import io.github.wulkanowy.data.flatResourceFlow
|
||||||
|
import io.github.wulkanowy.data.mapResourceData
|
||||||
|
import io.github.wulkanowy.data.onResourceError
|
||||||
|
import io.github.wulkanowy.data.repositories.AttendanceSummaryRepository
|
||||||
|
import io.github.wulkanowy.data.repositories.ConferenceRepository
|
||||||
|
import io.github.wulkanowy.data.repositories.ExamRepository
|
||||||
|
import io.github.wulkanowy.data.repositories.GradeRepository
|
||||||
|
import io.github.wulkanowy.data.repositories.HomeworkRepository
|
||||||
|
import io.github.wulkanowy.data.repositories.LuckyNumberRepository
|
||||||
|
import io.github.wulkanowy.data.repositories.MessageRepository
|
||||||
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
|
import io.github.wulkanowy.data.repositories.SchoolAnnouncementRepository
|
||||||
|
import io.github.wulkanowy.data.repositories.SemesterRepository
|
||||||
|
import io.github.wulkanowy.data.repositories.StudentRepository
|
||||||
|
import io.github.wulkanowy.data.repositories.TimetableRepository
|
||||||
import io.github.wulkanowy.domain.adminmessage.GetAppropriateAdminMessageUseCase
|
import io.github.wulkanowy.domain.adminmessage.GetAppropriateAdminMessageUseCase
|
||||||
import io.github.wulkanowy.ui.base.BasePresenter
|
import io.github.wulkanowy.ui.base.BasePresenter
|
||||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||||
import io.github.wulkanowy.utils.AdsHelper
|
import io.github.wulkanowy.utils.AdsHelper
|
||||||
import io.github.wulkanowy.utils.calculatePercentage
|
import io.github.wulkanowy.utils.calculatePercentage
|
||||||
import io.github.wulkanowy.utils.nextOrSameSchoolDay
|
import io.github.wulkanowy.utils.nextOrSameSchoolDay
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.catch
|
||||||
|
import kotlinx.coroutines.flow.combine
|
||||||
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
|
import kotlinx.coroutines.flow.emitAll
|
||||||
|
import kotlinx.coroutines.flow.filter
|
||||||
|
import kotlinx.coroutines.flow.filterNot
|
||||||
|
import kotlinx.coroutines.flow.flow
|
||||||
|
import kotlinx.coroutines.flow.flowOf
|
||||||
|
import kotlinx.coroutines.flow.map
|
||||||
|
import kotlinx.coroutines.flow.merge
|
||||||
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
@ -48,6 +75,11 @@ class DashboardPresenter @Inject constructor(
|
|||||||
|
|
||||||
private val firstLoadedItemList = mutableListOf<DashboardItem.Type>()
|
private val firstLoadedItemList = mutableListOf<DashboardItem.Type>()
|
||||||
|
|
||||||
|
private val selectedDashboardTiles
|
||||||
|
get() = preferencesRepository.selectedDashboardTiles
|
||||||
|
.filterNot { it == DashboardItem.Tile.ADS && !adsHelper.canShowAd }
|
||||||
|
.toSet()
|
||||||
|
|
||||||
private lateinit var lastError: Throwable
|
private lateinit var lastError: Throwable
|
||||||
|
|
||||||
override fun onAttachView(view: DashboardView) {
|
override fun onAttachView(view: DashboardView) {
|
||||||
@ -59,10 +91,19 @@ class DashboardPresenter @Inject constructor(
|
|||||||
showContent(false)
|
showContent(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val selectedDashboardTilesFlow = preferencesRepository.selectedDashboardTilesFlow
|
||||||
|
.map { selectedDashboardTiles }
|
||||||
|
val isAdsEnabledFlow = preferencesRepository.isAdsEnabledFlow
|
||||||
|
.filter { (adsHelper.canShowAd && it) || !it }
|
||||||
|
.map { selectedDashboardTiles }
|
||||||
|
val isMobileAdsSdkInitializedFlow = adsHelper.isMobileAdsSdkInitialized
|
||||||
|
.filter { it }
|
||||||
|
.map { selectedDashboardTiles }
|
||||||
|
|
||||||
merge(
|
merge(
|
||||||
preferencesRepository.selectedDashboardTilesFlow,
|
selectedDashboardTilesFlow,
|
||||||
preferencesRepository.isAdsEnabledFlow
|
isAdsEnabledFlow,
|
||||||
.map { preferencesRepository.selectedDashboardTiles }
|
isMobileAdsSdkInitializedFlow
|
||||||
)
|
)
|
||||||
.onEach { loadData(tilesToLoad = it) }
|
.onEach { loadData(tilesToLoad = it) }
|
||||||
.launch("dashboard_pref")
|
.launch("dashboard_pref")
|
||||||
@ -71,7 +112,7 @@ class DashboardPresenter @Inject constructor(
|
|||||||
fun onAdminMessageDismissed(adminMessage: AdminMessage) {
|
fun onAdminMessageDismissed(adminMessage: AdminMessage) {
|
||||||
preferencesRepository.dismissedAdminMessageIds += adminMessage.id
|
preferencesRepository.dismissedAdminMessageIds += adminMessage.id
|
||||||
|
|
||||||
loadData(preferencesRepository.selectedDashboardTiles)
|
loadData(selectedDashboardTiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onDragAndDropEnd(list: List<DashboardItem>) {
|
fun onDragAndDropEnd(list: List<DashboardItem>) {
|
||||||
@ -187,7 +228,7 @@ class DashboardPresenter @Inject constructor(
|
|||||||
|
|
||||||
fun onSwipeRefresh() {
|
fun onSwipeRefresh() {
|
||||||
Timber.i("Force refreshing the dashboard")
|
Timber.i("Force refreshing the dashboard")
|
||||||
loadData(preferencesRepository.selectedDashboardTiles, forceRefresh = true)
|
loadData(selectedDashboardTiles, forceRefresh = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onRetry() {
|
fun onRetry() {
|
||||||
@ -195,7 +236,7 @@ class DashboardPresenter @Inject constructor(
|
|||||||
showErrorView(false)
|
showErrorView(false)
|
||||||
showProgress(true)
|
showProgress(true)
|
||||||
}
|
}
|
||||||
loadData(preferencesRepository.selectedDashboardTiles, forceRefresh = true)
|
loadData(selectedDashboardTiles, forceRefresh = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onViewReselected() {
|
fun onViewReselected() {
|
||||||
@ -216,7 +257,7 @@ class DashboardPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onDashboardTileSettingsSelected(): Boolean {
|
fun onDashboardTileSettingsSelected(): Boolean {
|
||||||
view?.showDashboardTileSettings(preferencesRepository.selectedDashboardTiles.toList())
|
view?.showDashboardTileSettings(selectedDashboardTiles.toList())
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +273,7 @@ class DashboardPresenter @Inject constructor(
|
|||||||
|
|
||||||
private fun loadHorizontalGroup(student: Student, forceRefresh: Boolean) {
|
private fun loadHorizontalGroup(student: Student, forceRefresh: Boolean) {
|
||||||
flow {
|
flow {
|
||||||
val selectedTiles = preferencesRepository.selectedDashboardTiles
|
val selectedTiles = selectedDashboardTiles
|
||||||
val flowSuccess = flowOf(Resource.Success(null))
|
val flowSuccess = flowOf(Resource.Success(null))
|
||||||
|
|
||||||
val luckyNumberFlow = luckyNumberRepository.getLuckyNumber(student, forceRefresh)
|
val luckyNumberFlow = luckyNumberRepository.getLuckyNumber(student, forceRefresh)
|
||||||
|
@ -9,7 +9,11 @@ import android.view.MenuItem
|
|||||||
import android.view.ViewGroup.MarginLayoutParams
|
import android.view.ViewGroup.MarginLayoutParams
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.addCallback
|
import androidx.activity.addCallback
|
||||||
import androidx.core.view.*
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
@ -23,12 +27,19 @@ import io.github.wulkanowy.R
|
|||||||
import io.github.wulkanowy.data.db.entities.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
import io.github.wulkanowy.data.db.entities.StudentWithSemesters
|
import io.github.wulkanowy.data.db.entities.StudentWithSemesters
|
||||||
import io.github.wulkanowy.databinding.ActivityMainBinding
|
import io.github.wulkanowy.databinding.ActivityMainBinding
|
||||||
import io.github.wulkanowy.databinding.DialogAdsConsentBinding
|
|
||||||
import io.github.wulkanowy.ui.base.BaseActivity
|
import io.github.wulkanowy.ui.base.BaseActivity
|
||||||
import io.github.wulkanowy.ui.modules.Destination
|
import io.github.wulkanowy.ui.modules.Destination
|
||||||
import io.github.wulkanowy.ui.modules.account.accountquick.AccountQuickDialog
|
import io.github.wulkanowy.ui.modules.account.accountquick.AccountQuickDialog
|
||||||
import io.github.wulkanowy.ui.modules.settings.appearance.menuorder.AppMenuItem
|
import io.github.wulkanowy.ui.modules.settings.appearance.menuorder.AppMenuItem
|
||||||
import io.github.wulkanowy.utils.*
|
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||||
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
|
import io.github.wulkanowy.utils.InAppReviewHelper
|
||||||
|
import io.github.wulkanowy.utils.InAppUpdateHelper
|
||||||
|
import io.github.wulkanowy.utils.createNameInitialsDrawable
|
||||||
|
import io.github.wulkanowy.utils.dpToPx
|
||||||
|
import io.github.wulkanowy.utils.nickOrName
|
||||||
|
import io.github.wulkanowy.utils.safelyPopFragments
|
||||||
|
import io.github.wulkanowy.utils.setOnViewChangeListener
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
@ -312,40 +323,6 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showPrivacyPolicyDialog() {
|
|
||||||
val dialogAdsConsentBinding = DialogAdsConsentBinding.inflate(layoutInflater)
|
|
||||||
|
|
||||||
val dialog = MaterialAlertDialogBuilder(this)
|
|
||||||
.setTitle(R.string.pref_ads_consent_title)
|
|
||||||
.setMessage(R.string.pref_ads_consent_description)
|
|
||||||
.setView(dialogAdsConsentBinding.root)
|
|
||||||
.show()
|
|
||||||
|
|
||||||
dialogAdsConsentBinding.adsConsentOver.setOnCheckedChangeListener { _, isChecked ->
|
|
||||||
dialogAdsConsentBinding.adsConsentPersonalised.isEnabled = isChecked
|
|
||||||
}
|
|
||||||
|
|
||||||
dialogAdsConsentBinding.adsConsentPersonalised.setOnClickListener {
|
|
||||||
presenter.onPrivacyAgree(true)
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
dialogAdsConsentBinding.adsConsentNonPersonalised.setOnClickListener {
|
|
||||||
presenter.onPrivacyAgree(false)
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
dialogAdsConsentBinding.adsConsentPrivacy.setOnClickListener { presenter.onPrivacySelected() }
|
|
||||||
dialogAdsConsentBinding.adsConsentCancel.setOnClickListener { dialog.cancel() }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun openPrivacyPolicy() {
|
|
||||||
openInternetBrowser(
|
|
||||||
"https://wulkanowy.github.io/polityka-prywatnosci.html",
|
|
||||||
::showMessage
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
super.onSaveInstanceState(outState)
|
super.onSaveInstanceState(outState)
|
||||||
navController.onSaveInstanceState(outState)
|
navController.onSaveInstanceState(outState)
|
||||||
|
@ -19,7 +19,6 @@ import io.github.wulkanowy.utils.AdsHelper
|
|||||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.serialization.decodeFromString
|
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
@ -52,6 +51,7 @@ class MainPresenter @Inject constructor(
|
|||||||
destinationType in rootDestinationTypeList -> {
|
destinationType in rootDestinationTypeList -> {
|
||||||
rootDestinationTypeList.indexOf(destinationType)
|
rootDestinationTypeList.indexOf(destinationType)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> 4
|
else -> 4
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,6 +110,7 @@ class MainPresenter @Inject constructor(
|
|||||||
is AccountView,
|
is AccountView,
|
||||||
is StudentInfoView,
|
is StudentInfoView,
|
||||||
is AccountDetailsView -> false
|
is AccountDetailsView -> false
|
||||||
|
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,20 +149,8 @@ class MainPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onEnableAdsSelected() {
|
fun onEnableAdsSelected() {
|
||||||
view?.showPrivacyPolicyDialog()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onPrivacyAgree(isPersonalizedAds: Boolean) {
|
|
||||||
preferencesRepository.isAgreeToProcessData = true
|
|
||||||
preferencesRepository.isPersonalizedAdsEnabled = isPersonalizedAds
|
|
||||||
|
|
||||||
adsHelper.initialize()
|
|
||||||
|
|
||||||
preferencesRepository.isAdsEnabled = true
|
preferencesRepository.isAdsEnabled = true
|
||||||
}
|
adsHelper.initialize()
|
||||||
|
|
||||||
fun onPrivacySelected() {
|
|
||||||
view?.openPrivacyPolicy()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkInAppReview() {
|
private fun checkInAppReview() {
|
||||||
@ -189,8 +178,8 @@ class MainPresenter @Inject constructor(
|
|||||||
.getOrElse { return@launch }
|
.getOrElse { return@launch }
|
||||||
|
|
||||||
if (Instant.now().minus(Duration.ofDays(28)).isAfter(student.registrationDate)) {
|
if (Instant.now().minus(Duration.ofDays(28)).isAfter(student.registrationDate)) {
|
||||||
view?.showAppSupport()
|
|
||||||
preferencesRepository.isAppSupportShown = true
|
preferencesRepository.isAppSupportShown = true
|
||||||
|
view?.showAppSupport()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,10 +46,6 @@ interface MainView : BaseView {
|
|||||||
|
|
||||||
fun showAppSupport()
|
fun showAppSupport()
|
||||||
|
|
||||||
fun showPrivacyPolicyDialog()
|
|
||||||
|
|
||||||
fun openPrivacyPolicy()
|
|
||||||
|
|
||||||
fun openMoreDestination(destination: Destination)
|
fun openMoreDestination(destination: Destination)
|
||||||
|
|
||||||
interface MainChildView {
|
interface MainChildView {
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/ads_consent_privacy"
|
|
||||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="24dp"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
android:insetLeft="0dp"
|
|
||||||
android:insetTop="0dp"
|
|
||||||
android:insetRight="0dp"
|
|
||||||
android:insetBottom="0dp"
|
|
||||||
android:padding="0dp"
|
|
||||||
android:text="@string/pref_ads_privacy_policy"
|
|
||||||
android:textAllCaps="false"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<com.google.android.material.checkbox.MaterialCheckBox
|
|
||||||
android:id="@+id/ads_consent_over"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="17dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:text="@string/pref_ads_over_18_years_old"
|
|
||||||
android:textColor="?android:textColorSecondary"
|
|
||||||
android:textSize="14sp"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/ads_consent_privacy" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/ads_consent_personalised"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
android:enabled="false"
|
|
||||||
android:insetLeft="0dp"
|
|
||||||
android:insetTop="0dp"
|
|
||||||
android:insetRight="0dp"
|
|
||||||
android:insetBottom="0dp"
|
|
||||||
android:text="@string/pref_ads_option_personalized"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/ads_consent_over" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/ads_consent_non_personalised"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
android:layout_marginBottom="24dp"
|
|
||||||
android:insetLeft="0dp"
|
|
||||||
android:insetTop="0dp"
|
|
||||||
android:insetRight="0dp"
|
|
||||||
android:insetBottom="0dp"
|
|
||||||
android:text="@string/pref_ads_option_non_personalized"
|
|
||||||
app:layout_constraintBottom_toTopOf="@id/ads_consent_cancel"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/ads_consent_personalised"
|
|
||||||
app:layout_constraintVertical_bias="0" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/ads_consent_cancel"
|
|
||||||
style="@style/Widget.Material3.Button.OutlinedButton"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
android:layout_marginBottom="24dp"
|
|
||||||
android:insetLeft="0dp"
|
|
||||||
android:insetTop="0dp"
|
|
||||||
android:insetRight="0dp"
|
|
||||||
android:insetBottom="0dp"
|
|
||||||
android:text="@android:string/cancel"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintVertical_bias="0" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -769,13 +769,6 @@
|
|||||||
<string name="pref_ads_privacy_link">Ochrana osobních údajů</string>
|
<string name="pref_ads_privacy_link">Ochrana osobních údajů</string>
|
||||||
<string name="pref_ads_loading">Reklama se načítá</string>
|
<string name="pref_ads_loading">Reklama se načítá</string>
|
||||||
<string name="pref_ads_once_per_visit">Děkujeme za vaši podporu, vraťte se později pro více reklam</string>
|
<string name="pref_ads_once_per_visit">Děkujeme za vaši podporu, vraťte se později pro více reklam</string>
|
||||||
<string name="pref_ads_consent_title">Můžeme použít Vaše data k zobrazení reklam?</string>
|
|
||||||
<string name="pref_ads_consent_description">Volbu můžete kdykoliv změnit v nastavení aplikace. Můžeme použít Vaše data k zobrazení reklam šitých pro vás nebo pomocí méně vašich dat zobrazovat nepřizpůsobené reklamy. Podrobnosti naleznete v našich Zásadách ochrany osobních údajů</string>
|
|
||||||
<string name="pref_ads_summary_personalized">Přizpůsobené reklamy</string>
|
|
||||||
<string name="pref_ads_summary_non_personalized">Nepřizpůsobené reklamy</string>
|
|
||||||
<string name="pref_ads_over_18_years_old">Je mi více než 18 let</string>
|
|
||||||
<string name="pref_ads_option_personalized">Ano, přizpůsobené reklamy</string>
|
|
||||||
<string name="pref_ads_option_non_personalized">Ano, nepřizpůsobené reklamy</string>
|
|
||||||
<string name="pref_settings_advanced_title">Pokročilé</string>
|
<string name="pref_settings_advanced_title">Pokročilé</string>
|
||||||
<string name="pref_settings_appearance_title">Vzhled a chování</string>
|
<string name="pref_settings_appearance_title">Vzhled a chování</string>
|
||||||
<string name="pref_settings_notifications_title">Oznámení</string>
|
<string name="pref_settings_notifications_title">Oznámení</string>
|
||||||
|
@ -679,13 +679,6 @@
|
|||||||
<string name="pref_ads_privacy_link">Privacy policy</string>
|
<string name="pref_ads_privacy_link">Privacy policy</string>
|
||||||
<string name="pref_ads_loading">Ad is loading</string>
|
<string name="pref_ads_loading">Ad is loading</string>
|
||||||
<string name="pref_ads_once_per_visit">Thank you for your support, come back later for more ads</string>
|
<string name="pref_ads_once_per_visit">Thank you for your support, come back later for more ads</string>
|
||||||
<string name="pref_ads_consent_title">Can we use your data to display ads?</string>
|
|
||||||
<string name="pref_ads_consent_description">You can change your choice anytime in the app settings. We may use your data to display ads tailored to you or, using less of your data, display non-personalized ads. Please see our Privacy Policy for details</string>
|
|
||||||
<string name="pref_ads_summary_personalized">Personalized ads</string>
|
|
||||||
<string name="pref_ads_summary_non_personalized">Non-personalized ads</string>
|
|
||||||
<string name="pref_ads_over_18_years_old">I am over 18 years old</string>
|
|
||||||
<string name="pref_ads_option_personalized">Yes, personalized ads</string>
|
|
||||||
<string name="pref_ads_option_non_personalized">Yes, non-personalized ads</string>
|
|
||||||
<string name="pref_settings_advanced_title">Advanced</string>
|
<string name="pref_settings_advanced_title">Advanced</string>
|
||||||
<string name="pref_settings_appearance_title">Appearance & Behavior</string>
|
<string name="pref_settings_appearance_title">Appearance & Behavior</string>
|
||||||
<string name="pref_settings_notifications_title">Notifications</string>
|
<string name="pref_settings_notifications_title">Notifications</string>
|
||||||
|
@ -679,13 +679,6 @@
|
|||||||
<string name="pref_ads_privacy_link">Datenschutzerklärung</string>
|
<string name="pref_ads_privacy_link">Datenschutzerklärung</string>
|
||||||
<string name="pref_ads_loading">Anzeige wird geladen</string>
|
<string name="pref_ads_loading">Anzeige wird geladen</string>
|
||||||
<string name="pref_ads_once_per_visit">Vielen Dank für Ihre Unterstützung, kommen Sie später wieder für weitere Anzeigen</string>
|
<string name="pref_ads_once_per_visit">Vielen Dank für Ihre Unterstützung, kommen Sie später wieder für weitere Anzeigen</string>
|
||||||
<string name="pref_ads_consent_title">Können wir Ihre Daten zur Anzeige von Werbung verwenden?</string>
|
|
||||||
<string name="pref_ads_consent_description">Sie können Ihre Wahl jederzeit in den App-Einstellungen ändern. Wir verwenden Ihre Daten, um auf Sie zugeschnittene Anzeigen anzuzeigen oder unter Verwendung weniger Ihrer Daten nicht personalisierte Werbung anzuzeigen. Bitte lesen Sie unsere Datenschutzerklärung für Details</string>
|
|
||||||
<string name="pref_ads_summary_personalized">Personalisierte Werbung</string>
|
|
||||||
<string name="pref_ads_summary_non_personalized">keine personalisierte Werbung</string>
|
|
||||||
<string name="pref_ads_over_18_years_old">Ich bin über 18 Jahre alt</string>
|
|
||||||
<string name="pref_ads_option_personalized">Ja, personalisierte Werbung</string>
|
|
||||||
<string name="pref_ads_option_non_personalized">Ja, nicht personalisierte Werbung</string>
|
|
||||||
<string name="pref_settings_advanced_title">Erweitert</string>
|
<string name="pref_settings_advanced_title">Erweitert</string>
|
||||||
<string name="pref_settings_appearance_title">Aussehen & Verhalten</string>
|
<string name="pref_settings_appearance_title">Aussehen & Verhalten</string>
|
||||||
<string name="pref_settings_notifications_title">Benachrichtigungen</string>
|
<string name="pref_settings_notifications_title">Benachrichtigungen</string>
|
||||||
|
@ -679,13 +679,6 @@
|
|||||||
<string name="pref_ads_privacy_link">Privacy policy</string>
|
<string name="pref_ads_privacy_link">Privacy policy</string>
|
||||||
<string name="pref_ads_loading">Ad is loading</string>
|
<string name="pref_ads_loading">Ad is loading</string>
|
||||||
<string name="pref_ads_once_per_visit">Thank you for your support, come back later for more ads</string>
|
<string name="pref_ads_once_per_visit">Thank you for your support, come back later for more ads</string>
|
||||||
<string name="pref_ads_consent_title">Can we use your data to display ads?</string>
|
|
||||||
<string name="pref_ads_consent_description">You can change your choice anytime in the app settings. We may use your data to display ads tailored to you or, using less of your data, display non-personalized ads. Please see our Privacy Policy for details</string>
|
|
||||||
<string name="pref_ads_summary_personalized">Personalized ads</string>
|
|
||||||
<string name="pref_ads_summary_non_personalized">Non-personalized ads</string>
|
|
||||||
<string name="pref_ads_over_18_years_old">I am over 18 years old</string>
|
|
||||||
<string name="pref_ads_option_personalized">Yes, personalized ads</string>
|
|
||||||
<string name="pref_ads_option_non_personalized">Yes, non-personalized ads</string>
|
|
||||||
<string name="pref_settings_advanced_title">Advanced</string>
|
<string name="pref_settings_advanced_title">Advanced</string>
|
||||||
<string name="pref_settings_appearance_title">Appearance & Behavior</string>
|
<string name="pref_settings_appearance_title">Appearance & Behavior</string>
|
||||||
<string name="pref_settings_notifications_title">Notifications</string>
|
<string name="pref_settings_notifications_title">Notifications</string>
|
||||||
|
@ -679,13 +679,6 @@
|
|||||||
<string name="pref_ads_privacy_link">Privacy policy</string>
|
<string name="pref_ads_privacy_link">Privacy policy</string>
|
||||||
<string name="pref_ads_loading">Ad is loading</string>
|
<string name="pref_ads_loading">Ad is loading</string>
|
||||||
<string name="pref_ads_once_per_visit">Thank you for your support, come back later for more ads</string>
|
<string name="pref_ads_once_per_visit">Thank you for your support, come back later for more ads</string>
|
||||||
<string name="pref_ads_consent_title">Can we use your data to display ads?</string>
|
|
||||||
<string name="pref_ads_consent_description">You can change your choice anytime in the app settings. We may use your data to display ads tailored to you or, using less of your data, display non-personalized ads. Please see our Privacy Policy for details</string>
|
|
||||||
<string name="pref_ads_summary_personalized">Personalized ads</string>
|
|
||||||
<string name="pref_ads_summary_non_personalized">Non-personalized ads</string>
|
|
||||||
<string name="pref_ads_over_18_years_old">I am over 18 years old</string>
|
|
||||||
<string name="pref_ads_option_personalized">Yes, personalized ads</string>
|
|
||||||
<string name="pref_ads_option_non_personalized">Yes, non-personalized ads</string>
|
|
||||||
<string name="pref_settings_advanced_title">Advanced</string>
|
<string name="pref_settings_advanced_title">Advanced</string>
|
||||||
<string name="pref_settings_appearance_title">Appearance & Behavior</string>
|
<string name="pref_settings_appearance_title">Appearance & Behavior</string>
|
||||||
<string name="pref_settings_notifications_title">Notifications</string>
|
<string name="pref_settings_notifications_title">Notifications</string>
|
||||||
|
@ -769,13 +769,6 @@
|
|||||||
<string name="pref_ads_privacy_link">Polityka prywatności</string>
|
<string name="pref_ads_privacy_link">Polityka prywatności</string>
|
||||||
<string name="pref_ads_loading">Ładowanie reklamy</string>
|
<string name="pref_ads_loading">Ładowanie reklamy</string>
|
||||||
<string name="pref_ads_once_per_visit">Dziękujemy za wsparcie, wróć później po więcej reklam</string>
|
<string name="pref_ads_once_per_visit">Dziękujemy za wsparcie, wróć później po więcej reklam</string>
|
||||||
<string name="pref_ads_consent_title">Czy możemy używać Twoich danych do wyświetlania reklam?</string>
|
|
||||||
<string name="pref_ads_consent_description">Możesz zmienić swój wybór w dowolnym momencie w ustawieniach aplikacji. Możemy wykorzystać Twoje dane do wyświetlania reklam dostosowanych do Ciebie lub, przy użyciu mniejszej ilości danych, wyświetlić niepersonalizowane reklamy. Zobacz naszą Politykę Prywatności, aby uzyskać więcej informacji</string>
|
|
||||||
<string name="pref_ads_summary_personalized">Spersonalizowane reklamy</string>
|
|
||||||
<string name="pref_ads_summary_non_personalized">Niespersonalizowane reklamy</string>
|
|
||||||
<string name="pref_ads_over_18_years_old">Mam ukończone 18 lat</string>
|
|
||||||
<string name="pref_ads_option_personalized">Tak, spersonalizowane reklamy</string>
|
|
||||||
<string name="pref_ads_option_non_personalized">Tak, niespersonalizowane reklamy</string>
|
|
||||||
<string name="pref_settings_advanced_title">Zaawansowane</string>
|
<string name="pref_settings_advanced_title">Zaawansowane</string>
|
||||||
<string name="pref_settings_appearance_title">Wygląd i zachowanie</string>
|
<string name="pref_settings_appearance_title">Wygląd i zachowanie</string>
|
||||||
<string name="pref_settings_notifications_title">Powiadomienia</string>
|
<string name="pref_settings_notifications_title">Powiadomienia</string>
|
||||||
|
@ -769,13 +769,6 @@
|
|||||||
<string name="pref_ads_privacy_link">Политика конфиденциальности</string>
|
<string name="pref_ads_privacy_link">Политика конфиденциальности</string>
|
||||||
<string name="pref_ads_loading">Реклама загружается</string>
|
<string name="pref_ads_loading">Реклама загружается</string>
|
||||||
<string name="pref_ads_once_per_visit">Спасибо за вашу поддержку, возвращайтесь позже для дополнительной рекламы</string>
|
<string name="pref_ads_once_per_visit">Спасибо за вашу поддержку, возвращайтесь позже для дополнительной рекламы</string>
|
||||||
<string name="pref_ads_consent_title">Можем ли мы использовать ваши данные для показа рекламы?</string>
|
|
||||||
<string name="pref_ads_consent_description">Вы можете изменить свой выбор в любое время в настройках приложения. Мы можем использовать ваши данные для показа объявлений в соответствии с вашими пожеланиями или, используя меньше данных, отображать неперсональную рекламу. Пожалуйста, ознакомьтесь с нашей политикой конфиденциальности для подробностей</string>
|
|
||||||
<string name="pref_ads_summary_personalized">Персонализированная реклама</string>
|
|
||||||
<string name="pref_ads_summary_non_personalized">Неперсонализированная реклама</string>
|
|
||||||
<string name="pref_ads_over_18_years_old">Я старше 18 лет</string>
|
|
||||||
<string name="pref_ads_option_personalized">Да, персонализировать рекламу</string>
|
|
||||||
<string name="pref_ads_option_non_personalized">Да, не персонализировать рекламу</string>
|
|
||||||
<string name="pref_settings_advanced_title">Расширенные</string>
|
<string name="pref_settings_advanced_title">Расширенные</string>
|
||||||
<string name="pref_settings_appearance_title">Внешний вид и поведение</string>
|
<string name="pref_settings_appearance_title">Внешний вид и поведение</string>
|
||||||
<string name="pref_settings_notifications_title">Уведомления</string>
|
<string name="pref_settings_notifications_title">Уведомления</string>
|
||||||
|
@ -769,13 +769,6 @@
|
|||||||
<string name="pref_ads_privacy_link">Ochrana osobných údajov</string>
|
<string name="pref_ads_privacy_link">Ochrana osobných údajov</string>
|
||||||
<string name="pref_ads_loading">Reklama sa načítava</string>
|
<string name="pref_ads_loading">Reklama sa načítava</string>
|
||||||
<string name="pref_ads_once_per_visit">Ďakujeme za vašu podporu, vráťte sa neskôr pre viac reklám</string>
|
<string name="pref_ads_once_per_visit">Ďakujeme za vašu podporu, vráťte sa neskôr pre viac reklám</string>
|
||||||
<string name="pref_ads_consent_title">Môžeme použiť Vaše údaje na zobrazenie reklám?</string>
|
|
||||||
<string name="pref_ads_consent_description">Voľbu môžete kedykoľvek zmeniť v nastavení aplikácie. Môžeme použiť vaše údaje na zobrazenie reklám šitých pre vás alebo pomocou menej vašich dát zobrazovať neprispôsobené reklamy. Podrobnosti nájdete v našich Zásadách ochrany osobných údajov</string>
|
|
||||||
<string name="pref_ads_summary_personalized">Prispôsobené reklamy</string>
|
|
||||||
<string name="pref_ads_summary_non_personalized">Neprispôsobené reklamy</string>
|
|
||||||
<string name="pref_ads_over_18_years_old">Mám viac ako 18 rokov</string>
|
|
||||||
<string name="pref_ads_option_personalized">Áno, prispôsobené reklamy</string>
|
|
||||||
<string name="pref_ads_option_non_personalized">Áno, neprispôsobené reklamy</string>
|
|
||||||
<string name="pref_settings_advanced_title">Pokročilé</string>
|
<string name="pref_settings_advanced_title">Pokročilé</string>
|
||||||
<string name="pref_settings_appearance_title">Vzhľad a správanie</string>
|
<string name="pref_settings_appearance_title">Vzhľad a správanie</string>
|
||||||
<string name="pref_settings_notifications_title">Oznámenia</string>
|
<string name="pref_settings_notifications_title">Oznámenia</string>
|
||||||
|
@ -769,13 +769,6 @@
|
|||||||
<string name="pref_ads_privacy_link">Політика конфіденційності</string>
|
<string name="pref_ads_privacy_link">Політика конфіденційності</string>
|
||||||
<string name="pref_ads_loading">Реклама завантажується</string>
|
<string name="pref_ads_loading">Реклама завантажується</string>
|
||||||
<string name="pref_ads_once_per_visit">Дякуємо за вашу підтримку, повертайтеся пізніше для більшої кількості реклам</string>
|
<string name="pref_ads_once_per_visit">Дякуємо за вашу підтримку, повертайтеся пізніше для більшої кількості реклам</string>
|
||||||
<string name="pref_ads_consent_title">Чи можемо ми використовувати ваші дані для висвітлювання реклами?</string>
|
|
||||||
<string name="pref_ads_consent_description">Ви можете змінити свій вибір в будь-який час в налаштуваннях додатку. Ми можемо використовувати ваші дані для висвітлювання реклами, адаптованої до вас або, використовуючи менше ваших даних, висвітлювати неперсоналізовану рекламу. Перегляньте нашу Політику конфіденційності для подробиць</string>
|
|
||||||
<string name="pref_ads_summary_personalized">Персоналізована реклама</string>
|
|
||||||
<string name="pref_ads_summary_non_personalized">Неперсоналізована реклама</string>
|
|
||||||
<string name="pref_ads_over_18_years_old">Мені більше 18 років</string>
|
|
||||||
<string name="pref_ads_option_personalized">Так, персоналізована реклама</string>
|
|
||||||
<string name="pref_ads_option_non_personalized">Так, неперсоналізована реклама</string>
|
|
||||||
<string name="pref_settings_advanced_title">Додатково</string>
|
<string name="pref_settings_advanced_title">Додатково</string>
|
||||||
<string name="pref_settings_appearance_title">Вигляд та поведінка</string>
|
<string name="pref_settings_appearance_title">Вигляд та поведінка</string>
|
||||||
<string name="pref_settings_notifications_title">Сповіщення</string>
|
<string name="pref_settings_notifications_title">Сповіщення</string>
|
||||||
|
@ -37,8 +37,7 @@
|
|||||||
<string name="pref_key_ads_single_support">single_ad_support</string>
|
<string name="pref_key_ads_single_support">single_ad_support</string>
|
||||||
<string name="pref_key_ads_enabled">ads_enabled</string>
|
<string name="pref_key_ads_enabled">ads_enabled</string>
|
||||||
<string name="pref_key_ads_privacy_policy">ads_privacy_policy</string>
|
<string name="pref_key_ads_privacy_policy">ads_privacy_policy</string>
|
||||||
<string name="pref_key_ads_consent_data_processing">ads_consent_data_processing</string>
|
<string name="pref_key_ads_ump_agreements">ads_ump_agreements</string>
|
||||||
<string name="pref_key_ads_over_eighteen">ads_over_eighteen</string>
|
|
||||||
<string name="pref_key_incognito_moge">incognito_mode</string>
|
<string name="pref_key_incognito_moge">incognito_mode</string>
|
||||||
<string name="pref_key_menu_order">appearance_menu_order</string>
|
<string name="pref_key_menu_order">appearance_menu_order</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -749,7 +749,7 @@
|
|||||||
<string name="pref_ads_support_category_name">Support</string>
|
<string name="pref_ads_support_category_name">Support</string>
|
||||||
<string name="pref_ads_privacy_policy">Privacy Policy</string>
|
<string name="pref_ads_privacy_policy">Privacy Policy</string>
|
||||||
<string name="pref_ads_agreements">Agreements</string>
|
<string name="pref_ads_agreements">Agreements</string>
|
||||||
<string name="pref_ads_consent">Consent to processing of data related to ads</string>
|
<string name="pref_ads_consent">Show consent to data processing</string>
|
||||||
<string name="pref_ads_show_in_app">Show ads in app</string>
|
<string name="pref_ads_show_in_app">Show ads in app</string>
|
||||||
<string name="pref_ads_support">Watch single ad to support project</string>
|
<string name="pref_ads_support">Watch single ad to support project</string>
|
||||||
<string name="pref_ads_privacy_title">Consent to data processing</string>
|
<string name="pref_ads_privacy_title">Consent to data processing</string>
|
||||||
@ -758,13 +758,6 @@
|
|||||||
<string name="pref_ads_privacy_link">Privacy policy</string>
|
<string name="pref_ads_privacy_link">Privacy policy</string>
|
||||||
<string name="pref_ads_loading">Ad is loading</string>
|
<string name="pref_ads_loading">Ad is loading</string>
|
||||||
<string name="pref_ads_once_per_visit">Thank you for your support, come back later for more ads</string>
|
<string name="pref_ads_once_per_visit">Thank you for your support, come back later for more ads</string>
|
||||||
<string name="pref_ads_consent_title">Can we use your data to display ads?</string>
|
|
||||||
<string name="pref_ads_consent_description">You can change your choice anytime in the app settings. We may use your data to display ads tailored to you or, using less of your data, display non-personalized ads. Please see our Privacy Policy for details</string>
|
|
||||||
<string name="pref_ads_summary_personalized">Personalized ads</string>
|
|
||||||
<string name="pref_ads_summary_non_personalized">Non-personalized ads</string>
|
|
||||||
<string name="pref_ads_over_18_years_old">I am over 18 years old</string>
|
|
||||||
<string name="pref_ads_option_personalized">Yes, personalized ads</string>
|
|
||||||
<string name="pref_ads_option_non_personalized">Yes, non-personalized ads</string>
|
|
||||||
<string name="pref_settings_advanced_title">Advanced</string>
|
<string name="pref_settings_advanced_title">Advanced</string>
|
||||||
<string name="pref_settings_appearance_title">Appearance & Behavior</string>
|
<string name="pref_settings_appearance_title">Appearance & Behavior</string>
|
||||||
<string name="pref_settings_notifications_title">Notifications</string>
|
<string name="pref_settings_notifications_title">Notifications</string>
|
||||||
|
@ -2,19 +2,17 @@ package io.github.wulkanowy.ui.modules.settings.ads
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.preference.CheckBoxPreference
|
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.preference.SwitchPreferenceCompat
|
import androidx.preference.SwitchPreferenceCompat
|
||||||
import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd
|
import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.databinding.DialogAdsConsentBinding
|
|
||||||
import io.github.wulkanowy.ui.base.BaseActivity
|
import io.github.wulkanowy.ui.base.BaseActivity
|
||||||
import io.github.wulkanowy.ui.base.ErrorDialog
|
import io.github.wulkanowy.ui.base.ErrorDialog
|
||||||
import io.github.wulkanowy.ui.modules.auth.AuthDialog
|
import io.github.wulkanowy.ui.modules.auth.AuthDialog
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
|
import io.github.wulkanowy.utils.AdsHelper
|
||||||
import io.github.wulkanowy.utils.openInternetBrowser
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -24,6 +22,9 @@ class AdsFragment : PreferenceFragmentCompat(), MainView.TitledView, AdsView {
|
|||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: AdsPresenter
|
lateinit var presenter: AdsPresenter
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
lateinit var adsHelper: AdsHelper
|
||||||
|
|
||||||
override val titleStringId = R.string.pref_settings_ads_title
|
override val titleStringId = R.string.pref_settings_ads_title
|
||||||
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
@ -46,9 +47,16 @@ class AdsFragment : PreferenceFragmentCompat(), MainView.TitledView, AdsView {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
findPreference<CheckBoxPreference>(getString(R.string.pref_key_ads_consent_data_processing))
|
findPreference<Preference>(getString(R.string.pref_key_ads_ump_agreements))?.setOnPreferenceClickListener {
|
||||||
?.setOnPreferenceChangeListener { _, newValue ->
|
presenter.onUmpAgreementsSelected()
|
||||||
presenter.onConsentSelected(newValue as Boolean)
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
findPreference<Preference>(getString(R.string.pref_key_ads_single_support))
|
||||||
|
?.isEnabled = adsHelper.canShowAd
|
||||||
|
|
||||||
|
findPreference<SwitchPreferenceCompat>(getString(R.string.pref_key_ads_enabled))?.setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
presenter.onAdsEnabledSelected(newValue as Boolean)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,48 +67,6 @@ class AdsFragment : PreferenceFragmentCompat(), MainView.TitledView, AdsView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showPrivacyPolicyDialog() {
|
|
||||||
val dialogAdsConsentBinding = DialogAdsConsentBinding.inflate(layoutInflater)
|
|
||||||
|
|
||||||
val dialog = MaterialAlertDialogBuilder(requireContext())
|
|
||||||
.setTitle(R.string.pref_ads_consent_title)
|
|
||||||
.setMessage(R.string.pref_ads_consent_description)
|
|
||||||
.setView(dialogAdsConsentBinding.root)
|
|
||||||
.setOnCancelListener { presenter.onPrivacyDialogCanceled() }
|
|
||||||
.show()
|
|
||||||
|
|
||||||
dialogAdsConsentBinding.adsConsentOver.setOnCheckedChangeListener { _, isChecked ->
|
|
||||||
dialogAdsConsentBinding.adsConsentPersonalised.isEnabled = isChecked
|
|
||||||
}
|
|
||||||
|
|
||||||
dialogAdsConsentBinding.adsConsentPersonalised.setOnClickListener {
|
|
||||||
presenter.onPersonalizedAgree()
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
dialogAdsConsentBinding.adsConsentNonPersonalised.setOnClickListener {
|
|
||||||
presenter.onNonPersonalizedAgree()
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
dialogAdsConsentBinding.adsConsentPrivacy.setOnClickListener { presenter.onPrivacySelected() }
|
|
||||||
dialogAdsConsentBinding.adsConsentCancel.setOnClickListener { dialog.cancel() }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun showProcessingDataSummary(isPersonalized: Boolean?) {
|
|
||||||
val summaryText = isPersonalized?.let {
|
|
||||||
getString(if (it) R.string.pref_ads_summary_personalized else R.string.pref_ads_summary_non_personalized)
|
|
||||||
}
|
|
||||||
|
|
||||||
findPreference<CheckBoxPreference>(getString(R.string.pref_key_ads_consent_data_processing))
|
|
||||||
?.summary = summaryText
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setCheckedProcessingData(checked: Boolean) {
|
|
||||||
findPreference<CheckBoxPreference>(getString(R.string.pref_key_ads_consent_data_processing))
|
|
||||||
?.isChecked = checked
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setCheckedAdsEnabled(checked: Boolean) {
|
override fun setCheckedAdsEnabled(checked: Boolean) {
|
||||||
findPreference<SwitchPreferenceCompat>(getString(R.string.pref_key_ads_enabled))
|
findPreference<SwitchPreferenceCompat>(getString(R.string.pref_key_ads_enabled))
|
||||||
?.isChecked = checked
|
?.isChecked = checked
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package io.github.wulkanowy.ui.modules.settings.ads
|
package io.github.wulkanowy.ui.modules.settings.ads
|
||||||
|
|
||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
|
||||||
import io.github.wulkanowy.data.repositories.StudentRepository
|
import io.github.wulkanowy.data.repositories.StudentRepository
|
||||||
import io.github.wulkanowy.ui.base.BasePresenter
|
import io.github.wulkanowy.ui.base.BasePresenter
|
||||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||||
@ -13,18 +12,12 @@ class AdsPresenter @Inject constructor(
|
|||||||
errorHandler: ErrorHandler,
|
errorHandler: ErrorHandler,
|
||||||
studentRepository: StudentRepository,
|
studentRepository: StudentRepository,
|
||||||
private val adsHelper: AdsHelper,
|
private val adsHelper: AdsHelper,
|
||||||
private val preferencesRepository: PreferencesRepository
|
|
||||||
) : BasePresenter<AdsView>(errorHandler, studentRepository) {
|
) : BasePresenter<AdsView>(errorHandler, studentRepository) {
|
||||||
|
|
||||||
override fun onAttachView(view: AdsView) {
|
override fun onAttachView(view: AdsView) {
|
||||||
super.onAttachView(view)
|
super.onAttachView(view)
|
||||||
view.initView()
|
view.initView()
|
||||||
Timber.i("Settings ads view was initialized")
|
Timber.i("Settings ads view was initialized")
|
||||||
|
|
||||||
view.showProcessingDataSummary(
|
|
||||||
preferencesRepository.isPersonalizedAdsEnabled.takeIf {
|
|
||||||
preferencesRepository.isAgreeToProcessData
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onWatchSingleAdSelected() {
|
fun onWatchSingleAdSelected() {
|
||||||
@ -50,38 +43,17 @@ class AdsPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onConsentSelected(isChecked: Boolean) {
|
|
||||||
if (isChecked) {
|
|
||||||
view?.showPrivacyPolicyDialog()
|
|
||||||
} else {
|
|
||||||
view?.showProcessingDataSummary(null)
|
|
||||||
view?.setCheckedAdsEnabled(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onPrivacySelected() {
|
fun onPrivacySelected() {
|
||||||
view?.openPrivacyPolicy()
|
view?.openPrivacyPolicy()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onPrivacyDialogCanceled() {
|
fun onAdsEnabledSelected(newValue: Boolean) {
|
||||||
view?.setCheckedProcessingData(false)
|
if (newValue) {
|
||||||
}
|
|
||||||
|
|
||||||
fun onNonPersonalizedAgree() {
|
|
||||||
preferencesRepository.isPersonalizedAdsEnabled = false
|
|
||||||
|
|
||||||
adsHelper.initialize()
|
adsHelper.initialize()
|
||||||
|
}
|
||||||
view?.setCheckedProcessingData(true)
|
}
|
||||||
view?.showProcessingDataSummary(false)
|
|
||||||
}
|
fun onUmpAgreementsSelected() {
|
||||||
|
adsHelper.openAdsUmpAgreements()
|
||||||
fun onPersonalizedAgree() {
|
|
||||||
preferencesRepository.isPersonalizedAdsEnabled = true
|
|
||||||
|
|
||||||
adsHelper.initialize()
|
|
||||||
|
|
||||||
view?.setCheckedProcessingData(true)
|
|
||||||
view?.showProcessingDataSummary(true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,6 @@ interface AdsView : BaseView {
|
|||||||
|
|
||||||
fun showAd(ad: RewardedInterstitialAd)
|
fun showAd(ad: RewardedInterstitialAd)
|
||||||
|
|
||||||
fun showPrivacyPolicyDialog()
|
|
||||||
|
|
||||||
fun openPrivacyPolicy()
|
fun openPrivacyPolicy()
|
||||||
|
|
||||||
fun showLoadingSupportAd(show: Boolean)
|
fun showLoadingSupportAd(show: Boolean)
|
||||||
@ -18,8 +16,4 @@ interface AdsView : BaseView {
|
|||||||
fun showWatchAdOncePerVisit(show: Boolean)
|
fun showWatchAdOncePerVisit(show: Boolean)
|
||||||
|
|
||||||
fun setCheckedAdsEnabled(checked: Boolean)
|
fun setCheckedAdsEnabled(checked: Boolean)
|
||||||
|
|
||||||
fun setCheckedProcessingData(checked: Boolean)
|
|
||||||
|
|
||||||
fun showProcessingDataSummary(isPersonalized: Boolean?)
|
|
||||||
}
|
}
|
||||||
|
@ -1,49 +1,110 @@
|
|||||||
package io.github.wulkanowy.utils
|
package io.github.wulkanowy.utils
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import android.net.NetworkCapabilities
|
import android.net.NetworkCapabilities
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import com.google.ads.mediation.admob.AdMobAdapter
|
import com.google.android.gms.ads.AdListener
|
||||||
import com.google.android.gms.ads.*
|
import com.google.android.gms.ads.AdRequest
|
||||||
|
import com.google.android.gms.ads.AdSize
|
||||||
|
import com.google.android.gms.ads.AdView
|
||||||
|
import com.google.android.gms.ads.LoadAdError
|
||||||
|
import com.google.android.gms.ads.MobileAds
|
||||||
import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd
|
import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd
|
||||||
import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAdLoadCallback
|
import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAdLoadCallback
|
||||||
|
import com.google.android.ump.ConsentInformation
|
||||||
|
import com.google.android.ump.ConsentRequestParameters
|
||||||
|
import com.google.android.ump.UserMessagingPlatform
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
|
import dagger.hilt.android.scopes.ActivityScoped
|
||||||
import io.github.wulkanowy.BuildConfig
|
import io.github.wulkanowy.BuildConfig
|
||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import timber.log.Timber
|
||||||
import java.net.UnknownHostException
|
import java.net.UnknownHostException
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.coroutines.resume
|
import kotlin.coroutines.resume
|
||||||
import kotlin.coroutines.resumeWithException
|
import kotlin.coroutines.resumeWithException
|
||||||
import kotlin.coroutines.suspendCoroutine
|
import kotlin.coroutines.suspendCoroutine
|
||||||
|
|
||||||
|
@ActivityScoped
|
||||||
class AdsHelper @Inject constructor(
|
class AdsHelper @Inject constructor(
|
||||||
|
private val activity: Activity,
|
||||||
@ApplicationContext private val context: Context,
|
@ApplicationContext private val context: Context,
|
||||||
private val preferencesRepository: PreferencesRepository
|
preferencesRepository: PreferencesRepository
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
private var isMobileAdsInitializeCalled = AtomicBoolean(false)
|
||||||
|
private var consentInformation: ConsentInformation? = null
|
||||||
|
|
||||||
|
private val canRequestAd get() = consentInformation?.canRequestAds() == true
|
||||||
|
val isMobileAdsSdkInitialized = MutableStateFlow(false)
|
||||||
|
val canShowAd get() = isMobileAdsSdkInitialized.value && canRequestAd
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (preferencesRepository.isAdsEnabled) {
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun initialize() {
|
fun initialize() {
|
||||||
if (preferencesRepository.isAgreeToProcessData) {
|
val consentRequestParameters = ConsentRequestParameters.Builder()
|
||||||
MobileAds.initialize(context)
|
.build()
|
||||||
|
|
||||||
|
consentInformation = UserMessagingPlatform.getConsentInformation(context)
|
||||||
|
consentInformation?.requestConsentInfoUpdate(
|
||||||
|
activity,
|
||||||
|
consentRequestParameters,
|
||||||
|
{
|
||||||
|
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
|
||||||
|
activity
|
||||||
|
) { loadAndShowError ->
|
||||||
|
|
||||||
|
if (loadAndShowError != null) {
|
||||||
|
Timber.e(IllegalStateException("${loadAndShowError.errorCode}: ${loadAndShowError.message}"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canRequestAd) {
|
||||||
|
initializeMobileAds()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ requestConsentError ->
|
||||||
|
Timber.e(IllegalStateException("${requestConsentError.errorCode}: ${requestConsentError.message}"))
|
||||||
|
})
|
||||||
|
|
||||||
|
if (canRequestAd) {
|
||||||
|
initializeMobileAds()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun openAdsUmpAgreements() {
|
||||||
|
UserMessagingPlatform.showPrivacyOptionsForm(activity) {
|
||||||
|
if (it != null) {
|
||||||
|
Timber.e(IllegalStateException("${it.errorCode}: ${it.message}"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initializeMobileAds() {
|
||||||
|
if (isMobileAdsInitializeCalled.getAndSet(true)) return
|
||||||
|
|
||||||
|
MobileAds.initialize(context) {
|
||||||
|
isMobileAdsSdkInitialized.value = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getSupportAd(): RewardedInterstitialAd? {
|
suspend fun getSupportAd(): RewardedInterstitialAd? {
|
||||||
|
if (!canRequestAd) return null
|
||||||
if (!context.isInternetConnected()) {
|
if (!context.isInternetConnected()) {
|
||||||
throw UnknownHostException()
|
throw UnknownHostException()
|
||||||
}
|
}
|
||||||
|
|
||||||
val extra = Bundle().apply { putString("npa", "1") }
|
|
||||||
val adRequest = AdRequest.Builder()
|
val adRequest = AdRequest.Builder()
|
||||||
.apply {
|
|
||||||
if (!preferencesRepository.isPersonalizedAdsEnabled) {
|
|
||||||
addNetworkExtrasBundle(AdMobAdapter::class.java, extra)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
return suspendCoroutine {
|
return suspendCoroutine {
|
||||||
@ -64,13 +125,8 @@ class AdsHelper @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getDashboardTileAdBanner(width: Int): AdBanner {
|
suspend fun getDashboardTileAdBanner(width: Int): AdBanner {
|
||||||
val extra = Bundle().apply { putString("npa", "1") }
|
if (!canShowAd) throw IllegalStateException("Cannot show ad")
|
||||||
val adRequest = AdRequest.Builder()
|
val adRequest = AdRequest.Builder()
|
||||||
.apply {
|
|
||||||
if (!preferencesRepository.isPersonalizedAdsEnabled) {
|
|
||||||
addNetworkExtrasBundle(AdMobAdapter::class.java, extra)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
return suspendCoroutine {
|
return suspendCoroutine {
|
||||||
|
@ -1,25 +1,24 @@
|
|||||||
package io.github.wulkanowy.utils
|
package io.github.wulkanowy.utils
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import com.google.firebase.Firebase
|
||||||
import com.google.firebase.analytics.FirebaseAnalytics
|
import com.google.firebase.analytics.FirebaseAnalytics
|
||||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
import com.google.firebase.analytics.analytics
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import com.google.firebase.crashlytics.crashlytics
|
||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class AnalyticsHelper @Inject constructor(
|
class AnalyticsHelper @Inject constructor(
|
||||||
@ApplicationContext private val context: Context,
|
|
||||||
preferencesRepository: PreferencesRepository,
|
preferencesRepository: PreferencesRepository,
|
||||||
appInfo: AppInfo,
|
appInfo: AppInfo,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val analytics by lazy { FirebaseAnalytics.getInstance(context) }
|
private val analytics by lazy { Firebase.analytics }
|
||||||
|
|
||||||
private val crashlytics by lazy { FirebaseCrashlytics.getInstance() }
|
private val crashlytics by lazy { Firebase.crashlytics }
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (!appInfo.isDebug) {
|
if (!appInfo.isDebug) {
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
app:defaultValue="@string/pref_key_ads_enabled"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:key="@string/pref_key_ads_enabled"
|
||||||
|
app:singleLineTitle="false"
|
||||||
|
app:title="@string/pref_ads_show_in_app" />
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
app:title="@string/pref_ads_agreements">
|
app:title="@string/pref_ads_agreements">
|
||||||
@ -8,25 +14,17 @@
|
|||||||
app:key="@string/pref_key_ads_privacy_policy"
|
app:key="@string/pref_key_ads_privacy_policy"
|
||||||
app:singleLineTitle="false"
|
app:singleLineTitle="false"
|
||||||
app:title="@string/pref_ads_privacy_policy" />
|
app:title="@string/pref_ads_privacy_policy" />
|
||||||
<CheckBoxPreference
|
<Preference
|
||||||
app:defaultValue="@bool/pref_default_ads_consent_data_processing"
|
app:dependency="@string/pref_key_ads_enabled"
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
app:key="@string/pref_key_ads_consent_data_processing"
|
app:key="@string/pref_key_ads_ump_agreements"
|
||||||
app:singleLineTitle="false"
|
app:singleLineTitle="false"
|
||||||
app:title="@string/pref_ads_consent" />
|
app:title="@string/pref_ads_consent" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
app:title="@string/pref_ads_support_category_name">
|
app:title="@string/pref_ads_support_category_name">
|
||||||
<SwitchPreferenceCompat
|
|
||||||
app:defaultValue="@string/pref_key_ads_enabled"
|
|
||||||
app:dependency="@string/pref_key_ads_consent_data_processing"
|
|
||||||
app:iconSpaceReserved="false"
|
|
||||||
app:key="@string/pref_key_ads_enabled"
|
|
||||||
app:singleLineTitle="false"
|
|
||||||
app:title="@string/pref_ads_show_in_app" />
|
|
||||||
<Preference
|
<Preference
|
||||||
app:dependency="@string/pref_key_ads_consent_data_processing"
|
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
app:key="@string/pref_key_ads_single_support"
|
app:key="@string/pref_key_ads_single_support"
|
||||||
app:singleLineTitle="false"
|
app:singleLineTitle="false"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user