Merge "Sharesheet - Align spacing with spec" into qt-dev am: dd0e027ca5
am: ff3160dc1a
Change-Id: I30c62d4245b750db63f323c14c496daac4a99da9
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user