summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Matt Casey <mrcasey@google.com> 2022-05-02 21:31:10 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-05-02 21:31:10 +0000
commit5850ed9a6fda3ed1e2a224eb32c145afd71a05dc (patch)
treed4d43019837a9b5549b1fe5de5299997cb280921
parent837d12a2b2c3074273be9762a4355cc7ae8d13aa (diff)
parent5e35dcd369de4f184b39aac3a3f838b3e552db4b (diff)
Merge "Convert Personal/Work tabs to rounded bubbles" into tm-dev am: 5e35dcd369
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18090806 Change-Id: Ifa18c8b7d7471f117835350d28415957494b696c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--core/java/com/android/internal/app/ChooserActivity.java7
-rw-r--r--core/java/com/android/internal/app/ResolverActivity.java43
-rw-r--r--core/res/res/color-night/resolver_accent_ripple.xml20
-rw-r--r--core/res/res/color-night/resolver_profile_tab_selected_bg.xml19
-rw-r--r--core/res/res/color-night/resolver_profile_tab_text.xml20
-rw-r--r--core/res/res/color/resolver_accent_ripple.xml20
-rw-r--r--core/res/res/color/resolver_profile_tab_selected_bg.xml19
-rw-r--r--core/res/res/color/resolver_profile_tab_text.xml20
-rw-r--r--core/res/res/drawable/resolver_profile_tab_bg.xml45
-rw-r--r--core/res/res/layout/chooser_grid.xml8
-rw-r--r--core/res/res/layout/resolver_list.xml11
-rw-r--r--core/res/res/layout/resolver_profile_tab_button.xml29
-rw-r--r--core/res/res/values/symbols.xml2
13 files changed, 214 insertions, 49 deletions
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 3cb39e725214..f0a685ec4d2e 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -2507,11 +2507,6 @@ public class ChooserActivity extends ResolverActivity implements
offset += findViewById(R.id.tabs).getHeight();
}
- View tabDivider = findViewById(R.id.resolver_tab_divider);
- if (tabDivider.getVisibility() == View.VISIBLE) {
- offset += tabDivider.getHeight();
- }
-
if (recyclerView.getVisibility() == View.VISIBLE) {
int directShareHeight = 0;
rowsToShow = Math.min(4, rowsToShow);
@@ -2700,7 +2695,7 @@ public class ChooserActivity extends ResolverActivity implements
if (mResolverDrawerLayout == null) {
return;
}
- int elevatedViewResId = shouldShowTabs() ? R.id.resolver_tab_divider : R.id.chooser_header;
+ int elevatedViewResId = shouldShowTabs() ? R.id.tabs : R.id.chooser_header;
final View elevatedView = mResolverDrawerLayout.findViewById(elevatedViewResId);
final float defaultElevation = elevatedView.getElevation();
final float chooserHeaderScrollElevation =
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 3d93b2a231c2..bd5a73d8194a 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -69,7 +69,6 @@ import android.stats.devicepolicy.DevicePolicyEnums;
import android.text.TextUtils;
import android.util.Log;
import android.util.Slog;
-import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@@ -1711,23 +1710,32 @@ public class ResolverActivity extends Activity implements
tabHost.setup();
ViewPager viewPager = findViewById(R.id.profile_pager);
viewPager.setSaveEnabled(false);
+
+ Button personalButton = (Button) getLayoutInflater().inflate(
+ R.layout.resolver_profile_tab_button, tabHost.getTabWidget(), false);
+ personalButton.setText(getPersonalTabLabel());
+ personalButton.setContentDescription(getPersonalTabAccessibilityLabel());
+
TabHost.TabSpec tabSpec = tabHost.newTabSpec(TAB_TAG_PERSONAL)
.setContent(R.id.profile_pager)
- .setIndicator(getPersonalTabLabel());
+ .setIndicator(personalButton);
tabHost.addTab(tabSpec);
+ Button workButton = (Button) getLayoutInflater().inflate(
+ R.layout.resolver_profile_tab_button, tabHost.getTabWidget(), false);
+ workButton.setText(getWorkTabLabel());
+ workButton.setContentDescription(getWorkTabAccessibilityLabel());
+
tabSpec = tabHost.newTabSpec(TAB_TAG_WORK)
.setContent(R.id.profile_pager)
- .setIndicator(getWorkTabLabel());
+ .setIndicator(workButton);
tabHost.addTab(tabSpec);
TabWidget tabWidget = tabHost.getTabWidget();
tabWidget.setVisibility(View.VISIBLE);
- resetTabsHeaderStyle(tabWidget);
updateActiveTabStyle(tabHost);
tabHost.setOnTabChangedListener(tabId -> {
- resetTabsHeaderStyle(tabWidget);
updateActiveTabStyle(tabHost);
if (TAB_TAG_PERSONAL.equals(tabId)) {
viewPager.setCurrentItem(0);
@@ -1767,7 +1775,6 @@ public class ResolverActivity extends Activity implements
workTab.setFocusableInTouchMode(true);
workTab.requestFocus();
});
- findViewById(R.id.resolver_tab_divider).setVisibility(View.VISIBLE);
}
private String getPersonalTabLabel() {
@@ -1810,22 +1817,6 @@ public class ResolverActivity extends Activity implements
}
}
- private void resetTabsHeaderStyle(TabWidget tabWidget) {
- for (int i = 0; i < tabWidget.getChildCount(); i++) {
- View tabView = tabWidget.getChildAt(i);
- TextView title = tabView.findViewById(android.R.id.title);
- title.setTextAppearance(android.R.style.TextAppearance_DeviceDefault_DialogWindowTitle);
- title.setTextColor(getAttrColor(this, android.R.attr.textColorTertiary));
- title.setTextSize(TypedValue.COMPLEX_UNIT_PX,
- getResources().getDimension(R.dimen.resolver_tab_text_size));
- if (title.getText().equals(getPersonalTabLabel())) {
- tabView.setContentDescription(getPersonalTabAccessibilityLabel());
- } else if (title.getText().equals(getWorkTabLabel())) {
- tabView.setContentDescription(getWorkTabAccessibilityLabel());
- }
- }
- }
-
private String getPersonalTabAccessibilityLabel() {
return getSystemService(DevicePolicyManager.class).getResources().getString(
RESOLVER_PERSONAL_TAB_ACCESSIBILITY,
@@ -1846,9 +1837,11 @@ public class ResolverActivity extends Activity implements
}
private void updateActiveTabStyle(TabHost tabHost) {
- TextView title = tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab())
- .findViewById(android.R.id.title);
- title.setTextColor(getAttrColor(this, android.R.attr.colorAccent));
+ int currentTab = tabHost.getCurrentTab();
+ TextView selected = (TextView) tabHost.getTabWidget().getChildAt(currentTab);
+ TextView unselected = (TextView) tabHost.getTabWidget().getChildAt(1 - currentTab);
+ selected.setSelected(true);
+ unselected.setSelected(false);
}
private void setupViewVisibilities() {
diff --git a/core/res/res/color-night/resolver_accent_ripple.xml b/core/res/res/color-night/resolver_accent_ripple.xml
new file mode 100644
index 000000000000..f0ae77fc620d
--- /dev/null
+++ b/core/res/res/color-night/resolver_accent_ripple.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2022 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.
+ -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_accent1_300"/>
+</selector>
diff --git a/core/res/res/color-night/resolver_profile_tab_selected_bg.xml b/core/res/res/color-night/resolver_profile_tab_selected_bg.xml
new file mode 100644
index 000000000000..106fe1dc2ab3
--- /dev/null
+++ b/core/res/res/color-night/resolver_profile_tab_selected_bg.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
+ <item android:color="?androidprv:attr/colorAccentSecondary"/>
+</selector>
diff --git a/core/res/res/color-night/resolver_profile_tab_text.xml b/core/res/res/color-night/resolver_profile_tab_text.xml
new file mode 100644
index 000000000000..61a5140582d0
--- /dev/null
+++ b/core/res/res/color-night/resolver_profile_tab_text.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
+ <item android:color="?androidprv:attr/textColorPrimaryInverse" android:state_selected="true"/>
+ <item android:color="?androidprv:attr/textColorSecondary"/>
+</selector>
diff --git a/core/res/res/color/resolver_accent_ripple.xml b/core/res/res/color/resolver_accent_ripple.xml
new file mode 100644
index 000000000000..d5cac384ad92
--- /dev/null
+++ b/core/res/res/color/resolver_accent_ripple.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2022 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.
+ -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_accent2_50"/>
+</selector>
diff --git a/core/res/res/color/resolver_profile_tab_selected_bg.xml b/core/res/res/color/resolver_profile_tab_selected_bg.xml
new file mode 100644
index 000000000000..e7d2f1f86d6c
--- /dev/null
+++ b/core/res/res/color/resolver_profile_tab_selected_bg.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
+ <item android:color="?androidprv:attr/colorAccentPrimary"/>
+</selector>
diff --git a/core/res/res/color/resolver_profile_tab_text.xml b/core/res/res/color/resolver_profile_tab_text.xml
new file mode 100644
index 000000000000..6b8c42d70cdf
--- /dev/null
+++ b/core/res/res/color/resolver_profile_tab_text.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
+ <item android:color="?androidprv:attr/textColorPrimary" android:state_selected="true"/>
+ <item android:color="?androidprv:attr/textColorSecondary"/>
+</selector>
diff --git a/core/res/res/drawable/resolver_profile_tab_bg.xml b/core/res/res/drawable/resolver_profile_tab_bg.xml
new file mode 100644
index 000000000000..bc9634580007
--- /dev/null
+++ b/core/res/res/drawable/resolver_profile_tab_bg.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2022 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.
+ -->
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ android:color="@color/resolver_accent_ripple">
+
+ <item android:id="@android:id/mask">
+ <shape android:shape="rectangle">
+ <corners android:radius="12dp" />
+ <solid android:color="@color/resolver_accent_ripple" />
+ </shape>
+ </item>
+
+ <item>
+ <selector android:enterFadeDuration="100">
+ <item android:state_selected="false">
+ <shape android:shape="rectangle">
+ <corners android:radius="12dp" />
+ <solid android:color="?androidprv:attr/colorSurface" />
+ </shape>
+ </item>
+
+ <item android:state_selected="true">
+ <shape android:shape="rectangle">
+ <corners android:radius="12dp" />
+ <solid android:color="@color/resolver_profile_tab_selected_bg" />
+ </shape>
+ </item>
+ </selector>
+ </item>
+
+</ripple> \ No newline at end of file
diff --git a/core/res/res/layout/chooser_grid.xml b/core/res/res/layout/chooser_grid.xml
index 933b4d243df9..6e3a11af27a7 100644
--- a/core/res/res/layout/chooser_grid.xml
+++ b/core/res/res/layout/chooser_grid.xml
@@ -81,14 +81,6 @@
android:layout_height="wrap_content"
android:visibility="gone">
</TabWidget>
- <View
- android:id="@+id/resolver_tab_divider"
- android:visibility="gone"
- android:layout_alwaysShow="true"
- android:layout_width="match_parent"
- android:layout_height="1dp"
- android:background="?attr/colorBackground"
- android:foreground="?attr/dividerVertical" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
diff --git a/core/res/res/layout/resolver_list.xml b/core/res/res/layout/resolver_list.xml
index d791598a3552..8480ec37a79e 100644
--- a/core/res/res/layout/resolver_list.xml
+++ b/core/res/res/layout/resolver_list.xml
@@ -94,15 +94,8 @@
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:visibility="gone">
- </TabWidget>
- <View
- android:id="@+id/resolver_tab_divider"
- android:visibility="gone"
- android:layout_width="match_parent"
- android:layout_height="1dp"
- android:background="?attr/colorBackground"
- android:foreground="?attr/dividerVertical"/>
+ android:tabStripEnabled="false"
+ android:visibility="gone" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
diff --git a/core/res/res/layout/resolver_profile_tab_button.xml b/core/res/res/layout/resolver_profile_tab_button.xml
new file mode 100644
index 000000000000..936c8e23b87a
--- /dev/null
+++ b/core/res/res/layout/resolver_profile_tab_button.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2022 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.
+ -->
+
+ <Button
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="0dp"
+ android:layout_height="36dp"
+ android:layout_weight="1"
+ android:layout_marginVertical="6dp"
+ android:layout_marginHorizontal="4dp"
+ android:background="@drawable/resolver_profile_tab_bg"
+ android:textColor="@color/resolver_profile_tab_text"
+ android:textSize="@dimen/resolver_tab_text_size"
+ android:textAppearance="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle"
+ style="?android:attr/borderlessButtonStyle" />
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 5827874185b8..d4407a420443 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2728,6 +2728,7 @@
<java-symbol type="attr" name="touchscreenBlocksFocus" />
<java-symbol type="layout" name="resolver_list_with_default" />
<java-symbol type="layout" name="miniresolver" />
+ <java-symbol type="layout" name="resolver_profile_tab_button" />
<java-symbol type="string" name="activity_resolver_use_always" />
<java-symbol type="string" name="whichApplicationNamed" />
<java-symbol type="string" name="whichApplicationLabel" />
@@ -4294,7 +4295,6 @@
<java-symbol type="id" name="resolver_empty_state_subtitle" />
<java-symbol type="id" name="resolver_empty_state_button" />
<java-symbol type="id" name="resolver_empty_state_progress" />
- <java-symbol type="id" name="resolver_tab_divider" />
<java-symbol type="id" name="resolver_button_bar_divider" />
<java-symbol type="id" name="resolver_empty_state_container" />
<java-symbol type="id" name="button_bar_container" />