Loading res/layout/preference_external_action_icon.xml 0 → 100644 +22 −0 Original line number Diff line number Diff line <?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" /> No newline at end of file src/com/android/settings/dashboard/DashboardFragment.java +4 −0 Original line number Diff line number Diff line Loading @@ -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()); } Loading tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java +14 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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"); Loading @@ -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"; Loading @@ -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 Loading Loading
res/layout/preference_external_action_icon.xml 0 → 100644 +22 −0 Original line number Diff line number Diff line <?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" /> No newline at end of file
src/com/android/settings/dashboard/DashboardFragment.java +4 −0 Original line number Diff line number Diff line Loading @@ -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()); } Loading
tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java +14 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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"); Loading @@ -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"; Loading @@ -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 Loading