Skip to content

Commit c4d080e

Browse files
Merge pull request #16226 from nextcloud/style/noid/m3SeachBar
Migrate to M3 search bar style
2 parents c8469d6 + 961c441 commit c4d080e

File tree

2 files changed

+100
-95
lines changed

2 files changed

+100
-95
lines changed

app/src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public abstract class ToolbarActivity extends BaseActivity implements Injectable
6464
private AppBarLayout mAppBar;
6565
private RelativeLayout mDefaultToolbar;
6666
private MaterialToolbar mToolbar;
67-
private MaterialCardView mHomeSearchToolbar;
67+
private MaterialCardView mHomeSearchContainer;
68+
private LinearLayout mHomeSearchToolbar;
6869
private ImageView mPreviewImage;
6970
private FrameLayout mPreviewImageContainer;
7071
private LinearLayout mInfoBox;
@@ -88,6 +89,7 @@ private void setupToolbar(boolean isHomeSearchToolbarShow, boolean showSortListB
8889
mAppBar = findViewById(R.id.appbar);
8990
mDefaultToolbar = findViewById(R.id.default_toolbar);
9091
mHomeSearchToolbar = findViewById(R.id.home_toolbar);
92+
mHomeSearchContainer = findViewById(R.id.home_search_container);
9193
mMenuButton = findViewById(R.id.menu_button);
9294
mSearchText = findViewById(R.id.search_text);
9395
mSwitchAccountButton = findViewById(R.id.switch_account_button);
@@ -113,7 +115,7 @@ private void setupToolbar(boolean isHomeSearchToolbarShow, boolean showSortListB
113115
viewThemeUtils.platform.themeStatusBar(this);
114116
viewThemeUtils.material.colorMaterialTextButton(mSwitchAccountButton);
115117

116-
viewThemeUtils.material.themeSearchCardView(mHomeSearchToolbar);
118+
viewThemeUtils.material.themeSearchCardView(mHomeSearchContainer);
117119
viewThemeUtils.material.colorMaterialButtonContent(mMenuButton, ColorRole.ON_SURFACE);
118120
viewThemeUtils.material.colorMaterialButtonContent(mNotificationButton, ColorRole.ON_SURFACE);
119121
viewThemeUtils.platform.colorTextView(mSearchText, ColorRole.ON_SURFACE_VARIANT);
@@ -286,7 +288,7 @@ private void showHomeSearchToolbar(boolean isShow) {
286288
R.animator.appbar_elevation_off));
287289
mDefaultToolbar.setVisibility(View.GONE);
288290
mHomeSearchToolbar.setVisibility(View.VISIBLE);
289-
viewThemeUtils.material.themeSearchCardView(mHomeSearchToolbar);
291+
viewThemeUtils.material.themeSearchCardView(mHomeSearchContainer);
290292
viewThemeUtils.material.themeSearchBarText(mSearchText);
291293
} else {
292294
mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(),

app/src/main/res/layout/toolbar_standard.xml

Lines changed: 95 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!--
33
~ Nextcloud - Android Client
44
~
5+
~ SPDX-FileCopyrightText: 2017-2025 Andy Scherzinger <info@andy-scherzinger>
56
~ SPDX-FileCopyrightText: 2018-2020 Tobias Kaminsky <[email protected]>
6-
~ SPDX-FileCopyrightText: 2017-2020 Andy Scherzinger <info@andy-scherzinger>
7-
~ SPDX-FileCopyrightText: 22020 Joris Bodin <[email protected]>
7+
~ SPDX-FileCopyrightText: 2020 Joris Bodin <[email protected]>
88
~ SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
99
-->
1010
<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
@@ -16,9 +16,9 @@
1616
android:background="@color/bg_default">
1717

1818
<FrameLayout
19+
android:id="@+id/toolbar_frame"
1920
android:layout_width="match_parent"
2021
android:layout_height="wrap_content"
21-
android:id="@+id/toolbar_frame"
2222
app:layout_scrollFlags="scroll|enterAlways">
2323

2424
<!-- sorting/layout bar -->
@@ -56,11 +56,11 @@
5656
<com.google.android.material.button.MaterialButton
5757
android:id="@+id/switch_grid_view_button"
5858
style="@style/Widget.AppTheme.Button.IconButton"
59-
android:layout_width="48dp"
60-
android:layout_height="48dp"
59+
android:layout_width="@dimen/minimum_size_for_touchable_area"
60+
android:layout_height="@dimen/minimum_size_for_touchable_area"
6161
android:layout_marginEnd="1dp"
6262
android:contentDescription="@string/action_switch_grid_view"
63-
app:cornerRadius="24dp"
63+
app:cornerRadius="@dimen/button_corner_radius"
6464
app:icon="@drawable/ic_view_module"
6565
app:iconTint="@color/fontAppbar"
6666
app:layout_constraintBottom_toBottomOf="parent"
@@ -116,24 +116,24 @@
116116

117117
<LinearLayout
118118
android:id="@+id/toolbar_linear_layout"
119-
android:visibility="gone"
120-
tools:visibility="visible"
119+
android:layout_width="match_parent"
120+
android:layout_height="wrap_content"
121+
android:layout_marginStart="@dimen/standard_half_margin"
122+
android:layout_marginTop="@dimen/standard_half_margin"
123+
android:layout_marginEnd="@dimen/standard_margin"
124+
android:layout_marginBottom="@dimen/standard_quarter_margin"
121125
android:orientation="horizontal"
122-
android:layout_marginStart="8dp"
123-
android:layout_marginTop="8dp"
124-
android:layout_marginEnd="16dp"
125-
android:layout_marginBottom="4dp"
126+
android:visibility="gone"
126127
app:layout_constraintBottom_toBottomOf="parent"
127128
app:layout_constraintStart_toStartOf="parent"
128129
app:layout_constraintTop_toTopOf="parent"
129-
android:layout_width="match_parent"
130-
android:layout_height="wrap_content">
130+
tools:visibility="visible">
131131

132132
<com.google.android.material.button.MaterialButton
133133
android:id="@+id/toolbar_menu_button"
134134
style="@style/Widget.AppTheme.Button.IconButton"
135-
android:layout_width="48dp"
136-
android:layout_height="48dp"
135+
android:layout_width="@dimen/minimum_size_for_touchable_area"
136+
android:layout_height="@dimen/minimum_size_for_touchable_area"
137137
app:cornerRadius="@dimen/button_corner_radius"
138138
app:icon="@drawable/ic_menu"
139139
app:iconTint="@color/black" />
@@ -145,91 +145,94 @@
145145
android:lines="1"
146146
android:textSize="16sp"
147147
android:layout_width="wrap_content"
148-
android:layout_height="48dp"/>
148+
android:layout_height="@dimen/minimum_size_for_touchable_area"/>
149149

150150
</LinearLayout>
151151

152-
153152
<!-- home/search toolbar -->
154-
<com.google.android.material.card.MaterialCardView
153+
<LinearLayout
155154
android:id="@+id/home_toolbar"
156155
android:layout_width="match_parent"
157-
android:layout_height="50dp"
158-
android:layout_marginStart="16dp"
159-
android:layout_marginTop="8dp"
160-
android:layout_marginEnd="16dp"
161-
android:layout_marginBottom="4dp"
156+
android:layout_height="match_parent"
157+
android:layout_marginTop="@dimen/standard_half_margin"
158+
android:orientation="horizontal"
162159
android:visibility="gone"
163-
app:background="@color/appbar"
164-
app:cardCornerRadius="25dp"
165-
app:cardElevation="2dp"
166-
app:strokeWidth="0dp"
167160
tools:visibility="visible">
168161

169-
<androidx.constraintlayout.widget.ConstraintLayout
170-
android:layout_width="match_parent"
171-
android:layout_height="match_parent">
172-
173-
<com.google.android.material.button.MaterialButton
174-
android:id="@+id/menu_button"
175-
style="@style/Widget.AppTheme.Button.IconButton"
176-
android:layout_width="48dp"
177-
android:layout_height="48dp"
178-
android:layout_marginStart="5dp"
179-
android:contentDescription="@string/action_switch_grid_view"
180-
app:cornerRadius="@dimen/button_corner_radius"
181-
app:icon="@drawable/ic_menu"
182-
app:iconTint="@color/fontAppbar"
183-
app:iconSize="@dimen/search_bar_icon_size"
184-
app:layout_constraintBottom_toBottomOf="parent"
185-
app:layout_constraintStart_toStartOf="parent"
186-
app:layout_constraintTop_toTopOf="parent" />
187-
188-
<com.google.android.material.textview.MaterialTextView
189-
android:id="@+id/search_text"
190-
android:layout_width="0dp"
191-
android:layout_height="48dp"
192-
android:layout_marginStart="7dp"
193-
android:layout_marginEnd="18dp"
194-
android:ellipsize="end"
195-
android:gravity="start|center_vertical"
196-
android:lines="1"
197-
android:textColor="@color/fontSecondaryAppbar"
198-
android:textSize="16sp"
199-
app:layout_constraintBottom_toBottomOf="parent"
200-
app:layout_constraintLeft_toRightOf="@id/menu_button"
201-
app:layout_constraintRight_toLeftOf="@id/notification_button"
202-
app:layout_constraintTop_toTopOf="parent"
203-
tools:text="@string/placeholder_search_in_nextcloud" />
204-
205-
<com.google.android.material.button.MaterialButton
206-
android:id="@+id/notification_button"
207-
style="@style/Widget.AppTheme.Button.IconButton"
208-
android:layout_width="48dp"
209-
android:layout_height="48dp"
210-
android:contentDescription="@string/notification_icon_description"
211-
app:cornerRadius="@dimen/button_corner_radius"
212-
app:iconSize="@dimen/search_bar_icon_size"
213-
app:icon="@drawable/ic_notification"
214-
app:iconTint="@color/fontAppbar"
215-
app:layout_constraintBottom_toBottomOf="parent"
216-
app:layout_constraintEnd_toStartOf="@id/switch_account_button"
217-
app:layout_constraintTop_toTopOf="parent" />
218-
219-
<com.google.android.material.button.MaterialButton
220-
android:id="@+id/switch_account_button"
221-
style="@style/Widget.AppTheme.Button.IconButton"
222-
android:layout_width="48dp"
223-
android:layout_height="48dp"
224-
app:cornerRadius="@dimen/button_corner_radius"
225-
app:iconSize="30dp"
226-
app:layout_constraintBottom_toBottomOf="parent"
227-
app:layout_constraintEnd_toEndOf="parent"
228-
app:layout_constraintTop_toTopOf="parent" />
229-
230-
</androidx.constraintlayout.widget.ConstraintLayout>
231-
232-
</com.google.android.material.card.MaterialCardView>
162+
<com.google.android.material.button.MaterialButton
163+
android:id="@+id/menu_button"
164+
style="@style/Widget.AppTheme.Button.IconButton"
165+
android:layout_width="@dimen/minimum_size_for_touchable_area"
166+
android:layout_height="@dimen/minimum_size_for_touchable_area"
167+
android:layout_marginStart="@dimen/standard_quarter_margin"
168+
android:layout_marginEnd="@dimen/standard_half_margin"
169+
android:contentDescription="@string/drawer_open"
170+
app:cornerRadius="@dimen/button_corner_radius"
171+
app:icon="@drawable/ic_menu"
172+
app:iconSize="@dimen/search_bar_icon_size"
173+
app:iconTint="@color/fontAppbar" />
174+
175+
<com.google.android.material.card.MaterialCardView
176+
android:id="@+id/home_search_container"
177+
android:layout_width="0dp"
178+
android:layout_height="50dp"
179+
android:layout_marginEnd="@dimen/standard_half_margin"
180+
android:layout_marginBottom="4dp"
181+
android:layout_weight="1"
182+
app:background="@color/appbar"
183+
app:cardCornerRadius="25dp"
184+
app:cardElevation="2dp"
185+
app:strokeWidth="0dp">
186+
187+
<LinearLayout
188+
android:layout_width="match_parent"
189+
android:layout_height="match_parent"
190+
android:orientation="horizontal">
191+
192+
<com.google.android.material.textview.MaterialTextView
193+
android:id="@+id/search_text"
194+
android:layout_width="0dp"
195+
android:layout_height="match_parent"
196+
android:layout_marginStart="@dimen/standard_margin"
197+
android:layout_marginEnd="@dimen/zero"
198+
android:layout_weight="1"
199+
android:ellipsize="end"
200+
android:gravity="start|center_vertical"
201+
android:lines="1"
202+
android:textColor="@color/fontSecondaryAppbar"
203+
android:textSize="16sp"
204+
tools:text="@string/placeholder_search_in_nextcloud" />
205+
206+
<com.google.android.material.button.MaterialButton
207+
android:id="@+id/notification_button"
208+
style="@style/Widget.AppTheme.Button.IconButton"
209+
android:layout_width="@dimen/minimum_size_for_touchable_area"
210+
android:layout_height="@dimen/minimum_size_for_touchable_area"
211+
android:layout_marginStart="@dimen/zero"
212+
android:layout_marginEnd="@dimen/standard_quarter_margin"
213+
android:contentDescription="@string/notification_icon_description"
214+
app:cornerRadius="@dimen/button_corner_radius"
215+
app:icon="@drawable/ic_notification"
216+
app:iconSize="@dimen/search_bar_icon_size"
217+
app:iconTint="@color/fontAppbar"
218+
app:layout_constraintBottom_toBottomOf="parent"
219+
app:layout_constraintStart_toEndOf="@id/switch_account_button"
220+
app:layout_constraintTop_toTopOf="parent" />
221+
222+
</LinearLayout>
223+
224+
</com.google.android.material.card.MaterialCardView>
225+
226+
<com.google.android.material.button.MaterialButton
227+
android:id="@+id/switch_account_button"
228+
style="@style/Widget.AppTheme.Button.IconButton"
229+
android:layout_width="@dimen/minimum_size_for_touchable_area"
230+
android:layout_height="@dimen/minimum_size_for_touchable_area"
231+
android:layout_marginEnd="@dimen/standard_quarter_margin"
232+
app:cornerRadius="@dimen/button_corner_radius"
233+
app:iconSize="30dp"
234+
tools:icon="@drawable/ic_user_outline" />
235+
</LinearLayout>
233236

234237
</FrameLayout>
235238

0 commit comments

Comments
 (0)