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

Commit d5a37965 authored by Flavio Fiszman's avatar Flavio Fiszman
Browse files

Prompt People tile on marking as priority

Change-Id: I4ee1566762d381b6288e3b19c89db904a5d86d8b
Test: manual
Bug: 182570341
parent 502bae3d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -602,6 +602,9 @@
                android:resource="@xml/people_space_widget_info" />
        </receiver>

        <receiver android:name=".people.widget.PeopleSpaceWidgetPinnedReceiver"
            android:enabled="true"/>

        <!-- Widget service -->
        <service android:name=".people.widget.PeopleSpaceWidgetService"
            android:permission="android.permission.BIND_REMOTEVIEWS"
+2 −2
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ public final class Prefs {
            Key.HAS_SEEN_ODI_CAPTIONS_TOOLTIP,
            Key.HAS_SEEN_REVERSE_BOTTOM_SHEET,
            Key.CONTROLS_STRUCTURE_SWIPE_TOOLTIP_COUNT,
            Key.HAS_SEEN_PRIORITY_ONBOARDING
            Key.HAS_SEEN_PRIORITY_ONBOARDING_IN_S
    })
    // TODO: annotate these with their types so {@link PrefsCommandLine} can know how to set them
    public @interface Key {
@@ -124,7 +124,7 @@ public final class Prefs {
        String HAS_SEEN_REVERSE_BOTTOM_SHEET = "HasSeenReverseBottomSheet";
        String CONTROLS_STRUCTURE_SWIPE_TOOLTIP_COUNT = "ControlsStructureSwipeTooltipCount";
        /** Tracks whether the user has seen the onboarding screen for priority conversations */
        String HAS_SEEN_PRIORITY_ONBOARDING = "HasUserSeenPriorityOnboarding";
        String HAS_SEEN_PRIORITY_ONBOARDING_IN_S = "HasUserSeenPriorityOnboardingInS";
    }

    public static boolean getBoolean(Context context, @Key String key, boolean defaultValue) {
+10 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.dagger;
import android.content.BroadcastReceiver;

import com.android.systemui.media.dialog.MediaOutputDialogReceiver;
import com.android.systemui.people.widget.PeopleSpaceWidgetPinnedReceiver;
import com.android.systemui.screenshot.ActionProxyReceiver;
import com.android.systemui.screenshot.DeleteScreenshotReceiver;
import com.android.systemui.screenshot.SmartActionsReceiver;
@@ -69,4 +70,13 @@ public abstract class DefaultBroadcastReceiverBinder {
    public abstract BroadcastReceiver bindMediaOutputDialogReceiver(
            MediaOutputDialogReceiver broadcastReceiver);

    /**
     *
     */
    @Binds
    @IntoMap
    @ClassKey(PeopleSpaceWidgetPinnedReceiver.class)
    public abstract BroadcastReceiver bindPeopleSpaceWidgetPinnedReceiver(
            PeopleSpaceWidgetPinnedReceiver broadcastReceiver);

}
+15 −28
Original line number Diff line number Diff line
@@ -16,9 +16,7 @@

package com.android.systemui.people;

import android.app.people.ConversationChannel;
import android.app.people.IPeopleManager;
import android.app.people.PeopleSpaceTile;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
@@ -33,13 +31,16 @@ import android.os.UserHandle;
import android.util.Log;
import android.widget.RemoteViews;

import com.android.systemui.Dependency;
import com.android.systemui.shared.system.PeopleProviderUtils;
import com.android.systemui.statusbar.notification.NotificationEntryManager;

/** API that returns a People Tile preview. */
public class PeopleProvider extends ContentProvider {

    LauncherApps mLauncherApps;
    IPeopleManager mPeopleManager;
    NotificationEntryManager mNotificationEntryManager;

    private static final String TAG = "PeopleProvider";
    private static final boolean DEBUG = PeopleSpaceUtils.DEBUG;
@@ -57,18 +58,6 @@ public class PeopleProvider extends ContentProvider {
            throw new IllegalArgumentException("Invalid method");
        }

        // If services are not set as mocks in tests, fetch them now.
        mPeopleManager = mPeopleManager != null ? mPeopleManager
                : IPeopleManager.Stub.asInterface(
                        ServiceManager.getService(Context.PEOPLE_SERVICE));
        mLauncherApps = mLauncherApps != null ? mLauncherApps
                : getContext().getSystemService(LauncherApps.class);

        if (mPeopleManager == null || mLauncherApps == null) {
            Log.w(TAG, "Null system managers");
            return null;
        }

        if (extras == null) {
            Log.w(TAG, "Extras can't be null");
            throw new IllegalArgumentException("Extras can't be null");
@@ -94,24 +83,22 @@ public class PeopleProvider extends ContentProvider {
            throw new IllegalArgumentException("Null user handle");
        }

        ConversationChannel channel;
        try {
            channel = mPeopleManager.getConversation(
                    packageName, userHandle.getIdentifier(), shortcutId);
        } catch (Exception e) {
            Log.w(TAG, "Exception getting tiles: " + e);
            return null;
        }
        PeopleSpaceTile tile = PeopleSpaceUtils.getTile(channel, mLauncherApps);
        // If services are not set as mocks in tests, fetch them now.
        mPeopleManager = mPeopleManager != null ? mPeopleManager
                : IPeopleManager.Stub.asInterface(
                        ServiceManager.getService(Context.PEOPLE_SERVICE));
        mLauncherApps = mLauncherApps != null ? mLauncherApps
                : getContext().getSystemService(LauncherApps.class);
        mNotificationEntryManager = mNotificationEntryManager != null ? mNotificationEntryManager
                : Dependency.get(NotificationEntryManager.class);

        if (tile == null) {
            if (DEBUG) Log.i(TAG, "No tile was returned");
        RemoteViews view = PeopleSpaceUtils.getPreview(getContext(), mPeopleManager, mLauncherApps,
                mNotificationEntryManager, shortcutId, userHandle, packageName);
        if (view == null) {
            if (DEBUG) Log.d(TAG, "No preview available for shortcutId: " + shortcutId);
            return null;
        }

        if (DEBUG) Log.i(TAG, "Returning tile preview for shortcutId: " + shortcutId);
        final Bundle bundle = new Bundle();
        RemoteViews view = PeopleSpaceUtils.createRemoteViews(getContext(), tile, 0, bundle);
        bundle.putParcelable(PeopleProviderUtils.RESPONSE_KEY_REMOTE_VIEWS, view);
        return bundle;
    }
+5 −6
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import android.view.ViewGroup;

import com.android.systemui.R;
import com.android.systemui.people.widget.PeopleSpaceWidgetManager;
import com.android.systemui.people.widget.PeopleTileKey;
import com.android.systemui.statusbar.notification.NotificationEntryManager;

import java.util.List;
@@ -62,9 +61,12 @@ public class PeopleSpaceActivity extends Activity {
    private boolean mShowSingleConversation;

    @Inject
    public PeopleSpaceActivity(NotificationEntryManager notificationEntryManager) {
    public PeopleSpaceActivity(NotificationEntryManager notificationEntryManager,
            PeopleSpaceWidgetManager peopleSpaceWidgetManager) {
        super();
        mNotificationEntryManager = notificationEntryManager;
        mPeopleSpaceWidgetManager = peopleSpaceWidgetManager;

    }

    @Override
@@ -78,7 +80,6 @@ public class PeopleSpaceActivity extends Activity {
        mPackageManager = getPackageManager();
        mPeopleManager = IPeopleManager.Stub.asInterface(
                ServiceManager.getService(Context.PEOPLE_SERVICE));
        mPeopleSpaceWidgetManager = new PeopleSpaceWidgetManager(mContext);
        mLauncherApps = mContext.getSystemService(LauncherApps.class);
        setTileViewsWithPriorityConversations();
        mAppWidgetId = getIntent().getIntExtra(EXTRA_APPWIDGET_ID,
@@ -139,9 +140,7 @@ public class PeopleSpaceActivity extends Activity {
                        + mAppWidgetId);
            }
        }
        PeopleTileKey key = new PeopleTileKey(
                tile.getId(), tile.getUserHandle().getIdentifier(), tile.getPackageName());
        mPeopleSpaceWidgetManager.addNewWidget(mAppWidgetId, key);
        mPeopleSpaceWidgetManager.addNewWidget(mAppWidgetId, tile);
        finishActivity();
    }

Loading