OSDN Git Service

Revert "Move Gallery2 to androidx."
[android-x86/packages-apps-Gallery2.git] / src / com / android / gallery3d / app / AbstractGalleryActivity.java
index ac39aa5..9af1fb8 100644 (file)
@@ -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);
+        }
+    }
 }