2 * Copyright (C) 2013 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.gallery3d.filtershow.info;
19 import android.graphics.Bitmap;
20 import android.graphics.Rect;
21 import android.net.Uri;
22 import android.os.Bundle;
23 import android.support.v4.app.DialogFragment;
24 import android.text.Html;
25 import android.view.LayoutInflater;
26 import android.view.View;
27 import android.view.ViewGroup;
28 import android.view.Window;
29 import android.widget.ImageButton;
30 import android.widget.ImageView;
31 import android.widget.LinearLayout;
32 import android.widget.TextView;
33 import com.android.gallery3d.R;
34 import com.android.gallery3d.exif.ExifInterface;
35 import com.android.gallery3d.exif.ExifTag;
36 import com.android.gallery3d.filtershow.cache.ImageLoader;
37 import com.android.gallery3d.filtershow.imageshow.MasterImage;
39 import java.util.List;
41 public class InfoPanel extends DialogFragment {
42 public static final String FRAGMENT_TAG = "InfoPanel";
43 private static final String LOGTAG = FRAGMENT_TAG;
44 private LinearLayout mMainView;
45 private ImageView mImageThumbnail;
46 private TextView mImageName;
47 private TextView mImageSize;
48 private TextView mExifData;
50 private String createStringFromIfFound(ExifTag exifTag, int tag, int str) {
51 String exifString = "";
52 short tagId = exifTag.getTagId();
53 if (tagId == ExifInterface.getTrueTagKey(tag)) {
54 String label = getActivity().getString(str);
55 exifString += "<b>" + label + ": </b>";
56 exifString += exifTag.forceGetValueAsString();
63 public View onCreateView(LayoutInflater inflater, ViewGroup container,
64 Bundle savedInstanceState) {
65 if (getDialog() != null) {
66 getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
69 mMainView = (LinearLayout) inflater.inflate(
70 R.layout.filtershow_info_panel, null, false);
72 mImageThumbnail = (ImageView) mMainView.findViewById(R.id.imageThumbnail);
73 Bitmap bitmap = MasterImage.getImage().getFilteredImage();
74 mImageThumbnail.setImageBitmap(bitmap);
76 mImageName = (TextView) mMainView.findViewById(R.id.imageName);
77 mImageSize = (TextView) mMainView.findViewById(R.id.imageSize);
78 mExifData = (TextView) mMainView.findViewById(R.id.exifData);
79 TextView exifLabel = (TextView) mMainView.findViewById(R.id.exifLabel);
81 HistogramView histogramView = (HistogramView) mMainView.findViewById(R.id.histogramView);
82 histogramView.setBitmap(bitmap);
84 Uri uri = MasterImage.getImage().getUri();
85 String path = ImageLoader.getLocalPathFromUri(getActivity(), uri);
88 localUri = Uri.parse(path);
91 if (localUri != null) {
92 mImageName.setText(localUri.getLastPathSegment());
94 Rect originalBounds = MasterImage.getImage().getOriginalBounds();
95 mImageSize.setText("" + originalBounds.width() + " x " + originalBounds.height());
97 List<ExifTag> exif = MasterImage.getImage().getEXIF();
98 String exifString = "";
99 boolean hasExifData = false;
101 for (ExifTag tag : exif) {
102 exifString += createStringFromIfFound(tag,
103 ExifInterface.TAG_MODEL,
104 R.string.filtershow_exif_model);
105 exifString += createStringFromIfFound(tag,
106 ExifInterface.TAG_APERTURE_VALUE,
107 R.string.filtershow_exif_aperture);
108 exifString += createStringFromIfFound(tag,
109 ExifInterface.TAG_FOCAL_LENGTH,
110 R.string.filtershow_exif_focal_length);
111 exifString += createStringFromIfFound(tag,
112 ExifInterface.TAG_ISO_SPEED_RATINGS,
113 R.string.filtershow_exif_iso);
114 exifString += createStringFromIfFound(tag,
115 ExifInterface.TAG_SUBJECT_DISTANCE,
116 R.string.filtershow_exif_subject_distance);
117 exifString += createStringFromIfFound(tag,
118 ExifInterface.TAG_DATE_TIME_ORIGINAL,
119 R.string.filtershow_exif_date);
120 exifString += createStringFromIfFound(tag,
121 ExifInterface.TAG_F_NUMBER,
122 R.string.filtershow_exif_f_stop);
123 exifString += createStringFromIfFound(tag,
124 ExifInterface.TAG_EXPOSURE_TIME,
125 R.string.filtershow_exif_exposure_time);
126 exifString += createStringFromIfFound(tag,
127 ExifInterface.TAG_COPYRIGHT,
128 R.string.filtershow_exif_copyright);
133 exifLabel.setVisibility(View.VISIBLE);
134 mExifData.setText(Html.fromHtml(exifString));
136 exifLabel.setVisibility(View.GONE);