From 3006b21508cbc2136a4d104af93cd06c6599c39a Mon Sep 17 00:00:00 2001 From: Jeff Boek Date: Fri, 24 May 2019 11:35:51 -0700 Subject: [PATCH] For #225 - Adds list items for delete browsing data --- .../fenix/settings/DeleteBrowsingDataItem.kt | 56 ++++++++++++++++++ .../res/layout/delete_browsing_data_item.xml | 58 +++++++++++++++++++ .../layout/fragment_delete_browsing_data.xml | 37 +++++++++++- app/src/main/res/navigation/nav_graph.xml | 2 +- app/src/main/res/values/attrs.xml | 6 ++ 5 files changed, 155 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/org/mozilla/fenix/settings/DeleteBrowsingDataItem.kt create mode 100644 app/src/main/res/layout/delete_browsing_data_item.xml diff --git a/app/src/main/java/org/mozilla/fenix/settings/DeleteBrowsingDataItem.kt b/app/src/main/java/org/mozilla/fenix/settings/DeleteBrowsingDataItem.kt new file mode 100644 index 000000000..cb4b95520 --- /dev/null +++ b/app/src/main/java/org/mozilla/fenix/settings/DeleteBrowsingDataItem.kt @@ -0,0 +1,56 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix.settings + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import kotlinx.android.synthetic.main.delete_browsing_data_item.view.* +import org.mozilla.fenix.R + +class DeleteBrowsingDataItem @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr) { + init { + LayoutInflater.from(context).inflate(R.layout.delete_browsing_data_item, this, true) + + setOnClickListener { + checkbox.isChecked = !checkbox.isChecked + } + + attrs.let { + context.theme.obtainStyledAttributes( + it, + R.styleable.LibraryListItem, + 0, 0 + ).apply { + try { + val iconId = getResourceId( + R.styleable.DeleteBrowsingDataItem_deleteBrowsingDataItemIcon, + R.drawable.library_icon_reading_list_circle_background + ) + val titleId = getResourceId( + R.styleable.DeleteBrowsingDataItem_deleteBrowsingDataItemTitle, + R.string.browser_menu_your_library + ) + val subtitleId = getResourceId( + R.styleable.DeleteBrowsingDataItem_deleteBrowsingDataItemSubtitle, + R.string.browser_menu_your_library + ) + + + icon.background = resources.getDrawable(iconId, context.theme) + title.text = resources.getString(titleId) + subtitle.text = resources.getString(subtitleId) + } finally { + recycle() + } + } + } + } +} diff --git a/app/src/main/res/layout/delete_browsing_data_item.xml b/app/src/main/res/layout/delete_browsing_data_item.xml new file mode 100644 index 000000000..6f0402968 --- /dev/null +++ b/app/src/main/res/layout/delete_browsing_data_item.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_delete_browsing_data.xml b/app/src/main/res/layout/fragment_delete_browsing_data.xml index 38d9fb81c..7d73cd991 100644 --- a/app/src/main/res/layout/fragment_delete_browsing_data.xml +++ b/app/src/main/res/layout/fragment_delete_browsing_data.xml @@ -8,12 +8,43 @@ android:layout_width="fill_parent" android:layout_height="fill_parent"> - + android:layout_height="wrap_content" + android:orientation="vertical"> + + + - + \ No newline at end of file diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 2bc5334e1..1ac692ace 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/nav_graph" - app:startDestination="@id/homeFragment"> + app:startDestination="@id/deleteBrowsingDataFragment"> + + + + + +