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

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

Loading…
Cancel
Save