diff options
| -rw-r--r-- | core/java/com/android/internal/app/ChooserActivity.java | 37 | ||||
| -rw-r--r-- | core/res/res/layout/chooser_row.xml | 6 | ||||
| -rw-r--r-- | core/res/res/layout/resolve_grid_item.xml | 7 | ||||
| -rw-r--r-- | core/res/res/values/dimens.xml | 2 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 1 |
5 files changed, 43 insertions, 10 deletions
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index ece498191a18..54afc9553b0f 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -69,7 +69,10 @@ import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; import android.widget.AbsListView; import android.widget.BaseAdapter; +import android.widget.LinearLayout; import android.widget.ListView; +import android.widget.Space; + import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.app.ResolverActivity.TargetInfo; @@ -1412,6 +1415,10 @@ public class ChooserActivity extends ResolverActivity { } else { lp.height = v.getMeasuredHeight(); } + if (i != (mColumnCount - 1)) { + row.addView(new Space(ChooserActivity.this), + new LinearLayout.LayoutParams(0, 0, 1)); + } } // Pre-measure so we can scale later. @@ -1439,13 +1446,34 @@ public class ChooserActivity extends ResolverActivity { if (startType == ChooserListAdapter.TARGET_SERVICE) { holder.row.setBackgroundColor( getColor(R.color.chooser_service_row_background_color)); + int nextStartType = mChooserListAdapter.getPositionTargetType( + getFirstRowPosition(rowPosition + 1)); + int serviceSpacing = holder.row.getContext().getResources() + .getDimensionPixelSize(R.dimen.chooser_service_spacing); + int top = rowPosition == 0 ? serviceSpacing : 0; + if (nextStartType != ChooserListAdapter.TARGET_SERVICE) { + setVertPadding(holder, top, serviceSpacing); + } else { + setVertPadding(holder, top, 0); + } } else { holder.row.setBackgroundColor(Color.TRANSPARENT); + int lastStartType = mChooserListAdapter.getPositionTargetType( + getFirstRowPosition(rowPosition - 1)); + if (lastStartType == ChooserListAdapter.TARGET_SERVICE || rowPosition == 0) { + int serviceSpacing = holder.row.getContext().getResources() + .getDimensionPixelSize(R.dimen.chooser_service_spacing); + setVertPadding(holder, serviceSpacing, 0); + } else { + setVertPadding(holder, 0, 0); + } } final int oldHeight = holder.row.getLayoutParams().height; + int measuredRowHeight = holder.measuredRowHeight + holder.row.getPaddingTop() + + holder.row.getPaddingBottom(); holder.row.getLayoutParams().height = Math.max(1, - (int) (holder.measuredRowHeight * getRowScale(rowPosition))); + (int) (measuredRowHeight * getRowScale(rowPosition))); if (holder.row.getLayoutParams().height != oldHeight) { holder.row.requestLayout(); } @@ -1457,11 +1485,16 @@ public class ChooserActivity extends ResolverActivity { holder.itemIndices[i] = start + i; mChooserListAdapter.bindView(holder.itemIndices[i], v); } else { - v.setVisibility(View.GONE); + v.setVisibility(View.INVISIBLE); } } } + private void setVertPadding(RowViewHolder holder, int top, int bottom) { + holder.row.setPadding(holder.row.getPaddingLeft(), top, + holder.row.getPaddingRight(), bottom); + } + int getFirstRowPosition(int row) { final int callerCount = mChooserListAdapter.getCallerTargetCount(); final int callerRows = (int) Math.ceil((float) callerCount / mColumnCount); diff --git a/core/res/res/layout/chooser_row.xml b/core/res/res/layout/chooser_row.xml index 9baa32c67f3f..6c1271d6d72b 100644 --- a/core/res/res/layout/chooser_row.xml +++ b/core/res/res/layout/chooser_row.xml @@ -18,11 +18,9 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" - android:layout_width="match_parent" android:layout_height="wrap_content" - android:minHeight="80dp" + android:layout_width="match_parent" + android:layout_height="100dp" android:gravity="start|top" - android:paddingTop="8dp" - android:paddingBottom="8dp" android:paddingStart="@dimen/chooser_grid_padding" android:paddingEnd="@dimen/chooser_grid_padding" android:weightSum="4"> diff --git a/core/res/res/layout/resolve_grid_item.xml b/core/res/res/layout/resolve_grid_item.xml index 305c8b0a0c0f..71c153fa6021 100644 --- a/core/res/res/layout/resolve_grid_item.xml +++ b/core/res/res/layout/resolve_grid_item.xml @@ -18,10 +18,9 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="0dp" + android:layout_width="76dp" android:layout_height="wrap_content" - android:layout_weight="1" - android:minWidth="80dp" + android:minHeight="100dp" android:gravity="center" android:paddingTop="8dp" android:paddingBottom="8dp" @@ -49,7 +48,7 @@ <TextView android:id="@android:id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="8dp" + android:layout_marginTop="4dp" android:layout_marginLeft="4dp" android:layout_marginRight="4dp" android:textAppearance="?attr/textAppearanceSmall" diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index fa33d567983e..9f9c883fe6aa 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -533,6 +533,8 @@ <dimen name="content_rect_bottom_clip_allowance">20dp</dimen> <dimen name="chooser_grid_padding">0dp</dimen> + <!-- Spacing around the background change frome service to non-service --> + <dimen name="chooser_service_spacing">8dp</dimen> <item type="dimen" name="aerr_padding_list_top">15dp</item> <item type="dimen" name="aerr_padding_list_bottom">8dp</item> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 744393565b4a..63c122dcbb14 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3059,4 +3059,5 @@ <java-symbol type="array" name="config_batteryPackageTypeService" /> <java-symbol type="bool" name="config_showAreaUpdateInfoSettings" /> <java-symbol type="layout" name="shutdown_dialog" /> + <java-symbol type="dimen" name="chooser_service_spacing" /> </resources> |