mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/225 - Adds list items for delete browsing data
This commit is contained in:
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
58
app/src/main/res/layout/delete_browsing_data_item.xml
Normal file
58
app/src/main/res/layout/delete_browsing_data_item.xml
Normal file
@ -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>
|
@ -8,12 +8,43 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<org.mozilla.fenix.settings.DeleteBrowsingDataItem
|
||||
android:id="@+id/openTabsItem"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/library_bookmarks"
|
||||
android:focusable="true"
|
||||
app:listItemIcon="@drawable/bookmarks_circle_background_outline"
|
||||
app:listItemTitle="@string/library_bookmarks" />
|
||||
<org.mozilla.fenix.settings.DeleteBrowsingDataItem
|
||||
android:id="@+id/browsingDataItem"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/library_bookmarks"
|
||||
android:focusable="true"
|
||||
app:listItemIcon="@drawable/bookmarks_circle_background_outline"
|
||||
app:listItemTitle="@string/library_bookmarks" />
|
||||
<org.mozilla.fenix.settings.DeleteBrowsingDataItem
|
||||
android:id="@+id/collectionsItem"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/library_bookmarks"
|
||||
android:focusable="true"
|
||||
app:listItemIcon="@drawable/bookmarks_circle_background_outline"
|
||||
app:listItemTitle="@string/library_bookmarks" />
|
||||
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -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">
|
||||
|
||||
<action
|
||||
android:id="@+id/action_global_browser"
|
||||
|
@ -33,6 +33,12 @@
|
||||
<attr name="listItemIcon" format="reference" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="DeleteBrowsingDataItem">
|
||||
<attr name="deleteBrowsingDataItemTitle" format="reference" />
|
||||
<attr name="deleteBrowsingDataItemSubtitle" format="reference" />
|
||||
<attr name="deleteBrowsingDataItemIcon" format="reference" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="OnboardingRadioButton">
|
||||
<attr name="onboardingKey" format="reference" />
|
||||
</declare-styleable>
|
||||
|
Loading…
Reference in New Issue
Block a user