mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-25 13:39:24 +00:00
Hide bottom bar on scroll for Emoji pager.
This commit is contained in:
committed by
Cody Henthorne
parent
c202f97088
commit
262b4e7d62
@@ -149,7 +149,7 @@ public class EmojiKeyboardProvider implements MediaKeyboardProvider,
|
||||
|
||||
@Override
|
||||
public @NonNull Object instantiateItem(@NonNull ViewGroup container, int position) {
|
||||
EmojiPageView page = new EmojiPageView(context, emojiSelectionListener, variationSelectorListener, true, null);
|
||||
EmojiPageView page = new EmojiPageView(context, emojiSelectionListener, variationSelectorListener, true);
|
||||
page.setModel(pages.get(position));
|
||||
container.addView(page);
|
||||
return page;
|
||||
|
||||
@@ -9,22 +9,17 @@ import android.widget.FrameLayout;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiKeyboardProvider.EmojiEventListener;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiPageViewGridAdapter.VariationSelectorListener;
|
||||
import org.thoughtcrime.securesms.keyboard.emoji.KeyboardPageSearchView;
|
||||
import org.thoughtcrime.securesms.util.MappingModelList;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
||||
public class EmojiPageView extends FrameLayout implements VariationSelectorListener {
|
||||
private static final String TAG = Log.tag(EmojiPageView.class);
|
||||
@@ -36,23 +31,19 @@ public class EmojiPageView extends FrameLayout implements VariationSelectorListe
|
||||
private RecyclerView.OnItemTouchListener scrollDisabler;
|
||||
private VariationSelectorListener variationSelectorListener;
|
||||
private EmojiVariationSelectorPopup popup;
|
||||
private AppBarLayout appBarLayout;
|
||||
private boolean searchEnabled;
|
||||
|
||||
public EmojiPageView(@NonNull Context context,
|
||||
@NonNull EmojiEventListener emojiSelectionListener,
|
||||
@NonNull VariationSelectorListener variationSelectorListener,
|
||||
boolean allowVariations,
|
||||
@Nullable KeyboardPageSearchView.Callbacks searchCallbacks)
|
||||
boolean allowVariations)
|
||||
{
|
||||
this(context, emojiSelectionListener, variationSelectorListener, allowVariations, searchCallbacks, new GridLayoutManager(context, 8), R.layout.emoji_display_item);
|
||||
this(context, emojiSelectionListener, variationSelectorListener, allowVariations, new GridLayoutManager(context, 8), R.layout.emoji_display_item);
|
||||
}
|
||||
|
||||
public EmojiPageView(@NonNull Context context,
|
||||
@NonNull EmojiEventListener emojiSelectionListener,
|
||||
@NonNull VariationSelectorListener variationSelectorListener,
|
||||
boolean allowVariations,
|
||||
@Nullable KeyboardPageSearchView.Callbacks searchCallbacks,
|
||||
@NonNull RecyclerView.LayoutManager layoutManager,
|
||||
@LayoutRes int displayItemLayoutResId)
|
||||
{
|
||||
@@ -71,16 +62,19 @@ public class EmojiPageView extends FrameLayout implements VariationSelectorListe
|
||||
allowVariations,
|
||||
displayItemLayoutResId);
|
||||
|
||||
this.appBarLayout = view.findViewById(R.id.emoji_keyboard_search_appbar);
|
||||
((CoordinatorLayout.LayoutParams) this.appBarLayout.getLayoutParams()).setBehavior(new BlockableScrollBehavior());
|
||||
|
||||
KeyboardPageSearchView searchView = view.findViewById(R.id.emoji_keyboard_search_text);
|
||||
searchView.setCallbacks(searchCallbacks);
|
||||
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
recyclerView.setItemAnimator(null);
|
||||
}
|
||||
|
||||
public void presentForEmojiKeyboard() {
|
||||
recyclerView.setPadding(recyclerView.getPaddingLeft(),
|
||||
recyclerView.getPaddingTop(),
|
||||
recyclerView.getPaddingRight(),
|
||||
recyclerView.getPaddingBottom() + ViewUtil.dpToPx(56));
|
||||
|
||||
recyclerView.setClipToPadding(false);
|
||||
}
|
||||
|
||||
public void onSelected() {
|
||||
if (model.isDynamic() && recyclerView.getAdapter() != null) {
|
||||
recyclerView.getAdapter().notifyDataSetChanged();
|
||||
@@ -96,8 +90,7 @@ public class EmojiPageView extends FrameLayout implements VariationSelectorListe
|
||||
}
|
||||
|
||||
public void bindSearchableAdapter(@Nullable EmojiPageModel model) {
|
||||
this.searchEnabled = true;
|
||||
this.model = model;
|
||||
this.model = model;
|
||||
|
||||
EmojiPageViewGridAdapter adapter = adapterFactory.create();
|
||||
recyclerView.setAdapter(adapter);
|
||||
@@ -161,23 +154,6 @@ public class EmojiPageView extends FrameLayout implements VariationSelectorListe
|
||||
public void onRequestDisallowInterceptTouchEvent(boolean b) { }
|
||||
}
|
||||
|
||||
private class BlockableScrollBehavior extends AppBarLayout.Behavior {
|
||||
@Override public boolean onStartNestedScroll(@NonNull CoordinatorLayout parent,
|
||||
@NonNull AppBarLayout child,
|
||||
@NonNull View directTargetChild,
|
||||
View target,
|
||||
int nestedScrollAxes,
|
||||
int type)
|
||||
{
|
||||
return searchEnabled && super.onStartNestedScroll(parent, child, directTargetChild, target, nestedScrollAxes, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(@NonNull @NotNull CoordinatorLayout parent, @NonNull @NotNull AppBarLayout child, @NonNull @NotNull MotionEvent ev) {
|
||||
return searchEnabled && super.onTouchEvent(parent, child, ev);
|
||||
}
|
||||
}
|
||||
|
||||
private interface AdapterFactory {
|
||||
EmojiPageViewGridAdapter create();
|
||||
}
|
||||
|
||||
@@ -9,16 +9,16 @@ import org.thoughtcrime.securesms.util.MappingViewHolder
|
||||
|
||||
class EmojiKeyboardPageAdapter(
|
||||
private val emojiSelectionListener: EmojiKeyboardProvider.EmojiEventListener,
|
||||
private val variationSelectorListener: EmojiPageViewGridAdapter.VariationSelectorListener,
|
||||
private val searchCallbacks: KeyboardPageSearchView.Callbacks
|
||||
private val variationSelectorListener: EmojiPageViewGridAdapter.VariationSelectorListener
|
||||
) : MappingAdapter() {
|
||||
|
||||
init {
|
||||
registerFactory(EmojiPageMappingModel::class.java) { parent ->
|
||||
val pageView = EmojiPageView(parent.context, emojiSelectionListener, variationSelectorListener, true, searchCallbacks)
|
||||
val pageView = EmojiPageView(parent.context, emojiSelectionListener, variationSelectorListener, true)
|
||||
|
||||
val layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
pageView.layoutParams = layoutParams
|
||||
pageView.presentForEmojiKeyboard()
|
||||
|
||||
ViewHolder(pageView)
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ class EmojiKeyboardPageFragment : Fragment(R.layout.keyboard_pager_emoji_page_fr
|
||||
private lateinit var callback: Callback
|
||||
private lateinit var pagesAdapter: EmojiKeyboardPageAdapter
|
||||
private lateinit var categoriesAdapter: EmojiKeyboardPageCategoriesAdapter
|
||||
private lateinit var searchBar: KeyboardPageSearchView
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
@@ -38,6 +39,7 @@ class EmojiKeyboardPageFragment : Fragment(R.layout.keyboard_pager_emoji_page_fr
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
emojiPager = view.findViewById(R.id.emoji_pager)
|
||||
searchView = view.findViewById(R.id.emoji_search)
|
||||
searchBar = view.findViewById(R.id.emoji_keyboard_search_text)
|
||||
emojiCategoriesRecycler = view.findViewById(R.id.emoji_categories_recycler)
|
||||
backspaceView = view.findViewById(R.id.emoji_backspace)
|
||||
}
|
||||
@@ -47,7 +49,7 @@ class EmojiKeyboardPageFragment : Fragment(R.layout.keyboard_pager_emoji_page_fr
|
||||
|
||||
viewModel = ViewModelProviders.of(requireActivity()).get(EmojiKeyboardPageViewModel::class.java)
|
||||
|
||||
pagesAdapter = EmojiKeyboardPageAdapter(this, this, EmojiKeyboardPageSearchViewCallbacks())
|
||||
pagesAdapter = EmojiKeyboardPageAdapter(this, this)
|
||||
|
||||
categoriesAdapter = EmojiKeyboardPageCategoriesAdapter { key ->
|
||||
viewModel.onKeySelected(key)
|
||||
@@ -64,6 +66,8 @@ class EmojiKeyboardPageFragment : Fragment(R.layout.keyboard_pager_emoji_page_fr
|
||||
emojiPager.adapter = pagesAdapter
|
||||
emojiCategoriesRecycler.adapter = categoriesAdapter
|
||||
|
||||
searchBar.callbacks = EmojiKeyboardPageSearchViewCallbacks()
|
||||
|
||||
searchView.setOnClickListener {
|
||||
callback.openEmojiSearch()
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class EmojiSearchFragment : Fragment(R.layout.emoji_search_fragment), EmojiPageV
|
||||
val searchBar: KeyboardPageSearchView = view.findViewById(R.id.emoji_search_view)
|
||||
val resultsContainer: FrameLayout = view.findViewById(R.id.emoji_search_results_container)
|
||||
val noResults: TextView = view.findViewById(R.id.emoji_search_empty)
|
||||
val emojiPageView = EmojiPageView(requireContext(), eventListener, this, true, null, LinearLayoutManager(requireContext(), RecyclerView.HORIZONTAL, false), R.layout.emoji_search_result_display_item)
|
||||
val emojiPageView = EmojiPageView(requireContext(), eventListener, this, true, LinearLayoutManager(requireContext(), RecyclerView.HORIZONTAL, false), R.layout.emoji_search_result_display_item)
|
||||
|
||||
resultsContainer.addView(emojiPageView)
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ final class ReactWithAnyEmojiAdapter extends ListAdapter<ReactWithAnyEmojiPage,
|
||||
}
|
||||
|
||||
private EmojiPageView createEmojiPageView(@NonNull Context context) {
|
||||
return new EmojiPageView(context, emojiEventListener, variationSelectorListener, true, null);
|
||||
return new EmojiPageView(context, emojiEventListener, variationSelectorListener, true);
|
||||
}
|
||||
|
||||
static abstract class ReactWithAnyEmojiPageViewHolder extends RecyclerView.ViewHolder implements ScrollableChild {
|
||||
|
||||
@@ -1,39 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/emoji"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/signal_background_secondary">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/emoji_keyboard_search_appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/signal_background_secondary"
|
||||
app:elevation="0dp"
|
||||
app:expanded="false">
|
||||
|
||||
<org.thoughtcrime.securesms.keyboard.emoji.KeyboardPageSearchView
|
||||
android:id="@+id/emoji_keyboard_search_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:click_only="true"
|
||||
app:layout_scrollFlags="scroll"
|
||||
app:search_hint="@string/KeyboardPagerFragment_search_emoji"
|
||||
app:show_always="true" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/emoji"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="8dp"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="8dp" />
|
||||
@@ -1,77 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.coordinatorlayout.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:background="@color/signal_background_secondary">
|
||||
android:background="@color/signal_background_secondary">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/emoji_keyboard_search_appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/signal_background_secondary"
|
||||
app:elevation="0dp"
|
||||
app:expanded="false">
|
||||
|
||||
<org.thoughtcrime.securesms.keyboard.emoji.KeyboardPageSearchView
|
||||
android:id="@+id/emoji_keyboard_search_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:click_only="true"
|
||||
app:layout_scrollFlags="scroll|snap"
|
||||
app:search_hint="@string/KeyboardPagerFragment_search_emoji"
|
||||
app:show_always="true" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/emoji_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/subcategories_background"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_goneMarginTop="0dp" />
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
<View
|
||||
android:id="@+id/subcategories_background"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:layout_height="?actionBarSize"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@color/signal_background_secondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/emoji_search"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?selectableItemBackground"
|
||||
android:contentDescription="@string/KeyboardPagerFragment_open_emoji_search"
|
||||
android:padding="13dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:layout_constraintBottom_toBottomOf="@id/subcategories_background"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/subcategories_background"
|
||||
app:srcCompat="@drawable/ic_search_24"
|
||||
app:tint="@color/icon_tab_selector" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/emoji_backspace"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?selectableItemBackground"
|
||||
android:contentDescription="@string/KeyboardPagerFragment_backspace"
|
||||
android:padding="13dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:layout_constraintBottom_toBottomOf="@id/subcategories_background"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/subcategories_background"
|
||||
app:srcCompat="@drawable/ic_backspace_24"
|
||||
app:tint="@color/icon_tab_selector" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/emoji_categories_recycler"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintBottom_toBottomOf="@id/subcategories_background"
|
||||
app:layout_constraintEnd_toStartOf="@id/emoji_backspace"
|
||||
app:layout_constraintStart_toEndOf="@id/emoji_search"
|
||||
app:layout_constraintTop_toTopOf="@id/subcategories_background"
|
||||
tools:itemCount="10"
|
||||
tools:listitem="@layout/keyboard_pager_category_icon" />
|
||||
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_gravity="top"
|
||||
android:background="@color/signal_inverse_transparent_05"
|
||||
app:layout_constraintBottom_toTopOf="@+id/subcategories_background" />
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/emoji_search"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?selectableItemBackground"
|
||||
android:contentDescription="@string/KeyboardPagerFragment_open_emoji_search"
|
||||
android:padding="13dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/ic_search_24"
|
||||
app:tint="@color/icon_tab_selector" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/emoji_categories_recycler"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:itemCount="10"
|
||||
tools:listitem="@layout/keyboard_pager_category_icon" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/emoji_backspace"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?selectableItemBackground"
|
||||
android:contentDescription="@string/KeyboardPagerFragment_backspace"
|
||||
android:padding="13dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/ic_backspace_24"
|
||||
app:tint="@color/icon_tab_selector" />
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
Reference in New Issue
Block a user