12d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware/*
26c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong * Copyright (C) 2014 The Android Open Source Project
32d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware *
42d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware * Licensed under the Apache License, Version 2.0 (the "License");
52d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware * you may not use this file except in compliance with the License.
62d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware * You may obtain a copy of the License at
72d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware *
82d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware *      http://www.apache.org/licenses/LICENSE-2.0
92d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware *
102d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware * Unless required by applicable law or agreed to in writing, software
112d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware * distributed under the License is distributed on an "AS IS" BASIS,
122d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
132d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware * See the License for the specific language governing permissions and
142d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware * limitations under the License.
152d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware */
162d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiwarepackage com.android.camera.util;
172d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware
184f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Spragueimport android.content.ComponentName;
192d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiwareimport android.content.Context;
202d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiwareimport android.content.Intent;
216c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kongimport android.content.pm.PackageManager;
226c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kongimport android.graphics.drawable.Drawable;
2380461c2de3ee7f12e17e9951567a843c500b8fe1Alan Newbergerimport android.net.Uri;
242d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware
254f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Spragueimport com.android.camera2.R;
264f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague
276c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong/**
286c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong * A helper class to provide Gallery related info.
296c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong */
306c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kongpublic class GalleryHelper {
314f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague    private static final String GALLERY_PACKAGE_NAME = "com.android.gallery3d";
322d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware    private static final String GALLERY_ACTIVITY_CLASS =
334f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague        "com.android.gallery3d.app.GalleryActivity";
344f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague    private static final int GALLERY_APP_NAME_ID = R.string.gallery_app_name;
35d3de171d6afa5ebd74d56dde6d4818b14a001286Angus Kong
366c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong    public static void setGalleryIntentClassName(Intent intent) {
376c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong        intent.setClassName(GALLERY_PACKAGE_NAME, GALLERY_ACTIVITY_CLASS);
382d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware    }
392d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware
406c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong    public static Drawable getGalleryIcon(Context context, Intent galleryIntent) {
416c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong        if (galleryIntent != null) {
426c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong            try {
436c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong                return context.getPackageManager().getActivityIcon(galleryIntent);
446c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong            } catch (PackageManager.NameNotFoundException e) {
456c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong                // Do nothing.
466c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong            }
476c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong        }
486c0c7f1281425f4296cb1a42563d00ae056cd14aAngus Kong        return null;
492d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware    }
5080461c2de3ee7f12e17e9951567a843c500b8fe1Alan Newberger
514f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague    public static CharSequence getGalleryAppName(Context context, Intent galleryIntent) {
524f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague        ComponentName componentName = galleryIntent.getComponent();
534f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague        if (componentName != null
544f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague                && GALLERY_PACKAGE_NAME.equals(componentName.getPackageName())
554f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague                && GALLERY_ACTIVITY_CLASS.equals(componentName.getClassName())) {
564f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague            return context.getResources().getString(GALLERY_APP_NAME_ID);
574f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague        } else {
584f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague            return null;
594f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague        }
604f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague    }
614f93e19ddb504560752fd5da9fecc4b95a4f1733Spike Sprague
6280461c2de3ee7f12e17e9951567a843c500b8fe1Alan Newberger    public static void setContentUri(Intent intent, Uri uri) {
6380461c2de3ee7f12e17e9951567a843c500b8fe1Alan Newberger        // Do nothing.
6480461c2de3ee7f12e17e9951567a843c500b8fe1Alan Newberger    }
652d939fe70e52ba4805c6783b01530c8c1c67fb33Mangesh Ghiware}
66