Equal width for mini buttons

pull/194/merge
M66B 3 years ago
parent 0d9c4af681
commit 49ce21c90a

@ -308,12 +308,14 @@ public class FragmentDialogFolder extends FragmentDialogBase {
else { else {
if (data.favorites != null && data.favorites.size() > 0) { if (data.favorites != null && data.favorites.size() > 0) {
Button[] btn = new Button[]{btnFavorite1, btnFavorite2, btnFavorite3}; Button[] btn = new Button[]{btnFavorite1, btnFavorite2, btnFavorite3};
for (int i = 0; i < data.favorites.size(); i++) { for (int i = 0; i < btn.length; i++)
if (i < data.favorites.size()) {
EntityFolder favorite = data.favorites.get(i); EntityFolder favorite = data.favorites.get(i);
btn[i].setTag(favorite.id); btn[i].setTag(favorite.id);
btn[i].setText(favorite.getDisplayName(context)); btn[i].setText(favorite.getDisplayName(context));
btn[i].setVisibility(View.VISIBLE); btn[i].setVisibility(View.VISIBLE);
} } else
btn[i].setVisibility(View.INVISIBLE);
ibResetFavorites.setVisibility(View.VISIBLE); ibResetFavorites.setVisibility(View.VISIBLE);
} }

@ -192,19 +192,24 @@ public class FragmentDialogSearch extends FragmentDialogBase {
} }
}; };
boolean hasSearches = false;
Button[] btn = new Button[]{btnSearch1, btnSearch2, btnSearch3}; Button[] btn = new Button[]{btnSearch1, btnSearch2, btnSearch3};
for (int i = 1; i <= 3; i++) {
boolean has = prefs.contains("last_search" + i); int searches = 0;
if (has) { for (int i = 0; i < btn.length; i++)
hasSearches = true; if (prefs.contains("last_search" + (i + 1)))
String search = prefs.getString("last_search" + i, null); searches++;
btn[i - 1].setText(search);
btn[i - 1].setOnClickListener(onSearch); for (int i = 0; i < btn.length; i++) {
} if (prefs.contains("last_search" + (i + 1))) {
btn[i - 1].setVisibility(has ? View.VISIBLE : View.GONE); String search = prefs.getString("last_search" + (i + 1), null);
btn[i].setText(search);
btn[i].setOnClickListener(onSearch);
btn[i].setVisibility(View.VISIBLE);
} else
btn[i].setVisibility(searches > 0 ? View.INVISIBLE : View.GONE);
} }
ibResetSearches.setVisibility(hasSearches ? View.VISIBLE : View.GONE);
ibResetSearches.setVisibility(searches > 0 ? View.VISIBLE : View.GONE);
ibResetSearches.setOnClickListener(new View.OnClickListener() { ibResetSearches.setOnClickListener(new View.OnClickListener() {
@Override @Override

Loading…
Cancel
Save