1 package com.example.sampleleanbacklauncher.apps; 2 3 import android.content.Context; 4 import android.content.Intent; 5 import android.graphics.drawable.Drawable; 6 import android.util.Log; 7 8 import com.example.sampleleanbacklauncher.R; 9 10 public class NotificationsLaunchItem extends LaunchItem { 11 private static final String ACTION_OPEN_NOTIFICATIONS = "com.android.tv.NOTIFICATIONS_PANEL"; 12 13 // Change this to use a notification panel activity from a different package. 14 private static final String NOTIFICATIONS_PKG = "com.example.sampleleanbacklauncher"; 15 16 private final Context mContext; 17 private int mNotifsCount = 0; 18 NotificationsLaunchItem(Context context)19 public NotificationsLaunchItem(Context context) { 20 super(context, new Intent(ACTION_OPEN_NOTIFICATIONS).setPackage(NOTIFICATIONS_PKG), 21 context.getResources().getDrawable(R.drawable.ic_notifications, null), 22 context.getResources().getString(R.string.system_notifications)); 23 mContext = context; 24 } 25 setNotificationsCount(int count)26 public void setNotificationsCount(int count) { 27 mNotifsCount = count; 28 } 29 30 @Override getIntent()31 public Intent getIntent() { 32 return mIntent; 33 } 34 35 @Override getBanner()36 public Drawable getBanner() { 37 // No banner for notifications launch item. 38 return null; 39 } 40 41 @Override getLabel()42 public CharSequence getLabel() { 43 return mContext.getResources().getQuantityString(R.plurals.notifications_title, 44 mNotifsCount, mNotifsCount); 45 } 46 } 47