Search more

This commit is contained in:
M66B 2020-04-10 12:17:40 +02:00
parent 88b3c684eb
commit 5548691e4a
3 changed files with 58 additions and 1 deletions

View File

@ -23,6 +23,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.constraintlayout.widget.Group;
import androidx.cursoradapter.widget.SimpleCursorAdapter;
import androidx.preference.PreferenceManager;
@ -34,6 +35,8 @@ public class FragmentDialogSearch extends FragmentDialogBase {
final AutoCompleteTextView etQuery = dview.findViewById(R.id.etQuery);
final ImageButton ibInfo = dview.findViewById(R.id.ibInfo);
final ImageButton ibMore = dview.findViewById(R.id.ibMore);
final TextView tvMore = dview.findViewById(R.id.tvMore);
final CheckBox cbSearchIndex = dview.findViewById(R.id.cbSearchIndex);
final CheckBox cbSenders = dview.findViewById(R.id.cbSenders);
final CheckBox cbRecipients = dview.findViewById(R.id.cbRecipients);
@ -45,6 +48,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
final CheckBox cbHidden = dview.findViewById(R.id.cbHidden);
final CheckBox cbEncrypted = dview.findViewById(R.id.cbEncrypted);
final CheckBox cbAttachments = dview.findViewById(R.id.cbAttachments);
final Group grpMore = dview.findViewById(R.id.grpMore);
boolean pro = ActivityBilling.isPro(getContext());
@ -101,6 +105,25 @@ public class FragmentDialogSearch extends FragmentDialogBase {
etQuery.setAdapter(adapter);
View.OnClickListener onMore = new View.OnClickListener() {
@Override
public void onClick(View v) {
imm.hideSoftInputFromWindow(etQuery.getWindowToken(), 0);
if (grpMore.getVisibility() == View.VISIBLE) {
ibMore.setImageLevel(1);
grpMore.setVisibility(View.GONE);
} else {
ibMore.setImageLevel(0);
grpMore.setVisibility(View.VISIBLE);
}
}
};
ibMore.setOnClickListener(onMore);
tvMore.setOnClickListener(onMore);
cbSearchIndex.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@ -152,6 +175,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
}
});
ibMore.setImageLevel(1);
cbSearchIndex.setChecked(fts && pro);
cbSearchIndex.setEnabled(pro);
cbSenders.setChecked(last_search_senders);
@ -162,6 +186,8 @@ public class FragmentDialogSearch extends FragmentDialogBase {
cbUnseen.setChecked(filter_seen);
cbFlagged.setChecked(filter_unflagged);
grpMore.setVisibility(View.GONE);
if (!TextUtils.isEmpty(last_search)) {
etQuery.setText(last_search);
etQuery.setSelection(0, last_search.length());

View File

@ -47,6 +47,30 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ibInfo" />
<ImageButton
android:id="@+id/ibMore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="12dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:padding="3dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etQuery"
app:srcCompat="@drawable/expander" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvMore"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:gravity="center_vertical"
android:paddingStart="6dp"
android:text="@string/title_search_more"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="@+id/ibMore"
app:layout_constraintStart_toEndOf="@+id/ibMore"
app:layout_constraintTop_toTopOf="@+id/ibMore" />
<CheckBox
android:id="@+id/cbSearchIndex"
android:layout_width="0dp"
@ -56,7 +80,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etQuery" />
app:layout_constraintTop_toBottomOf="@id/ibMore" />
<CheckBox
android:id="@+id/cbSenders"
@ -192,5 +216,11 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbEncrypted" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpMore"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="cbSearchIndex,cbSenders,cbRecipients,cbSubject,cbKeywords,cbMessage,tvAnd,cbUnseen,cbFlagged,cbHidden,cbEncrypted,cbAttachments" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

View File

@ -904,6 +904,7 @@
<string name="title_search">Search</string>
<string name="title_search_for_hint">Enter text</string>
<string name="title_search_more">More options</string>
<string name="title_search_use_index">Use search index</string>
<string name="title_search_in_senders">In senders (from)</string>
<string name="title_search_in_recipients">In recipients (to, cc)</string>