From 68961fdcd72bac8018f48e7287e24a588d7c5266 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 22 Nov 2020 22:16:13 +0100 Subject: [PATCH 1/4] remove unused SwipeRefreshLayout and use self-explaining default for contact-list-empty-hint --- .../contact_selection_list_fragment.xml | 10 +---- .../BlockedAndShareContactsActivity.java | 6 --- .../securesms/ContactSelectionActivity.java | 39 +------------------ .../ContactSelectionListFragment.java | 21 ---------- 4 files changed, 3 insertions(+), 73 deletions(-) diff --git a/res/layout/contact_selection_list_fragment.xml b/res/layout/contact_selection_list_fragment.xml index 6ed8f5716..ee107da7b 100644 --- a/res/layout/contact_selection_list_fragment.xml +++ b/res/layout/contact_selection_list_fragment.xml @@ -4,11 +4,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical"> - - - - contactsFragment.setQueryFilter(filter)); } - @Override - public void onRefresh() { - new RefreshDirectoryTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, getApplicationContext()); - } - @Override public void onContactSelected(int specialId, String number) {} @Override public void onContactDeselected(int specialId, String number) {} - - private static class RefreshDirectoryTask extends AsyncTask { - - private final WeakReference activity; - - private RefreshDirectoryTask(ContactSelectionActivity activity) { - this.activity = new WeakReference<>(activity); - } - - @Override - protected Void doInBackground(Context... params) { - - return null; - } - - @Override - protected void onPostExecute(Void result) { - ContactSelectionActivity activity = this.activity.get(); - - if (activity != null && !activity.isFinishing()) { - activity.toolbar.clear(); - activity.contactsFragment.resetQueryFilter(); - } - } - } } diff --git a/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java b/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java index 8878c1c6c..d4a7058f6 100644 --- a/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java +++ b/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java @@ -30,7 +30,6 @@ import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.loader.app.LoaderManager; import androidx.loader.content.Loader; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.view.ActionMode; @@ -87,18 +86,14 @@ public class ContactSelectionListFragment extends Fragment private static final String TAG = ContactSelectionListFragment.class.getSimpleName(); public static final String MULTI_SELECT = "multi_select"; - public static final String REFRESHABLE = "refreshable"; - public static final String RECENTS = "recents"; public static final String SELECT_VERIFIED_EXTRA = "select_verified"; public static final String FROM_SHARE_ACTIVITY_EXTRA = "from_share_activity"; public static final String PRESELECTED_CONTACTS = "preselected_contacts"; private ApplicationDcContext dcContext; - private TextView emptyText; private Set selectedContacts; private OnContactSelectedListener onContactSelectedListener; - private SwipeRefreshLayout swipeRefresh; private String cursorFilter; private RecyclerView recyclerView; private StickyHeaderDecoration listDecoration; @@ -136,9 +131,7 @@ public class ContactSelectionListFragment extends Fragment public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.contact_selection_list_fragment, container, false); - emptyText = ViewUtil.findById(view, android.R.id.empty); recyclerView = ViewUtil.findById(view, R.id.recycler_view); - swipeRefresh = ViewUtil.findById(view, R.id.swipe_refresh); fastScroller = ViewUtil.findById(view, R.id.fast_scroller); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); actionModeCallback = new ActionMode.Callback() { @@ -188,10 +181,6 @@ public class ContactSelectionListFragment extends Fragment } }; - // There shouldn't be the need to pull to refresh the contacts - // swipeRefresh.setEnabled(getActivity().getIntent().getBooleanExtra(REFRESHABLE, true) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN); - swipeRefresh.setEnabled(false); - return view; } @@ -309,11 +298,6 @@ public class ContactSelectionListFragment extends Fragment public void resetQueryFilter() { setQueryFilter(null); - swipeRefresh.setRefreshing(false); - } - - public void setRefreshing(boolean refreshing) { - swipeRefresh.setRefreshing(refreshing); } public void reset() { @@ -337,7 +321,6 @@ public class ContactSelectionListFragment extends Fragment @Override public void onLoadFinished(Loader loader, DcContactsLoader.Ret data) { ((ContactSelectionListAdapter) recyclerView.getAdapter()).changeData(data); - emptyText.setText(R.string.contacts_empty_hint); boolean useFastScroller = (recyclerView.getAdapter().getItemCount() > 20); recyclerView.setVerticalScrollBarEnabled(!useFastScroller); if (useFastScroller) { @@ -451,10 +434,6 @@ public class ContactSelectionListFragment extends Fragment this.onContactSelectedListener = onContactSelectedListener; } - public void setOnRefreshListener(SwipeRefreshLayout.OnRefreshListener onRefreshListener) { - this.swipeRefresh.setOnRefreshListener(onRefreshListener); - } - public interface OnContactSelectedListener { void onContactSelected(int specialId, String number); void onContactDeselected(int specialId, String number); From ed9921f40ed122062985b392485fde3168964178 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 22 Nov 2020 22:32:19 +0100 Subject: [PATCH 2/4] show hint when there are no blocked contacts --- res/layout/contact_selection_list_fragment.xml | 3 ++- .../securesms/BlockedAndShareContactsActivity.java | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/res/layout/contact_selection_list_fragment.xml b/res/layout/contact_selection_list_fragment.xml index ee107da7b..29b2e57f5 100644 --- a/res/layout/contact_selection_list_fragment.xml +++ b/res/layout/contact_selection_list_fragment.xml @@ -16,7 +16,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center|center_vertical" - android:layout_marginTop="15dp" + android:padding="16dp" + android:lineSpacingMultiplier="1.3" android:visibility="gone" android:text="@string/contacts_empty_hint" android:textSize="20sp" /> diff --git a/src/org/thoughtcrime/securesms/BlockedAndShareContactsActivity.java b/src/org/thoughtcrime/securesms/BlockedAndShareContactsActivity.java index edd9a0700..a90c200a1 100644 --- a/src/org/thoughtcrime/securesms/BlockedAndShareContactsActivity.java +++ b/src/org/thoughtcrime/securesms/BlockedAndShareContactsActivity.java @@ -13,6 +13,7 @@ import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.TextView; import com.b44t.messenger.DcContext; import com.b44t.messenger.DcEvent; @@ -76,6 +77,7 @@ public class BlockedAndShareContactsActivity extends PassphraseRequiredActionBar private RecyclerView recyclerView; + private TextView emptyStateView; private boolean showOnlyBlocked; @@ -84,6 +86,8 @@ public class BlockedAndShareContactsActivity extends PassphraseRequiredActionBar View view = inflater.inflate(R.layout.contact_selection_list_fragment, container, false); recyclerView = ViewUtil.findById(view, R.id.recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); + emptyStateView = ViewUtil.findById(view, android.R.id.empty); + emptyStateView.setText(R.string.none_blocked_desktop); return view; } @@ -116,7 +120,13 @@ public class BlockedAndShareContactsActivity extends PassphraseRequiredActionBar @Override public void onLoadFinished(Loader loader, DcContactsLoader.Ret data) { - getContactSelectionListAdapter().changeData(data); + ContactSelectionListAdapter adapter = getContactSelectionListAdapter(); + if (adapter != null) { + adapter.changeData(data); + if (emptyStateView != null) { + emptyStateView.setVisibility(adapter.getItemCount() > 0 ? View.GONE : View.VISIBLE); + } + } } @Override From b284a70ef760a3e2dec554145a0ba1da8750b27a Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 22 Nov 2020 23:05:46 +0100 Subject: [PATCH 3/4] reword no-blocked-contats-hint --- res/values/strings.xml | 1 + .../thoughtcrime/securesms/BlockedAndShareContactsActivity.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index e9ea3250d..034d898b0 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -425,6 +425,7 @@ Your profile info Profile image Blocked contacts + If you block contacts, they will be shown here. Remove profile image? Password and account Your profile image and name will be shown alongside your messages when communicating with other users. Already sent information can not be deleted or removed. diff --git a/src/org/thoughtcrime/securesms/BlockedAndShareContactsActivity.java b/src/org/thoughtcrime/securesms/BlockedAndShareContactsActivity.java index a90c200a1..c1b9b3ae2 100644 --- a/src/org/thoughtcrime/securesms/BlockedAndShareContactsActivity.java +++ b/src/org/thoughtcrime/securesms/BlockedAndShareContactsActivity.java @@ -87,7 +87,7 @@ public class BlockedAndShareContactsActivity extends PassphraseRequiredActionBar recyclerView = ViewUtil.findById(view, R.id.recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); emptyStateView = ViewUtil.findById(view, android.R.id.empty); - emptyStateView.setText(R.string.none_blocked_desktop); + emptyStateView.setText(R.string.blocked_empty_hint); return view; } From e2c930c8954dbfa752231c7caf7212f286638297 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 23 Nov 2020 14:12:55 +0100 Subject: [PATCH 4/4] remove unused @string/contacts_empty_hint from xml and add a tools:text hint instead --- res/layout/contact_selection_list_fragment.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/layout/contact_selection_list_fragment.xml b/res/layout/contact_selection_list_fragment.xml index 29b2e57f5..0ed121989 100644 --- a/res/layout/contact_selection_list_fragment.xml +++ b/res/layout/contact_selection_list_fragment.xml @@ -19,8 +19,8 @@ android:padding="16dp" android:lineSpacingMultiplier="1.3" android:visibility="gone" - android:text="@string/contacts_empty_hint" - android:textSize="20sp" /> + android:textSize="20sp" + tools:text="No contacts." />