From 708331fca1f261a6be3c4c51ae2f7f35e9f97720 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Wed, 4 Jan 2023 21:54:03 -0300 Subject: [PATCH] Adding the ability to long click or to double click the search icon to bring up the keyboard (cherry picked from commit ee0737c9c76c1c4c6646238186b5591c779767de) --- .../android/fragments/HomeFragment.java | 19 ++++++++++++++----- .../fragments/discover/DiscoverFragment.java | 3 --- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java index c1d95b4f6..30b38ffbf 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java @@ -202,15 +202,23 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene private void onTabSelected(@IdRes int tab){ Fragment newFragment=fragmentForTab(tab); if(tab==currentTab){ + if(tab == R.id.tab_search){ + if(newFragment instanceof ScrollableToTop scrollable) + scrollable.scrollToTop(); + searchFragment.selectSearch(); + return; + } + if(newFragment instanceof ScrollableToTop scrollable) + scrollable.scrollToTop(); + return; + } + if(tab==currentTab && tab == R.id.tab_search){ if(newFragment instanceof ScrollableToTop scrollable) scrollable.scrollToTop(); return; } getChildFragmentManager().beginTransaction().hide(fragmentForTab(currentTab)).show(newFragment).commit(); maybeTriggerLoading(newFragment); -// if(tab == currentTab && tab == R.id.tab_search){ -// searchFragment.selectSearch(); -// } currentTab=tab; ((FragmentStackActivity)getActivity()).invalidateSystemBarColors(this); } @@ -239,10 +247,11 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene return true; } if(tab==R.id.tab_search){ - searchFragment.selectSearch(); onTabSelected(R.id.tab_search); + tabBar.selectTab(R.id.tab_search); + searchFragment.selectSearch(); + return true; } - return false; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java index c13c98c6c..dd40d2367 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java @@ -2,8 +2,6 @@ package org.joinmastodon.android.fragments.discover; import android.app.Fragment; import android.app.FragmentTransaction; -import android.content.Context; -import android.hardware.input.InputManager; import android.os.Build; import android.os.Bundle; import android.text.Editable; @@ -19,7 +17,6 @@ import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; -import android.widget.Toast; import org.joinmastodon.android.BuildConfig; import org.joinmastodon.android.GlobalUserPreferences;