ArticleListActivity: Don't set a support action bar anymore
Use toolbar as a toolbar
--- a/app/src/main/java/com/geekorum/ttrss/articles_list/ArticleListActivity.kt Thu Dec 06 15:36:32 2018 -0800
+++ b/app/src/main/java/com/geekorum/ttrss/articles_list/ArticleListActivity.kt Thu Dec 06 18:27:21 2018 -0800
@@ -58,8 +58,8 @@
*/
class ArticleListActivity : SessionActivity() {
companion object {
- private val FRAGMENT_ARTICLES_LIST = "articles_list"
- private val FRAGMENT_FEEDS_LIST = "feeds_list"
+ private const val FRAGMENT_ARTICLES_LIST = "articles_list"
+ private const val FRAGMENT_FEEDS_LIST = "feeds_list"
}
/**
@@ -135,21 +135,25 @@
val feed = Feed.createVirtualFeedForId(Feed.FEED_ID_ALL_ARTICLES)
activityViewModel.setSelectedFeed(feed)
}
- setupActionBar()
+ setupToolbar()
}
- private fun setupActionBar() {
+ private fun setupToolbar() {
val toolbar = binding.toolbar.toolbar
- setSupportActionBar(toolbar)
toolbar.title = title
if (!twoPane) {
actionBarDrawerToggle = ActionBarDrawerToggle(this, binding.headlinesDrawer, toolbar,
R.string.drawer_open, R.string.drawer_close)
binding.headlinesDrawer?.addDrawerListener(actionBarDrawerToggle!!)
+ } else {
+ toolbar.setNavigationIcon(R.drawable.ic_menu_24dp)
+ toolbar.setNavigationOnClickListener {
+ binding.middlePaneLayout.visibility = View.GONE
+ binding.startPaneLayout.visibility = View.VISIBLE
+ }
}
+ }
- supportActionBar?.setDisplayHomeAsUpEnabled(true)
- }
private fun setupPeriodicJobs() {
backgroundJobManager.setupPeriodicJobs()
@@ -165,16 +169,6 @@
actionBarDrawerToggle?.onConfigurationChanged(newConfig)
}
- override fun onOptionsItemSelected(item: MenuItem): Boolean {
- if (actionBarDrawerToggle?.onOptionsItemSelected(item) == true) {
- return true
- } else if (twoPane && item.itemId == android.R.id.home) {
- binding.middlePaneLayout.visibility = View.GONE
- binding.startPaneLayout.visibility = View.VISIBLE
- }
- return super.onOptionsItemSelected(item)
- }
-
private fun onArticleSelected(position: Int, item: Article) {
val articleUri = ContentUris.withAppendedId(ArticlesContract.Article.CONTENT_URI, item.id)
if (twoPane) {
@@ -197,6 +191,8 @@
* From MasterActivity
*/
private fun onFeedSelected(feed: Feed) {
+ title = feed.title
+ binding.toolbar.toolbar.title = title
supportFragmentManager.transaction {
val hf = ArticlesListFragment.newInstance(feed.id)
replace(R.id.middle_pane_layout, hf, FRAGMENT_ARTICLES_LIST)
@@ -206,6 +202,6 @@
binding.startPaneLayout.visibility = View.GONE
}
drawerLayout?.closeDrawers()
+ }
- }
}
--- a/app/src/main/java/com/geekorum/ttrss/articles_list/ArticlesListFragment.java Thu Dec 06 15:36:32 2018 -0800
+++ b/app/src/main/java/com/geekorum/ttrss/articles_list/ArticlesListFragment.java Thu Dec 06 18:27:21 2018 -0800
@@ -119,7 +119,6 @@
fragmentViewModel = ViewModelProviders.of(this, viewModelFactory).get(FragmentViewModel.class);
fragmentViewModel.init(feedId);
fragmentViewModel.getArticles().observe(this, articles -> adapter.submitList(articles));
- fragmentViewModel.getFeed().observe(this, feed -> requireActivity().setTitle(feed.getTitle()));
fragmentViewModel.getPendingArticlesSetUnread().observe(this, nbArticles -> {
if (nbArticles > 0) {
--- a/app/src/main/java/com/geekorum/ttrss/articles_list/FragmentViewModel.java Thu Dec 06 15:36:32 2018 -0800
+++ b/app/src/main/java/com/geekorum/ttrss/articles_list/FragmentViewModel.java Thu Dec 06 18:27:21 2018 -0800
@@ -90,7 +90,7 @@
return articles;
}
- public LiveData<Feed> getFeed() {
+ private LiveData<Feed> getFeed() {
if (feed == null) {
feed = Transformations.switchMap(feedId, id -> {
if (Feed.isVirtualFeed(id)) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/res/drawable/ic_menu_24dp.xml Thu Dec 06 18:27:21 2018 -0800
@@ -0,0 +1,31 @@
+<!--
+
+ Geekttrss is a RSS feed reader application on the Android Platform.
+
+ Copyright (C) 2017-2018 by Frederic-Charles Barthelery.
+
+ This file is part of Geekttrss.
+
+ Geekttrss is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Geekttrss is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Geekttrss. If not, see <http://www.gnu.org/licenses/>.
+
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="?colorControlNormal"
+ android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z"/>
+</vector>