diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-11-08 15:05:23 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-11-08 15:05:23 +0000 |
commit | d82752ff974cc6f12d02238f08becfe9117c4e87 (patch) | |
tree | 9dd64d9de4e0a749d835477dfc130aae603c7c1d | |
parent | 8083b46734fb8b0318e3ccccc5044d22530b4b70 (diff) | |
parent | 2f611f9a469713c45bc15a50162921b12c41cd9f (diff) | |
download | base-aml_net_331313030.tar.gz |
Snap for 9267292 from 2f611f9a469713c45bc15a50162921b12c41cd9f to mainline-networking-releaseaml_net_331313030aml_net_331313010
Change-Id: I9afeb76bb0ba69f632f02461e8aee1c87c6f5c5b
17 files changed, 277 insertions, 2 deletions
diff --git a/packages/PackageInstaller/res/values-te/strings.xml b/packages/PackageInstaller/res/values-te/strings.xml index c016bfc1f8bb..3344d4d90c24 100644 --- a/packages/PackageInstaller/res/values-te/strings.xml +++ b/packages/PackageInstaller/res/values-te/strings.xml @@ -73,8 +73,8 @@ <string name="uninstall_all_blocked_profile_owner" msgid="2009393666026751501">"ఈ యాప్ కొందరు వినియోగదారులకు లేదా కొన్ని ప్రొఫైళ్లకు అవసరం, ఇతరులకు అన్ఇన్స్టాల్ చేయబడింది"</string> <string name="uninstall_blocked_profile_owner" msgid="6373897407002404848">"మీ ప్రొఫైల్ కోసం ఈ యాప్ అవసరం, అందువల్ల దీన్ని అన్ఇన్స్టాల్ చేయడం కుదరదు."</string> <string name="uninstall_blocked_device_owner" msgid="6724602931761073901">"మీ పరికర నిర్వాహకులకు ఈ యాప్ అవసరం, అందువల్ల దీన్ని అన్ఇన్స్టాల్ చేయడం కుదరదు."</string> - <string name="manage_device_administrators" msgid="3092696419363842816">"పరికర నిర్వాహక యాప్లను నిర్వహించు"</string> - <string name="manage_users" msgid="1243995386982560813">"వినియోగదారులను నిర్వహించు"</string> + <string name="manage_device_administrators" msgid="3092696419363842816">"పరికర నిర్వాహక యాప్లను మేనేజ్ చేయండి"</string> + <string name="manage_users" msgid="1243995386982560813">"వినియోగదారులను మేనేజ్ చేయండి"</string> <string name="uninstall_failed_msg" msgid="2176744834786696012">"<xliff:g id="APP_NAME">%1$s</xliff:g>ని అన్ఇన్స్టాల్ చేయడం సాధ్యపడలేదు."</string> <string name="Parse_error_dlg_text" msgid="1661404001063076789">"ప్యాకేజీని అన్వయించడంలో సమస్య ఏర్పడింది."</string> <string name="wear_not_allowed_dlg_title" msgid="8664785993465117517">"Android Wear"</string> diff --git a/packages/SettingsLib/Android.bp b/packages/SettingsLib/Android.bp index 9a80b0267976..4b60341dd686 100644 --- a/packages/SettingsLib/Android.bp +++ b/packages/SettingsLib/Android.bp @@ -50,6 +50,7 @@ android_library { "SettingsLibTwoTargetPreference", "SettingsLibSettingsTransition", "SettingsLibButtonPreference", + "SettingsLibProfileSelector", "setupdesign", "zxing-core-1.7", ], diff --git a/packages/SettingsLib/ProfileSelector/Android.bp b/packages/SettingsLib/ProfileSelector/Android.bp new file mode 100644 index 000000000000..250cd755a6a6 --- /dev/null +++ b/packages/SettingsLib/ProfileSelector/Android.bp @@ -0,0 +1,27 @@ +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "frameworks_base_license" + // to get the below license kinds: + // SPDX-license-identifier-Apache-2.0 + default_applicable_licenses: ["frameworks_base_license"], +} + +android_library { + name: "SettingsLibProfileSelector", + + srcs: ["src/**/*.java"], + resource_dirs: ["res"], + + static_libs: [ + "com.google.android.material_material", + "SettingsLibSettingsTheme", + ], + + sdk_version: "system_current", + min_sdk_version: "23", + apex_available: [ + "//apex_available:platform", + "com.android.mediaprovider", + ], +} diff --git a/packages/SettingsLib/ProfileSelector/AndroidManifest.xml b/packages/SettingsLib/ProfileSelector/AndroidManifest.xml new file mode 100644 index 000000000000..a57469e39eb6 --- /dev/null +++ b/packages/SettingsLib/ProfileSelector/AndroidManifest.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2020 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. + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.settingslib.widget"> + + <uses-sdk android:minSdkVersion="23" /> +</manifest> diff --git a/packages/SettingsLib/res/color-night-v31/settingslib_tabs_indicator_color.xml b/packages/SettingsLib/ProfileSelector/res/color-night/settingslib_tabs_indicator_color.xml index 9a093601a92c..9a093601a92c 100644 --- a/packages/SettingsLib/res/color-night-v31/settingslib_tabs_indicator_color.xml +++ b/packages/SettingsLib/ProfileSelector/res/color-night/settingslib_tabs_indicator_color.xml diff --git a/packages/SettingsLib/res/color-night-v31/settingslib_tabs_text_color.xml b/packages/SettingsLib/ProfileSelector/res/color-night/settingslib_tabs_text_color.xml index 33f96df8d5b5..33f96df8d5b5 100644 --- a/packages/SettingsLib/res/color-night-v31/settingslib_tabs_text_color.xml +++ b/packages/SettingsLib/ProfileSelector/res/color-night/settingslib_tabs_text_color.xml diff --git a/packages/SettingsLib/res/color-v31/settingslib_tabs_indicator_color.xml b/packages/SettingsLib/ProfileSelector/res/color/settingslib_tabs_indicator_color.xml index 57fef52f15bd..57fef52f15bd 100644 --- a/packages/SettingsLib/res/color-v31/settingslib_tabs_indicator_color.xml +++ b/packages/SettingsLib/ProfileSelector/res/color/settingslib_tabs_indicator_color.xml diff --git a/packages/SettingsLib/res/color-v31/settingslib_tabs_text_color.xml b/packages/SettingsLib/ProfileSelector/res/color/settingslib_tabs_text_color.xml index df2346d7175e..df2346d7175e 100644 --- a/packages/SettingsLib/res/color-v31/settingslib_tabs_text_color.xml +++ b/packages/SettingsLib/ProfileSelector/res/color/settingslib_tabs_text_color.xml diff --git a/packages/SettingsLib/res/drawable-v31/settingslib_tabs_background.xml b/packages/SettingsLib/ProfileSelector/res/drawable/settingslib_tabs_background.xml index 5378eeef97e0..5378eeef97e0 100644 --- a/packages/SettingsLib/res/drawable-v31/settingslib_tabs_background.xml +++ b/packages/SettingsLib/ProfileSelector/res/drawable/settingslib_tabs_background.xml diff --git a/packages/SettingsLib/res/drawable-v31/settingslib_tabs_indicator_background.xml b/packages/SettingsLib/ProfileSelector/res/drawable/settingslib_tabs_indicator_background.xml index 9c10a5b59281..9c10a5b59281 100644 --- a/packages/SettingsLib/res/drawable-v31/settingslib_tabs_indicator_background.xml +++ b/packages/SettingsLib/ProfileSelector/res/drawable/settingslib_tabs_indicator_background.xml diff --git a/packages/SettingsLib/ProfileSelector/res/layout/tab_fragment.xml b/packages/SettingsLib/ProfileSelector/res/layout/tab_fragment.xml new file mode 100644 index 000000000000..0448c6c4f467 --- /dev/null +++ b/packages/SettingsLib/ProfileSelector/res/layout/tab_fragment.xml @@ -0,0 +1,38 @@ +<?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. + --> + +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:theme="@style/Theme.MaterialComponents.DayNight" + android:id="@+id/tab_container" + android:clipToPadding="true" + android:clipChildren="true" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <com.google.android.material.tabs.TabLayout + android:id="@+id/tabs" + style="@style/SettingsLibTabsStyle"/> + + <androidx.viewpager2.widget.ViewPager2 + android:id="@+id/view_pager" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + </androidx.viewpager2.widget.ViewPager2> +</LinearLayout>
\ No newline at end of file diff --git a/packages/SettingsLib/ProfileSelector/res/values/strings.xml b/packages/SettingsLib/ProfileSelector/res/values/strings.xml new file mode 100644 index 000000000000..68d4047a497c --- /dev/null +++ b/packages/SettingsLib/ProfileSelector/res/values/strings.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. + --> + +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + + <!-- Header for items under the personal user [CHAR LIMIT=30] --> + <string name="settingslib_category_personal">Personal</string> + <!-- Header for items under the work user [CHAR LIMIT=30] --> + <string name="settingslib_category_work">Work</string> +</resources>
\ No newline at end of file diff --git a/packages/SettingsLib/res/values-v31/styles.xml b/packages/SettingsLib/ProfileSelector/res/values/styles.xml index 0b703c99884b..0b703c99884b 100644 --- a/packages/SettingsLib/res/values-v31/styles.xml +++ b/packages/SettingsLib/ProfileSelector/res/values/styles.xml diff --git a/packages/SettingsLib/ProfileSelector/src/com/android/settingslib/widget/ProfileSelectFragment.java b/packages/SettingsLib/ProfileSelector/src/com/android/settingslib/widget/ProfileSelectFragment.java new file mode 100644 index 000000000000..ac426ed8b5d4 --- /dev/null +++ b/packages/SettingsLib/ProfileSelector/src/com/android/settingslib/widget/ProfileSelectFragment.java @@ -0,0 +1,118 @@ +/* + * 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. + */ + +package com.android.settingslib.widget; + +import android.app.Activity; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.fragment.app.Fragment; +import androidx.viewpager2.widget.ViewPager2; + +import com.google.android.material.tabs.TabLayout; +import com.google.android.material.tabs.TabLayoutMediator; + +/** + * Base fragment class for profile settings. + */ +public abstract class ProfileSelectFragment extends Fragment { + + /** + * Personal or Work profile tab of {@link ProfileSelectFragment} + * <p>0: Personal tab. + * <p>1: Work profile tab. + */ + public static final String EXTRA_SHOW_FRAGMENT_TAB = + ":settings:show_fragment_tab"; + + /** + * Used in fragment argument with Extra key EXTRA_SHOW_FRAGMENT_TAB + */ + public static final int PERSONAL_TAB = 0; + + /** + * Used in fragment argument with Extra key EXTRA_SHOW_FRAGMENT_TAB + */ + public static final int WORK_TAB = 1; + + private ViewGroup mContentView; + + private ViewPager2 mViewPager; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Defines the xml file for the fragment + mContentView = (ViewGroup) inflater.inflate(R.layout.tab_fragment, container, false); + + final Activity activity = getActivity(); + final int titleResId = getTitleResId(); + if (titleResId > 0) { + activity.setTitle(titleResId); + } + final int selectedTab = getTabId(activity, getArguments()); + + final View tabContainer = mContentView.findViewById(R.id.tab_container); + mViewPager = tabContainer.findViewById(R.id.view_pager); + mViewPager.setAdapter(new ProfileViewPagerAdapter(this)); + final TabLayout tabs = tabContainer.findViewById(R.id.tabs); + new TabLayoutMediator(tabs, mViewPager, + (tab, position) -> tab.setText(getPageTitle(position)) + ).attach(); + + tabContainer.setVisibility(View.VISIBLE); + final TabLayout.Tab tab = tabs.getTabAt(selectedTab); + tab.select(); + + return mContentView; + } + + /** + * create Personal or Work profile fragment + * <p>0: Personal profile. + * <p>1: Work profile. + */ + public abstract Fragment createFragment(int position); + + /** + * Returns a resource ID of the title + * Override this if the title needs to be updated dynamically. + */ + public int getTitleResId() { + return 0; + } + + int getTabId(Activity activity, Bundle bundle) { + if (bundle != null) { + final int extraTab = bundle.getInt(EXTRA_SHOW_FRAGMENT_TAB, -1); + if (extraTab != -1) { + return extraTab; + } + } + return PERSONAL_TAB; + } + + private CharSequence getPageTitle(int position) { + if (position == WORK_TAB) { + return getContext().getString(R.string.settingslib_category_work); + } + + return getString(R.string.settingslib_category_personal); + } +} diff --git a/packages/SettingsLib/ProfileSelector/src/com/android/settingslib/widget/ProfileViewPagerAdapter.java b/packages/SettingsLib/ProfileSelector/src/com/android/settingslib/widget/ProfileViewPagerAdapter.java new file mode 100644 index 000000000000..daf2564a674e --- /dev/null +++ b/packages/SettingsLib/ProfileSelector/src/com/android/settingslib/widget/ProfileViewPagerAdapter.java @@ -0,0 +1,43 @@ +/* + * 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. + */ + +package com.android.settingslib.widget; + +import androidx.fragment.app.Fragment; +import androidx.viewpager2.adapter.FragmentStateAdapter; + +/** + * ViewPager Adapter to handle between TabLayout and ViewPager2 + */ +public class ProfileViewPagerAdapter extends FragmentStateAdapter { + + private final ProfileSelectFragment mParentFragments; + + ProfileViewPagerAdapter(ProfileSelectFragment fragment) { + super(fragment); + mParentFragments = fragment; + } + + @Override + public Fragment createFragment(int position) { + return mParentFragments.createFragment(position); + } + + @Override + public int getItemCount() { + return 2; + } +} diff --git a/packages/SettingsLib/SelectorWithWidgetPreference/Android.bp b/packages/SettingsLib/SelectorWithWidgetPreference/Android.bp index bcc64d3cd234..b5a21bdae606 100644 --- a/packages/SettingsLib/SelectorWithWidgetPreference/Android.bp +++ b/packages/SettingsLib/SelectorWithWidgetPreference/Android.bp @@ -23,5 +23,6 @@ android_library { apex_available: [ "//apex_available:platform", "com.android.permission", + "com.android.mediaprovider", ], } diff --git a/packages/SettingsLib/SettingsTheme/Android.bp b/packages/SettingsLib/SettingsTheme/Android.bp index 8f18b9522a7f..b1eabe5b866b 100644 --- a/packages/SettingsLib/SettingsTheme/Android.bp +++ b/packages/SettingsLib/SettingsTheme/Android.bp @@ -23,5 +23,6 @@ android_library { "com.android.adservices", "com.android.cellbroadcast", "com.android.permission", + "com.android.mediaprovider", ], } |