For #10343: Remove 'Library' functionality from the app
Also adds Bookmarks and History items to browser menu.fennec/production
parent
ca7695854a
commit
b2e5820364
@ -1,82 +0,0 @@
|
|||||||
/* 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.library
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.Menu
|
|
||||||
import android.view.MenuInflater
|
|
||||||
import android.view.View
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.appcompat.widget.Toolbar
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import kotlinx.android.synthetic.main.fragment_library.*
|
|
||||||
import mozilla.appservices.places.BookmarkRoot
|
|
||||||
import mozilla.components.support.ktx.android.content.getColorFromAttr
|
|
||||||
import org.mozilla.fenix.R
|
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
|
||||||
import org.mozilla.fenix.ext.nav
|
|
||||||
import org.mozilla.fenix.ext.requireComponents
|
|
||||||
import org.mozilla.fenix.ext.setToolbarColors
|
|
||||||
import org.mozilla.fenix.ext.showToolbar
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays buttons to navigate to library sections, such as bookmarks and history.
|
|
||||||
*/
|
|
||||||
class LibraryFragment : Fragment(R.layout.fragment_library) {
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setHasOptionsMenu(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
initToolbar()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
libraryHistory.setOnClickListener {
|
|
||||||
requireComponents.analytics.metrics
|
|
||||||
.track(Event.LibrarySelectedItem(Event.LibrarySelectedItem.LibraryItem.HISTORY))
|
|
||||||
nav(
|
|
||||||
R.id.libraryFragment,
|
|
||||||
LibraryFragmentDirections.actionLibraryFragmentToHistoryFragment()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
libraryBookmarks.setOnClickListener {
|
|
||||||
requireComponents.analytics.metrics
|
|
||||||
.track(Event.LibrarySelectedItem(Event.LibrarySelectedItem.LibraryItem.BOOKMARKS))
|
|
||||||
nav(
|
|
||||||
R.id.libraryFragment,
|
|
||||||
LibraryFragmentDirections.actionLibraryFragmentToBookmarksFragment(BookmarkRoot.Mobile.id)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
requireComponents.analytics.metrics.track(Event.LibraryOpened)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
|
||||||
inflater.inflate(R.menu.library_menu, menu)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
|
||||||
super.onDestroy()
|
|
||||||
requireComponents.analytics.metrics.track(Event.LibraryClosed)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initToolbar() {
|
|
||||||
(activity as? AppCompatActivity)?.let { activity ->
|
|
||||||
val toolbar = activity.findViewById<Toolbar>(R.id.navigationToolbar)
|
|
||||||
toolbar?.setToolbarColors(
|
|
||||||
foreground = activity.getColorFromAttr(R.attr.primaryText),
|
|
||||||
background = activity.getColorFromAttr(R.attr.foundation)
|
|
||||||
)
|
|
||||||
showToolbar(getString(R.string.library_title))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
/* 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.library
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
import androidx.core.content.withStyledAttributes
|
|
||||||
import kotlinx.android.synthetic.main.library_list_item.view.libraryIcon
|
|
||||||
import kotlinx.android.synthetic.main.library_list_item.view.libraryItemTitle
|
|
||||||
import org.mozilla.fenix.R
|
|
||||||
|
|
||||||
class LibraryListItem @JvmOverloads constructor(
|
|
||||||
context: Context,
|
|
||||||
attrs: AttributeSet? = null,
|
|
||||||
defStyleAttr: Int = 0
|
|
||||||
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
|
||||||
init {
|
|
||||||
LayoutInflater.from(context).inflate(R.layout.library_list_item, this, true)
|
|
||||||
|
|
||||||
context.withStyledAttributes(attrs, R.styleable.LibraryListItem, defStyleAttr, 0) {
|
|
||||||
val id = getResourceId(
|
|
||||||
R.styleable.LibraryListItem_listItemIcon,
|
|
||||||
R.drawable.library_icon_reading_list_circle_background
|
|
||||||
)
|
|
||||||
libraryIcon?.background = resources.getDrawable(id, context.theme)
|
|
||||||
libraryItemTitle?.text = resources.getString(
|
|
||||||
getResourceId(
|
|
||||||
R.styleable.LibraryListItem_listItemTitle,
|
|
||||||
R.string.browser_menu_library
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
<?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/. -->
|
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item>
|
|
||||||
<shape android:shape="oval">
|
|
||||||
<size
|
|
||||||
android:width="40dp"
|
|
||||||
android:height="40dp" />
|
|
||||||
<solid android:color="@color/library_reading_list_icon_background" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
<item
|
|
||||||
android:bottom="8dp"
|
|
||||||
android:left="8dp"
|
|
||||||
android:right="8dp"
|
|
||||||
android:top="8dp">
|
|
||||||
<vector
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="@color/library_reading_list_icon"
|
|
||||||
android:pathData="M16.7 21H7.3A3.3 3.3 0 0 1 4 17.7V6.3C4 4.5 5.5 3 7.3 3h9.4C18.5 3 20 4.5 20 6.3v11.4c0 1.8-1.5 3.3-3.3 3.3zM7.3 5C6.6 5 6 5.6 6 6.3v11.4c0 0.7 0.6 1.3 1.3 1.3h9.4c0.7 0 1.3-0.6 1.3-1.3V6.3c0-0.7-0.6-1.3-1.3-1.3H7.3zM15 8H9a0.5 0.5 0 0 1 0-1h6a0.5 0.5 0 0 1 0 1zm0 3H9a0.5 0.5 0 0 1 0-1h6a0.5 0.5 0 0 1 0 1zm0 3H9a0.5 0.5 0 0 1 0-1h6a0.5 0.5 0 0 1 0 1zm-3.4 3H9a0.5 0.5 0 0 1 0-1h2.6a0.5 0.5 0 0 1 0 1z" />
|
|
||||||
</vector>
|
|
||||||
</item>
|
|
||||||
</layer-list>
|
|
@ -1,38 +0,0 @@
|
|||||||
<?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/. -->
|
|
||||||
<ScrollView 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="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
tools:context="org.mozilla.fenix.library.LibraryFragment">
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<org.mozilla.fenix.library.LibraryListItem
|
|
||||||
android:id="@+id/libraryBookmarks"
|
|
||||||
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.library.LibraryListItem
|
|
||||||
android:id="@+id/libraryHistory"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="?android:attr/selectableItemBackground"
|
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
app:listItemIcon="@drawable/library_icon_history_circle_background"
|
|
||||||
app:listItemTitle="@string/library_history" />
|
|
||||||
</LinearLayout>
|
|
||||||
</ScrollView>
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
|||||||
<?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/libraryIcon"
|
|
||||||
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/libraryItemTitle"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="@dimen/library_item_icon_margin_horizontal"
|
|
||||||
android:clickable="false"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:textAppearance="@style/ListItemTextStyle"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/libraryIcon"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
</merge>
|
|
Loading…
Reference in New Issue