Search in sources :

Example 31 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.

the class PanelFragment method createPanelContent.

private void createPanelContent() {
    final FragmentActivity activity = getActivity();
    if (activity == null) {
        return;
    }
    if (mLayoutView == null) {
        activity.finish();
        return;
    }
    final ViewGroup.LayoutParams params = mLayoutView.getLayoutParams();
    params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    mLayoutView.setLayoutParams(params);
    mPanelSlices = mLayoutView.findViewById(R.id.panel_parent_layout);
    mSeeMoreButton = mLayoutView.findViewById(R.id.see_more);
    mDoneButton = mLayoutView.findViewById(R.id.done);
    mTitleView = mLayoutView.findViewById(R.id.panel_title);
    mPanelHeader = mLayoutView.findViewById(R.id.panel_header);
    mTitleIcon = mLayoutView.findViewById(R.id.title_icon);
    mTitleGroup = mLayoutView.findViewById(R.id.title_group);
    mHeaderLayout = mLayoutView.findViewById(R.id.header_layout);
    mHeaderTitle = mLayoutView.findViewById(R.id.header_title);
    mHeaderSubtitle = mLayoutView.findViewById(R.id.header_subtitle);
    mFooterDivider = mLayoutView.findViewById(R.id.footer_divider);
    mProgressBar = mLayoutView.findViewById(R.id.progress_bar);
    mHeaderDivider = mLayoutView.findViewById(R.id.header_divider);
    // Make the panel layout gone here, to avoid janky animation when updating from old panel.
    // We will make it visible once the panel is ready to load.
    mPanelSlices.setVisibility(View.GONE);
    final Bundle arguments = getArguments();
    final String callingPackageName = arguments.getString(SettingsPanelActivity.KEY_CALLING_PACKAGE_NAME);
    mPanel = FeatureFactory.getFactory(activity).getPanelFeatureProvider().getPanel(activity, arguments);
    if (mPanel == null) {
        activity.finish();
        return;
    }
    mPanel.registerCallback(new LocalPanelCallback());
    if (mPanel instanceof LifecycleObserver) {
        getLifecycle().addObserver((LifecycleObserver) mPanel);
    }
    mMetricsProvider = FeatureFactory.getFactory(activity).getMetricsFeatureProvider();
    updateProgressBar();
    mPanelSlices.setLayoutManager(new LinearLayoutManager((activity)));
    // Add predraw listener to remove the animation and while we wait for Slices to load.
    mLayoutView.getViewTreeObserver().addOnPreDrawListener(mOnPreDrawListener);
    // Start loading Slices. When finished, the Panel will animate in.
    loadAllSlices();
    final IconCompat icon = mPanel.getIcon();
    final CharSequence title = mPanel.getTitle();
    final CharSequence subtitle = mPanel.getSubTitle();
    if (icon != null || (subtitle != null && subtitle.length() > 0)) {
        enablePanelHeader(icon, title, subtitle);
    } else {
        enableTitle(title);
    }
    mFooterDivider.setVisibility(View.GONE);
    mSeeMoreButton.setOnClickListener(getSeeMoreListener());
    mDoneButton.setOnClickListener(getCloseListener());
    if (mPanel.isCustomizedButtonUsed()) {
        enableCustomizedButton();
    } else if (mPanel.getSeeMoreIntent() == null) {
        // If getSeeMoreIntent() is null hide the mSeeMoreButton.
        mSeeMoreButton.setVisibility(View.GONE);
    }
    // Log panel opened.
    mMetricsProvider.action(0, /* attribution */
    SettingsEnums.PAGE_VISIBLE, /* opened panel - Action */
    mPanel.getMetricsCategory(), callingPackageName, 0);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) ViewGroup(android.view.ViewGroup) Bundle(android.os.Bundle) IconCompat(androidx.core.graphics.drawable.IconCompat) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) LifecycleObserver(androidx.lifecycle.LifecycleObserver)

Example 32 with IconCompat

use of androidx.core.graphics.drawable.IconCompat 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();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) ListBuilder(androidx.slice.builders.ListBuilder) Resources(android.content.res.Resources)

Example 33 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.

the class WifiCallingSliceHelper method getWifiCallingSlice.

/**
 * Builds a toggle slice where the intent takes you to the wifi calling page and the toggle
 * enables/disables wifi calling.
 */
private Slice getWifiCallingSlice(Uri sliceUri, boolean isWifiCallingEnabled, int subId) {
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
    final Resources res = getResourcesForSubId(subId);
    return new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext)).addRow(new RowBuilder().setTitle(res.getText(R.string.wifi_calling_settings_title)).addEndItem(SliceAction.createToggle(getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED), null, /* actionTitle */
    isWifiCallingEnabled)).setPrimaryAction(SliceAction.createDeeplink(getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY), icon, ListBuilder.ICON_IMAGE, res.getText(R.string.wifi_calling_settings_title)))).build();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) ListBuilder(androidx.slice.builders.ListBuilder) Resources(android.content.res.Resources) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Example 34 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.

the class WifiCallingSliceHelper method getNonActionableWifiCallingSlice.

/**
 * Returns Slice with the title and subtitle provided as arguments with wifi signal Icon.
 *
 * @param title    Title of the slice
 * @param subtitle Subtitle of the slice
 * @param sliceUri slice uri
 * @return Slice with title and subtitle
 */
private Slice getNonActionableWifiCallingSlice(CharSequence title, CharSequence subtitle, Uri sliceUri, PendingIntent primaryActionIntent) {
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
    final RowBuilder rowBuilder = new RowBuilder().setTitle(title).setPrimaryAction(SliceAction.createDeeplink(primaryActionIntent, icon, ListBuilder.SMALL_IMAGE, title));
    if (!Utils.isSettingsIntelligence(mContext)) {
        rowBuilder.setSubtitle(subtitle);
    }
    return new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext)).addRow(rowBuilder).build();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) ListBuilder(androidx.slice.builders.ListBuilder) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Example 35 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.

the class SliceBuilderUtilsTest method getSafeIcon_replacesEmptyIconWithSettingsIcon.

@Test
public void getSafeIcon_replacesEmptyIconWithSettingsIcon() {
    final int settingsIcon = R.drawable.ic_settings_accent;
    final int zeroIcon = 0x0;
    final SliceData data = getMockData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH, zeroIcon);
    final IconCompat actualIcon = SliceBuilderUtils.getSafeIcon(mContext, data);
    final int actualIconResource = actualIcon.toIcon().getResId();
    assertThat(actualIconResource).isNotEqualTo(zeroIcon);
    assertThat(actualIconResource).isEqualTo(settingsIcon);
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) Test(org.junit.Test)

Aggregations

IconCompat (androidx.core.graphics.drawable.IconCompat)102 ListBuilder (androidx.slice.builders.ListBuilder)55 PendingIntent (android.app.PendingIntent)42 SliceAction (androidx.slice.builders.SliceAction)39 Test (org.junit.Test)25 ColorInt (android.annotation.ColorInt)22 RowBuilder (androidx.slice.builders.ListBuilder.RowBuilder)21 SliceMetadata (androidx.slice.SliceMetadata)18 SliceAction (androidx.slice.core.SliceAction)18 Intent (android.content.Intent)14 Slice (androidx.slice.Slice)14 Drawable (android.graphics.drawable.Drawable)7 ShortcutInfoCompat (androidx.core.content.pm.ShortcutInfoCompat)6 SliceItem (androidx.slice.SliceItem)6 ColorDrawable (android.graphics.drawable.ColorDrawable)5 SpannableString (android.text.SpannableString)4 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)4 Resources (android.content.res.Resources)3 Bitmap (android.graphics.Bitmap)3 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)3