summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Matt Casey <mrcasey@google.com> 2022-05-24 01:01:44 +0000
committer Matt Casey <mrcasey@google.com> 2022-05-24 01:01:44 +0000
commit80ef161e48d73cb83ee9e5162ce099a148a3aed6 (patch)
tree54d2370c3801ba80a990dbab722f0eda6939dbf5
parentbf1f22d0a40da6d48e48ee95438b45a148e0c042 (diff)
Align outer edge of profile tabs and icons
Previously tabs were full-width, now they align with the outer edges of icons. In ResovlerActivity, this is constant. In ChooserActivity, the placement of the icons is based upon the icon count and layout width, so it must be computed at runtime. Bug: 233330219 Test: Manually with various orientations across Chooser and Resolver. Test: atest ResolverActivityTest, atest ChooserActivityTest Change-Id: I2009211c277f6ea0b3f14a06a54e82f4c190c564
-rw-r--r--core/java/com/android/internal/app/ChooserActivity.java17
-rw-r--r--core/res/res/layout/resolver_list.xml2
-rw-r--r--core/res/res/layout/resolver_profile_tab_button.xml2
-rw-r--r--core/res/res/values/dimens.xml1
-rw-r--r--core/res/res/values/symbols.xml1
5 files changed, 22 insertions, 1 deletions
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 468293862cd3..61c844ac8170 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -1002,6 +1002,7 @@ public class ChooserActivity extends ResolverActivity implements
mMaxTargetsPerRow = getResources().getInteger(R.integer.config_chooser_max_targets_per_row);
adjustPreviewWidth(newConfig.orientation, null);
updateStickyContentPreview();
+ updateTabPadding();
}
private boolean shouldDisplayLandscape(int orientation) {
@@ -1024,6 +1025,20 @@ public class ChooserActivity extends ResolverActivity implements
updateLayoutWidth(R.id.content_preview_file_layout, width, parent);
}
+ private void updateTabPadding() {
+ if (shouldShowTabs()) {
+ View tabs = findViewById(R.id.tabs);
+ float iconSize = getResources().getDimension(R.dimen.chooser_icon_size);
+ // The entire width consists of icons or padding. Divide the item padding in half to get
+ // paddingHorizontal.
+ float padding = (tabs.getWidth() - mMaxTargetsPerRow * iconSize)
+ / mMaxTargetsPerRow / 2;
+ // Subtract the margin the buttons already have.
+ padding -= getResources().getDimension(R.dimen.resolver_profile_tab_margin);
+ tabs.setPadding((int) padding, 0, (int) padding, 0);
+ }
+ }
+
private void updateLayoutWidth(int layoutResourceId, int width, View parent) {
View view = parent.findViewById(layoutResourceId);
if (view != null && view.getLayoutParams() != null) {
@@ -2480,6 +2495,8 @@ public class ChooserActivity extends ResolverActivity implements
recyclerView.setAdapter(gridAdapter);
((GridLayoutManager) recyclerView.getLayoutManager()).setSpanCount(
mMaxTargetsPerRow);
+
+ updateTabPadding();
}
UserHandle currentUserHandle = mChooserMultiProfilePagerAdapter.getCurrentUserHandle();
diff --git a/core/res/res/layout/resolver_list.xml b/core/res/res/layout/resolver_list.xml
index 8480ec37a79e..6a200d05c2d7 100644
--- a/core/res/res/layout/resolver_list.xml
+++ b/core/res/res/layout/resolver_list.xml
@@ -90,11 +90,13 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
+ <!-- horizontal padding = 8dp content padding - 4dp margin that tab buttons have. -->
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:tabStripEnabled="false"
+ android:paddingHorizontal="4dp"
android:visibility="gone" />
<FrameLayout
android:id="@android:id/tabcontent"
diff --git a/core/res/res/layout/resolver_profile_tab_button.xml b/core/res/res/layout/resolver_profile_tab_button.xml
index 936c8e23b87a..fd168e6414f1 100644
--- a/core/res/res/layout/resolver_profile_tab_button.xml
+++ b/core/res/res/layout/resolver_profile_tab_button.xml
@@ -21,7 +21,7 @@
android:layout_height="36dp"
android:layout_weight="1"
android:layout_marginVertical="6dp"
- android:layout_marginHorizontal="4dp"
+ android:layout_marginHorizontal="@dimen/resolver_profile_tab_margin"
android:background="@drawable/resolver_profile_tab_bg"
android:textColor="@color/resolver_profile_tab_text"
android:textSize="@dimen/resolver_tab_text_size"
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 211bf7f7b581..f3a8e48014c7 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -962,6 +962,7 @@
<dimen name="resolver_title_padding_bottom">0dp</dimen>
<dimen name="resolver_empty_state_container_padding_top">48dp</dimen>
<dimen name="resolver_empty_state_container_padding_bottom">8dp</dimen>
+ <dimen name="resolver_profile_tab_margin">4dp</dimen>
<dimen name="chooser_action_button_icon_size">18dp</dimen>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index e111ee184be1..137767dbbba4 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -4315,6 +4315,7 @@
<java-symbol type="dimen" name="resolver_title_padding_bottom" />
<java-symbol type="dimen" name="resolver_empty_state_container_padding_top" />
<java-symbol type="dimen" name="resolver_empty_state_container_padding_bottom" />
+ <java-symbol type="dimen" name="resolver_profile_tab_margin" />
<java-symbol type="string" name="config_deviceSpecificDisplayAreaPolicyProvider" />