[fenix] For https://github.com/mozilla-mobile/fenix/issues/225 - Adds list items for delete browsing data
parent
f0e5e9a3b7
commit
ccf637a74e
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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/. -->
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/library_item_height"
|
||||
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="@dimen/library_item_icon_height"
|
||||
android:layout_height="@dimen/library_item_icon_height"
|
||||
android:layout_marginStart="@dimen/library_item_icon_margin_horizontal"
|
||||
android:layout_marginTop="@dimen/library_item_icon_margin_vertical"
|
||||
android:layout_marginEnd="@dimen/library_item_icon_margin_horizontal"
|
||||
android:layout_marginBottom="@dimen/library_item_icon_margin_vertical"
|
||||
android:background="@drawable/library_icon_reading_list_circle_background"
|
||||
android:clickable="false"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/library_item_icon_margin_horizontal"
|
||||
android:textAppearance="@style/ListItemTextStyle"
|
||||
android:clickable="false"
|
||||
android:layout_marginTop="16dp"
|
||||
app:layout_constraintStart_toEndOf="@id/icon"
|
||||
app:layout_constraintEnd_toStartOf="@id/checkbox"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subtitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/library_item_icon_margin_horizontal"
|
||||
android:textAppearance="@style/SubtitleTextStyle"
|
||||
android:clickable="false"
|
||||
app:layout_constraintStart_toEndOf="@id/icon"
|
||||
app:layout_constraintEnd_toStartOf="@id/checkbox"
|
||||
app:layout_constraintTop_toBottomOf="@id/title" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/checkbox"
|
||||
android:clickable="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</merge>
|
Loading…
Reference in New Issue