summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2013-03-12 12:55:27 -0700
committerJohn Reck <jreck@google.com>2013-03-12 13:09:01 -0700
commit2594ea2c0c650c6f0d03ce5575315dfd0787d189 (patch)
treeaee765fd4b241c22212dd4a7d150a847dfd045ea
parent05a480847362eb9dbf57f73c83092e6a67f919f4 (diff)
downloadandroid_packages_apps_Snap-2594ea2c0c650c6f0d03ce5575315dfd0787d189.tar.gz
android_packages_apps_Snap-2594ea2c0c650c6f0d03ce5575315dfd0787d189.tar.bz2
android_packages_apps_Snap-2594ea2c0c650c6f0d03ce5575315dfd0787d189.zip
Fix ICS compatibility issues
Change-Id: I43f3236b9da0424fde66d3ad4d46403223fde8bf
-rw-r--r--src/com/android/photos/SelectionManager.java22
-rw-r--r--src/com/android/photos/adapters/PhotoThumbnailAdapter.java4
-rw-r--r--src/com/android/photos/views/SquareImageView.java53
3 files changed, 64 insertions, 15 deletions
diff --git a/src/com/android/photos/SelectionManager.java b/src/com/android/photos/SelectionManager.java
index d7e61d19a..979dcc7da 100644
--- a/src/com/android/photos/SelectionManager.java
+++ b/src/com/android/photos/SelectionManager.java
@@ -16,11 +16,11 @@
package com.android.photos;
-import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.nfc.NfcAdapter;
+import android.nfc.NfcAdapter.CreateBeamUrisCallback;
import android.nfc.NfcEvent;
import android.provider.MediaStore.Files.FileColumns;
import android.widget.ShareActionProvider;
@@ -31,7 +31,7 @@ import com.android.gallery3d.util.GalleryUtils;
import java.util.ArrayList;
-public class SelectionManager implements NfcAdapter.CreateBeamUrisCallback {
+public class SelectionManager {
private Activity mActivity;
private NfcAdapter mNfcAdapter;
private SelectedUriSource mUriSource;
@@ -41,12 +41,19 @@ public class SelectionManager implements NfcAdapter.CreateBeamUrisCallback {
public ArrayList<Uri> getSelectedShareableUris();
}
- @TargetApi(16)
public SelectionManager(Activity activity) {
mActivity = activity;
if (ApiHelper.AT_LEAST_16) {
mNfcAdapter = NfcAdapter.getDefaultAdapter(mActivity);
- mNfcAdapter.setBeamPushUrisCallback(this, mActivity);
+ mNfcAdapter.setBeamPushUrisCallback(new CreateBeamUrisCallback() {
+ @Override
+ public Uri[] createBeamUris(NfcEvent arg0) {
+ // This will have been preceded by a call to onItemSelectedStateChange
+ if (mCachedShareableUris == null) return null;
+ return mCachedShareableUris.toArray(
+ new Uri[mCachedShareableUris.size()]);
+ }
+ }, mActivity);
}
}
@@ -116,11 +123,4 @@ public class SelectionManager implements NfcAdapter.CreateBeamUrisCallback {
mShareIntent.removeExtra(Intent.EXTRA_STREAM);
mShareIntent.setAction(null).setType(null);
}
-
- @Override
- public Uri[] createBeamUris(NfcEvent event) {
- // This will have been preceded by a call to onItemSelectedStateChange
- if (mCachedShareableUris == null) return null;
- return mCachedShareableUris.toArray(new Uri[mCachedShareableUris.size()]);
- }
}
diff --git a/src/com/android/photos/adapters/PhotoThumbnailAdapter.java b/src/com/android/photos/adapters/PhotoThumbnailAdapter.java
index 5715795da..3776ca5a2 100644
--- a/src/com/android/photos/adapters/PhotoThumbnailAdapter.java
+++ b/src/com/android/photos/adapters/PhotoThumbnailAdapter.java
@@ -59,10 +59,6 @@ public class PhotoThumbnailAdapter extends CursorAdapter implements GalleryThumb
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View view = mInflater.inflate(R.layout.photo_set_item, parent, false);
- LayoutParams params = view.getLayoutParams();
- int columnWidth = ((GridView) parent).getColumnWidth();
- params.height = columnWidth;
- view.setLayoutParams(params);
return view;
}
diff --git a/src/com/android/photos/views/SquareImageView.java b/src/com/android/photos/views/SquareImageView.java
new file mode 100644
index 000000000..14eff1077
--- /dev/null
+++ b/src/com/android/photos/views/SquareImageView.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.photos.views;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+
+
+public class SquareImageView extends ImageView {
+
+ public SquareImageView(Context context) {
+ super(context);
+ }
+
+ public SquareImageView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public SquareImageView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+ int heightMode = MeasureSpec.getMode(heightMeasureSpec);
+ if (widthMode == MeasureSpec.EXACTLY && heightMode != MeasureSpec.EXACTLY) {
+ int width = MeasureSpec.getSize(widthMeasureSpec);
+ int height = width;
+ if (heightMode == MeasureSpec.AT_MOST) {
+ height = Math.min(height, MeasureSpec.getSize(heightMeasureSpec));
+ }
+ setMeasuredDimension(width, height);
+ } else {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+ }
+}