Merge "Render an additional icon to the tappable tiles with pending intents" into udc-d1-dev

This commit is contained in:
Peter Zhang
2023-05-12 12:12:21 +00:00
committed by Android (Google) Code Review
3 changed files with 40 additions and 1 deletions

View 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" />

View File

@@ -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());
}

View File

@@ -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;
@@ -353,6 +354,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");
@@ -363,7 +374,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";
@@ -380,6 +391,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