Skip to content

Commit 33a5226

Browse files
committed
Format the classes edited due to moving package changes
As these have "changed" since develop then they need formatting!
1 parent ec9166d commit 33a5226

File tree

6 files changed

+247
-234
lines changed

6 files changed

+247
-234
lines changed

app-tracking-protection/vpn-impl/src/main/java/com/duckduckgo/mobile/android/vpn/ui/newtab/AppTrackingProtectionStateView.kt

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,18 @@ import com.duckduckgo.mobile.android.vpn.ui.tracker_activity.DeviceShieldTracker
4646
import com.duckduckgo.newtabpage.api.NewTabPageSection
4747
import com.duckduckgo.newtabpage.api.NewTabPageSectionPlugin
4848
import dagger.android.support.AndroidSupportInjection
49-
import javax.inject.Inject
5049
import kotlinx.coroutines.cancel
5150
import kotlinx.coroutines.flow.launchIn
5251
import kotlinx.coroutines.flow.onEach
52+
import javax.inject.Inject
5353

5454
@InjectWith(ViewScope::class)
5555
class AppTrackingProtectionStateView @JvmOverloads constructor(
5656
context: Context,
5757
attrs: AttributeSet? = null,
5858
defStyle: Int = 0,
5959
) : FrameLayout(context, attrs, defStyle) {
60-
61-
override fun getTag(): String {
62-
return "AppTP"
63-
}
60+
override fun getTag(): String = "AppTP"
6461

6562
@Inject
6663
lateinit var deviceShieldPixels: DeviceShieldPixels
@@ -83,9 +80,10 @@ class AppTrackingProtectionStateView @JvmOverloads constructor(
8380
AndroidSupportInjection.inject(this)
8481
super.onAttachedToWindow()
8582

86-
conflatedJob += viewModel.viewStateFlow
87-
.onEach { viewState -> renderViewState(viewState) }
88-
.launchIn(findViewTreeLifecycleOwner()?.lifecycleScope!!)
83+
conflatedJob +=
84+
viewModel.viewStateFlow
85+
.onEach { viewState -> renderViewState(viewState) }
86+
.launchIn(findViewTreeLifecycleOwner()?.lifecycleScope!!)
8987

9088
deviceShieldPixels.didShowNewTabSummary()
9189

@@ -141,49 +139,56 @@ class AppTrackingProtectionStateView @JvmOverloads constructor(
141139
val lastTrackingApp = trackerBlocked.latestApp
142140
val otherApps = trackerBlocked.otherAppsSize
143141

144-
val textToStyle = if (trackersBlocked == 1) {
145-
when (otherApps) {
146-
0 -> resources.getString(
147-
R.string.atp_DailyLastCompanyBlockedHomeTabOneTimeZeroOtherApps,
148-
trackersBlocked,
149-
lastTrackingApp,
150-
)
151-
152-
1 -> resources.getString(
153-
R.string.atp_DailyLastCompanyBlockedHomeTabOneTimeOneOtherApp,
154-
trackersBlocked,
155-
lastTrackingApp,
156-
)
157-
158-
else -> resources.getString(
159-
R.string.atp_DailyLastCompanyBlockedHomeTabOneTimeMoreOtherApps,
160-
trackersBlocked,
161-
lastTrackingApp,
162-
otherApps,
163-
)
142+
val textToStyle =
143+
if (trackersBlocked == 1) {
144+
when (otherApps) {
145+
0 ->
146+
resources.getString(
147+
R.string.atp_DailyLastCompanyBlockedHomeTabOneTimeZeroOtherApps,
148+
trackersBlocked,
149+
lastTrackingApp,
150+
)
151+
152+
1 ->
153+
resources.getString(
154+
R.string.atp_DailyLastCompanyBlockedHomeTabOneTimeOneOtherApp,
155+
trackersBlocked,
156+
lastTrackingApp,
157+
)
158+
159+
else ->
160+
resources.getString(
161+
R.string.atp_DailyLastCompanyBlockedHomeTabOneTimeMoreOtherApps,
162+
trackersBlocked,
163+
lastTrackingApp,
164+
otherApps,
165+
)
166+
}
167+
} else {
168+
when (otherApps) {
169+
0 ->
170+
resources.getString(
171+
R.string.atp_DailyLastCompanyBlockedHomeTabOtherTimesZeroOtherApps,
172+
trackersBlocked,
173+
lastTrackingApp,
174+
)
175+
176+
1 ->
177+
resources.getString(
178+
R.string.atp_DailyLastCompanyBlockedHomeTabOtherTimesOneOtherApp,
179+
trackersBlocked,
180+
lastTrackingApp,
181+
)
182+
183+
else ->
184+
resources.getString(
185+
R.string.atp_DailyLastCompanyBlockedHomeTabOtherTimesMoreOtherApps,
186+
trackersBlocked,
187+
lastTrackingApp,
188+
otherApps,
189+
)
190+
}
164191
}
165-
} else {
166-
when (otherApps) {
167-
0 -> resources.getString(
168-
R.string.atp_DailyLastCompanyBlockedHomeTabOtherTimesZeroOtherApps,
169-
trackersBlocked,
170-
lastTrackingApp,
171-
)
172-
173-
1 -> resources.getString(
174-
R.string.atp_DailyLastCompanyBlockedHomeTabOtherTimesOneOtherApp,
175-
trackersBlocked,
176-
lastTrackingApp,
177-
)
178-
179-
else -> resources.getString(
180-
R.string.atp_DailyLastCompanyBlockedHomeTabOtherTimesMoreOtherApps,
181-
trackersBlocked,
182-
lastTrackingApp,
183-
otherApps,
184-
)
185-
}
186-
}
187192

188193
binding.deviceShieldCtaHeader.text = HtmlCompat.fromHtml(textToStyle, HtmlCompat.FROM_HTML_MODE_LEGACY)
189194
binding.deviceShieldCtaImage.setImageResource(R.drawable.ic_apptp_default)
@@ -202,9 +207,7 @@ class AppTrackingProtectionNewTabPageSectionPlugin @Inject constructor(
202207
) : NewTabPageSectionPlugin {
203208
override val name = NewTabPageSection.APP_TRACKING_PROTECTION.name
204209

205-
override fun getView(context: Context): View {
206-
return AppTrackingProtectionStateView(context)
207-
}
210+
override fun getView(context: Context): View = AppTrackingProtectionStateView(context)
208211

209212
override suspend fun isUserEnabled(): Boolean {
210213
if (vpnFeatureRemover.isFeatureRemoved()) {

app-tracking-protection/vpn-impl/src/main/java/com/duckduckgo/mobile/android/vpn/ui/privacyreport/DeviceShieldAppTrackersInfo.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import javax.inject.Inject
2929

3030
@InjectWith(ActivityScope::class)
3131
class DeviceShieldAppTrackersInfo : DuckDuckGoActivity() {
32-
3332
@Inject
3433
lateinit var deviceShieldPixels: DeviceShieldPixels
3534

@@ -55,9 +54,6 @@ class DeviceShieldAppTrackersInfo : DuckDuckGoActivity() {
5554
}
5655

5756
companion object {
58-
59-
internal fun intent(context: Context): Intent {
60-
return Intent(context, DeviceShieldAppTrackersInfo::class.java)
61-
}
57+
internal fun intent(context: Context): Intent = Intent(context, DeviceShieldAppTrackersInfo::class.java)
6258
}
6359
}

app-tracking-protection/vpn-impl/src/main/java/com/duckduckgo/mobile/android/vpn/ui/privacyreport/DeviceShieldFragment.kt

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@ import com.duckduckgo.mobile.android.vpn.state.VpnStateMonitor.VpnStopReason.REV
4141
import com.duckduckgo.mobile.android.vpn.ui.privacyreport.PrivacyReportViewModel.PrivacyReportView.TrackersBlocked
4242
import com.duckduckgo.mobile.android.vpn.ui.privacyreport.PrivacyReportViewModel.PrivacyReportView.ViewState
4343
import com.duckduckgo.mobile.android.vpn.ui.tracker_activity.DeviceShieldTrackerActivity
44-
import javax.inject.Inject
4544
import kotlinx.coroutines.flow.launchIn
4645
import kotlinx.coroutines.flow.onEach
46+
import javax.inject.Inject
4747

4848
@InjectWith(FragmentScope::class)
4949
class DeviceShieldFragment : DuckDuckGoFragment() {
50-
5150
@Inject
5251
lateinit var viewModelFactory: FragmentViewModelFactory
5352

@@ -58,8 +57,7 @@ class DeviceShieldFragment : DuckDuckGoFragment() {
5857
private lateinit var deviceShieldCtaHeaderTextView: TextView
5958
private lateinit var deviceShieldCtaImageView: ImageView
6059

61-
private inline fun <reified V : ViewModel> bindViewModel() =
62-
lazy { ViewModelProvider(this, viewModelFactory).get(V::class.java) }
60+
private inline fun <reified V : ViewModel> bindViewModel() = lazy { ViewModelProvider(this, viewModelFactory).get(V::class.java) }
6361

6462
private val viewModel: PrivacyReportViewModel by bindViewModel()
6563

@@ -145,45 +143,52 @@ class DeviceShieldFragment : DuckDuckGoFragment() {
145143
val lastTrackingApp = trackerBlocked.latestApp
146144
val otherApps = trackerBlocked.otherAppsSize
147145

148-
val textToStyle = if (trackersBlocked == 1) {
149-
when (otherApps) {
150-
0 -> resources.getString(
151-
R.string.atp_DailyLastCompanyBlockedHomeTabOneTimeZeroOtherApps,
152-
trackersBlocked,
153-
lastTrackingApp,
154-
)
155-
1 -> resources.getString(
156-
R.string.atp_DailyLastCompanyBlockedHomeTabOneTimeOneOtherApp,
157-
trackersBlocked,
158-
lastTrackingApp,
159-
)
160-
else -> resources.getString(
161-
R.string.atp_DailyLastCompanyBlockedHomeTabOneTimeMoreOtherApps,
162-
trackersBlocked,
163-
lastTrackingApp,
164-
otherApps,
165-
)
146+
val textToStyle =
147+
if (trackersBlocked == 1) {
148+
when (otherApps) {
149+
0 ->
150+
resources.getString(
151+
R.string.atp_DailyLastCompanyBlockedHomeTabOneTimeZeroOtherApps,
152+
trackersBlocked,
153+
lastTrackingApp,
154+
)
155+
1 ->
156+
resources.getString(
157+
R.string.atp_DailyLastCompanyBlockedHomeTabOneTimeOneOtherApp,
158+
trackersBlocked,
159+
lastTrackingApp,
160+
)
161+
else ->
162+
resources.getString(
163+
R.string.atp_DailyLastCompanyBlockedHomeTabOneTimeMoreOtherApps,
164+
trackersBlocked,
165+
lastTrackingApp,
166+
otherApps,
167+
)
168+
}
169+
} else {
170+
when (otherApps) {
171+
0 ->
172+
resources.getString(
173+
R.string.atp_DailyLastCompanyBlockedHomeTabOtherTimesZeroOtherApps,
174+
trackersBlocked,
175+
lastTrackingApp,
176+
)
177+
1 ->
178+
resources.getString(
179+
R.string.atp_DailyLastCompanyBlockedHomeTabOtherTimesOneOtherApp,
180+
trackersBlocked,
181+
lastTrackingApp,
182+
)
183+
else ->
184+
resources.getString(
185+
R.string.atp_DailyLastCompanyBlockedHomeTabOtherTimesMoreOtherApps,
186+
trackersBlocked,
187+
lastTrackingApp,
188+
otherApps,
189+
)
190+
}
166191
}
167-
} else {
168-
when (otherApps) {
169-
0 -> resources.getString(
170-
R.string.atp_DailyLastCompanyBlockedHomeTabOtherTimesZeroOtherApps,
171-
trackersBlocked,
172-
lastTrackingApp,
173-
)
174-
1 -> resources.getString(
175-
R.string.atp_DailyLastCompanyBlockedHomeTabOtherTimesOneOtherApp,
176-
trackersBlocked,
177-
lastTrackingApp,
178-
)
179-
else -> resources.getString(
180-
R.string.atp_DailyLastCompanyBlockedHomeTabOtherTimesMoreOtherApps,
181-
trackersBlocked,
182-
lastTrackingApp,
183-
otherApps,
184-
)
185-
}
186-
}
187192

188193
deviceShieldCtaHeaderTextView.text = HtmlCompat.fromHtml(textToStyle, HtmlCompat.FROM_HTML_MODE_LEGACY)
189194
deviceShieldCtaImageView.setImageResource(R.drawable.ic_apptp_default)

app-tracking-protection/vpn-impl/src/main/java/com/duckduckgo/mobile/android/vpn/ui/privacyreport/PrivacyReportViewModel.kt

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ import com.duckduckgo.mobile.android.vpn.stats.AppTrackerBlockingStatsRepository
3030
import com.duckduckgo.mobile.android.vpn.ui.onboarding.VpnStore
3131
import com.duckduckgo.mobile.android.vpn.ui.privacyreport.PrivacyReportViewModel.PrivacyReportView.TrackersBlocked
3232
import com.duckduckgo.mobile.android.vpn.ui.privacyreport.PrivacyReportViewModel.PrivacyReportView.ViewState
33-
import javax.inject.Inject
3433
import kotlinx.coroutines.flow.Flow
3534
import kotlinx.coroutines.flow.combine
3635
import kotlinx.coroutines.flow.map
3736
import kotlinx.coroutines.withContext
37+
import javax.inject.Inject
3838

3939
@ContributesViewModel(ViewScope::class)
4040
class PrivacyReportViewModel @Inject constructor(
@@ -44,14 +44,14 @@ class PrivacyReportViewModel @Inject constructor(
4444
vpnStateMonitor: VpnStateMonitor,
4545
private val dispatchers: DispatcherProvider,
4646
) : ViewModel() {
47-
48-
val viewStateFlow = vpnStateMonitor.getStateFlow(AppTpVpnFeature.APPTP_VPN).combine(getReport()) { vpnState, trackersBlocked ->
49-
ViewState(vpnState, trackersBlocked, shouldShowCTA())
50-
}
47+
val viewStateFlow =
48+
vpnStateMonitor.getStateFlow(AppTpVpnFeature.APPTP_VPN).combine(getReport()) { vpnState, trackersBlocked ->
49+
ViewState(vpnState, trackersBlocked, shouldShowCTA())
50+
}
5151

5252
@VisibleForTesting
53-
fun getReport(): Flow<TrackersBlocked> {
54-
return repository.getVpnTrackers({ dateOfLastHour() }).map { trackers ->
53+
fun getReport(): Flow<TrackersBlocked> =
54+
repository.getVpnTrackers({ dateOfLastHour() }).map { trackers ->
5555
if (trackers.isEmpty()) {
5656
TrackersBlocked("", 0, 0)
5757
} else {
@@ -62,23 +62,21 @@ class PrivacyReportViewModel @Inject constructor(
6262
TrackersBlocked(latestApp, otherAppsSize, trackers.sumOf { it.count })
6363
}
6464
}
65-
}
6665

67-
private suspend fun shouldShowCTA(): Boolean {
68-
return withContext(dispatchers.io()) {
66+
private suspend fun shouldShowCTA(): Boolean =
67+
withContext(dispatchers.io()) {
6968
if (vpnFeatureRemover.isFeatureRemoved()) {
7069
false
7170
} else {
7271
vpnStore.didShowOnboarding()
7372
}
7473
}
75-
}
7674

7775
object PrivacyReportView {
7876
data class ViewState(
79-
val vpnState: VpnState,
80-
val trackersBlocked: TrackersBlocked,
81-
val isFeatureEnabled: Boolean,
77+
val vpnState: VpnState,
78+
val trackersBlocked: TrackersBlocked,
79+
val isFeatureEnabled: Boolean,
8280
)
8381

8482
data class TrackersBlocked(

0 commit comments

Comments
 (0)