2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-09 19:10:42 +00:00

For #355 - Adds the history fragment and the ability to navigate to it

This commit is contained in:
Jeff Boek 2019-02-08 15:33:50 -08:00
parent 96853c978e
commit 0b147d8956
6 changed files with 104 additions and 5 deletions

View File

@ -5,6 +5,7 @@
package org.mozilla.fenix.library package org.mozilla.fenix.library
import android.os.Bundle import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu import android.view.Menu
import android.view.MenuInflater import android.view.MenuInflater
@ -12,8 +13,12 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.Group
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.Navigation import androidx.navigation.Navigation
import kotlinx.android.synthetic.main.fragment_library.*
import org.jetbrains.anko.constraint.layout.group
import org.jetbrains.anko.view
import org.mozilla.fenix.R import org.mozilla.fenix.R
class LibraryFragment : Fragment() { class LibraryFragment : Fragment() {
@ -32,6 +37,14 @@ class LibraryFragment : Fragment() {
(activity as AppCompatActivity).supportActionBar?.show() (activity as AppCompatActivity).supportActionBar?.show()
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
libraryHistory.setOnClickListener {
Navigation.findNavController(it).navigate(R.id.action_libraryFragment_to_historyFragment)
}
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.library_menu, menu) inflater.inflate(R.menu.library_menu, menu)
} }
@ -39,7 +52,8 @@ class LibraryFragment : Fragment() {
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) { return when (item.itemId) {
R.id.libraryClose -> { R.id.libraryClose -> {
Navigation.findNavController(requireActivity(), R.id.container).popBackStack() Navigation.findNavController(requireActivity(), R.id.container)
.popBackStack(R.id.browserFragment, false)
true true
} }
R.id.librarySearch -> { R.id.librarySearch -> {

View File

@ -18,6 +18,7 @@ class LibraryListItem @JvmOverloads constructor(
) : ConstraintLayout(context, attrs, defStyleAttr) { ) : ConstraintLayout(context, attrs, defStyleAttr) {
init { init {
LayoutInflater.from(context).inflate(R.layout.library_list_item, this, true) LayoutInflater.from(context).inflate(R.layout.library_list_item, this, true)
attrs.let { attrs.let {
context.theme.obtainStyledAttributes( context.theme.obtainStyledAttributes(
it, it,

View File

@ -0,0 +1,52 @@
/* 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.history
import android.os.Bundle
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.navigation.Navigation
import org.mozilla.fenix.R
class HistoryFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_history, container, false)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setHasOptionsMenu(true)
(activity as AppCompatActivity).supportActionBar?.show()
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.library_menu, menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.libraryClose -> {
Navigation.findNavController(requireActivity(), R.id.container).popBackStack(R.id.browserFragment, false)
true
}
R.id.librarySearch -> {
// TODO Library Search
true
}
else -> super.onOptionsItemSelected(item)
}
}
}

View File

@ -0,0 +1,12 @@
<?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/. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="org.mozilla.fenix.library.history.HistoryFragment">
</LinearLayout>

View File

@ -2,8 +2,10 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public <!-- 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 - 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/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/library_item_height" android:layout_height="@dimen/library_item_height"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
@ -16,6 +18,7 @@
android:layout_height="@dimen/library_item_icon_height" android:layout_height="@dimen/library_item_icon_height"
android:layout_margin="@dimen/library_item_icon_margin" android:layout_margin="@dimen/library_item_icon_margin"
android:background="@drawable/library_icon_logins_circle_background" android:background="@drawable/library_icon_logins_circle_background"
android:clickable="false"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -29,6 +32,7 @@
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1" android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
android:clickable="false"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/libraryIcon" app:layout_constraintStart_toEndOf="@id/libraryIcon"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -37,7 +41,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="1dp" android:layout_height="1dp"
android:background="@drawable/library_separator" android:background="@drawable/library_separator"
android:clickable="false"
app:layout_constraintStart_toStartOf="@id/libraryItemTitle" app:layout_constraintStart_toStartOf="@id/libraryItemTitle"
app:layout_constraintTop_toBottomOf="@id/libraryIcon" /> app:layout_constraintTop_toBottomOf="@id/libraryIcon" />
</merge>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -64,11 +64,27 @@
android:id="@+id/action_browserFragment_to_libraryFragment" android:id="@+id/action_browserFragment_to_libraryFragment"
app:destination="@id/libraryFragment" /> app:destination="@id/libraryFragment" />
</fragment> </fragment>
<fragment <fragment
android:id="@+id/libraryFragment" android:id="@+id/libraryFragment"
android:name="org.mozilla.fenix.library.LibraryFragment" android:name="org.mozilla.fenix.library.LibraryFragment"
android:label="@string/library_title" android:label="@string/library_title"
tools:layout="@layout/fragment_library" /> tools:layout="@layout/fragment_library">
<action
android:id="@+id/action_libraryFragment_to_historyFragment"
app:destination="@+id/historyFragment" />
</fragment>
<fragment
android:id="@+id/historyFragment"
android:name="org.mozilla.fenix.library.history.HistoryFragment"
android:label="@string/library_history"
tools:layout="@layout/fragment_history" />
<fragment <fragment
android:id="@+id/settingsFragment" android:id="@+id/settingsFragment"
android:name="org.mozilla.fenix.settings.SettingsFragment" android:name="org.mozilla.fenix.settings.SettingsFragment"