From b1889abb1b48bbde57b6b09f7f1d3c03f00e243c Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Wed, 28 Nov 2018 17:15:30 +0100 Subject: [PATCH] Add nice FAB animation & cleanups to layouts --- .../utils/FABAwareScrollingViewBehavior.java | 73 ++++++++++++++ .../main/res/layout/activity_magic_call.xml | 15 ++- app/src/main/res/layout/activity_main.xml | 9 +- app/src/main/res/layout/bottom_sheet.xml | 15 ++- app/src/main/res/layout/call_item.xml | 31 +++--- .../controller_account_verification.xml | 29 +++--- app/src/main/res/layout/controller_call.xml | 98 ++++++++----------- .../main/res/layout/controller_call_menu.xml | 13 ++- .../layout/controller_call_notification.xml | 31 +++--- app/src/main/res/layout/controller_chat.xml | 35 ++++--- .../layout/controller_conversations_rv.xml | 26 ++--- .../main/res/layout/controller_entry_menu.xml | 23 +++-- .../main/res/layout/controller_generic_rv.xml | 17 ++-- .../res/layout/controller_operations_menu.xml | 35 ++++--- .../layout/controller_server_selection.xml | 33 +++---- .../main/res/layout/controller_settings.xml | 59 +++++------ .../res/layout/controller_web_view_login.xml | 19 ++-- app/src/main/res/layout/fast_scroller.xml | 34 +++---- .../item_custom_incoming_preview_message.xml | 4 +- .../item_custom_incoming_text_message.xml | 18 ++-- .../item_custom_outcoming_preview_message.xml | 2 +- .../item_custom_outcoming_text_message.xml | 16 ++- .../main/res/layout/item_system_message.xml | 19 ++-- .../layout/library_fast_scroller_layout.xml | 12 +-- .../res/layout/notification_settings_item.xml | 5 +- app/src/main/res/layout/rv_item_app.xml | 21 ++-- .../main/res/layout/rv_item_call_header.xml | 25 +++-- app/src/main/res/layout/rv_item_contact.xml | 19 ++-- .../main/res/layout/rv_item_conversation.xml | 30 +++--- ...rv_item_conversation_with_last_message.xml | 33 +++---- .../main/res/layout/rv_item_empty_footer.xml | 9 +- app/src/main/res/layout/rv_item_mention.xml | 21 ++-- app/src/main/res/layout/rv_item_menu.xml | 13 ++- .../res/layout/rv_item_notification_sound.xml | 18 ++-- app/src/main/res/layout/rv_item_progress.xml | 10 +- .../main/res/layout/rv_item_title_header.xml | 19 ++-- .../main/res/layout/view_message_input.xml | 15 ++- 37 files changed, 460 insertions(+), 444 deletions(-) create mode 100644 app/src/main/java/com/nextcloud/talk/utils/FABAwareScrollingViewBehavior.java diff --git a/app/src/main/java/com/nextcloud/talk/utils/FABAwareScrollingViewBehavior.java b/app/src/main/java/com/nextcloud/talk/utils/FABAwareScrollingViewBehavior.java new file mode 100644 index 000000000..77841302c --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/utils/FABAwareScrollingViewBehavior.java @@ -0,0 +1,73 @@ +/* + * Copyright 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.nextcloud.talk.utils; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; + +import com.google.android.material.appbar.AppBarLayout; +import com.google.android.material.floatingactionbutton.FloatingActionButton; + +import java.util.List; + +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.view.ViewCompat; + +public class FABAwareScrollingViewBehavior extends AppBarLayout.ScrollingViewBehavior { + + public FABAwareScrollingViewBehavior(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) { + return super.layoutDependsOn(parent, child, dependency) || + dependency instanceof FloatingActionButton; + } + + @Override + public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final View child, + final View directTargetChild, final View target, final int nestedScrollAxes) { + // Ensure we react to vertical scrolling + return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL + || super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes); + } + + @Override + public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final View child, + final View target, final int dxConsumed, final int dyConsumed, + final int dxUnconsumed, final int dyUnconsumed) { + super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); + if (dyConsumed > 0) { + // User scrolled down -> hide the FAB + List dependencies = coordinatorLayout.getDependencies(child); + for (View view : dependencies) { + if (view instanceof FloatingActionButton) { + ((FloatingActionButton) view).hide(); + } + } + } else if (dyConsumed < 0) { + // User scrolled up -> show the FAB + List dependencies = coordinatorLayout.getDependencies(child); + for (View view : dependencies) { + if (view instanceof FloatingActionButton) { + ((FloatingActionButton) view).show(); + } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_magic_call.xml b/app/src/main/res/layout/activity_magic_call.xml index 672b8f9bd..342382ce4 100644 --- a/app/src/main/res/layout/activity_magic_call.xml +++ b/app/src/main/res/layout/activity_magic_call.xml @@ -1,5 +1,4 @@ - - + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true" + tools:context=".activities.MagicCallActivity"> + android:layout_height="match_parent" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3c42f40e0..ed8229431 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,6 +1,5 @@ - + android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> @@ -25,7 +23,6 @@ android:id="@+id/controller_container" android:layout_width="match_parent" android:layout_height="match_parent" - app:layout_behavior="@string/appbar_scrolling_view_behavior" - /> + app:layout_behavior="@string/appbar_scrolling_view_behavior" /> diff --git a/app/src/main/res/layout/bottom_sheet.xml b/app/src/main/res/layout/bottom_sheet.xml index cb18a8c4d..33ad49ee0 100644 --- a/app/src/main/res/layout/bottom_sheet.xml +++ b/app/src/main/res/layout/bottom_sheet.xml @@ -1,5 +1,4 @@ - - + xmlns:app="http://schemas.android.com/apk/res-auto" + android:id="@+id/bottom_sheet" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@color/white" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> \ No newline at end of file diff --git a/app/src/main/res/layout/call_item.xml b/app/src/main/res/layout/call_item.xml index 4971a365a..641e484ad 100644 --- a/app/src/main/res/layout/call_item.xml +++ b/app/src/main/res/layout/call_item.xml @@ -1,5 +1,4 @@ - - + android:id="@+id/relative_layout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1" + android:orientation="vertical"> + android:visibility="invisible" /> + android:layout_centerInParent="true" /> + android:layout_marginEnd="8dp" + android:layout_marginBottom="8dp" + android:textColor="@android:color/white" /> + android:visibility="invisible" /> + android:visibility="invisible" /> diff --git a/app/src/main/res/layout/controller_account_verification.xml b/app/src/main/res/layout/controller_account_verification.xml index 1ca51b0c9..5f633684d 100644 --- a/app/src/main/res/layout/controller_account_verification.xml +++ b/app/src/main/res/layout/controller_account_verification.xml @@ -1,5 +1,4 @@ - - + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/nc_white_color" + android:keepScreenOn="true"> + android:keepScreenOn="true" /> + tools:text="Verifying..." /> diff --git a/app/src/main/res/layout/controller_call.xml b/app/src/main/res/layout/controller_call.xml index 31d84100a..850178d52 100644 --- a/app/src/main/res/layout/controller_call.xml +++ b/app/src/main/res/layout/controller_call.xml @@ -100,75 +100,63 @@ - + android:layout_centerHorizontal="true" + android:layout_marginBottom="16dp" + android:animateLayoutChanges="true" + android:background="@android:color/transparent" + android:gravity="center"> + + - + - + - + - - - - diff --git a/app/src/main/res/layout/controller_call_menu.xml b/app/src/main/res/layout/controller_call_menu.xml index 13a77f5a5..21c711e62 100644 --- a/app/src/main/res/layout/controller_call_menu.xml +++ b/app/src/main/res/layout/controller_call_menu.xml @@ -1,5 +1,4 @@ - - + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@color/nc_white_color"> + tools:listitem="@layout/rv_item_conversation" /> diff --git a/app/src/main/res/layout/controller_call_notification.xml b/app/src/main/res/layout/controller_call_notification.xml index 8c52e0f41..53445c468 100644 --- a/app/src/main/res/layout/controller_call_notification.xml +++ b/app/src/main/res/layout/controller_call_notification.xml @@ -1,5 +1,4 @@ - - + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/constraintLayout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/grey950"> + android:layout_height="wrap_content"> + app:layout_constraintTop_toTopOf="parent" /> + tools:text="Victor Gregorius Magnus" /> @@ -67,7 +66,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.45" - tools:src="@color/white"/> + tools:src="@color/white" /> + app:frontImage="@drawable/ic_mic_white_24px" /> + app:frontImage="@drawable/ic_call_end_white_24px" /> + app:frontImage="@drawable/ic_videocam_white_24px" /> diff --git a/app/src/main/res/layout/controller_chat.xml b/app/src/main/res/layout/controller_chat.xml index da848fde5..9f2263dfb 100644 --- a/app/src/main/res/layout/controller_chat.xml +++ b/app/src/main/res/layout/controller_chat.xml @@ -1,5 +1,4 @@ - - + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:visibility="gone" /> + android:textSize="72sp" /> + android:textSize="20sp" /> + app:textAutoLink="all" /> + app:pb_textColor="@color/white" /> + android:background="@color/nc_light_grey" /> + app:inputTextSize="16sp" /> diff --git a/app/src/main/res/layout/controller_conversations_rv.xml b/app/src/main/res/layout/controller_conversations_rv.xml index 6e6f58a69..2079b5d1c 100644 --- a/app/src/main/res/layout/controller_conversations_rv.xml +++ b/app/src/main/res/layout/controller_conversations_rv.xml @@ -1,5 +1,4 @@ - - + android:indeterminateTintMode="src_in" /> + android:background="@drawable/ic_logo_blue" /> + android:textSize="20sp" /> + android:visibility="gone" + app:layout_behavior="com.nextcloud.talk.utils.FABAwareScrollingViewBehavior"> + tools:listitem="@layout/rv_item_conversation" /> - + + app:srcCompat="@drawable/ic_add_white_24px" /> diff --git a/app/src/main/res/layout/controller_entry_menu.xml b/app/src/main/res/layout/controller_entry_menu.xml index 2e3d198f9..cc3189f56 100644 --- a/app/src/main/res/layout/controller_entry_menu.xml +++ b/app/src/main/res/layout/controller_entry_menu.xml @@ -1,5 +1,4 @@ - - + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@color/nc_white_color"> + android:textColor="@color/colorPrimary" /> @@ -51,15 +50,15 @@ android:id="@+id/ok_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentEnd="true" android:layout_below="@id/text_field_boxes" - android:layout_marginBottom="12dp" - android:layout_marginEnd="8dp" + android:layout_alignParentEnd="true" android:layout_marginTop="8dp" + android:layout_marginEnd="8dp" + android:layout_marginBottom="12dp" android:alpha="0.7" android:background="#0000" android:enabled="false" android:text="@string/nc_proceed" - android:textColor="@color/colorPrimary"/> + android:textColor="@color/colorPrimary" /> \ No newline at end of file diff --git a/app/src/main/res/layout/controller_generic_rv.xml b/app/src/main/res/layout/controller_generic_rv.xml index a364253cd..4d18cc970 100644 --- a/app/src/main/res/layout/controller_generic_rv.xml +++ b/app/src/main/res/layout/controller_generic_rv.xml @@ -1,5 +1,4 @@ - - + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/generic_rv_layout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/nc_white_color"> + tools:listitem="@layout/rv_item_conversation" /> - + diff --git a/app/src/main/res/layout/controller_operations_menu.xml b/app/src/main/res/layout/controller_operations_menu.xml index d3a963113..7ba701e1f 100644 --- a/app/src/main/res/layout/controller_operations_menu.xml +++ b/app/src/main/res/layout/controller_operations_menu.xml @@ -1,5 +1,4 @@ - - + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@color/nc_white_color"> + android:keepScreenOn="true" /> + android:visibility="gone" /> + android:visibility="gone" />