From 3bf1d7c4f96d0329cf2fcf00adf886d780af342f Mon Sep 17 00:00:00 2001 From: Amine Bou Date: Tue, 5 Dec 2017 20:33:32 +0100 Subject: [PATCH] Added toolbar to reader activity. --- CHANGELOG.md | 2 ++ .../bou/readerforselfoss/ReaderActivity.kt | 15 +++++++++++++ app/src/main/res/layout/activity_reader.xml | 22 ++++++++++++++++--- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53ac5d4..1438b47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ - Changed versions handling. +- Toolbar in reader activity. + **1.5.4.22** - You can now scroll through the loaded articles ! diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/ReaderActivity.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/ReaderActivity.kt index 7e9801e..1b848a0 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/ReaderActivity.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/ReaderActivity.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.support.v4.app.FragmentManager import android.support.v4.app.FragmentStatePagerAdapter import android.support.v7.app.AppCompatActivity +import android.view.MenuItem import apps.amine.bou.readerforselfoss.api.selfoss.Item import apps.amine.bou.readerforselfoss.fragments.ArticleFragment import apps.amine.bou.readerforselfoss.transformers.DepthPageTransformer @@ -20,6 +21,10 @@ class ReaderActivity : AppCompatActivity() { Scoop.getInstance().apply(this) setContentView(R.layout.activity_reader) + setSupportActionBar(toolBar) + supportActionBar?.setDisplayHomeAsUpEnabled(true) + supportActionBar?.setDisplayShowHomeEnabled(true) + allItems = intent.getParcelableArrayListExtra("allItems") val currentItem = intent.getIntExtra("currentItem", 0) @@ -40,4 +45,14 @@ class ReaderActivity : AppCompatActivity() { return ArticleFragment.newInstance(position, allItems) } } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + android.R.id.home -> { + onBackPressed() + return true + } + } + return super.onOptionsItemSelected(item) + } } diff --git a/app/src/main/res/layout/activity_reader.xml b/app/src/main/res/layout/activity_reader.xml index 6829641..7527624 100644 --- a/app/src/main/res/layout/activity_reader.xml +++ b/app/src/main/res/layout/activity_reader.xml @@ -1,11 +1,27 @@ - + + + + + + + app:layout_constraintTop_toBottomOf="@+id/appBarLayout" />