Skip to content

Commit 010d9cf

Browse files
authored
Update Settings design: Add new SettingsListItem (#5318)
Task/Issue URL: https://app.asana.com/0/1207908166761516/1208785622935231/f ### Description - Adds all new Icons for Settings (not all are implemented) - Adds new SettingsListItem - Also added to the ADS screen - [Designs](https://www.figma.com/design/CjH849hL53lhsPlf6Ufeo4/%E2%9A%99%EF%B8%8F-Browser-Settings-Documentation-(All-Platforms)?node-id=7605-431390&t=loz3Qauz2ZOadWY7-4) - Tackles the privacy section without any copy changes which will be done in a later PR ### Steps to test this PR Pre-requisites: - `newSettings` feature flag must be enabled - Easier to start with a fresh launch - Don't enable DDG as default browser _Default Browser On/Off_ - [x] Open New Settings screen - [x] Default browser should be `off` ⚪ - [x] Press default browser - [x] Select DDG - [x] Press back to get back to the New Settings screen - [x] Default browser should be `on` 🟢 - [x] Press default browser - [x] Select another browser - [x] Press back to get back to the New Settings screen - [x] Default browser should be `off` ⚪ _Private Search_ - [x] Should be `on` and is always on _Web Tracking Protection_ - [x] Should be `on` and is always on _Cookie Pop-Up Protection_ - [x] Open New Settings screen - [x] Cookie Pop-Up Protection should be `on` 🟢 - [x] Press Cookie Pop-Up Protection - [x] Toggle **off** "Let DuckDuckGo handle cookie pop-ups" - [x] Press back - [x] Cookie Pop-Up Protection should be `off` ⚪ - [x] Press Cookie Pop-Up Protection - [x] Toggle **on** "Let DuckDuckGo handle cookie pop-ups" - [x] Press back - [x] Cookie Pop-Up Protection should be `on` 🟢 _App Tracking Protection_ - [x] Open New Settings screen - [x] App Tracking Protection should be `off` ⚪ - [x] Press App Tracking Protection - [x] Toggle **on** App Tracking Protection - [x] Press back - [x] App Tracking Protection should be `on` 🟢 - [x] Press App Tracking Protection - [x] Toggle **off** App Tracking Protection - [x] Press back - [x] App Tracking Protection should be `off` ⚪ _Email Protection_ - [x] Open New Settings screen - [x] Email Protection should be `off` ⚪ - [x] Press Email Protection - [x] Follow steps to turn on Email Protection - [x] Open New Settings screen - [x] Email Protection should be `on` 🟢 - [x] Press Email Protection - [x] Sign out - [x] Open New Settings screen - [x] Email Protection should be `off` ⚪ ### UI changes | Before | After | | ------ | ----- | ![Screenshot_20241126_145126](https://github.com/user-attachments/assets/5ec4e3a0-4c0a-4e33-ae30-891115a1e9f7)|![Screenshot_20241126_145056](https://github.com/user-attachments/assets/11998eff-03eb-4449-99cc-4bf1ecb1b09e)| ![Screenshot_20241126_145134](https://github.com/user-attachments/assets/e354dbe9-dfd3-4040-a179-bff6ce5cd936)|![Screenshot_20241126_145109](https://github.com/user-attachments/assets/fd538cc6-f873-4a55-b373-6c02623e04cd) ![Screenshot_20241126_145502](https://github.com/user-attachments/assets/b3955b96-8c5d-49fd-a5eb-a15e2ec4d083)|![Screenshot_20241126_145543](https://github.com/user-attachments/assets/661c22ac-b037-460f-b62e-f37a8e89083d) ### Demo https://github.com/user-attachments/assets/df4c0a75-05f9-4ddd-afe8-b9dfb58b7fb9
1 parent 04e0326 commit 010d9cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1258
-49
lines changed

app/src/main/java/com/duckduckgo/app/settings/NewSettingsActivity.kt

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import com.duckduckgo.autofill.api.AutofillScreens.AutofillSettingsScreen
5050
import com.duckduckgo.autofill.api.AutofillSettingsLaunchSource
5151
import com.duckduckgo.common.ui.DuckDuckGoActivity
5252
import com.duckduckgo.common.ui.view.gone
53-
import com.duckduckgo.common.ui.view.listitem.CheckListItem
5453
import com.duckduckgo.common.ui.view.listitem.TwoLineListItem
5554
import com.duckduckgo.common.ui.view.show
5655
import com.duckduckgo.common.ui.viewbinding.viewBinding
@@ -204,7 +203,6 @@ class NewSettingsActivity : DuckDuckGoActivity() {
204203
updateDefaultBrowserViewVisibility(it)
205204
updateDeviceShieldSettings(
206205
it.appTrackingProtectionEnabled,
207-
it.appTrackingProtectionOnboardingShown,
208206
)
209207
updateEmailSubtitle(it.emailAddress)
210208
updateAutofill(it.showAutofill)
@@ -247,13 +245,7 @@ class NewSettingsActivity : DuckDuckGoActivity() {
247245
}
248246

249247
private fun updateEmailSubtitle(emailAddress: String?) {
250-
if (emailAddress.isNullOrEmpty()) {
251-
viewsPrivacy.emailSetting.setSecondaryText(getString(com.duckduckgo.app.browser.R.string.settingsEmailProtectionSubtitle))
252-
viewsPrivacy.emailSetting.setItemStatus(CheckListItem.CheckItemStatus.DISABLED)
253-
} else {
254-
viewsPrivacy.emailSetting.setSecondaryText(emailAddress)
255-
viewsPrivacy.emailSetting.setItemStatus(CheckListItem.CheckItemStatus.ENABLED)
256-
}
248+
viewsPrivacy.emailSetting.setStatus(isOn = !emailAddress.isNullOrEmpty())
257249
}
258250

259251
private fun updateSyncSetting(visible: Boolean) {
@@ -263,15 +255,7 @@ class NewSettingsActivity : DuckDuckGoActivity() {
263255
}
264256

265257
private fun updateAutoconsent(enabled: Boolean) {
266-
if (enabled) {
267-
viewsPrivacy.cookiePopupProtectionSetting.setSecondaryText(getString(com.duckduckgo.app.browser.R.string.cookiePopupProtectionEnabled))
268-
viewsPrivacy.cookiePopupProtectionSetting.setItemStatus(CheckListItem.CheckItemStatus.ENABLED)
269-
} else {
270-
viewsPrivacy.cookiePopupProtectionSetting.setSecondaryText(
271-
getString(com.duckduckgo.app.browser.R.string.cookiePopupProtectionDescription),
272-
)
273-
viewsPrivacy.cookiePopupProtectionSetting.setItemStatus(CheckListItem.CheckItemStatus.DISABLED)
274-
}
258+
viewsPrivacy.cookiePopupProtectionSetting.setStatus(isOn = enabled)
275259
}
276260

277261
private fun processCommand(it: Command?) {
@@ -302,38 +286,16 @@ class NewSettingsActivity : DuckDuckGoActivity() {
302286
private fun updateDefaultBrowserViewVisibility(it: NewSettingsViewModel.ViewState) {
303287
with(viewsPrivacy.setAsDefaultBrowserSetting) {
304288
visibility = if (it.showDefaultBrowserSetting) {
305-
if (it.isAppDefaultBrowser) {
306-
setItemStatus(CheckListItem.CheckItemStatus.ENABLED)
307-
setSecondaryText(getString(com.duckduckgo.app.browser.R.string.settingsDefaultBrowserSetDescription))
308-
} else {
309-
setItemStatus(CheckListItem.CheckItemStatus.DISABLED)
310-
setSecondaryText(getString(com.duckduckgo.app.browser.R.string.settingsDefaultBrowserNotSetDescription))
311-
}
289+
setStatus(isOn = it.isAppDefaultBrowser)
312290
View.VISIBLE
313291
} else {
314292
View.GONE
315293
}
316294
}
317295
}
318296

319-
private fun updateDeviceShieldSettings(
320-
appTPEnabled: Boolean,
321-
appTrackingProtectionOnboardingShown: Boolean,
322-
) {
323-
with(viewsPrivacy) {
324-
if (appTPEnabled) {
325-
vpnSetting.setSecondaryText(getString(com.duckduckgo.app.browser.R.string.atp_SettingsDeviceShieldEnabled))
326-
vpnSetting.setItemStatus(CheckListItem.CheckItemStatus.ENABLED)
327-
} else {
328-
if (appTrackingProtectionOnboardingShown) {
329-
vpnSetting.setSecondaryText(getString(com.duckduckgo.app.browser.R.string.atp_SettingsDeviceShieldDisabled))
330-
vpnSetting.setItemStatus(CheckListItem.CheckItemStatus.WARNING)
331-
} else {
332-
vpnSetting.setSecondaryText(getString(com.duckduckgo.app.browser.R.string.atp_SettingsDeviceShieldNeverEnabled))
333-
vpnSetting.setItemStatus(CheckListItem.CheckItemStatus.DISABLED)
334-
}
335-
}
336-
}
297+
private fun updateDeviceShieldSettings(appTPEnabled: Boolean) {
298+
viewsPrivacy.vpnSetting.setStatus(isOn = appTPEnabled)
337299
}
338300

339301
private fun launchDefaultAppScreen() {

app/src/main/java/com/duckduckgo/app/settings/NewSettingsViewModel.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,22 @@ import androidx.lifecycle.ViewModel
2424
import androidx.lifecycle.viewModelScope
2525
import com.duckduckgo.anvil.annotations.ContributesViewModel
2626
import com.duckduckgo.app.browser.defaultbrowsing.DefaultBrowserDetector
27-
import com.duckduckgo.app.pixels.AppPixelName.*
27+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_ABOUT_PRESSED
28+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_ACCESSIBILITY_PRESSED
29+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_APPEARANCE_PRESSED
30+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_APPTP_PRESSED
31+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_COOKIE_POPUP_PROTECTION_PRESSED
32+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_DEFAULT_BROWSER_PRESSED
33+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_EMAIL_PROTECTION_PRESSED
34+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_FIRE_BUTTON_PRESSED
35+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_GENERAL_PRESSED
36+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_MAC_APP_PRESSED
37+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_OPENED
38+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_PERMISSIONS_PRESSED
39+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_PRIVATE_SEARCH_PRESSED
40+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_SYNC_PRESSED
41+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_WEB_TRACKING_PROTECTION_PRESSED
42+
import com.duckduckgo.app.pixels.AppPixelName.SETTINGS_WINDOWS_APP_PRESSED
2843
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchAboutScreen
2944
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchAccessibilitySettings
3045
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchAddHomeScreenWidget
@@ -86,7 +101,6 @@ class NewSettingsViewModel @Inject constructor(
86101
data class ViewState(
87102
val showDefaultBrowserSetting: Boolean = false,
88103
val isAppDefaultBrowser: Boolean = false,
89-
val appTrackingProtectionOnboardingShown: Boolean = false,
90104
val appTrackingProtectionEnabled: Boolean = false,
91105
val emailAddress: String? = null,
92106
val showAutofill: Boolean = false,
@@ -147,7 +161,6 @@ class NewSettingsViewModel @Inject constructor(
147161
currentViewState().copy(
148162
isAppDefaultBrowser = defaultBrowserAlready,
149163
showDefaultBrowserSetting = defaultWebBrowserCapability.deviceSupportsDefaultBrowserConfiguration(),
150-
appTrackingProtectionOnboardingShown = appTrackingProtection.isOnboarded(),
151164
appTrackingProtectionEnabled = appTrackingProtection.isRunning(),
152165
emailAddress = emailManager.getEmailAddress(),
153166
showAutofill = autofillCapabilityChecker.canAccessCredentialManagementScreen(),
@@ -170,7 +183,6 @@ class NewSettingsViewModel @Inject constructor(
170183
val isDeviceShieldEnabled = appTrackingProtection.isRunning()
171184
val currentState = currentViewState()
172185
viewState.value = currentState.copy(
173-
appTrackingProtectionOnboardingShown = appTrackingProtection.isOnboarded(),
174186
appTrackingProtectionEnabled = isDeviceShieldEnabled,
175187
isPrivacyProEnabled = subscriptions.isEligible(),
176188
)

app/src/main/res/layout/activity_settings_new.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626

2727
<include
2828
android:id="@+id/includeSettings"
29-
layout="@layout/content_settings" />
29+
layout="@layout/content_settings_new" />
3030

3131
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
~ Copyright (c) 2017 DuckDuckGo
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
18+
xmlns:app="http://schemas.android.com/apk/res-auto"
19+
xmlns:tools="http://schemas.android.com/tools"
20+
android:layout_width="match_parent"
21+
android:layout_height="match_parent"
22+
app:layout_behavior="@string/appbar_scrolling_view_behavior"
23+
tools:ignore="Overdraw">
24+
25+
<LinearLayout
26+
android:layout_width="match_parent"
27+
android:layout_height="wrap_content"
28+
android:orientation="vertical"
29+
android:paddingBottom="20dp">
30+
31+
<include
32+
android:id="@+id/contentSettingsPrivacy"
33+
layout="@layout/content_settings_new_privacy"
34+
android:layout_width="match_parent"
35+
android:layout_height="wrap_content"
36+
android:layout_marginTop="@dimen/keyline_4" />
37+
38+
<LinearLayout
39+
android:id="@+id/settingsSectionPro"
40+
android:layout_width="match_parent"
41+
android:layout_height="match_parent"
42+
android:orientation="vertical" >
43+
<com.duckduckgo.common.ui.view.divider.HorizontalDivider
44+
android:layout_width="match_parent"
45+
android:layout_height="wrap_content" />
46+
</LinearLayout>
47+
48+
<include
49+
android:id="@+id/contentSettingsSettings"
50+
layout="@layout/content_settings_settings"
51+
android:layout_width="match_parent"
52+
android:layout_height="wrap_content" />
53+
54+
<include
55+
android:id="@+id/contentSettingsMore"
56+
layout="@layout/content_settings_other"
57+
android:layout_width="match_parent"
58+
android:layout_height="wrap_content" />
59+
60+
<include
61+
android:id="@+id/contentSettingsInternal"
62+
layout="@layout/content_settings_internal"
63+
android:layout_width="match_parent"
64+
android:layout_height="wrap_content" />
65+
66+
</LinearLayout>
67+
68+
</ScrollView>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
~ Copyright (c) 2018 DuckDuckGo
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
18+
xmlns:app="http://schemas.android.com/apk/res-auto"
19+
android:id="@+id/settingsSectionPrivacy"
20+
android:layout_width="match_parent"
21+
android:layout_height="wrap_content"
22+
android:orientation="vertical">
23+
24+
<com.duckduckgo.common.ui.view.listitem.SectionHeaderListItem
25+
android:id="@+id/settingsPrivacyTitle"
26+
android:layout_width="match_parent"
27+
android:layout_height="wrap_content"
28+
app:primaryText="@string/settingsHeadingPrivacy" />
29+
30+
<com.duckduckgo.common.ui.view.listitem.SettingsListItem
31+
android:id="@+id/setAsDefaultBrowserSetting"
32+
android:layout_width="match_parent"
33+
android:layout_height="wrap_content"
34+
app:leadingIcon="@drawable/ic_default_browser_mobile_color_24"
35+
app:primaryText="@string/settingsDefaultBrowserTitle" />
36+
37+
<com.duckduckgo.common.ui.view.listitem.SettingsListItem
38+
android:id="@+id/privateSearchSetting"
39+
android:layout_width="match_parent"
40+
android:layout_height="wrap_content"
41+
app:isOn="true"
42+
app:leadingIcon="@drawable/ic_find_search_color_24"
43+
app:primaryText="@string/settingsPrivateSearchTitle" />
44+
45+
<com.duckduckgo.common.ui.view.listitem.SettingsListItem
46+
android:id="@+id/webTrackingProtectionSetting"
47+
android:layout_width="match_parent"
48+
android:layout_height="wrap_content"
49+
app:isOn="true"
50+
app:leadingIcon="@drawable/ic_shield_color_24"
51+
app:primaryText="@string/settingsWebTrackingProtectionTitle" />
52+
53+
<com.duckduckgo.common.ui.view.listitem.SettingsListItem
54+
android:id="@+id/cookiePopupProtectionSetting"
55+
android:layout_width="match_parent"
56+
android:layout_height="wrap_content"
57+
app:leadingIcon="@drawable/ic_cookie_color_24"
58+
app:primaryText="@string/cookiePopupProtectionTitle" />
59+
60+
<com.duckduckgo.common.ui.view.listitem.SettingsListItem
61+
android:id="@+id/vpnSetting"
62+
android:layout_width="match_parent"
63+
android:layout_height="wrap_content"
64+
app:leadingIcon="@drawable/ic_lock_color_24"
65+
app:primaryText="@string/atp_SettingsTitle" />
66+
67+
<com.duckduckgo.common.ui.view.listitem.SettingsListItem
68+
android:id="@+id/emailSetting"
69+
android:layout_width="match_parent"
70+
android:layout_height="wrap_content"
71+
app:leadingIcon="@drawable/ic_email_protection_color_24"
72+
app:primaryText="@string/settingsEmailProtectionTitle"
73+
app:showBetaPill="true" />
74+
75+
</LinearLayout>

common/common-ui/src/main/java/com/duckduckgo/common/ui/themepreview/ui/component/Component.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ enum class Component {
4444
SECTION_HEADER_LIST_ITEM,
4545
SINGLE_LINE_LIST_ITEM,
4646
TWO_LINE_LIST_ITEM,
47+
SETTINGS_LIST_ITEM,
4748
SECTION_DIVIDER,
4849
}

common/common-ui/src/main/java/com/duckduckgo/common/ui/themepreview/ui/component/ComponentViewHolder.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ sealed class ComponentViewHolder(val view: View) : RecyclerView.ViewHolder(view)
384384
}
385385
}
386386

387+
class SettingsListItemComponentViewHolder(parent: ViewGroup) :
388+
ComponentViewHolder(inflate(parent, R.layout.component_settings))
389+
387390
companion object {
388391
fun create(
389392
parent: ViewGroup,
@@ -408,6 +411,7 @@ sealed class ComponentViewHolder(val view: View) : RecyclerView.ViewHolder(view)
408411
Component.SECTION_DIVIDER -> DividerComponentViewHolder(parent)
409412
Component.CARD -> CardComponentViewHolder(parent)
410413
Component.EXPANDABLE_LAYOUT -> ExpandableComponentViewHolder(parent)
414+
Component.SETTINGS_LIST_ITEM -> SettingsListItemComponentViewHolder(parent)
411415
else -> {
412416
TODO()
413417
}

common/common-ui/src/main/java/com/duckduckgo/common/ui/themepreview/ui/component/listitems/ComponentListItemsElementsFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ import com.duckduckgo.common.ui.themepreview.ui.component.Component
2020
import com.duckduckgo.common.ui.themepreview.ui.component.Component.MENU_ITEM
2121
import com.duckduckgo.common.ui.themepreview.ui.component.Component.POPUP_MENU_ITEM
2222
import com.duckduckgo.common.ui.themepreview.ui.component.Component.SECTION_HEADER_LIST_ITEM
23+
import com.duckduckgo.common.ui.themepreview.ui.component.Component.SETTINGS_LIST_ITEM
2324
import com.duckduckgo.common.ui.themepreview.ui.component.Component.SINGLE_LINE_LIST_ITEM
2425
import com.duckduckgo.common.ui.themepreview.ui.component.Component.TWO_LINE_LIST_ITEM
2526
import com.duckduckgo.common.ui.themepreview.ui.component.ComponentFragment
2627

2728
class ComponentListItemsElementsFragment : ComponentFragment() {
2829
override fun getComponents(): List<Component> {
29-
return listOf(SECTION_HEADER_LIST_ITEM, SINGLE_LINE_LIST_ITEM, TWO_LINE_LIST_ITEM, MENU_ITEM, POPUP_MENU_ITEM)
30+
return listOf(SECTION_HEADER_LIST_ITEM, SINGLE_LINE_LIST_ITEM, TWO_LINE_LIST_ITEM, SETTINGS_LIST_ITEM, MENU_ITEM, POPUP_MENU_ITEM)
3031
}
3132
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2024 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.common.ui.view
18+
19+
import android.content.Context
20+
import android.util.AttributeSet
21+
import android.widget.LinearLayout
22+
import com.duckduckgo.common.ui.viewbinding.viewBinding
23+
import com.duckduckgo.mobile.android.databinding.ViewStatusIndicatorBinding
24+
25+
class StatusIndicator @JvmOverloads constructor(
26+
context: Context,
27+
attrs: AttributeSet? = null,
28+
defStyleAttr: Int = 0,
29+
) : LinearLayout(context, attrs, defStyleAttr) {
30+
31+
private val binding: ViewStatusIndicatorBinding by viewBinding()
32+
33+
fun setStatus(isOn: Boolean) {
34+
if (isOn) {
35+
binding.icon.isEnabled = true
36+
// TODO copy changes
37+
binding.label.text = "On"
38+
} else {
39+
binding.icon.isEnabled = false
40+
// TODO copy changes
41+
binding.label.text = "Off"
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)