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 ca33aefd9..adc75c615 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java @@ -235,6 +235,11 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene new AccountSwitcherSheet(getActivity()).show(); return true; } + if(tab==R.id.tab_search){ + searchFragment.selectSearch(true); + onTabSelected(tab); + } + 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 b67c7f5da..70cce0309 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,6 +2,8 @@ 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; @@ -46,6 +48,7 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop, private TabLayoutMediator tabLayoutMediator; private EditText searchEdit; private boolean searchActive; + private boolean wasTriggeredByLongPress = false; private FrameLayout searchView; private ImageButton searchBack, searchClear; private ProgressBar searchProgress; @@ -358,4 +361,12 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop, return position; } } + + public void selectSearch(boolean selectSearch){ + wasTriggeredByLongPress=selectSearch; + searchEdit.requestFocus(); + onSearchEditFocusChanged(searchEdit, selectSearch); + getActivity().getSystemService(InputMethodManager.class).showSoftInput(searchEdit, 0); + } + }