2019-02-05 22:52:04 +01:00
|
|
|
/* 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.LayoutInflater
|
2019-02-08 00:37:52 +01:00
|
|
|
import android.view.Menu
|
|
|
|
import android.view.MenuInflater
|
|
|
|
import android.view.MenuItem
|
2019-02-05 22:52:04 +01:00
|
|
|
import android.view.View
|
|
|
|
import android.view.ViewGroup
|
2019-02-08 00:37:52 +01:00
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
2019-02-05 22:52:04 +01:00
|
|
|
import androidx.fragment.app.Fragment
|
2019-02-08 00:37:52 +01:00
|
|
|
import androidx.navigation.Navigation
|
2019-02-09 00:33:50 +01:00
|
|
|
import kotlinx.android.synthetic.main.fragment_library.*
|
2019-03-22 01:08:03 +01:00
|
|
|
import org.mozilla.fenix.utils.ItsNotBrokenSnack
|
2019-02-05 22:52:04 +01:00
|
|
|
import org.mozilla.fenix.R
|
|
|
|
|
|
|
|
class LibraryFragment : Fragment() {
|
|
|
|
|
|
|
|
override fun onCreateView(
|
|
|
|
inflater: LayoutInflater,
|
|
|
|
container: ViewGroup?,
|
|
|
|
savedInstanceState: Bundle?
|
|
|
|
): View? {
|
|
|
|
return inflater.inflate(R.layout.fragment_library, container, false)
|
|
|
|
}
|
2019-02-08 00:37:52 +01:00
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
setHasOptionsMenu(true)
|
2019-02-25 20:37:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun onResume() {
|
|
|
|
super.onResume()
|
2019-02-08 00:37:52 +01:00
|
|
|
(activity as AppCompatActivity).supportActionBar?.show()
|
|
|
|
}
|
|
|
|
|
2019-02-09 00:33:50 +01:00
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
|
|
2019-03-22 01:08:03 +01:00
|
|
|
libraryHistory.setOnClickListener(
|
|
|
|
Navigation.createNavigateOnClickListener(
|
|
|
|
LibraryFragmentDirections.actionLibraryFragmentToHistoryFragment().actionId,
|
|
|
|
null
|
|
|
|
)
|
2019-02-12 18:47:51 +01:00
|
|
|
)
|
2019-03-22 01:08:03 +01:00
|
|
|
libraryDownloads.setOnClickListener {
|
2019-03-22 20:38:59 +01:00
|
|
|
ItsNotBrokenSnack(context!!).showSnackbar(issueNumber = "348")
|
2019-03-22 01:08:03 +01:00
|
|
|
}
|
|
|
|
libraryScreenshots.setOnClickListener {
|
2019-03-22 20:38:59 +01:00
|
|
|
ItsNotBrokenSnack(context!!).showSnackbar(issueNumber = "89")
|
2019-03-22 01:08:03 +01:00
|
|
|
}
|
2019-03-27 22:29:38 +01:00
|
|
|
libraryBookmarks.setOnClickListener {
|
2019-03-22 20:38:59 +01:00
|
|
|
ItsNotBrokenSnack(context!!).showSnackbar(issueNumber = "90")
|
2019-03-22 01:08:03 +01:00
|
|
|
}
|
|
|
|
libraryReadingList.setOnClickListener {
|
2019-03-22 20:38:59 +01:00
|
|
|
ItsNotBrokenSnack(context!!).showSnackbar(issueNumber = "913")
|
2019-03-22 01:08:03 +01:00
|
|
|
}
|
|
|
|
librarySessions.setOnClickListener {
|
2019-03-22 20:38:59 +01:00
|
|
|
ItsNotBrokenSnack(context!!).showSnackbar(issueNumber = "637")
|
2019-03-22 01:08:03 +01:00
|
|
|
}
|
2019-02-09 00:33:50 +01:00
|
|
|
}
|
|
|
|
|
2019-02-08 00:37:52 +01:00
|
|
|
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 -> {
|
2019-02-13 01:04:01 +01:00
|
|
|
Navigation.findNavController(requireActivity(), R.id.container).navigateUp()
|
2019-02-08 00:37:52 +01:00
|
|
|
true
|
|
|
|
}
|
|
|
|
R.id.librarySearch -> {
|
|
|
|
// TODO Library Search
|
2019-03-22 20:38:59 +01:00
|
|
|
ItsNotBrokenSnack(context!!).showSnackbar(issueNumber = "1118")
|
2019-02-08 00:37:52 +01:00
|
|
|
true
|
|
|
|
}
|
|
|
|
else -> super.onOptionsItemSelected(item)
|
|
|
|
}
|
|
|
|
}
|
2019-02-05 22:52:04 +01:00
|
|
|
}
|