Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aed7ad5a authored by Yanting Yang's avatar Yanting Yang
Browse files

Improve notification slice string on home page

Add ContextualNotificationChannelSlice to show more clear sub title on
notification slice.

Fixes: 128641319
Test: visual, robotests
Change-Id: I650102f4cde7d8d397c7a501ba9ee76c401ba9db
parent e4359a9e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
package com.android.settings.homepage.contextualcards;

import static com.android.settings.slices.CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI;
import static com.android.settings.slices.CustomSliceRegistry.CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI;
import static com.android.settings.slices.CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI;
import static com.android.settings.slices.CustomSliceRegistry.NOTIFICATION_CHANNEL_SLICE_URI;

import android.content.Context;
import android.database.ContentObserver;
@@ -208,7 +208,7 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
    private boolean isLargeCard(ContextualCard card) {
        return card.getSliceUri().equals(CONTEXTUAL_WIFI_SLICE_URI)
                || card.getSliceUri().equals(BLUETOOTH_DEVICES_SLICE_URI)
                || card.getSliceUri().equals(NOTIFICATION_CHANNEL_SLICE_URI);
                || card.getSliceUri().equals(CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI);
    }

    public interface CardContentLoaderListener {
+5 −3
Original line number Diff line number Diff line
@@ -56,10 +56,12 @@ public class SettingsContextualCardProvider extends ContextualCardProvider {
                        .setCardName(CustomSliceRegistry.BATTERY_FIX_SLICE_URI.toString())
                        .setCardCategory(ContextualCard.Category.IMPORTANT)
                        .build();
        final String contextualNotificationChannelSliceUri =
                CustomSliceRegistry.CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI.toString();
        final ContextualCard notificationChannelCard =
                ContextualCard.newBuilder()
                        .setSliceUri(CustomSliceRegistry.NOTIFICATION_CHANNEL_SLICE_URI.toString())
                        .setCardName(CustomSliceRegistry.NOTIFICATION_CHANNEL_SLICE_URI.toString())
                        .setSliceUri(contextualNotificationChannelSliceUri)
                        .setCardName(contextualNotificationChannelSliceUri)
                        .setCardCategory(ContextualCard.Category.POSSIBLE)
                        .build();
        final ContextualCardList cards = ContextualCardList.newBuilder()
+40 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.
 */

package com.android.settings.homepage.contextualcards.slices;

import android.content.Context;
import android.net.Uri;

import com.android.settings.R;
import com.android.settings.slices.CustomSliceRegistry;

public class ContextualNotificationChannelSlice extends NotificationChannelSlice {

    public ContextualNotificationChannelSlice(Context context) {
        super(context);
    }

    @Override
    public Uri getUri() {
        return CustomSliceRegistry.CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI;
    }

    @Override
    protected CharSequence getSubTitle(String packageName, int uid) {
        return mContext.getText(R.string.recently_installed_app);
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ public class NotificationChannelSlice implements CustomSliceable {
                return leftChannel.getId().compareTo(rightChannel.getId());
            };

    private final Context mContext;
    protected final Context mContext;
    @VisibleForTesting
    NotificationBackend mNotificationBackend;
    private String mPackageName;
@@ -413,7 +413,7 @@ public class NotificationChannelSlice implements CustomSliceable {
        return maxSentCountPackage;
    }

    private CharSequence getSubTitle(String packageName, int uid) {
    protected CharSequence getSubTitle(String packageName, int uid) {
        final int channelCount = mNotificationBackend.getChannelCount(packageName, uid);

        if (channelCount > DEFAULT_EXPANDED_ROW_COUNT) {
+13 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.settings.homepage.contextualcards.deviceinfo.EmergencyInfoSli
import com.android.settings.homepage.contextualcards.deviceinfo.StorageSlice;
import com.android.settings.homepage.contextualcards.slices.BatteryFixSlice;
import com.android.settings.homepage.contextualcards.slices.BluetoothDevicesSlice;
import com.android.settings.homepage.contextualcards.slices.ContextualNotificationChannelSlice;
import com.android.settings.homepage.contextualcards.slices.LowStorageSlice;
import com.android.settings.homepage.contextualcards.slices.NotificationChannelSlice;
import com.android.settings.location.LocationSlice;
@@ -94,6 +95,16 @@ public class CustomSliceRegistry {
            .appendPath("bluetooth_devices")
            .build();

    /**
     * Backing Uri for Contextual Notification channel Slice.
     */
    public static final Uri CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI = new Uri.Builder()
            .scheme(ContentResolver.SCHEME_CONTENT)
            .authority(SettingsSliceProvider.SLICE_AUTHORITY)
            .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
            .appendPath("contextual_notification_channel")
            .build();

    /**
     * Backing Uri for the Wifi Slice.
     */
@@ -318,6 +329,8 @@ public class CustomSliceRegistry {

        sUriToSlice.put(BATTERY_FIX_SLICE_URI, BatteryFixSlice.class);
        sUriToSlice.put(BLUETOOTH_DEVICES_SLICE_URI, BluetoothDevicesSlice.class);
        sUriToSlice.put(CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI,
                ContextualNotificationChannelSlice.class);
        sUriToSlice.put(CONTEXTUAL_WIFI_SLICE_URI, ContextualWifiSlice.class);
        sUriToSlice.put(DATA_USAGE_SLICE_URI, DataUsageSlice.class);
        sUriToSlice.put(DEVICE_INFO_SLICE_URI, DeviceInfoSlice.class);
Loading