From f37bb694f186fde6eadbe5743b3fa6b92e404f00 Mon Sep 17 00:00:00 2001
From: Vavassor <copernicus-@hotmail.com>
Date: Sat, 15 Jul 2017 03:10:55 -0400
Subject: [PATCH] Makes the toolbar shadow visible for pre-Lollipop android
 versions and fixes a crash when deleting a draft with no media attached.

---
 .../tusky/SavedTootActivity.java              |  10 +-
 .../color/drawer_visibility_panel_item.xml    |   5 -
 app/src/main/res/drawable/ic_mute_24dp.xml    |   3 +-
 app/src/main/res/drawable/ic_unmute_24dp.xml  |   3 +-
 app/src/main/res/layout/activity_about.xml    | 124 ++++++++----------
 .../main/res/layout/activity_account_list.xml |  25 ++--
 app/src/main/res/layout/activity_compose.xml  |   3 +-
 .../main/res/layout/activity_edit_profile.xml |  15 +--
 .../main/res/layout/activity_favourites.xml   |  29 ++--
 app/src/main/res/layout/activity_report.xml   |  21 +--
 .../main/res/layout/activity_saved_toot.xml   |  18 +--
 app/src/main/res/layout/activity_search.xml   |  57 ++++----
 app/src/main/res/layout/activity_view_tag.xml |  22 +---
 .../main/res/layout/activity_view_thread.xml  |  24 ++--
 .../main/res/layout/activity_view_video.xml   |   1 -
 app/src/main/res/layout/toolbar_basic.xml     |  20 +++
 .../main/res/layout/toolbar_shadow_shim.xml   |  13 ++
 17 files changed, 190 insertions(+), 203 deletions(-)
 delete mode 100644 app/src/main/res/color/drawer_visibility_panel_item.xml
 create mode 100644 app/src/main/res/layout/toolbar_basic.xml
 create mode 100644 app/src/main/res/layout/toolbar_shadow_shim.xml

diff --git a/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java b/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java
index d5551bf3..3e83074a 100644
--- a/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java
+++ b/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java
@@ -131,10 +131,12 @@ public class SavedTootActivity extends BaseActivity implements SavedTootAdapter.
         // Delete any media files associated with the status.
         ArrayList<String> uris = new Gson().fromJson(item.getUrls(),
                 new TypeToken<ArrayList<String>>() {}.getType());
-        for (String uriString : uris) {
-            Uri uri = Uri.parse(uriString);
-            if (getContentResolver().delete(uri, null, null) == 0) {
-                Log.e(TAG, String.format("Did not delete file %s.", uriString));
+        if (uris != null) {
+            for (String uriString : uris) {
+                Uri uri = Uri.parse(uriString);
+                if (getContentResolver().delete(uri, null, null) == 0) {
+                    Log.e(TAG, String.format("Did not delete file %s.", uriString));
+                }
             }
         }
         // update DB
diff --git a/app/src/main/res/color/drawer_visibility_panel_item.xml b/app/src/main/res/color/drawer_visibility_panel_item.xml
deleted file mode 100644
index 9849dfa9..00000000
--- a/app/src/main/res/color/drawer_visibility_panel_item.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:color="@color/button_dark" android:state_checked="true" />
-    <item android:color="?material_drawer_primary_icon" />
-</selector>
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_mute_24dp.xml b/app/src/main/res/drawable/ic_mute_24dp.xml
index 801dc934..bcdbb5a6 100644
--- a/app/src/main/res/drawable/ic_mute_24dp.xml
+++ b/app/src/main/res/drawable/ic_mute_24dp.xml
@@ -1,5 +1,6 @@
 <vector android:height="24dp" android:viewportHeight="35.43307"
-    android:viewportWidth="35.43307" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    android:viewportWidth="35.43307" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"
+    android:autoMirrored="true">
     <path android:fillAlpha="1" android:fillColor="#ffffff"
         android:pathData="m17.72,3.54 l-8.86,8.86 -7.09,0 0,10.63 7.09,0 8.86,8.86z"
         android:strokeAlpha="1" android:strokeColor="#00000000"
diff --git a/app/src/main/res/drawable/ic_unmute_24dp.xml b/app/src/main/res/drawable/ic_unmute_24dp.xml
index 7d4aadbd..fe37f7fb 100644
--- a/app/src/main/res/drawable/ic_unmute_24dp.xml
+++ b/app/src/main/res/drawable/ic_unmute_24dp.xml
@@ -1,5 +1,6 @@
 <vector android:height="24dp" android:viewportHeight="35.43307"
-    android:viewportWidth="35.43307" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    android:viewportWidth="35.43307" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"
+    android:autoMirrored="true">
     <path android:fillAlpha="1" android:fillColor="#ffffff"
         android:pathData="m17.72,3.54 l-8.86,8.86 -7.09,0 0,10.63 7.09,0 8.86,8.86z"
         android:strokeAlpha="1" android:strokeColor="#00000000"
diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml
index c1659b80..09d01bbb 100644
--- a/app/src/main/res/layout/activity_about.xml
+++ b/app/src/main/res/layout/activity_about.xml
@@ -1,88 +1,80 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.design.widget.CoordinatorLayout
     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="match_parent"
     tools:context="com.keylesspalace.tusky.AboutActivity">
 
-    <LinearLayout
+    <include layout="@layout/toolbar_basic" />
+
+    <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
+        android:layout_height="wrap_content"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior">
 
-        <android.support.v7.widget.Toolbar
-            android:id="@+id/toolbar"
+        <LinearLayout
             android:layout_width="match_parent"
-            android:layout_height="?attr/actionBarSize"
-            android:background="?attr/toolbar_background_color"
-            android:elevation="4dp" />
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:gravity="center"
+            android:paddingTop="16dp"
+            android:paddingBottom="16dp">
 
-        <ScrollView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content">
+            <ImageView
+                android:id="@+id/logo"
+                android:layout_width="200dp"
+                android:layout_height="200dp"
+                android:src="@mipmap/ic_logo"
+                android:contentDescription="@null" />
 
-            <LinearLayout
-                android:layout_width="match_parent"
+            <TextView
+                android:id="@+id/versionTV"
+                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:orientation="vertical"
-                android:gravity="center"
-                android:paddingTop="16dp"
-                android:paddingBottom="16dp">
+                android:paddingTop="8dp"
+                android:textIsSelectable="true"
+                android:textAppearance="@style/TextAppearance.AppCompat.Large" />
 
-                <ImageView
-                    android:id="@+id/logo"
-                    android:layout_width="200dp"
-                    android:layout_height="200dp"
-                    android:src="@mipmap/ic_logo"
-                    android:contentDescription="@null" />
+            <TextView
+                android:id="@+id/projectURL_TV"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:autoLink="web"
+                android:textIsSelectable="true"
+                android:padding="@dimen/text_content_margin"
+                android:text="@string/about_project_site"
+                android:textAlignment="center"
+                android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
 
-                <TextView
-                    android:id="@+id/versionTV"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:paddingTop="8dp"
-                    android:textIsSelectable="true"
-                    android:textAppearance="@style/TextAppearance.AppCompat.Large" />
+            <TextView
+                android:id="@+id/featuresURL_TV"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:autoLink="web"
+                android:textIsSelectable="true"
+                android:padding="@dimen/text_content_margin"
+                android:text="@string/about_bug_feature_request_site"
+                android:textAlignment="center"
+                android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
 
-                <TextView
-                    android:id="@+id/projectURL_TV"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:autoLink="web"
-                    android:textIsSelectable="true"
-                    android:padding="@dimen/text_content_margin"
-                    android:text="@string/about_project_site"
-                    android:textAlignment="center"
-                    android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
+            <Button
+                android:id="@+id/tusky_profile_button"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:clickable="true"
+                android:padding="@dimen/text_content_margin"
+                android:text="@string/about_tusky_account"
+                android:textAlignment="center"
+                android:textAllCaps="false"
+                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
+                android:textColor="@android:color/white" />
 
-                <TextView
-                    android:id="@+id/featuresURL_TV"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:autoLink="web"
-                    android:textIsSelectable="true"
-                    android:padding="@dimen/text_content_margin"
-                    android:text="@string/about_bug_feature_request_site"
-                    android:textAlignment="center"
-                    android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
+        </LinearLayout>
 
-                <Button
-                    android:id="@+id/tusky_profile_button"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:clickable="true"
-                    android:padding="@dimen/text_content_margin"
-                    android:text="@string/about_tusky_account"
-                    android:textAlignment="center"
-                    android:textAllCaps="false"
-                    android:textAppearance="@style/TextAppearance.AppCompat.Medium"
-                    android:textColor="@android:color/white" />
+    </ScrollView>
 
-            </LinearLayout>
-
-        </ScrollView>
-
-    </LinearLayout>
+    <include layout="@layout/toolbar_shadow_shim" />
 
 </android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_account_list.xml b/app/src/main/res/layout/activity_account_list.xml
index c5d72f85..60c3edf2 100644
--- a/app/src/main/res/layout/activity_account_list.xml
+++ b/app/src/main/res/layout/activity_account_list.xml
@@ -1,30 +1,21 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.design.widget.CoordinatorLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
+<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/activity_view_thread"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:context="com.keylesspalace.tusky.AccountListActivity">
 
-    <LinearLayout
+    <include layout="@layout/toolbar_basic" />
+
+    <FrameLayout
+        android:id="@+id/fragment_container"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:orientation="vertical">
+        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
 
-        <android.support.v7.widget.Toolbar
-            android:id="@+id/toolbar"
-            android:layout_width="match_parent"
-            android:layout_height="?attr/actionBarSize"
-            android:elevation="4dp"
-            android:background="?attr/toolbar_background_color" />
-
-        <FrameLayout
-            android:id="@+id/fragment_container"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent" />
-
-    </LinearLayout>
+    <include layout="@layout/toolbar_shadow_shim" />
 
     <FrameLayout
         android:id="@+id/overlay_fragment_container"
diff --git a/app/src/main/res/layout/activity_compose.xml b/app/src/main/res/layout/activity_compose.xml
index d479e93d..4d26b6f4 100644
--- a/app/src/main/res/layout/activity_compose.xml
+++ b/app/src/main/res/layout/activity_compose.xml
@@ -16,8 +16,7 @@
             android:layout_width="match_parent"
             android:layout_height="?attr/actionBarSize"
             android:layout_marginBottom="8dp"
-            android:background="@android:color/transparent"
-            android:elevation="4dp" />
+            android:background="@android:color/transparent" />
 
         <LinearLayout
             android:id="@+id/compose_content_warning_bar"
diff --git a/app/src/main/res/layout/activity_edit_profile.xml b/app/src/main/res/layout/activity_edit_profile.xml
index 94534b9a..50ed9deb 100644
--- a/app/src/main/res/layout/activity_edit_profile.xml
+++ b/app/src/main/res/layout/activity_edit_profile.xml
@@ -7,22 +7,18 @@
     android:layout_height="match_parent"
     tools:context="com.keylesspalace.tusky.EditProfileActivity">
 
+    <include layout="@layout/toolbar_basic" />
+
     <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="match_parent">
+        android:layout_height="match_parent"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior">
 
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:orientation="vertical">
 
-            <android.support.v7.widget.Toolbar
-                android:id="@+id/toolbar"
-                android:layout_width="match_parent"
-                android:layout_height="?attr/actionBarSize"
-                android:background="?attr/toolbar_background_color"
-                android:elevation="4dp" />
-
             <RelativeLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content">
@@ -81,6 +77,7 @@
                     android:elevation="4dp"
                     android:background="@drawable/round_button"
                     android:contentDescription="@string/label_avatar" />
+
             </RelativeLayout>
 
             <android.support.design.widget.TextInputLayout
@@ -122,6 +119,8 @@
 
     </ScrollView>
 
+    <include layout="@layout/toolbar_shadow_shim" />
+
     <ProgressBar
         android:id="@+id/edit_profile_save_progress"
         android:layout_width="wrap_content"
diff --git a/app/src/main/res/layout/activity_favourites.xml b/app/src/main/res/layout/activity_favourites.xml
index 2c22bd59..c0b95818 100644
--- a/app/src/main/res/layout/activity_favourites.xml
+++ b/app/src/main/res/layout/activity_favourites.xml
@@ -1,36 +1,25 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.design.widget.CoordinatorLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
+<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/activity_view_thread"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:context="com.keylesspalace.tusky.FavouritesActivity">
 
-    <LinearLayout
+    <include layout="@layout/toolbar_basic" />
+
+    <FrameLayout
+        android:id="@+id/fragment_container"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:orientation="vertical">
-
-        <android.support.v7.widget.Toolbar
-            android:id="@+id/toolbar"
-            android:layout_width="match_parent"
-            android:layout_height="?attr/actionBarSize"
-            android:elevation="4dp"
-            android:background="?attr/toolbar_background_color" />
-
-        <FrameLayout
-            android:id="@+id/fragment_container"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent" />
-
-    </LinearLayout>
+        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
 
     <FrameLayout
         android:id="@+id/overlay_fragment_container"
         android:layout_width="match_parent"
-        android:layout_height="match_parent">
+        android:layout_height="match_parent" />
 
-    </FrameLayout>
+    <include layout="@layout/toolbar_shadow_shim" />
 
 </android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_report.xml b/app/src/main/res/layout/activity_report.xml
index 05dab3f2..3ce030b9 100644
--- a/app/src/main/res/layout/activity_report.xml
+++ b/app/src/main/res/layout/activity_report.xml
@@ -1,18 +1,16 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.design.widget.CoordinatorLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
+<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <include layout="@layout/toolbar_basic" />
+
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:orientation="vertical">
-        <android.support.v7.widget.Toolbar
-            android:id="@+id/toolbar"
-            android:layout_width="match_parent"
-            android:layout_height="?attr/actionBarSize"
-            android:elevation="4dp"
-            android:background="?attr/toolbar_background_color" />
+        android:orientation="vertical"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior">
 
         <android.support.v7.widget.RecyclerView
             android:layout_width="match_parent"
@@ -38,4 +36,7 @@
             android:paddingBottom="8dp"
             android:hint="@string/report_comment_hint" />
     </LinearLayout>
+
+    <include layout="@layout/toolbar_shadow_shim" />
+
 </android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_saved_toot.xml b/app/src/main/res/layout/activity_saved_toot.xml
index 718273bc..05a04870 100644
--- a/app/src/main/res/layout/activity_saved_toot.xml
+++ b/app/src/main/res/layout/activity_saved_toot.xml
@@ -1,22 +1,18 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/activity_view_thread"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:context="com.keylesspalace.tusky.AccountListActivity">
 
+    <include layout="@layout/toolbar_basic" />
+
     <RelativeLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:orientation="vertical">
-
-        <android.support.v7.widget.Toolbar
-            android:id="@+id/toolbar"
-            android:layout_width="match_parent"
-            android:layout_height="?attr/actionBarSize"
-            android:background="?attr/toolbar_background_color"
-            android:elevation="4dp" />
+        app:layout_behavior="@string/appbar_scrolling_view_behavior">
 
         <TextView
             android:id="@+id/no_content"
@@ -29,10 +25,10 @@
         <android.support.v7.widget.RecyclerView
             android:id="@+id/recycler_view"
             android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:layout_below="@+id/toolbar" />
-
+            android:layout_height="match_parent" />
 
     </RelativeLayout>
 
+    <include layout="@layout/toolbar_shadow_shim" />
+
 </android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml
index 04ec3127..4573b670 100644
--- a/app/src/main/res/layout/activity_search.xml
+++ b/app/src/main/res/layout/activity_search.xml
@@ -6,10 +6,12 @@
     xmlns:app="http://schemas.android.com/apk/res-auto"
     tools:context="com.keylesspalace.tusky.SearchActivity">
 
-    <LinearLayout
+    <android.support.design.widget.AppBarLayout
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
+        android:layout_height="wrap_content"
+        android:stateListAnimator="@null"
+        android:elevation="0dp"
+        app:layout_collapseMode="pin">
 
         <android.support.v7.widget.Toolbar
             android:id="@+id/toolbar"
@@ -19,33 +21,36 @@
             app:navigationIcon="?attr/homeAsUpIndicator"
             app:contentInsetStartWithNavigation="0dp" />
 
-        <RelativeLayout
+    </android.support.design.widget.AppBarLayout>
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior">
+
+        <android.support.v7.widget.RecyclerView
             android:layout_width="match_parent"
-            android:layout_height="match_parent">
+            android:layout_height="match_parent"
+            android:id="@+id/recycler_view" />
 
-            <android.support.v7.widget.RecyclerView
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:id="@+id/recycler_view" />
+        <ProgressBar
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:id="@+id/progress_bar"
+            android:layout_centerInParent="true"
+            android:indeterminate="true"
+            android:visibility="gone" />
 
-            <ProgressBar
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:id="@+id/progress_bar"
-                android:layout_centerInParent="true"
-                android:indeterminate="true"
-                android:visibility="gone" />
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:id="@+id/message_no_results"
+            android:text="@string/search_no_results"
+            android:layout_centerInParent="true"
+            android:visibility="gone" />
 
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:id="@+id/message_no_results"
-                android:text="@string/search_no_results"
-                android:layout_centerInParent="true"
-                android:visibility="gone" />
+    </RelativeLayout>
 
-        </RelativeLayout>
-
-    </LinearLayout>
+    <include layout="@layout/toolbar_shadow_shim" />
 
 </android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_view_tag.xml b/app/src/main/res/layout/activity_view_tag.xml
index f2afb8b0..bc5c2ae9 100644
--- a/app/src/main/res/layout/activity_view_tag.xml
+++ b/app/src/main/res/layout/activity_view_tag.xml
@@ -1,29 +1,21 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/activity_view_thread"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:context="com.keylesspalace.tusky.ViewTagActivity">
 
-    <LinearLayout
+    <include layout="@layout/toolbar_basic" />
+
+    <FrameLayout
+        android:id="@+id/fragment_container"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:orientation="vertical">
+        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
 
-        <android.support.v7.widget.Toolbar
-            android:id="@+id/toolbar"
-            android:layout_width="match_parent"
-            android:layout_height="?attr/actionBarSize"
-            android:elevation="4dp"
-            android:background="?attr/toolbar_background_color" />
-
-        <FrameLayout
-            android:id="@+id/fragment_container"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent" />
-
-    </LinearLayout>
+    <include layout="@layout/toolbar_shadow_shim" />
 
     <FrameLayout
         android:id="@+id/overlay_fragment_container"
diff --git a/app/src/main/res/layout/activity_view_thread.xml b/app/src/main/res/layout/activity_view_thread.xml
index 8b2a203a..9228a01b 100644
--- a/app/src/main/res/layout/activity_view_thread.xml
+++ b/app/src/main/res/layout/activity_view_thread.xml
@@ -1,29 +1,21 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.design.widget.CoordinatorLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
+<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/activity_view_thread"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:context="com.keylesspalace.tusky.ViewThreadActivity">
 
-    <LinearLayout
+    <include layout="@layout/toolbar_basic" />
+
+    <FrameLayout
+        android:id="@+id/fragment_container"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:orientation="vertical">
+        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
 
-        <android.support.v7.widget.Toolbar
-            android:id="@+id/toolbar"
-            android:layout_width="match_parent"
-            android:layout_height="?attr/actionBarSize"
-            android:elevation="4dp"
-            android:background="?attr/toolbar_background_color" />
-
-        <FrameLayout
-            android:id="@+id/fragment_container"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent" />
-    </LinearLayout>
+    <include layout="@layout/toolbar_shadow_shim" />
 
     <FrameLayout
         android:id="@+id/overlay_fragment_container"
diff --git a/app/src/main/res/layout/activity_view_video.xml b/app/src/main/res/layout/activity_view_video.xml
index 7a15f215..0575d902 100644
--- a/app/src/main/res/layout/activity_view_video.xml
+++ b/app/src/main/res/layout/activity_view_video.xml
@@ -25,6 +25,5 @@
         android:layout_height="?attr/actionBarSize"
         android:theme="@style/AppTheme.Account.AppBarLayout"
         app:popupTheme="@style/AppTheme.Account.ToolbarPopupTheme.Dark"
-        android:elevation="4dp"
         android:background="@color/semi_transparent" />
 </android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/toolbar_basic.xml b/app/src/main/res/layout/toolbar_basic.xml
new file mode 100644
index 00000000..1086ee28
--- /dev/null
+++ b/app/src/main/res/layout/toolbar_basic.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<merge xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <android.support.design.widget.AppBarLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:stateListAnimator="@null"
+        android:elevation="0dp"
+        app:layout_collapseMode="pin">
+
+        <android.support.v7.widget.Toolbar
+            android:id="@+id/toolbar"
+            android:layout_width="match_parent"
+            android:layout_height="?attr/actionBarSize"
+            android:background="?attr/toolbar_background_color" />
+
+    </android.support.design.widget.AppBarLayout>
+
+</merge>
\ No newline at end of file
diff --git a/app/src/main/res/layout/toolbar_shadow_shim.xml b/app/src/main/res/layout/toolbar_shadow_shim.xml
new file mode 100644
index 00000000..fb34d21b
--- /dev/null
+++ b/app/src/main/res/layout/toolbar_shadow_shim.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<merge xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <View
+        android:id="@+id/toolbar_shadow_shim"
+        android:layout_width="match_parent"
+        android:layout_height="4dp"
+        android:background="@drawable/material_drawer_shadow_bottom"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior"
+        app:layout_collapseMode="pin" />
+
+</merge>
\ No newline at end of file