From ddffe198c6b257356c2e031d7948d9bca90c4102 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 10 Oct 2019 12:54:43 +0200 Subject: [PATCH] change background if no results found in channel search. fixes #3559 --- .../ui/ChannelDiscoveryActivity.java | 9 +++- .../no_results_primary_background_dark.xml | 41 +++++++++++++++++++ .../no_results_primary_background_light.xml | 41 +++++++++++++++++++ src/main/res/values/attrs.xml | 1 + src/main/res/values/themes.xml | 2 + 5 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 src/main/res/drawable/no_results_primary_background_dark.xml create mode 100644 src/main/res/drawable/no_results_primary_background_light.xml diff --git a/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java b/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java index b1684473d..e019b426e 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java @@ -32,6 +32,7 @@ import eu.siacs.conversations.services.ChannelDiscoveryService; import eu.siacs.conversations.ui.adapter.ChannelSearchResultAdapter; import eu.siacs.conversations.ui.util.PendingItem; import eu.siacs.conversations.ui.util.SoftKeyboardUtils; +import eu.siacs.conversations.ui.util.StyledAttributes; import eu.siacs.conversations.utils.AccountUtils; import rocks.xmpp.addr.Jid; @@ -128,6 +129,7 @@ public class ChannelDiscoveryActivity extends XmppActivity implements MenuItem.O private void toggleLoadingScreen() { adapter.submitList(Collections.emptyList()); binding.progressBar.setVisibility(View.VISIBLE); + binding.list.setBackgroundColor(StyledAttributes.getColor(this, R.attr.color_background_primary)); } @Override @@ -172,11 +174,16 @@ public class ChannelDiscoveryActivity extends XmppActivity implements MenuItem.O } @Override - public void onChannelSearchResultsFound(List results) { + public void onChannelSearchResultsFound(final List results) { runOnUiThread(() -> { adapter.submitList(results); binding.list.setVisibility(View.VISIBLE); binding.progressBar.setVisibility(View.GONE); + if (results.size() == 0) { + binding.list.setBackground(StyledAttributes.getDrawable(this, R.attr.activity_primary_background_no_results)); + } else { + binding.list.setBackgroundColor(StyledAttributes.getColor(this, R.attr.color_background_primary)); + } }); } diff --git a/src/main/res/drawable/no_results_primary_background_dark.xml b/src/main/res/drawable/no_results_primary_background_dark.xml new file mode 100644 index 000000000..48597d05c --- /dev/null +++ b/src/main/res/drawable/no_results_primary_background_dark.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + diff --git a/src/main/res/drawable/no_results_primary_background_light.xml b/src/main/res/drawable/no_results_primary_background_light.xml new file mode 100644 index 000000000..efe31413a --- /dev/null +++ b/src/main/res/drawable/no_results_primary_background_light.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml index 1f78b19a2..ce15d0013 100644 --- a/src/main/res/values/attrs.xml +++ b/src/main/res/values/attrs.xml @@ -22,6 +22,7 @@ + diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml index b03c2476e..6ebf7505c 100644 --- a/src/main/res/values/themes.xml +++ b/src/main/res/values/themes.xml @@ -18,6 +18,7 @@ @drawable/search_background_light @drawable/no_results_background_light + @drawable/no_results_primary_background_light @drawable/list_item_background_light @color/black @@ -127,6 +128,7 @@ @color/black26 @drawable/search_background_dark @drawable/no_results_background_dark + @drawable/no_results_primary_background_dark @drawable/list_item_background_dark @color/red_a100