Mini buttons for recent searches

pull/194/merge
M66B 3 years ago
parent 565defc4a9
commit 0d9c4af681

@ -85,9 +85,9 @@ public class FragmentDialogSearch extends FragmentDialogBase {
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_search, null);
TextViewAutoCompleteAction etQuery = dview.findViewById(R.id.etQuery);
TextView tvSearch1 = dview.findViewById(R.id.tvSearch1);
TextView tvSearch2 = dview.findViewById(R.id.tvSearch2);
TextView tvSearch3 = dview.findViewById(R.id.tvSearch3);
Button btnSearch1 = dview.findViewById(R.id.btnSearch1);
Button btnSearch2 = dview.findViewById(R.id.btnSearch2);
Button btnSearch3 = dview.findViewById(R.id.btnSearch3);
ImageButton ibResetSearches = dview.findViewById(R.id.ibResetSearches);
ImageButton ibInfo = dview.findViewById(R.id.ibInfo);
@ -193,16 +193,16 @@ public class FragmentDialogSearch extends FragmentDialogBase {
};
boolean hasSearches = false;
TextView[] views = new TextView[]{tvSearch1, tvSearch2, tvSearch3};
Button[] btn = new Button[]{btnSearch1, btnSearch2, btnSearch3};
for (int i = 1; i <= 3; i++) {
boolean has = prefs.contains("last_search" + i);
if (has) {
hasSearches = true;
String search = prefs.getString("last_search" + i, null);
views[i - 1].setText(search);
views[i - 1].setOnClickListener(onSearch);
btn[i - 1].setText(search);
btn[i - 1].setOnClickListener(onSearch);
}
views[i - 1].setVisibility(has ? View.VISIBLE : View.GONE);
btn[i - 1].setVisibility(has ? View.VISIBLE : View.GONE);
}
ibResetSearches.setVisibility(hasSearches ? View.VISIBLE : View.GONE);
@ -212,7 +212,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
SharedPreferences.Editor editor = prefs.edit();
for (int i = 1; i <= 3; i++) {
editor.remove("last_search" + i);
views[i - 1].setVisibility(View.GONE);
btn[i - 1].setVisibility(View.GONE);
}
editor.apply();
ibResetSearches.setVisibility(View.GONE);

@ -130,58 +130,46 @@
<requestFocus />
</eu.faircode.email.TextViewAutoCompleteAction>
<eu.faircode.email.FixedTextView
android:id="@+id/tvSearch1"
<Button
android:id="@+id/btnSearch1"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:ellipsize="end"
android:padding="6dp"
android:singleLine="true"
android:text="search1"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/tvSearch2"
app:layout_constraintEnd_toStartOf="@+id/btnSearch2"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etQuery" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSearch2"
<Button
android:id="@+id/btnSearch2"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:ellipsize="end"
android:padding="6dp"
android:singleLine="true"
android:text="search2"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/tvSearch3"
app:layout_constraintEnd_toStartOf="@+id/btnSearch3"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toEndOf="@id/tvSearch1"
app:layout_constraintStart_toEndOf="@id/btnSearch1"
app:layout_constraintTop_toBottomOf="@id/etQuery" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSearch3"
<Button
android:id="@+id/btnSearch3"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:ellipsize="end"
android:padding="6dp"
android:singleLine="true"
android:text="search3"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/ibResetSearches"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toEndOf="@id/tvSearch2"
app:layout_constraintStart_toEndOf="@id/btnSearch2"
app:layout_constraintTop_toBottomOf="@id/etQuery" />
<eu.faircode.email.FixedImageButton
@ -204,7 +192,7 @@
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSearch1" />
app:layout_constraintTop_toBottomOf="@id/btnSearch1" />
<eu.faircode.email.FixedImageButton
android:id="@+id/ibMore"

Loading…
Cancel
Save