Device Year Class

Starting with PSPDFKit 4.3 for Android, we introduced Device Year Class — a library from Facebook that analyzes an Android device‘s specifications. When rendering low-resolution images, we felt the need to implement a simple algorithm that maps a device‘s RAM, CPU cores, and clock speed in order to calculate the best resolution possible without performance degradation.

The goal of Device Year Class is to classify a device in one of the following categories:

  • LOW_RES_RENDER_HIGH — Reserved for high-end devices from 2014 and later. This category will use a maximum pixel count of 2048 * 2048, even for those device screens with a higher resolution.
  • LOW_RES_RENDER_MEDIUM — Middle-end devices from 2013. This category will use a maximum pixel count of 1536 * 1536 and will fall back to the actual screen resolution when lower.
  • LOW_RES_RENDER_LOW — Low-end devices from 2012. This category will use a maximum pixel count of 1024 * 1024 and will fall back to the actual screen resolution when lower.
  • LOW_RES_RENDER_VERY_LOW — Very old devices. This category is reserved for those devices with poor specs and limited memory, and it will use a safe maximum pixel count of 512 * 512.

Add Device Year Class (Only for Manual Integration)

Important: This integration is only required if you manually integrate the PSPDFKit aar file. If you used Maven/Gradle for integrating PSPDFKit, Device Year Class has already been set up for you.

  1. Go to https://github.com/facebook/device-year-class and look for the current version of Device Year Class.

  2. Inside the dependencies block of your app/build.gradle, add the following (replace the version with the current one):

    build.gradle
    1
    2
    3
    
    dependencies {
        compile 'com.facebook.device.yearclass:yearclass:2.0.0'
    }
    
  3. Run your app. PSPDFKit will automatically pick up Device Year Class and use it.

Remove Device Year Class

If you do not want to use Device Year Class in your app, you can disable it by excluding the transitive Gradle dependency inside your build.gradle. PSPDFKit will detect that Device Year Class is no longer present and will fall back to the maximum pixel count of 1024 * 1024, most suited for the majority of use cases and compatible with a wide range of devices:

Copy
build.gradle
1
2
3
4
5
dependencies {
    compile('com.pspdfkit:pspdfkit:5.0.1') {
        exclude group: 'com.facebook.device.yearclass', module: 'yearclass'
    }
}

To set a fixed low resolution render pixel count check our section about Low-res Render API.

Note: Deactivating Device Year Class will lead to unoptimized values for the latest devices.