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

Commit 953639cb authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Do not disable the add printer icon and have special empty view if no

print services are enabled

The add printer icon is always visible as this is used for both adding
a printer and adding addition print services

We have three different empty views now:
1. No print services
2. No printers found (not search filter set)
3. No printers found (search filter set)

Bug: 24132367
Change-Id: Ic30812b60986f1e0f023488cefc6aa901ce20824
parent d07d7aff
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -149,6 +149,9 @@
    <!-- 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 print services. [CHAR LIMIT=50] -->
    <string name="print_no_print_services">No print services enabled</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>

+12 −5
Original line number Diff line number Diff line
@@ -84,6 +84,11 @@ public final class SelectPrinterActivity extends Activity {

    private static final String EXTRA_PRINTER_ID = "EXTRA_PRINTER_ID";

    /**
     * If there are any enabled print services
     */
    private boolean mHasEnabledPrintServices;

    private final ArrayList<PrintServiceInfo> mAddPrinterServices =
            new ArrayList<>();

@@ -175,10 +180,6 @@ public final class SelectPrinterActivity extends Activity {
            }
        });

        if (mAddPrinterServices.isEmpty()) {
            menu.removeItem(R.id.action_add_printer);
        }

        return true;
    }

@@ -230,6 +231,7 @@ public final class SelectPrinterActivity extends Activity {
    public void onResume() {
        super.onResume();
        updateServicesWithAddPrinterActivity();
        updateEmptyView((DestinationAdapter)mListView.getAdapter());
        invalidateOptionsMenu();
    }

@@ -258,6 +260,7 @@ public final class SelectPrinterActivity extends Activity {
    }

    private void updateServicesWithAddPrinterActivity() {
        mHasEnabledPrintServices = true;
        mAddPrinterServices.clear();

        // Get all enabled print services.
@@ -266,6 +269,7 @@ public final class SelectPrinterActivity extends Activity {

        // No enabled print services - done.
        if (enabledServices.isEmpty()) {
            mHasEnabledPrintServices = false;
            return;
        }

@@ -324,7 +328,10 @@ public final class SelectPrinterActivity extends Activity {
        }
        TextView titleView = (TextView) findViewById(R.id.title);
        View progressBar = findViewById(R.id.progress_bar);
        if (adapter.getUnfilteredCount() <= 0) {
        if (!mHasEnabledPrintServices) {
            titleView.setText(R.string.print_no_print_services);
            progressBar.setVisibility(View.GONE);
        } else if (adapter.getUnfilteredCount() <= 0) {
            titleView.setText(R.string.print_searching_for_printers);
            progressBar.setVisibility(View.VISIBLE);
        } else {