X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fcom%2Fandroid%2Fgallery3d%2Fapp%2FAbstractGalleryActivity.java;h=9af1fb8baef121aefe438eba24b38fee05b47a3f;hb=fac21a096afbe8eb517726cf4f9f093eade87ddc;hp=ac39aa560a382e0a1c4d41d3191a6434c69654b7;hpb=4c629168e7a967032172b7135631a85c49fddbf6;p=android-x86%2Fpackages-apps-Gallery2.git diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java index ac39aa560..9af1fb8ba 100644 --- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java +++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java @@ -29,8 +29,10 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.res.Configuration; +import android.net.Uri; import android.os.Bundle; import android.os.IBinder; +import android.support.v4.print.PrintHelper; import android.view.Menu; import android.view.MenuItem; import android.view.Window; @@ -40,14 +42,16 @@ import com.android.gallery3d.R; import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.MediaItem; +import com.android.gallery3d.filtershow.cache.ImageLoader; import com.android.gallery3d.ui.GLRoot; import com.android.gallery3d.ui.GLRootView; -import com.android.gallery3d.util.LightCycleHelper.PanoramaViewHelper; +import com.android.gallery3d.util.PanoramaViewHelper; import com.android.gallery3d.util.ThreadPool; import com.android.photos.data.GalleryBitmapPool; +import java.io.FileNotFoundException; + public class AbstractGalleryActivity extends Activity implements GalleryContext { - @SuppressWarnings("unused") private static final String TAG = "AbstractGalleryActivity"; private GLRootView mGLRootView; private StateManager mStateManager; @@ -311,10 +315,12 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext private BatchService mBatchService; private boolean mBatchServiceIsBound = false; private ServiceConnection mBatchServiceConnection = new ServiceConnection() { + @Override public void onServiceConnected(ComponentName className, IBinder service) { mBatchService = ((BatchService.LocalBinder)service).getService(); } + @Override public void onServiceDisconnected(ComponentName className) { mBatchService = null; } @@ -340,4 +346,23 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext throw new RuntimeException("Batch service unavailable"); } } + + public void printSelectedImage(Uri uri) { + if (uri == null) { + return; + } + String path = ImageLoader.getLocalPathFromUri(this, uri); + if (path != null) { + Uri localUri = Uri.parse(path); + path = localUri.getLastPathSegment(); + } else { + path = uri.getLastPathSegment(); + } + PrintHelper printer = new PrintHelper(this); + try { + printer.printBitmap(path, uri); + } catch (FileNotFoundException fnfe) { + Log.e(TAG, "Error printing an image", fnfe); + } + } }