Align the "Open activity" UI style with usual accessibility service "Use service"

Root Cause: "Open activity" Preference is not part of the widget SettingsMainSwitchBarPreference, so its UI style did not be inherited.

Solution: "Open activity" has different concept from switch bar, we need to manual set its bacground to comply with the SettingsLib style.

Bug: 207067203
Test: manual test
Change-Id: I66f63f6952e5c4770509febc0e53eca6dc6eedb9
This commit is contained in:
jasonwshsu
2021-11-22 19:57:47 +08:00
parent 0a8f978357
commit a8442468ad
2 changed files with 38 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2021 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:minHeight="@dimen/settingslib_min_switch_bar_height"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_margin="@dimen/settingslib_switchbar_margin"
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
android:paddingEnd="@dimen/settingslib_switchbar_padding_right"
android:background="@drawable/settingslib_switch_bar_bg_on">
<TextView
android:id="@android:id/title"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginEnd="@dimen/settingslib_switch_title_margin"
android:layout_marginVertical="@dimen/settingslib_switch_title_margin"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceListItem"
style="@style/MainSwitchText.Settingslib" />
</LinearLayout>

View File

@@ -150,6 +150,7 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
private void initLaunchPreference() {
final Preference launchPreference = new Preference(getPrefContext());
launchPreference.setLayoutResource(R.layout.accessibility_launch_activity_preference);
launchPreference.setKey(KEY_LAUNCH_PREFERENCE);
final AccessibilityShortcutInfo info = getAccessibilityShortcutInfo();