PrintHelper.java 7.96 KB
package android.support.v4.print;

import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build.VERSION;
import android.print.PrintAttributes.Builder;
import android.print.PrintAttributes.MediaSize;
import android.print.PrintManager;
import ds;
import dt;
import du;
import java.io.FileNotFoundException;

public final class PrintHelper
{
  public static final int COLOR_MODE_COLOR = 2;
  public static final int COLOR_MODE_MONOCHROME = 1;
  public static final int ORIENTATION_LANDSCAPE = 1;
  public static final int ORIENTATION_PORTRAIT = 2;
  public static final int SCALE_MODE_FILL = 2;
  public static final int SCALE_MODE_FIT = 1;
  g a;
  
  public PrintHelper(Context paramContext)
  {
    if (systemSupportsPrint())
    {
      if (Build.VERSION.SDK_INT >= 24)
      {
        this.a = new c(paramContext);
        return;
      }
      if (Build.VERSION.SDK_INT >= 23)
      {
        this.a = new b(paramContext);
        return;
      }
      if (Build.VERSION.SDK_INT >= 20)
      {
        this.a = new a(paramContext);
        return;
      }
      this.a = new e(paramContext);
      return;
    }
    this.a = new f((byte)0);
  }
  
  public static boolean systemSupportsPrint()
  {
    return Build.VERSION.SDK_INT >= 19;
  }
  
  public final int getColorMode()
  {
    return this.a.b();
  }
  
  public final int getOrientation()
  {
    return this.a.c();
  }
  
  public final int getScaleMode()
  {
    return this.a.a();
  }
  
  public final void printBitmap(String paramString, Bitmap paramBitmap)
  {
    this.a.a(paramString, paramBitmap, null);
  }
  
  public final void printBitmap(String paramString, Bitmap paramBitmap, OnPrintFinishCallback paramOnPrintFinishCallback)
  {
    this.a.a(paramString, paramBitmap, paramOnPrintFinishCallback);
  }
  
  public final void printBitmap(String paramString, Uri paramUri)
    throws FileNotFoundException
  {
    this.a.a(paramString, paramUri, null);
  }
  
  public final void printBitmap(String paramString, Uri paramUri, OnPrintFinishCallback paramOnPrintFinishCallback)
    throws FileNotFoundException
  {
    this.a.a(paramString, paramUri, paramOnPrintFinishCallback);
  }
  
  public final void setColorMode(int paramInt)
  {
    this.a.b(paramInt);
  }
  
  public final void setOrientation(int paramInt)
  {
    this.a.c(paramInt);
  }
  
  public final void setScaleMode(int paramInt)
  {
    this.a.a(paramInt);
  }
  
  public static abstract interface OnPrintFinishCallback
  {
    public abstract void onFinish();
  }
  
  static final class a
    extends PrintHelper.d<ds>
  {
    a(Context paramContext)
    {
      super();
    }
  }
  
  static final class b
    extends PrintHelper.d<dt>
  {
    b(Context paramContext)
    {
      super();
    }
  }
  
  static final class c
    extends PrintHelper.d<du>
  {
    c(Context paramContext)
    {
      super();
    }
  }
  
  static class d<RealHelper extends PrintHelperKitkat>
    implements PrintHelper.g
  {
    private final RealHelper a;
    
    protected d(RealHelper paramRealHelper)
    {
      this.a = paramRealHelper;
    }
    
    public final int a()
    {
      return this.a.f;
    }
    
    public final void a(int paramInt)
    {
      this.a.f = paramInt;
    }
    
    public final void a(String paramString, Bitmap paramBitmap, final PrintHelper.OnPrintFinishCallback paramOnPrintFinishCallback)
    {
      PrintHelperKitkat.OnPrintFinishCallback local1 = null;
      if (paramOnPrintFinishCallback != null) {
        local1 = new PrintHelperKitkat.OnPrintFinishCallback()
        {
          public final void onFinish()
          {
            paramOnPrintFinishCallback.onFinish();
          }
        };
      }
      PrintHelperKitkat localPrintHelperKitkat = this.a;
      int i;
      PrintManager localPrintManager;
      if (paramBitmap != null)
      {
        i = localPrintHelperKitkat.f;
        localPrintManager = (PrintManager)localPrintHelperKitkat.a.getSystemService("print");
        if (!PrintHelperKitkat.a(paramBitmap)) {
          break label108;
        }
      }
      label108:
      for (paramOnPrintFinishCallback = PrintAttributes.MediaSize.UNKNOWN_PORTRAIT;; paramOnPrintFinishCallback = PrintAttributes.MediaSize.UNKNOWN_LANDSCAPE)
      {
        paramOnPrintFinishCallback = new PrintAttributes.Builder().setMediaSize(paramOnPrintFinishCallback).setColorMode(localPrintHelperKitkat.g).build();
        localPrintManager.print(paramString, new PrintHelperKitkat.1(localPrintHelperKitkat, paramString, i, paramBitmap, local1), paramOnPrintFinishCallback);
        return;
      }
    }
    
    public final void a(String paramString, Uri paramUri, final PrintHelper.OnPrintFinishCallback paramOnPrintFinishCallback)
      throws FileNotFoundException
    {
      Object localObject = null;
      if (paramOnPrintFinishCallback != null) {
        localObject = new PrintHelperKitkat.OnPrintFinishCallback()
        {
          public final void onFinish()
          {
            paramOnPrintFinishCallback.onFinish();
          }
        };
      }
      paramOnPrintFinishCallback = this.a;
      paramUri = new PrintHelperKitkat.3(paramOnPrintFinishCallback, paramString, paramUri, (PrintHelperKitkat.OnPrintFinishCallback)localObject, paramOnPrintFinishCallback.f);
      localObject = (PrintManager)paramOnPrintFinishCallback.a.getSystemService("print");
      PrintAttributes.Builder localBuilder = new PrintAttributes.Builder();
      localBuilder.setColorMode(paramOnPrintFinishCallback.g);
      if ((paramOnPrintFinishCallback.h == 1) || (paramOnPrintFinishCallback.h == 0)) {
        localBuilder.setMediaSize(PrintAttributes.MediaSize.UNKNOWN_LANDSCAPE);
      }
      for (;;)
      {
        ((PrintManager)localObject).print(paramString, paramUri, localBuilder.build());
        return;
        if (paramOnPrintFinishCallback.h == 2) {
          localBuilder.setMediaSize(PrintAttributes.MediaSize.UNKNOWN_PORTRAIT);
        }
      }
    }
    
    public final int b()
    {
      return this.a.g;
    }
    
    public final void b(int paramInt)
    {
      this.a.g = paramInt;
    }
    
    public final int c()
    {
      PrintHelperKitkat localPrintHelperKitkat = this.a;
      if (localPrintHelperKitkat.h == 0) {
        return 1;
      }
      return localPrintHelperKitkat.h;
    }
    
    public final void c(int paramInt)
    {
      this.a.h = paramInt;
    }
  }
  
  static final class e
    extends PrintHelper.d<PrintHelperKitkat>
  {
    e(Context paramContext)
    {
      super();
    }
  }
  
  static final class f
    implements PrintHelper.g
  {
    int a = 2;
    int b = 2;
    int c = 1;
    
    public final int a()
    {
      return this.a;
    }
    
    public final void a(int paramInt)
    {
      this.a = paramInt;
    }
    
    public final void a(String paramString, Bitmap paramBitmap, PrintHelper.OnPrintFinishCallback paramOnPrintFinishCallback) {}
    
    public final void a(String paramString, Uri paramUri, PrintHelper.OnPrintFinishCallback paramOnPrintFinishCallback) {}
    
    public final int b()
    {
      return this.b;
    }
    
    public final void b(int paramInt)
    {
      this.b = paramInt;
    }
    
    public final int c()
    {
      return this.c;
    }
    
    public final void c(int paramInt)
    {
      this.c = paramInt;
    }
  }
  
  static abstract interface g
  {
    public abstract int a();
    
    public abstract void a(int paramInt);
    
    public abstract void a(String paramString, Bitmap paramBitmap, PrintHelper.OnPrintFinishCallback paramOnPrintFinishCallback);
    
    public abstract void a(String paramString, Uri paramUri, PrintHelper.OnPrintFinishCallback paramOnPrintFinishCallback)
      throws FileNotFoundException;
    
    public abstract int b();
    
    public abstract void b(int paramInt);
    
    public abstract int c();
    
    public abstract void c(int paramInt);
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/print/PrintHelper.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */