예제 #1
0
 @Override
 public void onNotificationDataChanged(@NonNull OpenNotification notification, int event) {
   Check.getInstance().isInMainThread();
   switch (event) {
     case OpenNotification.EVENT_ICON:
       updateIcons();
       break;
   }
 }
예제 #2
0
  /** @param n */
  public void setNotification(@Nullable OpenNotification n) {
    Check.getInstance().isInMainThread();
    unregisterNotificationListener();
    mNotification = n;
    registerNotificationListener();

    synchronized (NotificationPresenter.getInstance().monitor) {
      // Update everything
      updateTitle();
      updateTimestamp();
      updateSubtitle();
      updateMessage();
      updateActions();
      updateIcons();
    }
  }
예제 #3
0
  public void resume() {
    Check.getInstance().isInMainThread();
    mResumed = true;

    synchronized (NotificationPresenter.getInstance().monitor) {
      if (Operator.bitAnd(mPendingUpdates, PENDING_UPDATE_TITLE)) updateTitle();
      if (Operator.bitAnd(mPendingUpdates, PENDING_UPDATE_SUBTITLE)) updateSubtitle();
      if (Operator.bitAnd(mPendingUpdates, PENDING_UPDATE_TIMESTAMP)) updateTimestamp();
      if (Operator.bitAnd(mPendingUpdates, PENDING_UPDATE_MESSAGE)) updateMessage();
      if (Operator.bitAnd(mPendingUpdates, PENDING_UPDATE_ACTIONS)) updateActions();
      if (Operator.bitAnd(mPendingUpdates, PENDING_UPDATE_ICONS)) updateIcons();
    }
    mPendingUpdates = 0;

    registerNotificationListener();
  }
예제 #4
0
  /**
   * Updates message from the current {@link #mNotification notificiation}.
   *
   * @see #setMessages(CharSequence[])
   * @see #isMessageSecret()
   */
  private void updateMessage() {
    if (isPendingUpdate(PENDING_UPDATE_MESSAGE)) return;
    if (mNotification == null) {
      setMessages(null);
      return;
    }

    final boolean secret = isMessageSecret();

    // Get message text
    if (secret) {
      CharSequence[] messages;
      if (sSecureContentLabelRef == null || (messages = sSecureContentLabelRef.get()) == null) {
        final CharSequence cs = mContext.getString(R.string.privacy_mode_hidden_content);
        final SpannableString ss = new SpannableString(cs);
        Check.getInstance().isTrue(ss.length());
        ss.setSpan(
            new StyleSpan(Typeface.ITALIC),
            0 /* start */,
            ss.length() /* end */,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        messages = new CharSequence[] {ss};
        sSecureContentLabelRef = new SoftReference<>(messages);
      }

      setMessages(messages);
    } else {
      CharSequence message;
      if (mBig) {
        if (mNotification.messageTextLines != null) {
          setMessages(mNotification.messageTextLines);
          return;
        }

        message = NullUtils.whileNotNull(mNotification.messageBigText, mNotification.messageText);
      } else {
        message = mNotification.messageText;
      }

      setMessages(TextUtils.isEmpty(message) ? null : new CharSequence[] {message});
    }
  }
예제 #5
0
 public void pause() {
   Check.getInstance().isInMainThread();
   unregisterNotificationListener();
   mResumed = false;
 }
예제 #6
0
 /** {@inheritDoc} */
 @Override
 public void requestCheckout() {
   Check.getInstance().isFalse(mCheckoutRequest);
   Check.getInstance().isFalse(mCreated); // not created yet.
   mCheckoutRequest = true;
 }
  public PermissionNotificationListener(@NonNull Context context) {
    super(context);
    Check.getInstance().isTrue(Device.hasJellyBeanMR2Api());

    mComponentString = new ComponentName(mContext, MediaService.class).flattenToString();
  }