Render an additional icon to the tappable tiles with pending intents
Test: robotest, manual Bug: 281517110 Change-Id: Ia5fbae63d56a6f1e6ee8fb3ee58ae912d14b6c75
This commit is contained in:
22
res/layout/preference_external_action_icon.xml
Normal file
22
res/layout/preference_external_action_icon.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2023 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.
|
||||
-->
|
||||
|
||||
<ImageView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:src="@drawable/ic_chevron_right_24dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="8dp" />
|
@@ -573,6 +573,10 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
||||
return (tile instanceof ActivityTile || tile.hasPendingIntent())
|
||||
? new PrimarySwitchPreference(getPrefContext())
|
||||
: new SwitchPreference(getPrefContext());
|
||||
} else if (tile.hasPendingIntent()) {
|
||||
Preference preference = new Preference(getPrefContext());
|
||||
preference.setWidgetLayoutResource(R.layout.preference_external_action_icon);
|
||||
return preference;
|
||||
} else {
|
||||
return new Preference(getPrefContext());
|
||||
}
|
||||
|
@@ -49,6 +49,7 @@ import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.slices.BlockingSlicePrefController;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
@@ -351,6 +352,16 @@ public class DashboardFragmentTest {
|
||||
assertThat(pref).isInstanceOf(SwitchPreference.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createPreference_isActivityTile_returnPreference() {
|
||||
final Preference pref = mTestFragment.createPreference(mActivityTile);
|
||||
|
||||
assertThat(pref).isInstanceOf(Preference.class);
|
||||
assertThat(pref).isNotInstanceOf(PrimarySwitchPreference.class);
|
||||
assertThat(pref).isNotInstanceOf(SwitchPreference.class);
|
||||
assertThat(pref.getWidgetLayoutResource()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createPreference_isActivityTileAndHasSwitch_returnPrimarySwitchPreference() {
|
||||
mActivityTile.getMetaData().putString(META_DATA_PREFERENCE_SWITCH_URI, "uri");
|
||||
@@ -361,7 +372,7 @@ public class DashboardFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createPreference_isProviderTileWithPendingIntent_returnPreference() {
|
||||
public void createPreference_isProviderTileWithPendingIntent_returnPreferenceWithIcon() {
|
||||
final ProviderInfo providerInfo = new ProviderInfo();
|
||||
providerInfo.packageName = "pkg";
|
||||
providerInfo.name = "provider";
|
||||
@@ -378,6 +389,8 @@ public class DashboardFragmentTest {
|
||||
assertThat(pref).isInstanceOf(Preference.class);
|
||||
assertThat(pref).isNotInstanceOf(PrimarySwitchPreference.class);
|
||||
assertThat(pref).isNotInstanceOf(SwitchPreference.class);
|
||||
assertThat(pref.getWidgetLayoutResource())
|
||||
.isEqualTo(R.layout.preference_external_action_icon);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user