<?xml version="1.0" encoding="utf-8"?>
-<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.photos.views.SquareImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="200dip"
+ android:layout_height="wrap_content"
android:id="@+id/thumbnail">
-</ImageView>
\ No newline at end of file
+</com.android.photos.views.SquareImageView>
\ No newline at end of file
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;
import java.util.ArrayList;
-public class SelectionManager implements NfcAdapter.CreateBeamUrisCallback {
+public class SelectionManager {
private Activity mActivity;
private NfcAdapter mNfcAdapter;
private SelectedUriSource mUriSource;
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);
}
}
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()]);
- }
}
@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;
}
--- /dev/null
+/*
+ * 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);
+ }
+ }
+}