Follow

Getting Started

Setting up your own client

  1. Unzip the source in your desired working directory
  2. Import the project into your IDE
  3. If you intend to build from the command line, or your IDE requires it, you might need to set your Android sdk.dir in thelocal.properties file.

Note that JDK 6 is required for Android development. Make sure your IDE is compiling with Java 1.6. (In Eclipse this specified in Preferences → Java → Compiler → Compiler compliance level: 1.6)

The default application is quite small - most of the functionality is provided by the Pugpig.jar library in your libs subdirectory, which implements the com.kaldorgroup.pugpig.* package hierarchy. You will need to customise this small default application to suit your needs:

Changing your package name

Pugpig for Android provides a default application with a package name of com.example.pugpigapplication (in src, the default Android source directory). You should rename this to something more suitable for your application. Your IDE should help you with renaming packages as a refactor operation, but you should ensure that your AndroidManifest.xml file is updated correctly:

<manifest ... package="com.yourcompany.yourapplication" ...>
    ...
    <application ...>
        <meta-data android:name="ApplicationDelegate" android:value="com.yourcompany.yourapplication.AppDelegate" />
        <activity android:name="com.yourcompany.yourapplication.DocumentPickerViewController" ...>...</activity>
        <activity android:name="com.yourcompany.yourapplication.DocumentViewController" ...>...</activity>
    </application>
</manifest>

Changing the name of your application

You will also want to change the name of your application (in the usual place - res/values/strings.xml).

Use your own endpoint

You must now provide an endpoint for downloading editions. If you do not set an endpoint, your application will crash on startup!

In your AppDelegate.java file, add the URL for your OPDS endpoint:

  // TODO: Fill in your OPDS endpoint URL here.
  final URL url = URLUtils.URLWithString("");

Configuring your pane model

Pugpig supports single pane and variable pane models. In the single pane model, each page is assumed to be exactly as wide as the page control. The variable pane model assumes that pages are of arbitrary width, and Pugpig divides them into panes.

By default Pugpig uses the single pane model. If your text overflows the single pane model, you want to use the variable pane model, and you'll need to set an appropriate pane manager in the openDocument method in DocumentViewController.java.

  private void openDocument(Document document) {
    ...
 
    // Add the line below to enable variable panes.
    pageControl.setPaneManager(document.paneManagerWithClass(VariablePanePartitioning.class));
 
    pageControl.setImageStore(document.imageStore());
    pageControl.setDataSource(document.dataSource());
    ...
  }

File Sharing Providers

In the AndroidManifest.xml set a file sharing provider in order to be able to share the documents.

The android.authorities must be unique per app and the path must be the application package. The android.name should be the package of what triggers sharing (same across apps).

Example:

 <provider
              android:name="com.kaldorgroup.pugpig.sharing.FileSharingProvider"
              android:authorities="com.example.pugpigapplication.FileSharingProvider"
              android:exported="true"
              android:grantUriPermissions="true"/>

See https://developer.android.com/guide/topics/manifest/provider-element.html

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk