summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/com/android/internal/app/ChooserActivity.java64
-rw-r--r--core/res/res/layout/chooser_grid.xml7
-rw-r--r--core/res/res/layout/chooser_grid_preview_text.xml17
-rw-r--r--core/res/res/layout/chooser_row.xml4
-rw-r--r--core/res/res/layout/resolve_grid_item.xml6
-rw-r--r--core/res/res/values/dimens.xml2
6 files changed, 43 insertions, 57 deletions
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index b51f8080569f..bfdbf4c1ec23 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -101,9 +101,7 @@ import android.view.animation.DecelerateInterpolator;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
-import android.widget.LinearLayout;
import android.widget.ListView;
-import android.widget.Space;
import android.widget.TextView;
import android.widget.Toast;
@@ -1604,7 +1602,7 @@ public class ChooserActivity extends ResolverActivity {
private final Intent mFillInIntent;
private final int mFillInFlags;
private final float mModifiedScore;
- private boolean mIsSuspended;
+ private boolean mIsSuspended = false;
SelectableTargetInfo(DisplayResolveInfo sourceInfo, ChooserTarget chooserTarget,
float modifiedScore) {
@@ -1619,6 +1617,8 @@ public class ChooserActivity extends ResolverActivity {
final PackageManager pm = getPackageManager();
mBadgeIcon = pm.getApplicationIcon(ai.applicationInfo);
mBadgeContentDescription = pm.getApplicationLabel(ai.applicationInfo);
+ mIsSuspended =
+ (ai.applicationInfo.flags & ApplicationInfo.FLAG_SUSPENDED) != 0;
}
}
}
@@ -1633,8 +1633,6 @@ public class ChooserActivity extends ResolverActivity {
mFillInIntent = null;
mFillInFlags = 0;
- ApplicationInfo ai = sourceInfo.getResolveInfo().activityInfo.applicationInfo;
- mIsSuspended = (ai.flags & ApplicationInfo.FLAG_SUSPENDED) != 0;
}
private SelectableTargetInfo(SelectableTargetInfo other, Intent fillInIntent, int flags) {
@@ -1836,7 +1834,7 @@ public class ChooserActivity extends ResolverActivity {
return;
}
- if (mChooserRowAdapter.calculateMaxTargetsPerRow(right - left)
+ if (mChooserRowAdapter.calculateChooserTargetWidth(right - left)
|| mAdapterView.getAdapter() == null) {
mAdapterView.setAdapter(mChooserRowAdapter);
@@ -2325,9 +2323,9 @@ public class ChooserActivity extends ResolverActivity {
class ChooserRowAdapter extends BaseAdapter {
private ChooserListAdapter mChooserListAdapter;
private final LayoutInflater mLayoutInflater;
- private int mCalculatedMaxTargetsPerRow = MAX_TARGETS_PER_ROW_LANDSCAPE;
private DirectShareViewHolder mDirectShareViewHolder;
+ private int mChooserTargetWidth = 0;
private static final int VIEW_TYPE_DIRECT_SHARE = 0;
private static final int VIEW_TYPE_NORMAL = 1;
@@ -2356,25 +2354,23 @@ public class ChooserActivity extends ResolverActivity {
}
/**
- * Determine how many targets can comfortably fit in a single row.
+ * Calculate the chooser target width to maximize space per item
*
* @param width The new row width to use for recalculation
- * @return true if the numbers of targets per row has changed
+ * @return true if the view width has changed
*/
- public boolean calculateMaxTargetsPerRow(int width) {
- int targetWidth = getResources().getDimensionPixelSize(
+ public boolean calculateChooserTargetWidth(int width) {
+ int targetMinWidth = getResources().getDimensionPixelSize(
R.dimen.chooser_target_width);
- if (targetWidth == 0 || width == 0) {
+ if (width == 0) {
return false;
}
- int margin = getResources().getDimensionPixelSize(
- R.dimen.chooser_edge_margin_normal);
-
- int newCount = (width - margin * 2) / targetWidth;
- if (newCount != mCalculatedMaxTargetsPerRow) {
- mCalculatedMaxTargetsPerRow = newCount;
+ int targetWidth = width / getMaxTargetsPerRow();
+ int newWidth = Math.max(targetWidth, targetMinWidth);
+ if (newWidth != mChooserTargetWidth) {
+ mChooserTargetWidth = newWidth;
return true;
}
@@ -2388,7 +2384,7 @@ public class ChooserActivity extends ResolverActivity {
maxTargets = MAX_TARGETS_PER_ROW_LANDSCAPE;
}
- return Math.min(maxTargets, mCalculatedMaxTargetsPerRow);
+ return maxTargets;
}
@Override
@@ -2498,6 +2494,8 @@ public class ChooserActivity extends ResolverActivity {
private RowViewHolder loadViewsIntoRow(RowViewHolder holder) {
final int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+ final int exactSpec = MeasureSpec.makeMeasureSpec(mChooserTargetWidth,
+ MeasureSpec.EXACTLY);
int columnCount = holder.getColumnCount();
final boolean isDirectShare = holder instanceof DirectShareViewHolder;
@@ -2533,20 +2531,20 @@ public class ChooserActivity extends ResolverActivity {
}
// Force height to be a given so we don't have visual disruption during scaling.
- v.measure(spec, spec);
- setViewHeight(v, v.getMeasuredHeight());
+ v.measure(exactSpec, spec);
+ setViewBounds(v, v.getMeasuredWidth(), v.getMeasuredHeight());
}
final ViewGroup viewGroup = holder.getViewGroup();
// Pre-measure and fix height so we can scale later.
holder.measure();
- setViewHeight(viewGroup, holder.getMeasuredRowHeight());
+ setViewBounds(viewGroup, LayoutParams.MATCH_PARENT, holder.getMeasuredRowHeight());
if (isDirectShare) {
DirectShareViewHolder dsvh = (DirectShareViewHolder) holder;
- setViewHeight(dsvh.getRow(0), dsvh.getMinRowHeight());
- setViewHeight(dsvh.getRow(1), dsvh.getMinRowHeight());
+ setViewBounds(dsvh.getRow(0), LayoutParams.MATCH_PARENT, dsvh.getMinRowHeight());
+ setViewBounds(dsvh.getRow(1), LayoutParams.MATCH_PARENT, dsvh.getMinRowHeight());
}
viewGroup.setTag(holder);
@@ -2554,13 +2552,14 @@ public class ChooserActivity extends ResolverActivity {
return holder;
}
- private void setViewHeight(View view, int heightPx) {
+ private void setViewBounds(View view, int widthPx, int heightPx) {
LayoutParams lp = view.getLayoutParams();
if (lp == null) {
- lp = new LayoutParams(LayoutParams.MATCH_PARENT, heightPx);
+ lp = new LayoutParams(widthPx, heightPx);
view.setLayoutParams(lp);
} else {
lp.height = heightPx;
+ lp.width = widthPx;
}
}
@@ -2712,11 +2711,6 @@ public class ChooserActivity extends ResolverActivity {
return mMeasuredRowHeight;
}
- protected void addSpacer(ViewGroup row) {
- row.addView(new Space(ChooserActivity.this),
- new LinearLayout.LayoutParams(0, 0, 1));
- }
-
public void setItemIndex(int itemIndex, int listIndex) {
mItemIndices[itemIndex] = listIndex;
}
@@ -2756,10 +2750,6 @@ public class ChooserActivity extends ResolverActivity {
mRow.addView(v);
mCells[index] = v;
- if (index != (mCells.length - 1)) {
- addSpacer(mRow);
- }
-
return mRow;
}
@@ -2794,10 +2784,6 @@ public class ChooserActivity extends ResolverActivity {
row.addView(v);
mCells[index] = v;
- if (index % mCellCountPerRow != (mCellCountPerRow - 1)) {
- addSpacer(row);
- }
-
return row;
}
diff --git a/core/res/res/layout/chooser_grid.xml b/core/res/res/layout/chooser_grid.xml
index 1f8041741b46..68c62a6ebf3e 100644
--- a/core/res/res/layout/chooser_grid.xml
+++ b/core/res/res/layout/chooser_grid.xml
@@ -32,11 +32,11 @@
<ImageView
android:id="@+id/drag"
- android:layout_width="32dp"
+ android:layout_width="24dp"
android:layout_height="4dp"
android:src="@drawable/ic_drag_handle"
android:clickable="true"
- android:layout_marginTop="@dimen/chooser_view_spacing"
+ android:layout_marginTop="@dimen/chooser_edge_margin_thin"
android:tint="@color/lighter_gray"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true" />
@@ -61,8 +61,9 @@
android:layout_width="wrap_content"
android:textAppearance="?attr/textAppearanceMedium"
android:textSize="20sp"
+ android:textColor="?attr/textColorPrimary"
android:gravity="center"
- android:paddingTop="@dimen/chooser_view_spacing"
+ android:paddingTop="@dimen/chooser_edge_margin_thin"
android:paddingBottom="@dimen/chooser_view_spacing"
android:paddingLeft="24dp"
android:paddingRight="24dp"
diff --git a/core/res/res/layout/chooser_grid_preview_text.xml b/core/res/res/layout/chooser_grid_preview_text.xml
index 6abf57a0f9f2..45287002ebf7 100644
--- a/core/res/res/layout/chooser_grid_preview_text.xml
+++ b/core/res/res/layout/chooser_grid_preview_text.xml
@@ -43,15 +43,16 @@
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:gravity="start|top"
- android:paddingRight="24dp"
+ android:paddingRight="@dimen/chooser_view_spacing"
android:maxLines="2"/>
- <Button
+ <ImageButton
android:id="@+id/copy_button"
- android:layout_width="24dp"
- android:layout_height="24dp"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:padding="12dp"
android:gravity="center"
android:layout_gravity="center_vertical"
- android:foreground="@drawable/ic_content_copy_gm2"
+ android:src="@drawable/ic_content_copy_gm2"
android:clickable="true"
android:background="?attr/selectableItemBackgroundBorderless"/>
</LinearLayout>
@@ -63,8 +64,8 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
- android:layout_marginLeft="@dimen/chooser_edge_margin_thin"
- android:layout_marginRight="@dimen/chooser_edge_margin_thin"
+ android:layout_marginLeft="@dimen/chooser_edge_margin_normal"
+ android:layout_marginRight="@dimen/chooser_edge_margin_normal"
android:minHeight="80dp"
android:background="@drawable/chooser_content_preview_rounded"
android:id="@+id/content_preview_title_layout">
@@ -87,7 +88,7 @@
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:maxLines="2"
- android:textAppearance="?attr/textAppearanceMedium"/>
+ android:textSize="20sp"/>
</LinearLayout>
</LinearLayout>
diff --git a/core/res/res/layout/chooser_row.xml b/core/res/res/layout/chooser_row.xml
index 742d7eedaced..f5814c3251f6 100644
--- a/core/res/res/layout/chooser_row.xml
+++ b/core/res/res/layout/chooser_row.xml
@@ -20,9 +20,7 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="100dp"
- android:gravity="start|top"
- android:paddingStart="@dimen/chooser_edge_margin_normal"
- android:paddingEnd="@dimen/chooser_edge_margin_normal">
+ android:gravity="start|top">
<TextView
android:id="@+id/chooser_row_text_option"
android:layout_width="match_parent"
diff --git a/core/res/res/layout/resolve_grid_item.xml b/core/res/res/layout/resolve_grid_item.xml
index 7065149e268e..256d94e5c330 100644
--- a/core/res/res/layout/resolve_grid_item.xml
+++ b/core/res/res/layout/resolve_grid_item.xml
@@ -24,8 +24,8 @@
android:gravity="center"
android:paddingTop="24dp"
android:paddingBottom="8dp"
- android:paddingLeft="2dp"
- android:paddingRight="2dp"
+ android:paddingLeft="12dp"
+ android:paddingRight="12dp"
android:focusable="true"
android:background="?attr/selectableItemBackgroundBorderless">
@@ -45,7 +45,6 @@
android:textAppearance="?attr/textAppearanceSmall"
android:textColor="?attr/textColorPrimary"
android:textSize="14sp"
- android:fontFamily="sans-serif-condensed"
android:gravity="top|center_horizontal"
android:lines="1"
android:ellipsize="end" />
@@ -54,6 +53,7 @@
<TextView android:id="@android:id/text2"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="12sp"
+ android:textColor="?attr/textColorSecondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 02cbc2e578cf..b81db158082c 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -728,6 +728,6 @@
<dimen name="chooser_preview_width">-1px</dimen>
<dimen name="resolver_icon_size">42dp</dimen>
<dimen name="resolver_badge_size">18dp</dimen>
- <dimen name="chooser_target_width">76dp</dimen>
+ <dimen name="chooser_target_width">90dp</dimen>
<dimen name="chooser_max_collapsed_height">288dp</dimen>
</resources>