Fix scrolling to new tabs.
[PrivacyBrowser.git] / app / src / main / res / layout / main_framelayout.xml
1 <?xml version="1.0" encoding="utf-8"?>
2
3 <!--
4   Copyright © 2015-2017,2019 Soren Stoutner <soren@stoutner.com>.
5
6   This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>>.
7
8   Privacy Browser is free software: you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation, either version 3 of the License, or
11   (at your option) any later version.
12
13   Privacy Browser is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18   You should have received a copy of the GNU General Public License
19   along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
20
21 <FrameLayout
22     xmlns:android="http://schemas.android.com/apk/res/android"
23     xmlns:android.support.design="http://schemas.android.com/apk/res-auto"
24     xmlns:tools="http://schemas.android.com/tools"
25     android:id="@+id/root_framelayout"
26     android:layout_height="match_parent"
27     android:layout_width="match_parent" >
28
29     <androidx.drawerlayout.widget.DrawerLayout
30         android:id="@+id/drawerlayout"
31         android:layout_height="match_parent"
32         android:layout_width="match_parent" >
33
34         <!-- The relative layout contains the AdView and the coordinator layout, which contains the rest of the views.
35             `android:fitsSystemWindows="true"` moves the toolbar below the system status bar but lets the drawers slide under the translucent status bar.
36             When it is specified, the theme should include `<item name="android:windowTranslucentStatus">true</item>`. -->
37         <RelativeLayout
38             android:id="@+id/main_content_relativelayout"
39             android:layout_height="match_parent"
40             android:layout_width="match_parent"
41             android:fitsSystemWindows="true" >
42
43             <!-- Include the AdView.  For the standard flavor, this just includes a TextView with `visibility="gone"`. -->
44             <include layout="@layout/adview" />
45
46             <!-- Setting the CoordinatorLayout to be `focusableInTouchMode` prevents the URL text box from stealing focus on launch and opening the keyboard. -->
47             <androidx.coordinatorlayout.widget.CoordinatorLayout
48                 android:layout_height="match_parent"
49                 android:layout_width="match_parent"
50                 android:layout_above="@id/adview"
51                 android:focusable="true"
52                 android:focusableInTouchMode="true" >
53
54                 <!-- The theme has to be defined here because the activity uses a `NoActionBar` theme. -->
55                 <com.google.android.material.appbar.AppBarLayout
56                     android:layout_height="wrap_content"
57                     android:layout_width="match_parent"
58                     android:theme="@style/PrivacyBrowserAppBarLight" >
59
60                     <androidx.appcompat.widget.Toolbar
61                         android:id="@+id/toolbar"
62                         android:layout_height="wrap_content"
63                         android:layout_width="match_parent"
64                         android.support.design:layout_scrollFlags="scroll|enterAlways|snap" />
65
66                     <LinearLayout
67                         android:layout_height="wrap_content"
68                         android:layout_width="wrap_content"
69                         android:orientation="horizontal"
70                         android.support.design:layout_scrollFlags="scroll|enterAlways|snap" >
71
72                         <com.google.android.material.tabs.TabLayout
73                             android:id="@+id/tablayout"
74                             android:layout_height="wrap_content"
75                             android:layout_width="0dp"
76                             android:layout_weight="1"
77                             android.support.design:tabIndicatorGravity="top"
78                             android.support.design:tabMode="scrollable" />
79
80                         <ImageView
81                             android:layout_height="wrap_content"
82                             android:layout_width="wrap_content"
83                             android:layout_gravity="center_vertical"
84                             android:paddingStart="10dp"
85                             android:paddingEnd="10dp"
86                             android:src="@drawable/add_light"
87                             android:tint="?attr/addTabIconTintColor"
88                             android:onClick="addTab"
89                             android:contentDescription="@string/add_tab" />
90                     </LinearLayout>
91
92                     <!-- The find on page linear layout.  It is initially `visibility="gone"`. -->
93                     <LinearLayout
94                         android:id="@+id/find_on_page_linearlayout"
95                         android:layout_height="wrap_content"
96                         android:layout_width="match_parent"
97                         android:orientation="horizontal"
98                         android:visibility="gone" >
99
100                         <!-- `android:imeOptions="actionDone"` sets the keyboard to have a `check mark` key instead of a `new line` key. -->
101                         <EditText
102                             android:id="@+id/find_on_page_edittext"
103                             android:layout_height="wrap_content"
104                             android:layout_width="0dp"
105                             android:layout_weight="1"
106                             android:layout_marginStart="8dp"
107                             android:layout_marginEnd="4dp"
108                             android:hint="@string/find_on_page"
109                             android:lines="1"
110                             android:imeOptions="actionDone"
111                             android:inputType="text"
112                             tools:ignore="Autofill" />
113
114                         <TextView
115                             android:id="@+id/find_on_page_count_textview"
116                             android:layout_height="wrap_content"
117                             android:layout_width="wrap_content"
118                             android:layout_marginStart="4dp"
119                             android:layout_marginEnd="4dp"
120                             android:text="@string/zero_of_zero" />
121
122                         <ImageView
123                             android:id="@+id/find_previous"
124                             android:src="@drawable/previous"
125                             android:layout_width="35dp"
126                             android:layout_height="35dp"
127                             android:layout_marginStart="4dp"
128                             android:layout_marginEnd="4dp"
129                             android:layout_gravity="center_vertical"
130                             android:tint="?attr/findOnPageIconTintColor"
131                             android:contentDescription="@string/previous"
132                             android:onClick="findPreviousOnPage" />
133
134                         <ImageView
135                             android:id="@+id/find_next"
136                             android:src="@drawable/next"
137                             android:layout_width="35dp"
138                             android:layout_height="35dp"
139                             android:layout_marginStart="4dp"
140                             android:layout_marginEnd="4dp"
141                             android:layout_gravity="center_vertical"
142                             android:tint="?attr/findOnPageIconTintColor"
143                             android:contentDescription="@string/next"
144                             android:onClick="findNextOnPage" />
145
146                         <ImageView
147                             android:id="@+id/close_find"
148                             android:src="@drawable/close_light"
149                             android:layout_width="35dp"
150                             android:layout_height="35dp"
151                             android:layout_marginStart="4dp"
152                             android:layout_marginEnd="8dp"
153                             android:layout_gravity="center_vertical"
154                             android:tint="?attr/findOnPageIconTintColor"
155                             android:contentDescription="@string/close"
156                             android:onClick="closeFindOnPage" />
157                     </LinearLayout>
158                 </com.google.android.material.appbar.AppBarLayout>
159
160                 <!-- `app:layout_behavior="@string/appbar_scrolling_view_behavior"` must be set on the sibling of AppBarLayout. -->
161                 <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
162                     android:id="@+id/swiperefreshlayout"
163                     android:layout_width="match_parent"
164                     android:layout_height="match_parent"
165                     android.support.design:layout_behavior="@string/appbar_scrolling_view_behavior" >
166
167                         <androidx.viewpager.widget.ViewPager
168                             android:id="@+id/webviewpager"
169                             android:layout_width="match_parent"
170                             android:layout_height="match_parent" />
171                 </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
172             </androidx.coordinatorlayout.widget.CoordinatorLayout>
173         </RelativeLayout>
174
175         <!-- The navigation drawer. -->
176         <com.google.android.material.navigation.NavigationView
177             android:id="@+id/navigationview"
178             android:layout_height="match_parent"
179             android:layout_width="wrap_content"
180             android:layout_gravity="start"
181             android.support.design:headerLayout="@layout/navigation_header"
182             android.support.design:menu="@menu/webview_navigation_menu"
183             android.support.design:itemIconTint="?attr/navigationIconTintColor" />
184
185         <!-- Include the bookmarks drawer, which varies based on screen width. -->
186         <include layout="@layout/bookmarks_drawer" />
187     </androidx.drawerlayout.widget.DrawerLayout>
188
189     <!-- `The full screen video frame layout is used to display full screen videos.  It is initially `android:visibility="gone"` to hide it from view. -->
190     <FrameLayout
191         android:id="@+id/full_screen_video_framelayout"
192         android:layout_height="match_parent"
193         android:layout_width="match_parent"
194         android:visibility="gone" />
195 </FrameLayout>