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

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

Carry over orientation when updating the printAttributes with the capabilities of the printer.

Bug: 19194758
Change-Id: Iaa9897bc730d8cefa63bed8a5ad02e0a5dc89c71
parent c080f112
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -1003,7 +1003,9 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
        if (currMediaSize == null) {
            attributes.setMediaSize(defaults.getMediaSize());
        } else {
            boolean foundCurrentMediaSize = false;
            MediaSize newMediaSize = null;
            boolean isPortrait = currMediaSize.isPortrait();

            // Try to find the current media size in the capabilities as
            // it may be in a different orientation.
            MediaSize currMediaSizePortrait = currMediaSize.asPortrait();
@@ -1011,14 +1013,21 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
            for (int i = 0; i < mediaSizeCount; i++) {
                MediaSize mediaSize = sortedMediaSizes.get(i);
                if (currMediaSizePortrait.equals(mediaSize.asPortrait())) {
                    attributes.setMediaSize(currMediaSize);
                    foundCurrentMediaSize = true;
                    newMediaSize = mediaSize;
                    break;
                }
            }
            // If we did not find the current media size fall back to default.
            if (!foundCurrentMediaSize) {
                attributes.setMediaSize(defaults.getMediaSize());
            if (newMediaSize == null) {
                newMediaSize = defaults.getMediaSize();
            }

            if (newMediaSize != null) {
                if (isPortrait) {
                    attributes.setMediaSize(newMediaSize.asPortrait());
                } else {
                    attributes.setMediaSize(newMediaSize.asLandscape());
                }
            }
        }