From e541def5c5c1179431dcf677592422c51861052c Mon Sep 17 00:00:00 2001 From: tmfang Date: Tue, 20 Nov 2018 17:53:41 +0800 Subject: [PATCH 01/16] Create "on lock screen notifications" in Privacy Test: visual, robotest Bug: 116628158 Change-Id: I056f3734c591f8b300ae1003364ed4c1c2b2f9e3 --- res/xml/privacy_dashboard_settings.xml | 25 +++++++++++++ .../privacy/PrivacyDashboardFragment.java | 36 +++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml index 5d11936bf9f..79e2e714dc7 100644 --- a/res/xml/privacy_dashboard_settings.xml +++ b/res/xml/privacy_dashboard_settings.xml @@ -21,6 +21,7 @@ android:key="privacy_dashboard_page" android:title="@string/privacy_dashboard_title"> + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/android/settings/privacy/PrivacyDashboardFragment.java b/src/com/android/settings/privacy/PrivacyDashboardFragment.java index dd4c8fa03f5..91e85b3a3e6 100644 --- a/src/com/android/settings/privacy/PrivacyDashboardFragment.java +++ b/src/com/android/settings/privacy/PrivacyDashboardFragment.java @@ -22,7 +22,10 @@ import android.provider.SearchIndexableResource; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.R; import com.android.settings.dashboard.DashboardFragment; +import com.android.settings.notification.LockScreenNotificationPreferenceController; import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settingslib.core.AbstractPreferenceController; +import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.search.SearchIndexable; import java.util.ArrayList; @@ -31,6 +34,11 @@ import java.util.List; @SearchIndexable public class PrivacyDashboardFragment extends DashboardFragment { private static final String TAG = "PrivacyDashboardFragment"; + private static final String KEY_LOCK_SCREEN_NOTIFICATIONS = "privacy_lock_screen_notifications"; + private static final String KEY_WORK_PROFILE_CATEGORY = + "privacy_work_profile_notifications_category"; + private static final String KEY_NOTIFICATION_WORK_PROFILE_NOTIFICATIONS = + "privacy_lock_screen_work_profile_notifications"; @Override public int getMetricsCategory() { @@ -52,6 +60,28 @@ public class PrivacyDashboardFragment extends DashboardFragment { return R.string.help_url_privacy_dashboard; } + @Override + protected List createPreferenceControllers(Context context) { + return buildPreferenceControllers(context, getSettingsLifecycle()); + } + + private static List buildPreferenceControllers( + Context context, Lifecycle lifecycle) { + final List controllers = new ArrayList<>(); + final LockScreenNotificationPreferenceController notificationController = + new LockScreenNotificationPreferenceController(context, + KEY_LOCK_SCREEN_NOTIFICATIONS, + KEY_WORK_PROFILE_CATEGORY, + KEY_NOTIFICATION_WORK_PROFILE_NOTIFICATIONS); + if (lifecycle != null) { + lifecycle.addObserver(notificationController); + } + controllers.add(notificationController); + + return controllers; + + } + public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider() { @Override @@ -64,5 +94,11 @@ public class PrivacyDashboardFragment extends DashboardFragment { result.add(sir); return result; } + + @Override + public List createPreferenceControllers( + Context context) { + return buildPreferenceControllers(context, null); + } }; } From 17f04b66b2263a0b15c7568dd9dd83f1b31b1215 Mon Sep 17 00:00:00 2001 From: Neil Fuller Date: Fri, 16 Nov 2018 21:23:33 +0000 Subject: [PATCH 02/16] Track move of timezone classes to libcore.timezone Some time zone related libcore classes are moving from libcore.util to libcore.timezone. Bug: 119026403 Test: build only Merged-In: I920411dfa7e000a0da9678826a035e0461211619 Change-Id: I920411dfa7e000a0da9678826a035e0461211619 (cherry picked from commit 1e1961a5b30dd93560bff2301b95e6a99a603cba) --- .../datetime/timezone/model/FilteredCountryTimeZones.java | 2 +- .../settings/datetime/timezone/model/TimeZoneData.java | 6 +++--- .../settings/datetime/timezone/FixedOffsetPickerTest.java | 2 +- .../settings/datetime/timezone/RegionSearchPickerTest.java | 2 +- .../settings/datetime/timezone/model/TimeZoneDataTest.java | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java b/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java index 858c8eb1b39..6af0911b34f 100644 --- a/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java +++ b/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java @@ -16,7 +16,7 @@ package com.android.settings.datetime.timezone.model; -import libcore.util.CountryTimeZones; +import libcore.timezone.CountryTimeZones; import java.util.Collections; import java.util.List; diff --git a/src/com/android/settings/datetime/timezone/model/TimeZoneData.java b/src/com/android/settings/datetime/timezone/model/TimeZoneData.java index c9148450691..61244f291e3 100644 --- a/src/com/android/settings/datetime/timezone/model/TimeZoneData.java +++ b/src/com/android/settings/datetime/timezone/model/TimeZoneData.java @@ -18,9 +18,9 @@ package com.android.settings.datetime.timezone.model; import androidx.annotation.VisibleForTesting; import androidx.collection.ArraySet; -import libcore.util.CountryTimeZones; -import libcore.util.CountryZonesFinder; -import libcore.util.TimeZoneFinder; +import libcore.timezone.CountryTimeZones; +import libcore.timezone.CountryZonesFinder; +import libcore.timezone.TimeZoneFinder; import java.lang.ref.WeakReference; import java.util.Collections; diff --git a/tests/robotests/src/com/android/settings/datetime/timezone/FixedOffsetPickerTest.java b/tests/robotests/src/com/android/settings/datetime/timezone/FixedOffsetPickerTest.java index 9d650cc45af..00e36f92f74 100644 --- a/tests/robotests/src/com/android/settings/datetime/timezone/FixedOffsetPickerTest.java +++ b/tests/robotests/src/com/android/settings/datetime/timezone/FixedOffsetPickerTest.java @@ -22,7 +22,7 @@ import com.android.settings.datetime.timezone.BaseTimeZoneAdapter.AdapterItem; import com.android.settings.datetime.timezone.model.TimeZoneData; import com.android.settings.testutils.SettingsRobolectricTestRunner; -import libcore.util.CountryZonesFinder; +import libcore.timezone.CountryZonesFinder; import org.junit.Before; import org.junit.Test; diff --git a/tests/robotests/src/com/android/settings/datetime/timezone/RegionSearchPickerTest.java b/tests/robotests/src/com/android/settings/datetime/timezone/RegionSearchPickerTest.java index 02a3122cb9e..8810a9ff29c 100644 --- a/tests/robotests/src/com/android/settings/datetime/timezone/RegionSearchPickerTest.java +++ b/tests/robotests/src/com/android/settings/datetime/timezone/RegionSearchPickerTest.java @@ -33,7 +33,7 @@ import com.android.settings.datetime.timezone.RegionSearchPicker.RegionItem; import com.android.settings.datetime.timezone.model.TimeZoneData; import com.android.settings.testutils.SettingsRobolectricTestRunner; -import libcore.util.CountryZonesFinder; +import libcore.timezone.CountryZonesFinder; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java b/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java index 0359cfcd7ae..05cf6e534f8 100644 --- a/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java +++ b/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java @@ -26,9 +26,9 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import libcore.util.CountryTimeZones; -import libcore.util.CountryTimeZones.TimeZoneMapping; -import libcore.util.CountryZonesFinder; +import libcore.timezone.CountryTimeZones; +import libcore.timezone.CountryTimeZones.TimeZoneMapping; +import libcore.timezone.CountryZonesFinder; import java.util.ArrayList; import java.util.Arrays; From 87cd0f9db8d21ebb1843b80aadbc7f52835664b4 Mon Sep 17 00:00:00 2001 From: Yanting Yang Date: Mon, 26 Nov 2018 16:39:30 +0800 Subject: [PATCH 03/16] Modify margin for overall contextual settings home screen - Excluding margin of search bar, it will be modified by b/118886724. Bug: 119639077 Test: robotests, visual Change-Id: I6776d69842c952de04864b5439ca2cd2fbdd5e09 --- res/layout/homepage_slice_tile.xml | 2 -- res/layout/settings_homepage_container.xml | 4 +++- res/values/dimens.xml | 4 ++-- res/values/styles.xml | 1 - 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/res/layout/homepage_slice_tile.xml b/res/layout/homepage_slice_tile.xml index dbdb91bec8c..e062dbaf080 100644 --- a/res/layout/homepage_slice_tile.xml +++ b/res/layout/homepage_slice_tile.xml @@ -30,8 +30,6 @@ android:id="@+id/slice_view" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="@dimen/homepage_card_vertical_margin" - android:layout_marginTop="@dimen/homepage_card_vertical_margin" android:paddingStart="@dimen/homepage_card_padding_start" android:paddingEnd="@dimen/homepage_card_padding_end"/> diff --git a/res/layout/settings_homepage_container.xml b/res/layout/settings_homepage_container.xml index 7a84e32d61c..42b78b441cb 100644 --- a/res/layout/settings_homepage_container.xml +++ b/res/layout/settings_homepage_container.xml @@ -42,7 +42,9 @@ + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/homepage_card_side_margin" + android:layout_marginEnd="@dimen/homepage_card_side_margin"/> 24dp 8dp 2dp - 4dp - 8dp + 8dp + 4dp 16dp 16dp diff --git a/res/values/styles.xml b/res/values/styles.xml index cfc5fd3abb1..3ce11931eb4 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -482,7 +482,6 @@ + + diff --git a/res/xml/network_and_internet.xml b/res/xml/network_and_internet.xml index 8e36e919220..c21886965fa 100644 --- a/res/xml/network_and_internet.xml +++ b/res/xml/network_and_internet.xml @@ -64,7 +64,7 @@ settings:useAdminDisabledSummary="true" /> + * Displays Wifi (full Slice) and Airplane mode. + *

+ */ +public class InternetConnectivityPanel implements PanelContent { + + @VisibleForTesting + static final Uri AIRPLANE_URI = new Uri.Builder() + .scheme(ContentResolver.SCHEME_CONTENT) + .authority(SettingsSlicesContract.AUTHORITY) + .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION) + .appendPath(SettingsSlicesContract.KEY_AIRPLANE_MODE) + .build(); + + private final Context mContext; + + public static InternetConnectivityPanel create(Context context) { + return new InternetConnectivityPanel(context); + } + + private InternetConnectivityPanel(Context context) { + mContext = context.getApplicationContext(); + } + + @Override + public String getTitle() { + return (String) mContext.getText(R.string.internet_connectivity_panel_title); + } + + @Override + public List getSlices() { + final List uris = new ArrayList<>(); + uris.add(WifiSlice.WIFI_URI); + uris.add(AIRPLANE_URI); + return uris; + } + + @Override + public Intent getSeeMoreIntent() { + return null; + } +} diff --git a/src/com/android/settings/panel/PanelContent.java b/src/com/android/settings/panel/PanelContent.java new file mode 100644 index 00000000000..bd84c2fa617 --- /dev/null +++ b/src/com/android/settings/panel/PanelContent.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2018 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.settings.panel; + +import android.content.Intent; +import android.net.Uri; + +import java.util.List; + +/** + * Represents the data class needed to create a Settings Panel. See {@link PanelFragment}. + */ +public interface PanelContent { + + /** + * @return a string for the title of the Panel. + */ + CharSequence getTitle(); + + /** + * @return an ordered list of the Slices to be displayed in the Panel. The first item in the + * list is shown on top of the Panel. + */ + List getSlices(); + + + /** + * @return an {@link Intent} to the full content in Settings that is summarized by the Panel. + * + *

+ * For example, for the connectivity panel you would intent to the Network & Internet page. + *

+ */ + Intent getSeeMoreIntent(); +} diff --git a/src/com/android/settings/panel/PanelFeatureProvider.java b/src/com/android/settings/panel/PanelFeatureProvider.java new file mode 100644 index 00000000000..7d6c5581d25 --- /dev/null +++ b/src/com/android/settings/panel/PanelFeatureProvider.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2018 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.settings.panel; + +import android.content.Context; + +public interface PanelFeatureProvider { + + /** + * Returns {@link PanelContent} as specified by the {@param panelType}. + */ + PanelContent getPanel(Context context, String panelType); +} diff --git a/src/com/android/settings/panel/PanelFeatureProviderImpl.java b/src/com/android/settings/panel/PanelFeatureProviderImpl.java new file mode 100644 index 00000000000..2e840786b7f --- /dev/null +++ b/src/com/android/settings/panel/PanelFeatureProviderImpl.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2018 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.settings.panel; + +import android.content.Context; + +public class PanelFeatureProviderImpl implements PanelFeatureProvider { + + @Override + public PanelContent getPanel(Context context, String panelType) { + switch (panelType) { + case SettingsPanelActivity.PANEL_TYPE_WIFI: + return InternetConnectivityPanel.create(context); + } + + throw new IllegalStateException("No matching panel for: " + panelType); + } +} diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java new file mode 100644 index 00000000000..bbdaec351f4 --- /dev/null +++ b/src/com/android/settings/panel/PanelFragment.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2018 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.settings.panel; + +import android.net.Uri; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import android.widget.LinearLayout; + +import androidx.lifecycle.LiveData; +import androidx.slice.Slice; +import androidx.slice.widget.SliceLiveData; +import androidx.slice.widget.SliceView; + +import com.android.settings.R; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; + +import com.android.settings.overlay.FeatureFactory; + +import java.util.ArrayList; +import java.util.List; + +public class PanelFragment extends Fragment { + + private static final String TAG = "PanelFragment"; + + private List mSliceViewList; + private List> mSliceDataList; + private LinearLayout mPanelLayout; + + public PanelFragment() { + mSliceViewList = new ArrayList<>(); + mSliceDataList = new ArrayList<>(); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + final FragmentActivity activity = getActivity(); + final View view = inflater.inflate(R.layout.panel_layout, container, false); + + mPanelLayout = view.findViewById(R.id.panel_parent_layout); + final Bundle arguments = getArguments(); + + final String panelType = arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT); + + final PanelContent panel = FeatureFactory.getFactory(activity) + .getPanelFeatureProvider() + .getPanel(activity, panelType); + + activity.setTitle(panel.getTitle()); + + + for (Uri uri : panel.getSlices()) { + final SliceView sliceView = new SliceView(activity); + mPanelLayout.addView(sliceView); + final LiveData liveData = SliceLiveData.fromUri(activity, uri); + liveData.observe(this /* lifecycleOwner */, sliceView); + + mSliceDataList.add(liveData); + mSliceViewList.add(sliceView); + } + + return view; + } +} diff --git a/src/com/android/settings/panel/SettingsPanelActivity.java b/src/com/android/settings/panel/SettingsPanelActivity.java new file mode 100644 index 00000000000..db1f60d3e49 --- /dev/null +++ b/src/com/android/settings/panel/SettingsPanelActivity.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2018 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.settings.panel; + +import android.content.ComponentName; +import android.content.Intent; +import android.os.Bundle; + +import android.text.TextUtils; +import android.util.Log; +import android.view.Gravity; +import android.view.Window; +import android.view.WindowManager; + +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; + +import com.android.settings.R; + +/** + * Dialog Activity to host Settings Slices. + * + * TODO link to action / framework API + */ +public class SettingsPanelActivity extends FragmentActivity { + + private final String TAG = "panel_activity"; + + /** + * Key specifying which Panel the app is requesting. + */ + public static final String KEY_PANEL_TYPE_ARGUMENT = "PANEL_TYPE_ARGUMENT"; + + + // TODO (b/117804442) move to framework + public static final String EXTRA_PANEL_TYPE = "com.android.settings.panel.extra"; + + // TODO (b/117804442) move to framework + public static final String PANEL_TYPE_WIFI = "wifi_panel"; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final ComponentName callingActivityName = getCallingActivity(); + + if (callingActivityName == null) { + Log.e(TAG, "Must start with startActivityForResult. Closing."); + finish(); + return; + } + + final Intent callingIntent = getIntent(); + if (callingIntent == null) { + Log.e(TAG, "Null intent, closing Panel Activity"); + finish(); + return; + } + + final String typeExtra = callingIntent.getStringExtra(EXTRA_PANEL_TYPE); + if (TextUtils.isEmpty(typeExtra)) { + Log.e(TAG, "No intent passed, closing Panel Activity"); + return; + } + + setContentView(R.layout.settings_panel); + + // Move the window to the bottom of screen, and make it take up the entire screen width. + final Window window = getWindow(); + window.setGravity(Gravity.BOTTOM); + window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, + WindowManager.LayoutParams.WRAP_CONTENT); + + + final Bundle bundle = new Bundle(); + bundle.putString(KEY_PANEL_TYPE_ARGUMENT, typeExtra); + + final PanelFragment panelFragment = new PanelFragment(); + panelFragment.setArguments(bundle); + + final FragmentManager fragmentManager = getSupportFragmentManager(); + final Fragment fragment = fragmentManager.findFragmentById(R.id.main_content); + if (fragment == null) { + fragmentManager.beginTransaction().add(R.id.main_content, panelFragment).commit(); + } + } +} diff --git a/src/com/android/settings/slices/SettingsSliceProvider.java b/src/com/android/settings/slices/SettingsSliceProvider.java index fa669bb451a..952fc8b4596 100644 --- a/src/com/android/settings/slices/SettingsSliceProvider.java +++ b/src/com/android/settings/slices/SettingsSliceProvider.java @@ -427,7 +427,7 @@ public class SettingsSliceProvider extends SliceProvider { try { sliceData = mSlicesDatabaseAccessor.getSliceDataFromUri(uri); } catch (IllegalStateException e) { - Log.d(TAG, "Could not create slicedata for uri: " + uri); + Log.d(TAG, "Could not create slicedata for uri: " + uri, e); return; } diff --git a/src/com/android/settings/slices/SlicesFeatureProviderImpl.java b/src/com/android/settings/slices/SlicesFeatureProviderImpl.java index 39d385eb9d4..508eb1c1d78 100644 --- a/src/com/android/settings/slices/SlicesFeatureProviderImpl.java +++ b/src/com/android/settings/slices/SlicesFeatureProviderImpl.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2018 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.settings.slices; import android.content.Context; diff --git a/tests/robotests/assets/grandfather_not_implementing_instrumentable b/tests/robotests/assets/grandfather_not_implementing_instrumentable index 625d9ffecf2..04ef0ef9594 100644 --- a/tests/robotests/assets/grandfather_not_implementing_instrumentable +++ b/tests/robotests/assets/grandfather_not_implementing_instrumentable @@ -6,4 +6,5 @@ com.android.settings.password.ChooseLockPattern$SaveAndFinishWorker com.android.settings.RestrictedListPreference$RestrictedListPreferenceDialogFragment com.android.settings.password.ConfirmDeviceCredentialBaseFragment$LastTryDialog com.android.settings.password.CredentialCheckResultTracker -com.android.settings.dashboard.profileselector.ProfileSelectDialog \ No newline at end of file +com.android.settings.dashboard.profileselector.ProfileSelectDialog +com.android.settings.panel.PanelFragment \ No newline at end of file diff --git a/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java index 91a545c595d..46d177f88a9 100644 --- a/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java @@ -187,11 +187,4 @@ public class AirplaneModePreferenceControllerTest { new AirplaneModePreferenceController(mContext,"toggle_airplane"); assertThat(controller.isSliceable()).isTrue(); } - - @Test - public void isSliceableIncorrectKey_returnsFalse() { - final AirplaneModePreferenceController controller = - new AirplaneModePreferenceController(mContext, "bad_key"); - assertThat(controller.isSliceable()).isFalse(); - } } diff --git a/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java b/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java new file mode 100644 index 00000000000..3e210f5298c --- /dev/null +++ b/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2018 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.settings.panel; + +import static com.google.common.truth.Truth.assertThat; + +import android.net.Uri; + +import com.android.settings.testutils.SettingsRobolectricTestRunner; +import com.android.settings.wifi.WifiSlice; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RuntimeEnvironment; + +import java.util.List; + +@RunWith(SettingsRobolectricTestRunner.class) + +public class InternetConnectivityPanelTest { + + private InternetConnectivityPanel mPanel; + + @Before + public void setUp() { + mPanel = InternetConnectivityPanel.create(RuntimeEnvironment.application); + } + + @Test + public void getSlices_containsNecessarySlices() { + final List uris = mPanel.getSlices(); + + assertThat(uris).containsExactly(WifiSlice.WIFI_URI, + InternetConnectivityPanel.AIRPLANE_URI); + } +} diff --git a/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java new file mode 100644 index 00000000000..050fd0cd899 --- /dev/null +++ b/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2018 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.settings.panel; + +import static com.google.common.truth.Truth.assertThat; + +import android.content.Context; + +import com.android.settings.testutils.SettingsRobolectricTestRunner; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.robolectric.RuntimeEnvironment; + +@RunWith(SettingsRobolectricTestRunner.class) +public class PanelFeatureProviderImplTest { + + private Context mContext; + private PanelFeatureProviderImpl mProvider; + + @Before + public void setUp() { + mContext = RuntimeEnvironment.application; + mProvider = new PanelFeatureProviderImpl(); + } + + @Test + public void getPanel_internetConnectivityKey_returnsCorrectPanel() { + final PanelContent panel = mProvider.getPanel(mContext, + SettingsPanelActivity.PANEL_TYPE_WIFI); + + assertThat(panel).isInstanceOf(InternetConnectivityPanel.class); + } + +} diff --git a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java index 24db8298c80..e14ef1f4b9d 100644 --- a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java +++ b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java @@ -33,6 +33,7 @@ import com.android.settings.overlay.DockUpdaterFeatureProvider; import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.SupportFeatureProvider; import com.android.settings.overlay.SurveyFeatureProvider; +import com.android.settings.panel.PanelFeatureProvider; import com.android.settings.search.SearchFeatureProvider; import com.android.settings.security.SecurityFeatureProvider; import com.android.settings.slices.SlicesFeatureProvider; @@ -61,6 +62,7 @@ public class FakeFeatureFactory extends FeatureFactory { public final UserFeatureProvider userFeatureProvider; public final AssistGestureFeatureProvider assistGestureFeatureProvider; public final AccountFeatureProvider mAccountFeatureProvider; + public final PanelFeatureProvider mPanelFeatureProvider; public SlicesFeatureProvider slicesFeatureProvider; public SearchFeatureProvider searchFeatureProvider; @@ -102,6 +104,7 @@ public class FakeFeatureFactory extends FeatureFactory { assistGestureFeatureProvider = mock(AssistGestureFeatureProvider.class); slicesFeatureProvider = mock(SlicesFeatureProvider.class); mAccountFeatureProvider = mock(AccountFeatureProvider.class); + mPanelFeatureProvider = mock(PanelFeatureProvider.class); } @Override @@ -183,4 +186,9 @@ public class FakeFeatureFactory extends FeatureFactory { public AccountFeatureProvider getAccountFeatureProvider() { return mAccountFeatureProvider; } + + @Override + public PanelFeatureProvider getPanelFeatureProvider() { + return mPanelFeatureProvider; + } } From 7119c04794d5dc0e63fd149592afe3ad898eb1af Mon Sep 17 00:00:00 2001 From: Leon Liao Date: Thu, 22 Nov 2018 11:17:31 +0800 Subject: [PATCH 06/16] Update Strings for Accessibility Timeout Update or replace inaccurate strings in Accessibility Timeout feature. Bug: 119283926 Bug: 119835657 Test: atest AccessibilityTimeoutControllerTest Test: make RunSettingsRoboTests Change-Id: I94a972332bbc2596b57f3369ad3af4ba1d24210b --- res/values/strings.xml | 24 ++++++++++--------- ...accessibility_content_timeout_settings.xml | 4 ++-- ...accessibility_control_timeout_settings.xml | 4 ++-- res/xml/accessibility_settings.xml | 6 ++--- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 151ea149952..2b736a3cb4b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4574,22 +4574,24 @@ Combine channels when playing audio - + Default - + 10 seconds - + 30 seconds - + 1 minute - + 2 minutes - - Content Timeout - - Control Timeout - - Choose how long it takes before automatically disappearing messages go away.\nSome apps may not support this setting yet. + + Time to read + + Time to take action + + Choose how much time you want to read and take action on messages that automatically go away.\n\nSupport for this setting is up to each app. + + Choose how long to show messages that ask you to take action, but are visible only temporarily.\n\nNot all apps support this setting. Touch & hold delay diff --git a/res/xml/accessibility_content_timeout_settings.xml b/res/xml/accessibility_content_timeout_settings.xml index 51573c958e5..d4504495342 100644 --- a/res/xml/accessibility_content_timeout_settings.xml +++ b/res/xml/accessibility_content_timeout_settings.xml @@ -19,7 +19,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:key="accessibility_content_timeout_preference" - android:title="@string/accessibility_accessibility_content_timeout_preference_title" + android:title="@string/accessibility_content_timeout_preference_title" android:persistent="false" > @@ -111,8 +110,7 @@ Date: Tue, 27 Nov 2018 10:13:32 +0800 Subject: [PATCH 07/16] Update icon color for "Accessibility" and "Support & Tips" Change-Id: I8cc9f5fcb6d4ba53cebdc7b580390b0f61194c75 Fixes: 119785748 Test: robotests & visual --- color-check-baseline.xml | 4 ++-- res/values/colors.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/color-check-baseline.xml b/color-check-baseline.xml index 0ae001d4852..1a69b13adc2 100644 --- a/color-check-baseline.xml +++ b/color-check-baseline.xml @@ -1177,7 +1177,7 @@ priority="4" summary="Using hardcoded color" explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes. This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app." - errorLine1=" <color name="homepage_accessibility_background">#5011C1</color>" + errorLine1=" <color name="homepage_accessibility_background">#783BE5</color>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> #C14CE6 #0F9D58 #F15B8D - #5011C1 + #783BE5 #9E9E9E - #26459C + #3F5FBD #1A73E8 #2EC7DC #9FA8DA From 7fb3461a59f79c779c67c094eb3bac45e442216e Mon Sep 17 00:00:00 2001 From: Mill Chen Date: Thu, 15 Nov 2018 17:38:45 +0800 Subject: [PATCH 08/16] Implement the renderers for conditional header and footer Bug: 119593268 Bug: 113451905 Test: visual Change-Id: I43d6ca8508f0ba49796004d679d6cbe37ddf4455 --- .../contextualcards/ContextualCard.java | 5 +- .../ConditionContextualCardController.java | 5 + .../ConditionFooterContextualCard.java | 50 ++++++++++ ...ConditionFooterContextualCardRenderer.java | 79 +++++++++++++++ .../ConditionHeaderContextualCard.java | 66 +++++++++++++ ...ConditionHeaderContextualCardRenderer.java | 97 +++++++++++++++++++ 6 files changed, 301 insertions(+), 1 deletion(-) create mode 100644 src/com/android/settings/homepage/contextualcards/conditional/ConditionFooterContextualCard.java create mode 100644 src/com/android/settings/homepage/contextualcards/conditional/ConditionFooterContextualCardRenderer.java create mode 100644 src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCard.java create mode 100644 src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCardRenderer.java diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCard.java b/src/com/android/settings/homepage/contextualcards/ContextualCard.java index 4e4e34f282f..ca5555b855d 100644 --- a/src/com/android/settings/homepage/contextualcards/ContextualCard.java +++ b/src/com/android/settings/homepage/contextualcards/ContextualCard.java @@ -33,13 +33,16 @@ public class ContextualCard { /** * Flags indicating the type of the ContextualCard. */ - @IntDef({CardType.DEFAULT, CardType.SLICE, CardType.LEGACY_SUGGESTION, CardType.CONDITIONAL}) + @IntDef({CardType.DEFAULT, CardType.SLICE, CardType.LEGACY_SUGGESTION, CardType.CONDITIONAL, + CardType.CONDITIONAL_HEADER, CardType.CONDITIONAL_FOOTER}) @Retention(RetentionPolicy.SOURCE) public @interface CardType { int DEFAULT = 0; int SLICE = 1; int LEGACY_SUGGESTION = 2; int CONDITIONAL = 3; + int CONDITIONAL_HEADER = 4; + int CONDITIONAL_FOOTER = 5; } private final Builder mBuilder; diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java index 6fcc636d140..4eb4c6b35ba 100644 --- a/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java +++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java @@ -42,6 +42,7 @@ public class ConditionContextualCardController implements ContextualCardControll private final ConditionManager mConditionManager; private ContextualCardUpdateListener mListener; + private boolean mIsExpanded; public ConditionContextualCardController(Context context) { mContext = context; @@ -49,6 +50,10 @@ public class ConditionContextualCardController implements ContextualCardControll mConditionManager.startMonitoringStateChange(); } + public void setIsExpanded(boolean isExpanded) { + mIsExpanded = isExpanded; + } + @Override public void setCardUpdateListener(ContextualCardUpdateListener listener) { mListener = listener; diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionFooterContextualCard.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionFooterContextualCard.java new file mode 100644 index 00000000000..17a5bfa45da --- /dev/null +++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionFooterContextualCard.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2018 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.settings.homepage.contextualcards.conditional; + +import com.android.settings.homepage.contextualcards.ContextualCard; + +/** + * Data class representing a condition footer {@link ContextualCard}. + * + * Use this class for {@link ConditionFooterContextualCardRenderer} and + * {@link ConditionContextualCardController}. + */ +public class ConditionFooterContextualCard extends ContextualCard { + + private ConditionFooterContextualCard(Builder builder) { + super(builder); + } + + @Override + public int getCardType() { + return CardType.CONDITIONAL_FOOTER; + } + + public static class Builder extends ContextualCard.Builder { + + @Override + public Builder setCardType(int cardType) { + throw new IllegalArgumentException( + "Cannot change card type for " + getClass().getName()); + } + + public ConditionFooterContextualCard build() { + return new ConditionFooterContextualCard(this); + } + } +} \ No newline at end of file diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionFooterContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionFooterContextualCardRenderer.java new file mode 100644 index 00000000000..2465ca4ab75 --- /dev/null +++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionFooterContextualCardRenderer.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2018 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.settings.homepage.contextualcards.conditional; + +import android.app.settings.SettingsEnums; +import android.content.Context; +import android.view.View; + +import androidx.recyclerview.widget.RecyclerView; + +import com.android.internal.logging.nano.MetricsProto; +import com.android.settings.R; +import com.android.settings.homepage.contextualcards.ContextualCard; +import com.android.settings.homepage.contextualcards.ContextualCardRenderer; +import com.android.settings.homepage.contextualcards.ControllerRendererPool; +import com.android.settings.overlay.FeatureFactory; +import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; + +public class ConditionFooterContextualCardRenderer implements ContextualCardRenderer { + public static final int VIEW_TYPE = R.layout.homepage_condition_footer; + private static final String TAG = "ConditionFooterRenderer"; + + private final Context mContext; + private final ControllerRendererPool mControllerRendererPool; + + public ConditionFooterContextualCardRenderer(Context context, + ControllerRendererPool controllerRendererPool) { + mContext = context; + mControllerRendererPool = controllerRendererPool; + } + + @Override + public int getViewType(boolean isHalfWidth) { + return VIEW_TYPE; + } + + @Override + public RecyclerView.ViewHolder createViewHolder(View view) { + return new ConditionFooterCardHolder(view); + } + + @Override + public void bindView(RecyclerView.ViewHolder holder, ContextualCard card) { + final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory( + mContext).getMetricsFeatureProvider(); + holder.itemView.setOnClickListener(v -> { + metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN, + MetricsProto.MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND, + SettingsEnums.SETTINGS_HOMEPAGE, + null /* key */, + 0 /* false */); + final ConditionContextualCardController controller = + mControllerRendererPool.getController(mContext, + ContextualCard.CardType.CONDITIONAL_FOOTER); + controller.setIsExpanded(false); + controller.onConditionsChanged(); + }); + } + + public static class ConditionFooterCardHolder extends RecyclerView.ViewHolder { + public ConditionFooterCardHolder(View itemView) { + super(itemView); + } + } +} diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCard.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCard.java new file mode 100644 index 00000000000..f1a0fede469 --- /dev/null +++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCard.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2018 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.settings.homepage.contextualcards.conditional; + +import com.android.settings.homepage.contextualcards.ContextualCard; + +import java.util.List; + +/** + * Data class representing a condition header {@link ContextualCard}. + * + * Use this class to store additional attributes on top of {@link ContextualCard} for + * {@link ConditionHeaderContextualCardRenderer} and {@link ConditionContextualCardController}. + */ +public class ConditionHeaderContextualCard extends ContextualCard { + + private final List mConditionalCards; + + private ConditionHeaderContextualCard(Builder builder) { + super(builder); + mConditionalCards = builder.mConditionalCards; + } + + @Override + public int getCardType() { + return CardType.CONDITIONAL_HEADER; + } + + public List getConditionalCards() { + return mConditionalCards; + } + + public static class Builder extends ContextualCard.Builder { + + private List mConditionalCards; + + public Builder setConditionalCards(List conditionalCards) { + mConditionalCards = conditionalCards; + return this; + } + + @Override + public Builder setCardType(int cardType) { + throw new IllegalArgumentException( + "Cannot change card type for " + getClass().getName()); + } + + public ConditionHeaderContextualCard build() { + return new ConditionHeaderContextualCard(this); + } + } +} \ No newline at end of file diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCardRenderer.java new file mode 100644 index 00000000000..a98c82d4178 --- /dev/null +++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCardRenderer.java @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2018 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.settings.homepage.contextualcards.conditional; + +import android.app.settings.SettingsEnums; +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ImageView; +import android.widget.LinearLayout; + +import androidx.recyclerview.widget.RecyclerView; + +import com.android.internal.logging.nano.MetricsProto; +import com.android.settings.R; +import com.android.settings.homepage.contextualcards.ContextualCard; +import com.android.settings.homepage.contextualcards.ContextualCardRenderer; +import com.android.settings.homepage.contextualcards.ControllerRendererPool; +import com.android.settings.overlay.FeatureFactory; +import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; + +public class ConditionHeaderContextualCardRenderer implements ContextualCardRenderer { + public static final int VIEW_TYPE = R.layout.homepage_condition_header; + private static final String TAG = "ConditionHeaderRenderer"; + + private final Context mContext; + private final ControllerRendererPool mControllerRendererPool; + + public ConditionHeaderContextualCardRenderer(Context context, + ControllerRendererPool controllerRendererPool) { + mContext = context; + mControllerRendererPool = controllerRendererPool; + } + + @Override + public int getViewType(boolean isHalfWidth) { + return VIEW_TYPE; + } + + @Override + public RecyclerView.ViewHolder createViewHolder(View view) { + return new ConditionHeaderCardHolder(view); + } + + @Override + public void bindView(RecyclerView.ViewHolder holder, ContextualCard contextualCard) { + final ConditionHeaderContextualCard headerCard = + (ConditionHeaderContextualCard) contextualCard; + final ConditionHeaderCardHolder view = (ConditionHeaderCardHolder) holder; + final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory( + mContext).getMetricsFeatureProvider(); + view.icons.removeAllViews(); + headerCard.getConditionalCards().stream().forEach(card -> { + final ImageView icon = (ImageView) LayoutInflater.from(mContext).inflate( + R.layout.homepage_condition_header_icon, view.icons, false); + icon.setImageDrawable(card.getIconDrawable()); + view.icons.addView(icon); + }); + view.itemView.setOnClickListener(v -> { + metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN, + MetricsProto.MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND, + SettingsEnums.SETTINGS_HOMEPAGE, + null /* key */, + 1 /* true */); + final ConditionContextualCardController controller = + mControllerRendererPool.getController(mContext, + ContextualCard.CardType.CONDITIONAL_HEADER); + controller.setIsExpanded(true); + controller.onConditionsChanged(); + }); + } + + public static class ConditionHeaderCardHolder extends RecyclerView.ViewHolder { + public final LinearLayout icons; + public final ImageView expandIndicator; + + public ConditionHeaderCardHolder(View itemView) { + super(itemView); + icons = itemView.findViewById(R.id.header_icons_container); + expandIndicator = itemView.findViewById(R.id.expand_indicator); + } + } +} From 7b2529d142e8893b49d1cf7e01465411bd7d2f40 Mon Sep 17 00:00:00 2001 From: tmfang Date: Mon, 26 Nov 2018 15:09:12 +0800 Subject: [PATCH 09/16] Clean up LayoutPreference - There is no any custom preference uses R.id.all_details, so clean up some code. Test: robotest Bug: 120005054 Change-Id: Ib40483934cd6d6c0bbaa2864d40dbf09483d98aa --- src/com/android/settings/applications/LayoutPreference.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/com/android/settings/applications/LayoutPreference.java b/src/com/android/settings/applications/LayoutPreference.java index 9c3cfaf1f8d..68413e7a841 100644 --- a/src/com/android/settings/applications/LayoutPreference.java +++ b/src/com/android/settings/applications/LayoutPreference.java @@ -82,10 +82,6 @@ public class LayoutPreference extends Preference { private void setView(View view) { setLayoutResource(R.layout.layout_preference_frame); - final ViewGroup allDetails = view.findViewById(R.id.all_details); - if (allDetails != null) { - Utils.forceCustomPadding(allDetails, true /* additive padding */); - } mRootView = view; setShouldDisableView(false); } From dce94bb23762aa8292cd1fc9a4ee69cde1fa886f Mon Sep 17 00:00:00 2001 From: tmfang Date: Mon, 26 Nov 2018 18:41:01 +0800 Subject: [PATCH 10/16] Use SettingsLib's LayoutPreference - Remove LayoutPreference in Settings source code. - Remove unused style, layout - Replace old imports to com.android.settingslib.widget.LayoutPreference - Replace old XML tag to com.android.settingslib.widget.LayoutPreference Test: robotest, manual test Bug: 120005054 Change-Id: I9ae1ae14a16f443e11ac5d75b6038c7c5e253844 --- res/layout/layout_preference_frame.xml | 18 --- res/layout/settings_entity_header.xml | 105 ---------------- res/values/styles.xml | 24 ---- res/xml/account_type_settings.xml | 4 +- res/xml/app_info_settings.xml | 4 +- res/xml/app_notification_settings.xml | 4 +- res/xml/app_storage_settings.xml | 4 +- res/xml/bluetooth_device_details_fragment.xml | 2 +- res/xml/channel_notification_settings.xml | 4 +- res/xml/dream_fragment_overview.xml | 2 +- res/xml/my_device_info.xml | 2 +- res/xml/night_display_settings.xml | 2 +- res/xml/notification_group_settings.xml | 4 +- res/xml/power_usage_detail.xml | 2 +- res/xml/power_usage_details.xml | 2 +- res/xml/power_usage_summary.xml | 2 +- res/xml/security_settings_face.xml | 2 +- res/xml/usb_details_fragment.xml | 2 +- res/xml/wifi_network_details_fragment.xml | 2 +- res/xml/zen_mode_event_rule_settings.xml | 4 +- res/xml/zen_mode_schedule_rule_settings.xml | 4 +- res/xml/zen_mode_settings.xml | 2 +- .../settings/SettingsPreferenceFragment.java | 2 +- .../AccountHeaderPreferenceController.java | 2 +- .../RemoveAccountPreferenceController.java | 2 +- .../applications/AppStorageSettings.java | 1 + .../applications/LayoutPreference.java | 119 ------------------ .../AppHeaderViewPreferenceController.java | 3 +- ...InstantAppButtonsPreferenceController.java | 2 +- ...tingsRemoveButtonPreferenceController.java | 2 +- .../BluetoothDetailsHeaderController.java | 2 +- .../usb/UsbDetailsHeaderController.java | 2 +- .../aboutphone/MyDeviceInfoFragment.java | 3 +- .../display/ColorModePreferenceFragment.java | 2 +- ...DisplayActivationPreferenceController.java | 2 +- .../dream/StartNowPreferenceController.java | 2 +- .../fuelgauge/AdvancedPowerUsageDetail.java | 2 +- .../BatteryHeaderPreferenceController.java | 2 +- .../settings/fuelgauge/PowerUsageSummary.java | 2 +- .../BlockPreferenceController.java | 2 +- .../HeaderPreferenceController.java | 2 +- .../NotificationSwitchBarPreference.java | 2 +- ...tomaticRuleHeaderPreferenceController.java | 14 +-- ...tomaticRuleSwitchPreferenceController.java | 2 +- .../ZenModeButtonPreferenceController.java | 2 +- .../widget/EntityHeaderController.java | 5 +- .../widget/TwoStateButtonPreference.java | 2 +- .../WifiDetailPreferenceController.java | 2 +- ...AccountHeaderPreferenceControllerTest.java | 2 +- ...RemoveAccountPreferenceControllerTest.java | 2 +- .../applications/AppInfoWithHeaderTest.java | 1 + .../applications/LayoutPreferenceTest.java | 93 -------------- ...AppHeaderViewPreferenceControllerTest.java | 2 +- ...antAppButtonsPreferenceControllerTest.java | 2 +- .../BluetoothDetailsHeaderControllerTest.java | 2 +- .../usb/UsbDetailsHeaderControllerTest.java | 2 +- .../ColorModePreferenceFragmentTest.java | 2 +- ...layActivationPreferenceControllerTest.java | 2 +- .../StartNowPreferenceControllerTest.java | 2 +- .../AdvancedPowerUsageDetailTest.java | 2 +- ...BatteryHeaderPreferenceControllerTest.java | 2 +- .../fuelgauge/PowerUsageSummaryTest.java | 2 +- .../BlockPreferenceControllerTest.java | 2 +- .../HeaderPreferenceControllerTest.java | 2 +- .../SettingsRobolectricTestRunner.java | 2 + .../widget/EntityHeaderControllerTest.java | 2 +- .../WifiDetailPreferenceControllerTest.java | 2 +- 67 files changed, 78 insertions(+), 436 deletions(-) delete mode 100644 res/layout/layout_preference_frame.xml delete mode 100644 res/layout/settings_entity_header.xml delete mode 100644 src/com/android/settings/applications/LayoutPreference.java delete mode 100644 tests/robotests/src/com/android/settings/applications/LayoutPreferenceTest.java diff --git a/res/layout/layout_preference_frame.xml b/res/layout/layout_preference_frame.xml deleted file mode 100644 index eec3d7af345..00000000000 --- a/res/layout/layout_preference_frame.xml +++ /dev/null @@ -1,18 +0,0 @@ - - diff --git a/res/layout/settings_entity_header.xml b/res/layout/settings_entity_header.xml deleted file mode 100644 index 5f5fe004a99..00000000000 --- a/res/layout/settings_entity_header.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/values/styles.xml b/res/values/styles.xml index 3ce11931eb4..4be1bb3569e 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -331,23 +331,6 @@ ?android:attr/textColorSecondary - - - - - -