It already works, although not to my standard yet

This commit is contained in:
LucasGGamerM 2023-01-03 11:10:53 -03:00
parent f510ee3b4d
commit a0c26b748a
2 changed files with 16 additions and 0 deletions

View File

@ -235,6 +235,11 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
new AccountSwitcherSheet(getActivity()).show(); new AccountSwitcherSheet(getActivity()).show();
return true; return true;
} }
if(tab==R.id.tab_search){
searchFragment.selectSearch(true);
onTabSelected(tab);
}
return false; return false;
} }

View File

@ -2,6 +2,8 @@ package org.joinmastodon.android.fragments.discover;
import android.app.Fragment; import android.app.Fragment;
import android.app.FragmentTransaction; import android.app.FragmentTransaction;
import android.content.Context;
import android.hardware.input.InputManager;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable; import android.text.Editable;
@ -46,6 +48,7 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
private TabLayoutMediator tabLayoutMediator; private TabLayoutMediator tabLayoutMediator;
private EditText searchEdit; private EditText searchEdit;
private boolean searchActive; private boolean searchActive;
private boolean wasTriggeredByLongPress = false;
private FrameLayout searchView; private FrameLayout searchView;
private ImageButton searchBack, searchClear; private ImageButton searchBack, searchClear;
private ProgressBar searchProgress; private ProgressBar searchProgress;
@ -358,4 +361,12 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
return position; return position;
} }
} }
public void selectSearch(boolean selectSearch){
wasTriggeredByLongPress=selectSearch;
searchEdit.requestFocus();
onSearchEditFocusChanged(searchEdit, selectSearch);
getActivity().getSystemService(InputMethodManager.class).showSoftInput(searchEdit, 0);
}
} }