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

Commit 7be27aca authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Svetoslav
Browse files

Print attributes hint not honored.

1. Initially we have a single printer, the fake PDF printer, and
   wait for printers to be discovered. This printer was handling
   only a couple of media sizes. Hence, if the app provides a
   media size hint and the PDF printer does not support it, we
   were essentially ignoring the suggested media size since it
   was not supported by the selected printer and we fell back to
   the default paper size for that printer. The fake PDF printer
   should support all predefined media sizes.

2. The list of available paper sizes was shown in the order they
   are added ignoring the current locale. It is much better user
   experience if the media sizes used in the current locale are
   shown at the top and all others after that. Also the media
   sizes for the current locale should be alphabetically ordered
   so the user can quickly find the desired one.

3. The orientation was reset on media size or printer change.

bug:10564537

Change-Id: Iaa0d42242730ce69cea3effd4d0f4bc087068804
parent 5c126892
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -19302,7 +19302,7 @@ package android.print {
    field public static final android.print.PrintAttributes.MediaSize OM_PA_KAI;
    field public static final android.print.PrintAttributes.MediaSize PRC_1;
    field public static final android.print.PrintAttributes.MediaSize PRC_10;
    field public static final android.print.PrintAttributes.MediaSize PRC_16k;
    field public static final android.print.PrintAttributes.MediaSize PRC_16K;
    field public static final android.print.PrintAttributes.MediaSize PRC_2;
    field public static final android.print.PrintAttributes.MediaSize PRC_3;
    field public static final android.print.PrintAttributes.MediaSize PRC_4;
+23 −2
Original line number Diff line number Diff line
@@ -22,10 +22,13 @@ import android.content.res.Resources.NotFoundException;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;

import com.android.internal.R;

import java.util.Map;

/**
 * This class represents the attributes of a print job.
 */
@@ -267,6 +270,9 @@ public final class PrintAttributes implements Parcelable {
    public static final class MediaSize {
        private static final String LOG_TAG = "MediaSize";

        private static final Map<String, MediaSize> sIdToMediaSizeMap =
                new ArrayMap<String, MediaSize>();

        /**
         * Unknown media size in portrait mode.
         * <p>
@@ -494,8 +500,8 @@ public final class PrintAttributes implements Parcelable {
                        R.string.mediasize_chinese_prc_10, 12756, 18032);

        /** Chinese PRC 16k media size: 146mm x 215mm (5.749" x 8.465") */
        public static final MediaSize PRC_16k =
                new MediaSize("PRC_16k", "android",
        public static final MediaSize PRC_16K =
                new MediaSize("PRC_16K", "android",
                        R.string.mediasize_chinese_prc_16k, 5749, 8465);
        /** Chinese Pa Kai media size: 267mm x 389mm (10.512" x 15.315") */
        public static final MediaSize OM_PA_KAI =
@@ -651,6 +657,9 @@ public final class PrintAttributes implements Parcelable {
            mWidthMils = widthMils;
            mHeightMils = heightMils;
            mLabel = null;

            // Build this mapping only for predefined media sizes.
            sIdToMediaSizeMap.put(mId, this);
        }

        /**
@@ -854,6 +863,18 @@ public final class PrintAttributes implements Parcelable {
            builder.append("}");
            return builder.toString();
        }

        /**
         * Gets a standard media size given its id.
         *
         * @param id The media size id.
         * @return The media size for the given id or null.
         *
         * @hide
         */
        public static MediaSize getStandardMediaSizeById(String id) {
            return sIdToMediaSizeMap.get(id);
        }
    }

    /**
+33 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2013 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<resources>

    <string-array name="pdf_printer_media_sizes" translatable="false">
        <item>NA_LETTER</item>
        <item>NA_GOVT_LETTER</item>
        <item>NA_LEGAL</item>
        <item>NA_JUNIOR_LEGAL</item>
        <item>NA_LEDGER</item>
        <item>NA_TABLOID</item>
        <item>NA_INDEX_3X5</item>
        <item>NA_INDEX_4X6</item>
        <item>NA_INDEX_5X8</item>
        <item>NA_MONARCH</item>
        <item>NA_QUARTO</item>
        <item>NA_FOOLSCAP</item>
    </string-array>

</resources>
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2013 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<resources>

    <string name="mediasize_default">NA_LETTER</string>
    <string name="mediasize_standard">@string/mediasize_standard_north_america</string>

</resources>
+33 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2013 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<resources>

    <string-array name="pdf_printer_media_sizes" translatable="false">
        <item>NA_LETTER</item>
        <item>NA_GOVT_LETTER</item>
        <item>NA_LEGAL</item>
        <item>NA_JUNIOR_LEGAL</item>
        <item>NA_LEDGER</item>
        <item>NA_TABLOID</item>
        <item>NA_INDEX_3X5</item>
        <item>NA_INDEX_4X6</item>
        <item>NA_INDEX_5X8</item>
        <item>NA_MONARCH</item>
        <item>NA_QUARTO</item>
        <item>NA_FOOLSCAP</item>
    </string-array>

</resources>
Loading