Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep in-files search dialog open, closes #1663, by @harshad1 #1689

Merged
merged 7 commits into from
May 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import android.app.Activity;
import android.content.Context;
import android.database.DataSetObserver;
import android.graphics.Typeface;
import android.support.v4.content.ContextCompat;
import android.support.v4.util.Pair;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatEditText;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -102,13 +104,22 @@ public void beforeTextChanged(final CharSequence arg0, final int arg1, final int
return false;
});

// Long click on file name takes us to the top of the file
expandableListView.setOnItemLongClickListener((parent, view, position, id) -> {
final long pos = expandableListView.getExpandableListPosition(position);
final int type = ExpandableListView.getPackedPositionType(pos);
if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
final int groupPosition = ExpandableListView.getPackedPositionGroup(position);
// Start on end of first line
dialogCallback.callback(((GroupItemsInfo) expandableListView.getExpandableListAdapter().getGroup(groupPosition)).path, 0);
};
return true;
});

expandableListView.setOnChildClickListener((parent, v, groupPosition, childPosition, id) -> {
GroupItemsInfo groupItem = (GroupItemsInfo) parent.getExpandableListAdapter().getGroup(groupPosition);
Pair<String, Integer> childItem = (Pair<String, Integer>) parent.getExpandableListAdapter().getChild(groupPosition, childPosition);
if (childItem.second >= 0) {
if (dialog != null && dialog.get() != null) {
dialog.get().dismiss();
}
if (childItem != null && childItem.second != null && childItem.second >= 0) {
dialogCallback.callback(groupItem.path, childItem.second);
}
return false;
Expand Down