Merge "Convert Personal/Work tabs to rounded bubbles" into tm-dev

This commit is contained in:
Matt Casey
2022-05-02 21:05:36 +00:00
committed by Android (Google) Code Review
13 changed files with 214 additions and 49 deletions

View File

@@ -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 =

View File

@@ -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() {

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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"

View File

@@ -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"

View File

@@ -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" />

View File

@@ -2723,6 +2723,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" />
@@ -4289,7 +4290,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" />