Added action bar and some relevant styles to apk.
Test: atest
Fixes: 231982352
Change-Id: Id3d4d0f3d99801278c53ecedb4fd2117009db431
diff --git a/adservices/apk/Android.bp b/adservices/apk/Android.bp
index e71a553..cee3374 100644
--- a/adservices/apk/Android.bp
+++ b/adservices/apk/Android.bp
@@ -49,6 +49,8 @@
// TODO(b/230653497): Try to remove this.
"androidx.room_room-runtime",
"tflite_support_classifiers_java",
+ "SettingsLibActionBarShadow",
+ "SettingsLibSettingsTheme",
],
resource_dirs: ["res"],
aaptflags: [
@@ -67,6 +69,9 @@
android_library {
name: "adservices-assets",
sdk_version: "module_current",
+ static_libs: [
+ "SettingsLibSettingsTheme",
+ ],
asset_dirs: [
"assets",
],
diff --git a/adservices/apk/AndroidManifest.xml b/adservices/apk/AndroidManifest.xml
index f915df3..6766aae 100644
--- a/adservices/apk/AndroidManifest.xml
+++ b/adservices/apk/AndroidManifest.xml
@@ -87,12 +87,13 @@
<uses-permission android:name="android.permission.ADSERVICES_ACCESS_CONSENT_SERVICE" />
<application
- android:label="Android AdServices"
- android:forceQueryable="true"
- android:allowBackup="true"
- android:icon="@mipmap/ic_launcher"
- android:roundIcon="@mipmap/ic_launcher_round"
- android:supportsRtl="true">
+ android:label="Android AdServices"
+ android:forceQueryable="true"
+ android:allowBackup="true"
+ android:icon="@mipmap/ic_launcher"
+ android:roundIcon="@mipmap/ic_launcher_round"
+ android:supportsRtl="true"
+ android:theme="@style/FilterTouches">
<service android:name="com.android.adservices.adselection.AdSelectionService"
android:exported="true"
android:visibleToInstantApps="false">
@@ -149,8 +150,9 @@
<!-- Activity for Adservices Settings UI -->
<activity
- android:name="com.android.adservices.ui.settings.AdServicesSettingsActivity"
- android:exported="true">
+ android:name="com.android.adservices.ui.settings.AdServicesSettingsActivity"
+ android:exported="true"
+ android:theme="@style/Theme.AdServices.Settings">
<intent-filter android:priority="1">
<action android:name="android.adservices.ui.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/adservices/apk/build.gradle b/adservices/apk/build.gradle
index 5ca4da5..a8c5f9d 100644
--- a/adservices/apk/build.gradle
+++ b/adservices/apk/build.gradle
@@ -46,14 +46,30 @@
'../service-core/java',
'../framework/java',
'../../../../../external/guava/guava/src',
+ '../../../../../frameworks/base/packages/SettingsLib/' +
+ 'ActionBarShadow/src',
]
java.setIncludes(new HashSet([
'com/android/adservices/ui/**/*.java',
'com/android/adservices/service/consent/*.java',
'com/android/adservices/*.java',
+ 'com/android/settingslib/widget/**/*.java',
'com/google/common/collect/*.java',
]))
- res.srcDirs = ['res']
+ res.srcDirs = [
+ 'res',
+ '../../../../../frameworks/base/packages/SettingsLib/' +
+ 'SettingsTheme/res',
+ '../../../../../frameworks/base/core/res/res',
+ ]
+ resources.setIncludes(new HashSet([
+ 'drawable/*',
+ 'drawable24/*',
+ 'layout/*',
+ 'mipmap-*/*',
+ 'values/*',
+ 'xml/*',
+ ]))
}
androidTest {
diff --git a/adservices/apk/java/com/android/adservices/ui/settings/ActionDelegate.java b/adservices/apk/java/com/android/adservices/ui/settings/ActionDelegate.java
index 17a3d93..2ded5ba 100644
--- a/adservices/apk/java/com/android/adservices/ui/settings/ActionDelegate.java
+++ b/adservices/apk/java/com/android/adservices/ui/settings/ActionDelegate.java
@@ -18,7 +18,7 @@
import static com.android.adservices.ui.settings.fragments.AdServicesSettingsMainFragment.PRIVACY_SANDBOX_BETA_SWITCH_KEY;
import static com.android.adservices.ui.settings.fragments.AdServicesSettingsMainFragment.TOPICS_PREFERENCE_BUTTON_KEY;
-import android.widget.TextView;
+import android.view.View;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
@@ -186,8 +186,7 @@
}
private void configureBlockedTopicsFragmentButton(AdServicesSettingsTopicsFragment fragment) {
- TextView blockedTopicsButton =
- fragment.requireView().findViewById(R.id.blocked_topics_button);
+ View blockedTopicsButton = fragment.requireView().findViewById(R.id.blocked_topics_button);
blockedTopicsButton.setOnClickListener(
view -> {
@@ -196,7 +195,7 @@
}
private void configureResetTopicsButton(AdServicesSettingsTopicsFragment fragment) {
- TextView resetTopicsButton = fragment.requireView().findViewById(R.id.reset_topics_button);
+ View resetTopicsButton = fragment.requireView().findViewById(R.id.reset_topics_button);
resetTopicsButton.setOnClickListener(
view -> {
diff --git a/adservices/apk/java/com/android/adservices/ui/settings/fragments/AdServicesSettingsMainFragment.java b/adservices/apk/java/com/android/adservices/ui/settings/fragments/AdServicesSettingsMainFragment.java
index 96f971b..085e673 100644
--- a/adservices/apk/java/com/android/adservices/ui/settings/fragments/AdServicesSettingsMainFragment.java
+++ b/adservices/apk/java/com/android/adservices/ui/settings/fragments/AdServicesSettingsMainFragment.java
@@ -15,6 +15,7 @@
*/
package com.android.adservices.ui.settings.fragments;
+import android.app.ActionBar;
import android.os.Bundle;
import androidx.lifecycle.ViewModelProvider;
@@ -25,6 +26,7 @@
import com.android.adservices.ui.settings.ActionDelegate;
import com.android.adservices.ui.settings.AdServicesSettingsActivity;
import com.android.adservices.ui.settings.viewmodels.MainViewModel;
+import com.android.settingslib.widget.ActionBarShadowController;
import java.util.Objects;
@@ -38,6 +40,8 @@
public static final String PRIVACY_SANDBOX_BETA_SWITCH_KEY = "privacy_sandbox_beta_switch";
public static final String TOPICS_PREFERENCE_BUTTON_KEY = "topics_preference";
+ protected boolean mUseShadowController = true;
+
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.main_preferences, rootKey);
@@ -49,9 +53,31 @@
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
+ initActionBar();
initActionListeners();
}
+ /**
+ * Attaching {@link ActionBarShadowController} from SettingsLib to have the same action bar
+ * style as the Android Settings App.
+ */
+ private void initActionBar() {
+ if (getListView() != null) {
+ ActionBar ab = requireActivity().getActionBar();
+
+ if (ab != null) {
+ ab.setDisplayHomeAsUpEnabled(true);
+ ab.setTitle(R.string.settingsUI_privacy_sandbox_beta_title);
+ ab.setElevation(0);
+ }
+
+ if (mUseShadowController) {
+ ActionBarShadowController.attachToView(
+ getActivity(), getLifecycle(), getListView());
+ }
+ }
+ }
+
// initialize all action listeners
private void initActionListeners() {
ActionDelegate actionDelegate =
diff --git a/adservices/apk/java/com/android/adservices/ui/settings/viewadatpors/TopicsListViewAdapter.java b/adservices/apk/java/com/android/adservices/ui/settings/viewadatpors/TopicsListViewAdapter.java
index a3f421f..bdb22f0 100644
--- a/adservices/apk/java/com/android/adservices/ui/settings/viewadatpors/TopicsListViewAdapter.java
+++ b/adservices/apk/java/com/android/adservices/ui/settings/viewadatpors/TopicsListViewAdapter.java
@@ -18,6 +18,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -81,12 +82,12 @@
public static class TopicsViewHolder extends RecyclerView.ViewHolder {
private final TextView mTopicTextView;
- private final TextView mOptionTextView;
+ private final Button mOptionButtonView;
public TopicsViewHolder(View itemView) {
super(itemView);
mTopicTextView = itemView.findViewById(R.id.topic_text);
- mOptionTextView = itemView.findViewById(R.id.option_text);
+ mOptionButtonView = itemView.findViewById(R.id.option_button);
}
/** Set the human readable string for the topic and listener for block topic logic. */
@@ -95,14 +96,14 @@
// TODO(b/234655984): show readable string of topic
mTopicTextView.setText(Integer.toString(topic.getTopic()));
if (mIsBlockedTopicsListItem) {
- mOptionTextView.setText(R.string.settingsUI_unblock_topic_title);
- mOptionTextView.setOnClickListener(
+ mOptionButtonView.setText(R.string.settingsUI_unblock_topic_title);
+ mOptionButtonView.setOnClickListener(
view -> {
viewModel.restoreTopicConsentButtonClickHandler(topic);
});
} else {
- mOptionTextView.setText(R.string.settingsUI_block_topic_title);
- mOptionTextView.setOnClickListener(
+ mOptionButtonView.setText(R.string.settingsUI_block_topic_title);
+ mOptionButtonView.setOnClickListener(
view -> {
viewModel.revokeTopicConsentButtonClickHandler(topic);
});
diff --git a/adservices/apk/res/drawable/ic_button.xml b/adservices/apk/res/drawable/ic_button.xml
new file mode 100644
index 0000000..d079484
--- /dev/null
+++ b/adservices/apk/res/drawable/ic_button.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <corners android:radius="24dp" />
+ <stroke android:width="1px" android:color="@android:color/primary_text_light" />
+</shape>
diff --git a/adservices/apk/res/drawable/ic_chevron_right_24dp.xml b/adservices/apk/res/drawable/ic_chevron_right_24dp.xml
new file mode 100644
index 0000000..c3b0aa4
--- /dev/null
+++ b/adservices/apk/res/drawable/ic_chevron_right_24dp.xml
@@ -0,0 +1,26 @@
+<?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.
+-->
+<vector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:autoMirrored="true"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path android:fillColor="@android:color/secondary_text_light"
+ android:pathData="M9.71,18.71l-1.42,-1.42l5.3,-5.29l-5.3,-5.29l1.42,-1.42l6.7,6.71z"/>
+</vector>
diff --git a/adservices/apk/res/drawable/ic_restart_alt_24dp.xml b/adservices/apk/res/drawable/ic_restart_alt_24dp.xml
new file mode 100644
index 0000000..ce18214
--- /dev/null
+++ b/adservices/apk/res/drawable/ic_restart_alt_24dp.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="@android:color/secondary_text_light"
+ android:pathData="M6 13c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91zm14 0c0-4.42-3.58-8-8-8-.06 0-.12.01-.18.01l1.09-1.09L11.5 2.5 8 6l3.5 3.5 1.41-1.41-1.08-1.08c.06 0 .12-.01.17-.01 3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93z"/>
+</vector>
diff --git a/adservices/apk/res/layout/adservices_settings_main_activity.xml b/adservices/apk/res/layout/adservices_settings_main_activity.xml
index c3df5a6..4a117e3 100644
--- a/adservices/apk/res/layout/adservices_settings_main_activity.xml
+++ b/adservices/apk/res/layout/adservices_settings_main_activity.xml
@@ -13,10 +13,14 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-<androidx.fragment.app.FragmentContainerView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/fragment_container_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:name="com.android.adservices.ui.settings.fragments.AdServicesSettingsMainFragment" />
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:theme="@style/AdServices.Settings">
+ <androidx.fragment.app.FragmentContainerView
+ android:id="@+id/fragment_container_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:name="com.android.adservices.ui.settings.fragments.AdServicesSettingsMainFragment" />
+</LinearLayout>
diff --git a/adservices/apk/res/layout/topic_item.xml b/adservices/apk/res/layout/topic_item.xml
index cb0601e..9eafc39 100644
--- a/adservices/apk/res/layout/topic_item.xml
+++ b/adservices/apk/res/layout/topic_item.xml
@@ -13,34 +13,30 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-<RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <TextView
- android:id="@+id/topic_text"
- android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="0dp"
- android:layout_marginStart="0dp"
- android:layout_marginEnd="10dp"
- android:layout_alignParentStart="true"
- android:layout_alignParentTop="true"
- android:layout_toStartOf="@+id/option_text"
- android:paddingTop="24dp"
- android:paddingBottom="24dp"
- android:textColor="@android:color/secondary_text_light"
- android:textSize="20sp" />
+ android:gravity="center_vertical">
<TextView
- android:id="@+id/option_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentEnd="true"
- android:layout_alignParentTop="true"
- android:paddingTop="24dp"
- android:paddingBottom="24dp"
- android:text="@string/settingsUI_block_topic_title"
- android:textColor="@android:color/secondary_text_light"
- android:textSize="20sp" />
+ android:id="@+id/topic_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="0dp"
+ android:layout_marginStart="0dp"
+ android:layout_marginEnd="10dp"
+ android:layout_alignParentStart="true"
+ android:layout_alignParentTop="true"
+ android:layout_toStartOf="@+id/option_button"
+ android:paddingTop="24dp"
+ android:paddingBottom="24dp"
+ android:textColor="@android:color/primary_text_light"
+ android:textSize="20sp" />
+ <Button
+ android:id="@+id/option_button"
+ style="@style/ActionPrimaryButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentEnd="true"
+ android:layout_centerVertical="true"
+ android:background="@drawable/ic_button" />
</RelativeLayout>
diff --git a/adservices/apk/res/layout/topics_fragment.xml b/adservices/apk/res/layout/topics_fragment.xml
index 3dd3b13..91f57cb 100644
--- a/adservices/apk/res/layout/topics_fragment.xml
+++ b/adservices/apk/res/layout/topics_fragment.xml
@@ -28,24 +28,39 @@
android:layout_height="wrap_content"
android:clipToPadding="false"
android:scrollbars="none" />
- <TextView
- android:id="@+id/blocked_topics_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="24dp"
- android:paddingBottom="24dp"
- android:key="blocked_topics"
- android:text="@string/settingsUI_blocked_topics_title"
- android:textColor="@android:color/secondary_text_light"
- android:textSize="20sp" />
- <TextView
- android:id="@+id/reset_topics_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="24dp"
- android:paddingBottom="24dp"
- android:key="reset_topics"
- android:text="@string/settingsUI_reset_topics_title"
- android:textColor="@android:color/secondary_text_light"
- android:textSize="20sp" />
+
+ <LinearLayout
+ android:id="@+id/blocked_topics_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="24dp"
+ android:paddingBottom="24dp"
+ android:key="blocked_topics"
+ android:text="@string/settingsUI_blocked_topics_title"
+ android:textColor="@android:color/secondary_text_light"
+ android:textSize="20sp"
+ android:drawableStart="@drawable/ic_chevron_right_24dp"
+ android:drawablePadding="28dp"/>
+ </LinearLayout>
+ <LinearLayout
+ android:id="@+id/reset_topics_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="24dp"
+ android:paddingBottom="24dp"
+ android:key="reset_topics"
+ android:text="@string/settingsUI_reset_topics_title"
+ android:textColor="@android:color/secondary_text_light"
+ android:textSize="20sp"
+ android:drawableStart="@drawable/ic_restart_alt_24dp"
+ android:drawablePadding="28dp"/>
+ </LinearLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
diff --git a/adservices/apk/res/values/styles.xml b/adservices/apk/res/values/styles.xml
new file mode 100644
index 0000000..77a57e5
--- /dev/null
+++ b/adservices/apk/res/values/styles.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <style name="option_button_style">
+ <item name="android:textSize">14sp</item>
+ <item name="android:letterSpacing">0.02</item>
+ <item name="android:textColor">@android:color/secondary_text_light</item>
+ </style>
+
+ <style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button">
+ <item name="android:textSize">16sp</item>
+ <item name="android:minHeight">16sp</item>
+ <item name="android:paddingTop">8dp</item>
+ <item name="android:paddingBottom">8dp</item>
+ <item name="android:paddingStart">16dp</item>
+ <item name="android:paddingEnd">16dp</item>
+ <item name="android:fontFamily">@*android:string/config_bodyFontFamilyMedium</item>
+ </style>
+</resources>
diff --git a/adservices/apk/res/values/themes.xml b/adservices/apk/res/values/themes.xml
new file mode 100644
index 0000000..7a36fd5
--- /dev/null
+++ b/adservices/apk/res/values/themes.xml
@@ -0,0 +1,52 @@
+<?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.
+-->
+<resources>
+ <!-- This theme should contain attributes that should always be set despite OEM overlays. -->
+ <style name="Theme.AdServices.Settings" parent="Theme.SubSettingsBase">
+ <!-- These two attributes are required when using Toolbar as ActionBar. -->
+ <item name="android:windowActionBar">true</item>
+ <item name="android:windowNoTitle">false</item>
+ </style>
+
+ <!-- TODO(b/230373237):styling for header title, keep for future changes -->
+ <style name="TextAppearance.CategoryTitle"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textAllCaps">true</item>
+ <item name="android:textSize">11sp</item>
+ <!-- 0.8 Spacing, 0.8/11 = 0.072727273 -->
+ <item name="android:letterSpacing">0.072727273</item>
+ </style>
+
+ <style name="AdServices.Settings" parent="android:Theme.DeviceDefault.Settings">
+ <item name="android:colorBackgroundCacheHint">@null</item>
+ <item name="android:navigationBarColor">@android:color/transparent</item>
+ <item name="android:navigationBarDividerColor">@null</item>
+ <item name="android:statusBarColor">@android:color/transparent</item>
+ <item name="android:windowActionBar">false</item>
+ <item name="android:windowAnimationStyle">@null</item>
+ <item name="android:windowBackground">@android:color/transparent</item>
+ <item name="android:windowContentOverlay">@null</item>
+ <item name="android:windowDisablePreview">true</item>
+ <item name="android:windowIsTranslucent">true</item>
+ <item name="android:windowLightNavigationBar">false</item>
+ <item name="android:windowLightStatusBar">false</item>
+ <item name="android:windowNoTitle">true</item>
+ </style>
+
+ <style name="FilterTouches">
+ <item name="android:filterTouchesWhenObscured">true</item>
+ </style>
+</resources>
diff --git a/adservices/apk/tests/Android.bp b/adservices/apk/tests/Android.bp
index 64f3186..af9fe75 100644
--- a/adservices/apk/tests/Android.bp
+++ b/adservices/apk/tests/Android.bp
@@ -34,6 +34,8 @@
"androidx.test.rules",
"mockito-target-extended-minus-junit4",
"truth-prebuilt",
+ "SettingsLibActionBarShadow",
+ "SettingsLibSettingsTheme",
],
libs: [
"android.test.base",