Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 264c566a authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Update the empty state for the "all printers activity"

The empty state is now showing searching for printers hint if
the user is not searching, otherwise the empty state's hint is
a searching for printers message.

bug:10983508

Change-Id: I3df79c167546998c8055d9ff85efa8b460a15e48
parent 0ea7d1e8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@
            </ImageView>

            <TextView
                android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
@@ -56,6 +57,7 @@
            </TextView>

            <ProgressBar
                android:id="@+id/progress_bar"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:indeterminate="true"
+4 −1
Original line number Diff line number Diff line
@@ -83,9 +83,12 @@
    <!-- Title for the alert dialog for selecting a print service. [CHAR LIMIT=50] -->
    <string name="choose_print_service">Choose print service</string>

    <!-- Title for the prompt shown as a placeholder if no printers are found while searching. [CHAR LIMIT=50] -->
    <!-- Title for the prompt shown as a placeholder if no printers are found while not searching. [CHAR LIMIT=50] -->
    <string name="print_searching_for_printers">Searching for printers</string>

    <!-- Title for the prompt shown as a placeholder if there are no printers while searching. [CHAR LIMIT=50] -->
    <string name="print_no_printers">No printers found</string>

    <!-- Notifications -->

    <!-- Template for the notificaiton label for a printing print job. [CHAR LIMIT=25] -->
+34 −1
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.database.DataSetObserver;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
@@ -94,7 +95,21 @@ public final class SelectPrinterFragment extends ListFragment {
    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        setListAdapter(new DestinationAdapter());
        final DestinationAdapter adapter = new DestinationAdapter();
        adapter.registerDataSetObserver(new DataSetObserver() {
            @Override
            public void onChanged() {
                if (adapter.getCount() <= 0) {
                    updateEmptyView(adapter);
                }
            }

            @Override
            public void onInvalidated() {
                updateEmptyView(adapter);
            }
        });
        setListAdapter(adapter);
        View emptyView = getActivity().findViewById(R.id.empty_print_state);
        getListView().setEmptyView(emptyView);
    }
@@ -214,6 +229,18 @@ public final class SelectPrinterFragment extends ListFragment {
        transaction.commit();
    }

    public void updateEmptyView(DestinationAdapter adapter) {
        TextView titleView = (TextView) getActivity().findViewById(R.id.title);
        View progressBar = getActivity().findViewById(R.id.progress_bar);
        if (adapter.getUnfilteredCount() <= 0) {
            titleView.setText(R.string.print_searching_for_printers);
            progressBar.setVisibility(View.VISIBLE);
        } else {
            titleView.setText(R.string.print_no_printers);
            progressBar.setVisibility(View.GONE);
        }
    }

    public static class AddPrinterAlertDialogFragment extends DialogFragment {

        private String mAddPrintServiceItem;
@@ -339,6 +366,12 @@ public final class SelectPrinterFragment extends ListFragment {
            };
        }

        public int getUnfilteredCount() {
            synchronized (mLock) {
                return mPrinters.size();
            }
        }

        @Override
        public int getCount() {
            synchronized (mLock) {