use of androidx.slice.builders.ListBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ZenModeSliceBuilder method getSlice.
/**
* Return a ZenMode Slice bound to {@link CustomSliceRegistry#ZEN_MODE_URI}.
* <p>
* Note that you should register a listener for {@link #INTENT_FILTER} to get changes for
* ZenMode.
*/
public static Slice getSlice(Context context) {
final boolean isZenModeEnabled = isZenModeEnabled(context);
final CharSequence title = context.getText(R.string.zen_mode_settings_title);
final CharSequence subtitle = context.getText(R.string.zen_mode_slice_subtitle);
@ColorInt final int color = Utils.getColorAccentDefaultColor(context);
final PendingIntent toggleAction = getBroadcastIntent(context);
final PendingIntent primaryAction = getPrimaryAction(context);
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, (IconCompat) null, /* icon */
ListBuilder.ICON_IMAGE, title);
final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction, null, /* actionTitle */
isZenModeEnabled);
return new ListBuilder(context, CustomSliceRegistry.ZEN_MODE_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(title).setSubtitle(subtitle).addEndItem(toggleSliceAction).setPrimaryAction(primarySliceAction)).build();
}
use of androidx.slice.builders.ListBuilder in project android_packages_apps_Settings by omnirom.
the class FaceSetupSlice method getSlice.
@Override
public Slice getSlice() {
mFaceManager = Utils.getFaceManagerOrNull(mContext);
if (mFaceManager == null) {
return new ListBuilder(mContext, CustomSliceRegistry.FACE_ENROLL_SLICE_URI, ListBuilder.INFINITY).setIsError(true).build();
}
final int userId = UserHandle.myUserId();
final boolean hasEnrolledTemplates = mFaceManager.hasEnrolledTemplates(userId);
final int shouldReEnroll = FaceSetupSlice.getReEnrollSetting(mContext, userId);
CharSequence title = "";
CharSequence subtitle = "";
// stay the same.
if (!hasEnrolledTemplates) {
title = mContext.getText(R.string.security_settings_face_settings_enroll);
subtitle = mContext.getText(R.string.security_settings_face_settings_context_subtitle);
} else if (shouldReEnroll == FACE_RE_ENROLL_SUGGESTED) {
title = mContext.getText(R.string.security_settings_face_enroll_should_re_enroll_title);
subtitle = mContext.getText(R.string.security_settings_face_enroll_should_re_enroll_subtitle);
} else if (shouldReEnroll == FACE_RE_ENROLL_REQUIRED) {
title = mContext.getText(R.string.security_settings_face_enroll_must_re_enroll_title);
subtitle = mContext.getText(R.string.security_settings_face_enroll_must_re_enroll_subtitle);
} else {
return new ListBuilder(mContext, CustomSliceRegistry.FACE_ENROLL_SLICE_URI, ListBuilder.INFINITY).setIsError(true).build();
}
final ListBuilder listBuilder = new ListBuilder(mContext, CustomSliceRegistry.FACE_ENROLL_SLICE_URI, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext));
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_face_24dp);
return listBuilder.addRow(buildRowBuilder(title, subtitle, icon, mContext, getIntent())).build();
}
use of androidx.slice.builders.ListBuilder in project android_packages_apps_Settings by omnirom.
the class ZenModeSliceBuilder method getSlice.
/**
* Return a ZenMode Slice bound to {@link CustomSliceRegistry#ZEN_MODE_URI}.
* <p>
* Note that you should register a listener for {@link #INTENT_FILTER} to get changes for
* ZenMode.
*/
public static Slice getSlice(Context context) {
final boolean isZenModeEnabled = isZenModeEnabled(context);
final CharSequence title = context.getText(R.string.zen_mode_settings_title);
final CharSequence subtitle = context.getText(R.string.zen_mode_slice_subtitle);
@ColorInt final int color = Utils.getColorAccentDefaultColor(context);
final PendingIntent toggleAction = getBroadcastIntent(context);
final PendingIntent primaryAction = getPrimaryAction(context);
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, (IconCompat) null, /* icon */
ListBuilder.ICON_IMAGE, title);
final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction, null, /* actionTitle */
isZenModeEnabled);
final RowBuilder rowBuilder = new RowBuilder().setTitle(title).addEndItem(toggleSliceAction).setPrimaryAction(primarySliceAction);
if (!Utils.isSettingsIntelligence(context)) {
rowBuilder.setSubtitle(subtitle);
}
return new ListBuilder(context, CustomSliceRegistry.ZEN_MODE_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(rowBuilder).build();
}
use of androidx.slice.builders.ListBuilder in project android_packages_apps_Settings by omnirom.
the class ProviderModelSliceTest method setUp.
@Before
@UiThreadTest
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
mFeatureFactory = FakeFeatureFactory.setupForTest();
when(mFeatureFactory.wifiTrackerLibProvider.createWifiPickerTracker(any(), any(), any(), any(), any(), anyLong(), anyLong(), any())).thenReturn(mWifiPickerTracker);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mConnectivityManager);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
when(mWifiManager.isWifiEnabled()).thenReturn(true);
// Set-up specs for SliceMetadata.
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
mMockNetworkProviderWorker = spy(new MockNetworkProviderWorker(mContext, PROVIDER_MODEL_SLICE_URI));
mMockProviderModelSlice = spy(new MockProviderModelSlice(mContext, mMockNetworkProviderWorker));
mMockAlertDialog = new AlertDialog.Builder(mContext).setTitle("").create();
mMockAlertDialog = spy(mMockAlertDialog);
mMockProviderModelSlice.setMobileDataDisableDialog(mMockAlertDialog);
mListBuilder = spy(new ListBuilder(mContext, PROVIDER_MODEL_SLICE_URI, ListBuilder.INFINITY).setAccentColor(-1));
when(mProviderModelSliceHelper.createListBuilder(PROVIDER_MODEL_SLICE_URI)).thenReturn(mListBuilder);
when(mProviderModelSliceHelper.getSubscriptionManager()).thenReturn(mSubscriptionManager);
mWifiList = new ArrayList<>();
mMockNetworkProviderWorker.updateSelfResults(mWifiList);
mockBuilder();
}
use of androidx.slice.builders.ListBuilder in project android_packages_apps_Settings by omnirom.
the class WifiCallingSliceHelper method getWifiCallingPreferenceSlice.
/**
* Returns actionable wifi calling preference slice.
*
* @param isWifiOnlySupported adds row for wifi only if this is true
* @param currentWfcPref current Preference {@link ImsConfig}
* @param sliceUri sliceUri
* @param subId subscription id
* @return Slice for actionable wifi calling preference settings
*/
private Slice getWifiCallingPreferenceSlice(boolean isWifiOnlySupported, int currentWfcPref, Uri sliceUri, int subId) {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
final Resources res = getResourcesForSubId(subId);
// Top row shows information on current preference state
final ListBuilder listBuilder = new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext));
final ListBuilder.HeaderBuilder headerBuilder = new ListBuilder.HeaderBuilder().setTitle(res.getText(R.string.wifi_calling_mode_title)).setPrimaryAction(SliceAction.createDeeplink(getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY), icon, ListBuilder.ICON_IMAGE, res.getText(R.string.wifi_calling_mode_title)));
if (!Utils.isSettingsIntelligence(mContext)) {
headerBuilder.setSubtitle(getWifiCallingPreferenceSummary(currentWfcPref, subId));
}
listBuilder.setHeader(headerBuilder);
if (isWifiOnlySupported) {
listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder, com.android.internal.R.string.wfc_mode_wifi_only_summary, ACTION_WIFI_CALLING_PREFERENCE_WIFI_ONLY, currentWfcPref == ImsMmTelManager.WIFI_MODE_WIFI_ONLY, subId));
}
listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder, com.android.internal.R.string.wfc_mode_wifi_preferred_summary, ACTION_WIFI_CALLING_PREFERENCE_WIFI_PREFERRED, currentWfcPref == ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED, subId));
listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder, com.android.internal.R.string.wfc_mode_cellular_preferred_summary, ACTION_WIFI_CALLING_PREFERENCE_CELLULAR_PREFERRED, currentWfcPref == ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, subId));
return listBuilder.build();
}
Aggregations