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

Commit 33c98a1f authored by Benjamin Gordon's avatar Benjamin Gordon
Browse files

PrintSpooler: Add bottom padding to preview area

When edge-to-edge support was added to print preview, the new top insets
pushed down the preview area.  If there are more pages than can fit on a
single screen, the selection button on the last page is no longer
reachable.  Restore this by inserting bottom padding equal to the insets
that were previously applied on the container; this ensures the bottom
active content can be scrolled up above the navigation bar.

Bug: 406287680
Test: Manually print multi-page docs in various orientations
Flag: EXEMPT bugfix
Change-Id: Ib59c5df8898186c6ec9affbe4119731e2d4c96e4
parent 3b20644f
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -16,24 +16,27 @@

package com.android.printspooler.ui;

import android.graphics.Insets;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.print.PageRange;
import android.print.PrintAttributes.MediaSize;
import android.print.PrintAttributes.Margins;
import android.print.PrintAttributes.MediaSize;
import android.print.PrintDocumentInfo;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.support.v7.widget.RecyclerView.LayoutManager;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.View;
import android.view.WindowInsets;

import com.android.internal.os.SomeArgs;
import com.android.printspooler.R;
import com.android.printspooler.model.MutexFileProvider;
import com.android.printspooler.widget.PrintContentView;
import com.android.printspooler.widget.EmbeddedContentContainer;
import com.android.printspooler.widget.PrintContentView;
import com.android.printspooler.widget.PrintOptionsLayout;

import java.io.File;
@@ -215,6 +218,13 @@ class PrintPreviewController implements MutexFileProvider.OnReleaseRequestCallba

    @Override
    public void setPadding(int left, int top, int right, int bottom) {
        WindowInsets winsets = mRecyclerView.getRootWindowInsets();
        if (winsets != null) {
            // The preview area has been pushed down to make space for the other settings content.
            // Insert enough padding to allow the user to scroll a multi-page document back up.
            Insets insets = winsets.getInsets(WindowInsets.Type.systemBars());
            bottom += insets.bottom + insets.top;
        }
        mRecyclerView.setPadding(left, top, right, bottom);
    }