Example usage for android.content.res Resources getColor

List of usage examples for android.content.res Resources getColor

Introduction

In this page you can find the example usage for android.content.res Resources getColor.

Prototype

@ColorInt
@Deprecated
public int getColor(@ColorRes int id) throws NotFoundException 

Source Link

Document

Returns a color integer associated with a particular resource ID.

Usage

From source file:com.andrewshu.android.reddit.threads.ThreadsListActivity.java

public static void fillThreadsListItemView(int position, View view, ThingInfo item, ListActivity activity,
        HttpClient client, RedditSettings settings,
        ThumbnailOnClickListenerFactory thumbnailOnClickListenerFactory) {

    Resources res = activity.getResources();

    TextView titleView = (TextView) view.findViewById(R.id.title);
    TextView votesView = (TextView) view.findViewById(R.id.votes);
    TextView numCommentsSubredditView = (TextView) view.findViewById(R.id.numCommentsSubreddit);
    TextView nsfwView = (TextView) view.findViewById(R.id.nsfw);
    //        TextView submissionTimeView = (TextView) view.findViewById(R.id.submissionTime);
    ImageView voteUpView = (ImageView) view.findViewById(R.id.vote_up_image);
    ImageView voteDownView = (ImageView) view.findViewById(R.id.vote_down_image);
    View thumbnailContainer = view.findViewById(R.id.thumbnail_view);
    FrameLayout thumbnailFrame = (FrameLayout) view.findViewById(R.id.thumbnail_frame);
    ImageView thumbnailImageView = (ImageView) view.findViewById(R.id.thumbnail);
    ProgressBar indeterminateProgressBar = (ProgressBar) view.findViewById(R.id.indeterminate_progress);

    // Set the title and domain using a SpannableStringBuilder
    SpannableStringBuilder builder = new SpannableStringBuilder();
    String title = item.getTitle();
    if (title == null)
        title = "";
    SpannableString titleSS = new SpannableString(title);
    int titleLen = title.length();
    titleSS.setSpan(/*from w  ww  .ja v a 2 s . co  m*/
            new TextAppearanceSpan(activity,
                    Util.getTextAppearanceResource(settings.getTheme(), android.R.style.TextAppearance_Large)),
            0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    String domain = item.getDomain();
    if (domain == null)
        domain = "";
    int domainLen = domain.length();
    SpannableString domainSS = new SpannableString("(" + item.getDomain() + ")");
    domainSS.setSpan(
            new TextAppearanceSpan(activity,
                    Util.getTextAppearanceResource(settings.getTheme(), android.R.style.TextAppearance_Small)),
            0, domainLen + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    if (Util.isLightTheme(settings.getTheme())) {
        if (item.isClicked()) {
            ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.purple));
            titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        } else {
            ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.blue));
            titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        domainSS.setSpan(new ForegroundColorSpan(res.getColor(R.color.gray_50)), 0, domainLen + 2,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        if (item.isClicked()) {
            ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.gray_50));
            titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        domainSS.setSpan(new ForegroundColorSpan(res.getColor(R.color.gray_75)), 0, domainLen + 2,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }

    builder.append(titleSS).append(" ").append(domainSS);
    titleView.setText(builder);

    votesView.setText("" + item.getScore());
    numCommentsSubredditView.setText(Util.showNumComments(item.getNum_comments()) + "  " + item.getSubreddit());

    if (item.isOver_18()) {
        nsfwView.setVisibility(View.VISIBLE);
    } else {
        nsfwView.setVisibility(View.GONE);
    }

    // Set the up and down arrow colors based on whether user likes
    if (settings.isLoggedIn()) {
        if (item.getLikes() == null) {
            voteUpView.setImageResource(R.drawable.vote_up_gray);
            voteDownView.setImageResource(R.drawable.vote_down_gray);
            votesView.setTextColor(res.getColor(R.color.gray_75));
        } else if (item.getLikes() == true) {
            voteUpView.setImageResource(R.drawable.vote_up_red);
            voteDownView.setImageResource(R.drawable.vote_down_gray);
            votesView.setTextColor(res.getColor(R.color.arrow_red));
        } else {
            voteUpView.setImageResource(R.drawable.vote_up_gray);
            voteDownView.setImageResource(R.drawable.vote_down_blue);
            votesView.setTextColor(res.getColor(R.color.arrow_blue));
        }
    } else {
        voteUpView.setImageResource(R.drawable.vote_up_gray);
        voteDownView.setImageResource(R.drawable.vote_down_gray);
        votesView.setTextColor(res.getColor(R.color.gray_75));
    }

    // Thumbnails open links
    if (thumbnailContainer != null) {
        if (Common.shouldLoadThumbnails(activity, settings)) {
            thumbnailContainer.setVisibility(View.VISIBLE);

            if (item.getUrl() != null) {
                OnClickListener thumbnailOnClickListener = thumbnailOnClickListenerFactory
                        .getThumbnailOnClickListener(item, activity);
                if (thumbnailOnClickListener != null) {
                    thumbnailFrame.setOnClickListener(thumbnailOnClickListener);
                }
            }

            // Show thumbnail based on ThingInfo
            if ("default".equals(item.getThumbnail()) || "self".equals(item.getThumbnail())
                    || StringUtils.isEmpty(item.getThumbnail())) {
                indeterminateProgressBar.setVisibility(View.GONE);
                thumbnailImageView.setVisibility(View.VISIBLE);
                thumbnailImageView.setImageResource(R.drawable.go_arrow);
            } else {
                indeterminateProgressBar.setVisibility(View.GONE);
                thumbnailImageView.setVisibility(View.VISIBLE);
                if (item.getThumbnailBitmap() != null) {
                    thumbnailImageView.setImageBitmap(item.getThumbnailBitmap());
                } else {
                    thumbnailImageView.setImageBitmap(null);
                    new ShowThumbnailsTask(activity, client, R.drawable.go_arrow)
                            .execute(new ThumbnailLoadAction(item, thumbnailImageView, position));
                }
            }

            // Set thumbnail background based on current theme
            if (Util.isLightTheme(settings.getTheme()))
                thumbnailFrame.setBackgroundResource(R.drawable.thumbnail_background_light);
            else
                thumbnailFrame.setBackgroundResource(R.drawable.thumbnail_background_dark);
        } else {
            // if thumbnails disabled, hide thumbnail icon
            thumbnailContainer.setVisibility(View.GONE);
        }
    }
}

From source file:com.wanikani.androidnotifier.ItemsFragment.java

/**
 * Creation of the fragment. We build up all the singletons, leaving the
 * bundle alone, because we set the retain instance flag to <code>true</code>.
 *    @param bundle the saved instance state
 *///from   w w  w  . j a  v  a  2s . com
@Override
public void onCreate(Bundle bundle) {
    Resources res;

    super.onCreate(bundle);

    setRetainInstance(true);

    fmap = new EnumMap<FilterType, Filter>(FilterType.class);
    fmap.put(FilterType.NONE, new NoFilter(this));
    fmap.put(FilterType.LEVEL, new LevelFilter(this));
    fmap.put(FilterType.CRITICAL, new CriticalFilter(this));
    fmap.put(FilterType.TOXIC, new ToxicFilter(this));
    fmap.put(FilterType.UNLOCKS, new UnlockFilter(this));

    filterType = FilterType.LEVEL;

    lcl = new LevelClickListener();

    mpl = new MenuPopupListener();
    rgl = new RadioGroupListener();

    res = getResources();
    srsht = new EnumMap<SRSLevel, Drawable>(SRSLevel.class);
    srsht.put(SRSLevel.APPRENTICE, res.getDrawable(R.drawable.apprentice));
    srsht.put(SRSLevel.GURU, res.getDrawable(R.drawable.guru));
    srsht.put(SRSLevel.MASTER, res.getDrawable(R.drawable.master));
    srsht.put(SRSLevel.ENLIGHTEN, res.getDrawable(R.drawable.enlighten));
    srsht.put(SRSLevel.BURNED, res.getDrawable(R.drawable.burned));

    normalColor = res.getColor(R.color.normal);
    importantColor = res.getColor(R.color.important);
    selectedColor = res.getColor(R.color.selected);
    unselectedColor = res.getColor(R.color.unselected);

    lad = new LevelListAdapter();
    iad = new ItemListAdapter(Item.SortByType.INSTANCE, ItemInfo.AVAILABLE);

    iss = new ItemSearchDialog.State();
}

From source file:in.shick.diode.threads.ThreadsListActivity.java

public static void fillThreadsListItemView(int position, View view, ThingInfo item, ListActivity activity,
        HttpClient client, RedditSettings settings,
        ThumbnailOnClickListenerFactory thumbnailOnClickListenerFactory) {

    Resources res = activity.getResources();
    ViewHolder vh;/*  w w  w .  ja v a  2 s  .c o  m*/
    if (view.getTag() == null) {
        vh = new ViewHolder();
        vh.titleView = (TextView) view.findViewById(R.id.title);
        vh.votesView = (TextView) view.findViewById(R.id.votes);
        vh.numCommentsSubredditView = (TextView) view.findViewById(R.id.numCommentsSubreddit);
        vh.nsfwView = (TextView) view.findViewById(R.id.nsfw);
        vh.voteUpView = (ImageView) view.findViewById(R.id.vote_up_image);
        vh.voteDownView = (ImageView) view.findViewById(R.id.vote_down_image);
        vh.thumbnailContainer = view.findViewById(R.id.thumbnail_view);
        vh.thumbnailFrame = (FrameLayout) view.findViewById(R.id.thumbnail_frame);
        vh.thumbnailImageView = (ImageView) view.findViewById(R.id.thumbnail);
        vh.indeterminateProgressBar = (ProgressBar) view.findViewById(R.id.indeterminate_progress);
        view.setTag(vh);
    } else {
        vh = (ViewHolder) view.getTag();
    }

    // Need to store the Thing's id in the thumbnail image so that the thumbnail loader task
    // knows that the row is still displaying the requested thumbnail.
    vh.thumbnailImageView.setTag(item.getId());
    // Set the title and domain using a SpannableStringBuilder
    SpannableStringBuilder builder = new SpannableStringBuilder();
    String title = item.getTitle();
    if (title == null)
        title = "";
    SpannableString titleSS = new SpannableString(title);
    int titleLen = title.length();
    titleSS.setSpan(
            new TextAppearanceSpan(activity,
                    Util.getTextAppearanceResource(settings.getTheme(), android.R.style.TextAppearance_Large)),
            0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    String domain = item.getDomain();
    if (domain == null)
        domain = "";
    String flair = item.getLink_flair_text();
    if (flair == null) {
        flair = "";
    } else {
        flair = "[" + flair + "] ";
    }
    int domainLen = domain.length() + flair.length();
    SpannableString domainSS = new SpannableString(flair + "(" + item.getDomain() + ")");
    domainSS.setSpan(
            new TextAppearanceSpan(activity,
                    Util.getTextAppearanceResource(settings.getTheme(), android.R.style.TextAppearance_Small)),
            0, domainLen + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    if (Util.isLightTheme(settings.getTheme())) {
        if (item.isClicked()) {
            ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.purple));
            titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        } else {
            ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.blue));
            titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        domainSS.setSpan(new ForegroundColorSpan(res.getColor(R.color.gray_50)), 0, domainLen + 2,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        if (item.isClicked()) {
            ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.gray_50));
            titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        domainSS.setSpan(new ForegroundColorSpan(res.getColor(R.color.gray_75)), 0, domainLen + 2,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }

    builder.append(titleSS).append(" ").append(domainSS);
    vh.titleView.setText(builder);

    vh.votesView.setText(String.format(Locale.US, "%d", item.getScore()));
    // Lock icon emoji
    String preText = item.isLocked() ? "\uD83D\uDD12 " : "";
    vh.numCommentsSubredditView
            .setText(preText + Util.showNumComments(item.getNum_comments()) + "  " + item.getSubreddit());

    vh.nsfwView.setVisibility(item.isOver_18() ? View.VISIBLE : View.GONE);

    // Set the up and down arrow colors based on whether user likes
    if (settings.isLoggedIn()) {
        if (item.getLikes() == null) {
            vh.voteUpView.setImageResource(R.drawable.vote_up_gray);
            vh.voteDownView.setImageResource(R.drawable.vote_down_gray);
            vh.votesView.setTextColor(res.getColor(R.color.gray_75));
        } else if (item.getLikes()) {
            vh.voteUpView.setImageResource(R.drawable.vote_up_red);
            vh.voteDownView.setImageResource(R.drawable.vote_down_gray);
            vh.votesView.setTextColor(res.getColor(R.color.arrow_red));
        } else {
            vh.voteUpView.setImageResource(R.drawable.vote_up_gray);
            vh.voteDownView.setImageResource(R.drawable.vote_down_blue);
            vh.votesView.setTextColor(res.getColor(R.color.arrow_blue));
        }
    } else {
        vh.voteUpView.setImageResource(R.drawable.vote_up_gray);
        vh.voteDownView.setImageResource(R.drawable.vote_down_gray);
        vh.votesView.setTextColor(res.getColor(R.color.gray_75));
    }

    // Thumbnails open links
    if (vh.thumbnailContainer != null) {
        if (Common.shouldLoadThumbnails(activity, settings)) {
            vh.thumbnailContainer.setVisibility(View.VISIBLE);

            if (item.getUrl() != null) {
                OnClickListener thumbnailOnClickListener = thumbnailOnClickListenerFactory
                        .getThumbnailOnClickListener(item, activity);
                if (thumbnailOnClickListener != null) {
                    vh.thumbnailFrame.setOnClickListener(thumbnailOnClickListener);
                }
            }

            // Show thumbnail based on ThingInfo
            if (Constants.NSFW_STRING.equalsIgnoreCase(item.getThumbnail())
                    || Constants.DEFAULT_STRING.equals(item.getThumbnail())
                    || Constants.SUBMIT_KIND_SELF.equals(item.getThumbnail())
                    || StringUtils.isEmpty(item.getThumbnail())) {
                vh.indeterminateProgressBar.setVisibility(View.GONE);
                vh.thumbnailImageView.setVisibility(View.VISIBLE);
                vh.thumbnailImageView.setImageResource(R.drawable.go_arrow);
            } else {
                if (item.getThumbnailBitmap() != null) {
                    vh.indeterminateProgressBar.setVisibility(View.GONE);
                    vh.thumbnailImageView.setVisibility(View.VISIBLE);
                    vh.thumbnailImageView.setImageBitmap(item.getThumbnailBitmap());
                } else {
                    vh.indeterminateProgressBar.setVisibility(View.VISIBLE);
                    vh.thumbnailImageView.setVisibility(View.GONE);
                    vh.thumbnailImageView.setImageBitmap(null);
                    new ShowThumbnailsTask(activity, client, R.drawable.go_arrow)
                            .execute(new ThumbnailLoadAction(item, vh.thumbnailImageView, position,
                                    vh.indeterminateProgressBar));
                }
            }

            // Set thumbnail background based on current theme
            if (Util.isLightTheme(settings.getTheme()))
                vh.thumbnailFrame.setBackgroundResource(R.drawable.thumbnail_background_light);
            else
                vh.thumbnailFrame.setBackgroundResource(R.drawable.thumbnail_background_dark);
        } else {
            // if thumbnails disabled, hide thumbnail icon
            vh.thumbnailContainer.setVisibility(View.GONE);
        }
    }
}

From source file:com.android.calendar.EventInfoFragment.java

private void updateEvent(View view) {
    if (mEventCursor == null || view == null) {
        return;/*from  w  ww .j  a  v a 2  s. c  o  m*/
    }

    Context context = view.getContext();
    if (context == null) {
        return;
    }

    String eventName = mEventCursor.getString(EVENT_INDEX_TITLE);
    if (eventName == null || eventName.length() == 0) {
        eventName = getActivity().getString(R.string.no_title_label);
    }

    // 3rd parties might not have specified the start/end time when firing the
    // Events.CONTENT_URI intent.  Update these with values read from the db.
    if (mStartMillis == 0 && mEndMillis == 0) {
        mStartMillis = mEventCursor.getLong(EVENT_INDEX_DTSTART);
        mEndMillis = mEventCursor.getLong(EVENT_INDEX_DTEND);
        if (mEndMillis == 0) {
            String duration = mEventCursor.getString(EVENT_INDEX_DURATION);
            if (!TextUtils.isEmpty(duration)) {
                try {
                    Duration d = new Duration();
                    d.parse(duration);
                    long endMillis = mStartMillis + d.getMillis();
                    if (endMillis >= mStartMillis) {
                        mEndMillis = endMillis;
                    } else {
                        Log.d(TAG, "Invalid duration string: " + duration);
                    }
                } catch (DateException e) {
                    Log.d(TAG, "Error parsing duration string " + duration, e);
                }
            }
            if (mEndMillis == 0) {
                mEndMillis = mStartMillis;
            }
        }
    }

    mAllDay = mEventCursor.getInt(EVENT_INDEX_ALL_DAY) != 0;
    String location = mEventCursor.getString(EVENT_INDEX_EVENT_LOCATION);
    String description = mEventCursor.getString(EVENT_INDEX_DESCRIPTION);
    String rRule = mEventCursor.getString(EVENT_INDEX_RRULE);
    String eventTimezone = mEventCursor.getString(EVENT_INDEX_EVENT_TIMEZONE);

    mHeadlines.setBackgroundColor(mCurrentColor);

    // What
    if (eventName != null) {
        setTextCommon(view, R.id.title, eventName);
    }

    // When
    // Set the date and repeats (if any)
    String localTimezone = Utils.getTimeZone(mActivity, mTZUpdater);

    Resources resources = context.getResources();
    String displayedDatetime = Utils.getDisplayedDatetime(mStartMillis, mEndMillis, System.currentTimeMillis(),
            localTimezone, mAllDay, context);

    String displayedTimezone = null;
    if (!mAllDay) {
        displayedTimezone = Utils.getDisplayedTimezone(mStartMillis, localTimezone, eventTimezone);
    }
    // Display the datetime.  Make the timezone (if any) transparent.
    if (displayedTimezone == null) {
        setTextCommon(view, R.id.when_datetime, displayedDatetime);
    } else {
        int timezoneIndex = displayedDatetime.length();
        displayedDatetime += "  " + displayedTimezone;
        SpannableStringBuilder sb = new SpannableStringBuilder(displayedDatetime);
        ForegroundColorSpan transparentColorSpan = new ForegroundColorSpan(
                resources.getColor(R.color.event_info_headline_transparent_color));
        sb.setSpan(transparentColorSpan, timezoneIndex, displayedDatetime.length(),
                Spannable.SPAN_INCLUSIVE_INCLUSIVE);
        setTextCommon(view, R.id.when_datetime, sb);
    }

    // Display the repeat string (if any)
    String repeatString = null;
    if (!TextUtils.isEmpty(rRule)) {
        EventRecurrence eventRecurrence = new EventRecurrence();
        eventRecurrence.parse(rRule);
        Time date = new Time(localTimezone);
        date.set(mStartMillis);
        if (mAllDay) {
            date.timezone = Time.TIMEZONE_UTC;
        }
        eventRecurrence.setStartDate(date);
        repeatString = EventRecurrenceFormatter.getRepeatString(mContext, resources, eventRecurrence, true);
    }
    if (repeatString == null) {
        view.findViewById(R.id.when_repeat).setVisibility(View.GONE);
    } else {
        setTextCommon(view, R.id.when_repeat, repeatString);
    }

    // Organizer view is setup in the updateCalendar method

    // Where
    if (location == null || location.trim().length() == 0) {
        setVisibilityCommon(view, R.id.where, View.GONE);
    } else {
        final TextView textView = mWhere;
        if (textView != null) {
            textView.setAutoLinkMask(0);
            textView.setText(location.trim());
            try {
                textView.setText(Utils.extendedLinkify(textView.getText().toString(), true));

                // Linkify.addLinks() sets the TextView movement method if it finds any links.
                // We must do the same here, in case linkify by itself did not find any.
                // (This is cloned from Linkify.addLinkMovementMethod().)
                MovementMethod mm = textView.getMovementMethod();
                if ((mm == null) || !(mm instanceof LinkMovementMethod)) {
                    if (textView.getLinksClickable()) {
                        textView.setMovementMethod(LinkMovementMethod.getInstance());
                    }
                }
            } catch (Exception ex) {
                // unexpected
                Log.e(TAG, "Linkification failed", ex);
            }

            textView.setOnTouchListener(new OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    try {
                        return v.onTouchEvent(event);
                    } catch (ActivityNotFoundException e) {
                        // ignore
                        return true;
                    }
                }
            });
        }
    }

    // Description
    if (description != null && description.length() != 0) {
        mDesc.setText(description);
    }

    // Launch Custom App
    if (Utils.isJellybeanOrLater()) {
        updateCustomAppButton();
    }
}

From source file:org.getlantern.firetweet.util.Utils.java

public static void setMenuForStatus(final Context context, final Menu menu, final ParcelableStatus status,
        final ParcelableCredentials account) {
    if (context == null || menu == null || status == null)
        return;/*from w  ww . ja v  a  2s.  c om*/
    final Resources resources = context.getResources();
    final int retweetHighlight = resources.getColor(R.color.highlight_retweet);
    final int favoriteHighlight = resources.getColor(R.color.highlight_favorite);
    final boolean isMyRetweet = isMyRetweet(status);
    final MenuItem delete = menu.findItem(MENU_DELETE);
    if (delete != null) {
        delete.setVisible(status.account_id == status.user_id && !isMyRetweet);
    }
    final MenuItem retweet = menu.findItem(MENU_RETWEET);
    if (retweet != null) {
        retweet.setVisible(!status.user_is_protected || isMyRetweet);
        ActionIconDrawable.setMenuHighlight(retweet, new FiretweetMenuInfo(isMyRetweet, retweetHighlight));
        retweet.setTitle(isMyRetweet ? R.string.cancel_retweet : R.string.retweet);
    }
    final MenuItem retweetSubItem = menu.findItem(R.id.retweet_submenu);
    if (retweetSubItem != null) {
        ActionIconDrawable.setMenuHighlight(retweetSubItem,
                new FiretweetMenuInfo(isMyRetweet, retweetHighlight));
    }
    final MenuItem favorite = menu.findItem(MENU_FAVORITE);
    if (favorite != null) {
        ActionIconDrawable.setMenuHighlight(favorite,
                new FiretweetMenuInfo(status.is_favorite, favoriteHighlight));
        favorite.setTitle(status.is_favorite ? R.string.unfavorite : R.string.favorite);
    }
    final MenuItem translate = menu.findItem(MENU_TRANSLATE);
    if (translate != null) {
        final boolean isOfficialKey = isOfficialCredentials(context, account);
        final SharedPreferencesWrapper prefs = SharedPreferencesWrapper.getInstance(context,
                SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
        final boolean forcePrivateApis = prefs.getBoolean(KEY_FORCE_USING_PRIVATE_APIS, false);
        setMenuItemAvailability(menu, MENU_TRANSLATE, forcePrivateApis || isOfficialKey);
    }
    menu.removeGroup(MENU_GROUP_STATUS_EXTENSION);
    addIntentToMenuForExtension(context, menu, MENU_GROUP_STATUS_EXTENSION, INTENT_ACTION_EXTENSION_OPEN_STATUS,
            EXTRA_STATUS, EXTRA_STATUS_JSON, status);
    //final MenuItem shareItem = menu.findItem(R.id.share);
    //final ActionProvider shareProvider = MenuItemCompat.getActionProvider(shareItem);
    /*
    if (shareProvider instanceof SupportStatusShareProvider) {
    ((SupportStatusShareProvider) shareProvider).setStatus(status);
    } else if (shareProvider instanceof ShareActionProvider) {
    final Intent shareIntent = createStatusShareIntent(context, status);
    ((ShareActionProvider) shareProvider).setShareIntent(shareIntent);
    final Menu shareSubMenu = shareItem.getSubMenu();
    final Intent shareIntent = createStatusShareIntent(context, status);
    shareSubMenu.removeGroup(MENU_GROUP_STATUS_SHARE);
    addIntentToMenu(context, shareSubMenu, shareIntent, MENU_GROUP_STATUS_SHARE);
    } */

}

From source file:org.getlantern.firetweet.util.Utils.java

public static int getCardHighlightColor(final Resources res, final boolean isMention, final boolean isFavorite,
        final boolean isRetweet) {
    if (isMention)
        return res.getColor(R.color.highlight_reply);
    else if (isFavorite)
        return res.getColor(R.color.highlight_favorite);
    else if (isRetweet)
        res.getColor(R.color.highlight_retweet);
    return Color.TRANSPARENT;
}

From source file:com.ichi2.anki2.Reviewer.java

private void initLayout(Integer layout) {
    setContentView(layout);//from w w  w.  jav a 2s . c  om

    mMainLayout = findViewById(R.id.main_layout);
    Themes.setContentStyle(mMainLayout, Themes.CALLER_REVIEWER);

    mCardContainer = (FrameLayout) findViewById(R.id.flashcard_frame);
    setInAnimation(false);

    findViewById(R.id.top_bar).setOnClickListener(mCardStatisticsListener);

    mCardFrame = (FrameLayout) findViewById(R.id.flashcard);
    mTouchLayer = (FrameLayout) findViewById(R.id.touch_layer);
    mTouchLayer.setOnTouchListener(mGestureListener);
    if (mPrefTextSelection && mLongClickWorkaround) {
        mTouchLayer.setOnLongClickListener(mLongClickListener);
    }
    if (mPrefTextSelection) {
        mClipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    }
    mCardFrame.removeAllViews();
    if (!mChangeBorderStyle) {
        ((View) findViewById(R.id.flashcard_border)).setVisibility(View.VISIBLE);
    }
    // hunt for input issue 720, like android issue 3341
    if (AnkiDroidApp.SDK_VERSION <= 7 && (mCard != null)) {
        mCard.setFocusableInTouchMode(true);
    }

    // Initialize swipe
    gestureDetector = new GestureDetector(new MyGestureDetector());

    mProgressBar = (ProgressBar) findViewById(R.id.flashcard_progressbar);

    // initialise shake detection
    if (mShakeEnabled) {
        mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
        mSensorManager.registerListener(mSensorListener,
                mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
        mAccel = 0.00f;
        mAccelCurrent = SensorManager.GRAVITY_EARTH;
        mAccelLast = SensorManager.GRAVITY_EARTH;
    }

    Resources res = getResources();

    mEase1 = (Button) findViewById(R.id.ease1);
    mEase1.setTextColor(res.getColor(R.color.next_time_failed_color));
    mEase1Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease1);
    mEase1Layout.setOnClickListener(mSelectEaseHandler);

    mEase2 = (Button) findViewById(R.id.ease2);
    mEase2.setTextColor(res.getColor(R.color.next_time_usual_color));
    mEase2Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease2);
    mEase2Layout.setOnClickListener(mSelectEaseHandler);

    mEase3 = (Button) findViewById(R.id.ease3);
    mEase3Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease3);
    mEase3Layout.setOnClickListener(mSelectEaseHandler);

    mEase4 = (Button) findViewById(R.id.ease4);
    mEase4Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease4);
    mEase4Layout.setOnClickListener(mSelectEaseHandler);

    mNext1 = (TextView) findViewById(R.id.nextTime1);
    mNext2 = (TextView) findViewById(R.id.nextTime2);
    mNext3 = (TextView) findViewById(R.id.nextTime3);
    mNext4 = (TextView) findViewById(R.id.nextTime4);

    mNext1.setTextColor(res.getColor(R.color.next_time_failed_color));
    mNext2.setTextColor(res.getColor(R.color.next_time_usual_color));

    if (!mshowNextReviewTime) {
        ((TextView) findViewById(R.id.nextTimeflip)).setVisibility(View.GONE);
        mNext1.setVisibility(View.GONE);
        mNext2.setVisibility(View.GONE);
        mNext3.setVisibility(View.GONE);
        mNext4.setVisibility(View.GONE);
    }

    mFlipCard = (Button) findViewById(R.id.flip_card);
    mFlipCardLayout = (LinearLayout) findViewById(R.id.flashcard_layout_flip);
    mFlipCardLayout.setOnClickListener(mFlipCardListener);

    mTextBarRed = (TextView) findViewById(R.id.red_number);
    mTextBarBlack = (TextView) findViewById(R.id.black_number);
    mTextBarBlue = (TextView) findViewById(R.id.blue_number);

    if (mShowProgressBars) {
        mSessionProgressTotalBar = (View) findViewById(R.id.daily_bar);
        mSessionProgressBar = (View) findViewById(R.id.session_progress);
        mProgressBars = (LinearLayout) findViewById(R.id.progress_bars);
    }

    mCardTimer = (Chronometer) findViewById(R.id.card_time);
    if (mShowProgressBars && mProgressBars.getVisibility() != View.VISIBLE) {
        switchVisibility(mProgressBars, View.VISIBLE);
    }

    mChosenAnswer = (TextView) findViewById(R.id.choosen_answer);

    if (mPrefWhiteboard) {
        mWhiteboard = new Whiteboard(this, mInvertedColors, mBlackWhiteboard);
        FrameLayout.LayoutParams lp2 = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT);
        mWhiteboard.setLayoutParams(lp2);
        FrameLayout fl = (FrameLayout) findViewById(R.id.whiteboard);
        fl.addView(mWhiteboard);

        mWhiteboard.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (mShowWhiteboard) {
                    return false;
                }
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        });
    }
    mAnswerField = (EditText) findViewById(R.id.answer_field);

    mNextTimeTextColor = getResources().getColor(R.color.next_time_usual_color);
    mNextTimeTextRecomColor = getResources().getColor(R.color.next_time_recommended_color);
    mForegroundColor = getResources().getColor(R.color.next_time_usual_color);
    if (mInvertedColors) {
        invertColors(true);
    }

    mLookUpIcon = findViewById(R.id.lookup_button);
    mLookUpIcon.setVisibility(View.GONE);
    mLookUpIcon.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            if (clipboardHasText()) {
                lookUp();
            }
        }

    });
    initControls();
}

From source file:com.nit.vicky.Reviewer.java

private void initLayout(Integer layout) {
    setContentView(layout);//from   www. ja v  a  2  s  .c  o m

    mMainLayout = findViewById(R.id.main_layout);
    Themes.setContentStyle(mMainLayout, Themes.CALLER_REVIEWER);

    mCardContainer = (FrameLayout) findViewById(R.id.flashcard_frame);
    setInAnimation(false);

    findViewById(R.id.top_bar).setOnClickListener(mCardStatisticsListener);

    mCardFrame = (FrameLayout) findViewById(R.id.flashcard);
    mTouchLayer = (FrameLayout) findViewById(R.id.touch_layer);
    mTouchLayer.setOnTouchListener(mGestureListener);
    if (mPrefTextSelection && mLongClickWorkaround) {
        mTouchLayer.setOnLongClickListener(mLongClickListener);
    }
    if (mPrefTextSelection) {
        mClipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    }
    mCardFrame.removeAllViews();
    if (!mChangeBorderStyle) {
        ((View) findViewById(R.id.flashcard_border)).setVisibility(View.VISIBLE);
    }
    // hunt for input issue 720, like android issue 3341
    if (AnkiDroidApp.SDK_VERSION <= 7 && (mCard != null)) {
        mCard.setFocusableInTouchMode(true);
    }

    // Initialize swipe
    gestureDetector = new GestureDetector(new MyGestureDetector());

    mProgressBar = (ProgressBar) findViewById(R.id.flashcard_progressbar);

    // initialise shake detection
    if (mShakeEnabled) {
        mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
        mSensorManager.registerListener(mSensorListener,
                mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
        mAccel = 0.00f;
        mAccelCurrent = SensorManager.GRAVITY_EARTH;
        mAccelLast = SensorManager.GRAVITY_EARTH;
    }

    Resources res = getResources();

    mEase1 = (Button) findViewById(R.id.ease1);
    mEase1.setTextColor(res.getColor(R.color.next_time_failed_color));
    mEase1Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease1);
    mEase1Layout.setOnClickListener(mSelectEaseHandler);

    mEase2 = (Button) findViewById(R.id.ease2);
    mEase2.setTextColor(res.getColor(R.color.next_time_usual_color));
    mEase2Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease2);
    mEase2Layout.setOnClickListener(mSelectEaseHandler);

    mEase3 = (Button) findViewById(R.id.ease3);
    mEase3Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease3);
    mEase3Layout.setOnClickListener(mSelectEaseHandler);

    mEase4 = (Button) findViewById(R.id.ease4);
    mEase4Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease4);
    mEase4Layout.setOnClickListener(mSelectEaseHandler);

    mNext1 = (TextView) findViewById(R.id.nextTime1);
    mNext2 = (TextView) findViewById(R.id.nextTime2);
    mNext3 = (TextView) findViewById(R.id.nextTime3);
    mNext4 = (TextView) findViewById(R.id.nextTime4);

    mNext1.setTextColor(res.getColor(R.color.next_time_failed_color));
    mNext2.setTextColor(res.getColor(R.color.next_time_usual_color));

    if (!mShowNextReviewTime) {
        ((TextView) findViewById(R.id.nextTimeflip)).setVisibility(View.GONE);
        mNext1.setVisibility(View.GONE);
        mNext2.setVisibility(View.GONE);
        mNext3.setVisibility(View.GONE);
        mNext4.setVisibility(View.GONE);
    }

    mFlipCard = (Button) findViewById(R.id.flip_card);
    mFlipCardLayout = (LinearLayout) findViewById(R.id.flashcard_layout_flip);
    mFlipCardLayout.setOnClickListener(mFlipCardListener);

    mTextBarRed = (TextView) findViewById(R.id.red_number);
    mTextBarBlack = (TextView) findViewById(R.id.black_number);
    mTextBarBlue = (TextView) findViewById(R.id.blue_number);

    if (!mShowRemainingCardCount) {
        mTextBarRed.setVisibility(View.GONE);
        mTextBarBlack.setVisibility(View.GONE);
        mTextBarBlue.setVisibility(View.GONE);
    }

    if (mShowProgressBars) {
        mSessionProgressTotalBar = (View) findViewById(R.id.daily_bar);
        mSessionProgressBar = (View) findViewById(R.id.session_progress);
        mProgressBars = (LinearLayout) findViewById(R.id.progress_bars);
    }

    mCardTimer = (Chronometer) findViewById(R.id.card_time);
    if (mShowProgressBars && mProgressBars.getVisibility() != View.VISIBLE) {
        switchVisibility(mProgressBars, View.VISIBLE);
    }

    mChosenAnswer = (TextView) findViewById(R.id.choosen_answer);

    if (mPrefWhiteboard) {
        mWhiteboard = new Whiteboard(this, mInvertedColors, mBlackWhiteboard);
        FrameLayout.LayoutParams lp2 = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT);
        mWhiteboard.setLayoutParams(lp2);
        FrameLayout fl = (FrameLayout) findViewById(R.id.whiteboard);
        fl.addView(mWhiteboard);

        mWhiteboard.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (mShowWhiteboard) {
                    return false;
                }
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        });
    }
    mAnswerField = (EditText) findViewById(R.id.answer_field);

    mNextTimeTextColor = getResources().getColor(R.color.next_time_usual_color);
    mNextTimeTextRecomColor = getResources().getColor(R.color.next_time_recommended_color);
    mForegroundColor = getResources().getColor(R.color.next_time_usual_color);
    if (mInvertedColors) {
        invertColors(true);
    }

    mLookUpIcon = findViewById(R.id.lookup_button);
    mLookUpIcon.setVisibility(View.GONE);
    mLookUpIcon.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            if (clipboardHasText()) {
                lookUp();
            }
        }

    });
    initControls();
}

From source file:com.hichinaschool.flashcards.anki.Reviewer.java

private void initLayout(Integer layout) {
    setContentView(layout);/*from w w w  . ja v a2s . c  o  m*/

    mMainLayout = findViewById(R.id.main_layout);
    Themes.setContentStyle(mMainLayout, Themes.CALLER_REVIEWER);

    mCardContainer = (FrameLayout) findViewById(R.id.flashcard_frame);
    setInAnimation(false);

    findViewById(R.id.top_bar).setOnClickListener(mCardStatisticsListener);

    mCardFrame = (FrameLayout) findViewById(R.id.flashcard);
    mTouchLayer = (FrameLayout) findViewById(R.id.touch_layer);
    mTouchLayer.setOnTouchListener(mGestureListener);
    if (mPrefTextSelection && mLongClickWorkaround) {
        mTouchLayer.setOnLongClickListener(mLongClickListener);
    }
    if (mPrefTextSelection) {
        mClipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    }
    mCardFrame.removeAllViews();
    if (!mChangeBorderStyle) {
        ((View) findViewById(R.id.flashcard_border)).setVisibility(View.VISIBLE);
    }
    // hunt for input issue 720, like android issue 3341
    if (AnkiDroidApp.SDK_VERSION <= 7 && (mCard != null)) {
        mCard.setFocusableInTouchMode(true);
    }

    // Initialize swipe
    gestureDetector = new GestureDetector(new MyGestureDetector());

    mProgressBar = (ProgressBar) findViewById(R.id.flashcard_progressbar);

    // initialise shake detection
    if (mShakeEnabled) {
        mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
        mSensorManager.registerListener(mSensorListener,
                mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
        mAccel = 0.00f;
        mAccelCurrent = SensorManager.GRAVITY_EARTH;
        mAccelLast = SensorManager.GRAVITY_EARTH;
    }

    Resources res = getResources();

    mEase1 = (Button) findViewById(R.id.ease1);
    mEase1.setTextColor(res.getColor(R.color.next_time_failed_color));
    mEase1Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease1);
    mEase1Layout.setOnClickListener(mSelectEaseHandler);

    mEase2 = (Button) findViewById(R.id.ease2);
    mEase2.setTextColor(res.getColor(R.color.next_time_usual_color));
    mEase2Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease2);
    mEase2Layout.setOnClickListener(mSelectEaseHandler);

    mEase3 = (Button) findViewById(R.id.ease3);
    mEase3Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease3);
    mEase3Layout.setOnClickListener(mSelectEaseHandler);

    mEase4 = (Button) findViewById(R.id.ease4);
    mEase4Layout = (LinearLayout) findViewById(R.id.flashcard_layout_ease4);
    mEase4Layout.setOnClickListener(mSelectEaseHandler);

    mNext1 = (TextView) findViewById(R.id.nextTime1);
    mNext2 = (TextView) findViewById(R.id.nextTime2);
    mNext3 = (TextView) findViewById(R.id.nextTime3);
    mNext4 = (TextView) findViewById(R.id.nextTime4);

    mNext1.setTextColor(res.getColor(R.color.next_time_failed_color));
    mNext2.setTextColor(res.getColor(R.color.next_time_usual_color));

    if (!mShowNextReviewTime) {
        ((TextView) findViewById(R.id.nextTimeflip)).setVisibility(View.GONE);
        mNext1.setVisibility(View.GONE);
        mNext2.setVisibility(View.GONE);
        mNext3.setVisibility(View.GONE);
        mNext4.setVisibility(View.GONE);
    }

    mFlipCard = (Button) findViewById(R.id.flip_card);
    mFlipCardLayout = (LinearLayout) findViewById(R.id.flashcard_layout_flip);
    mFlipCardLayout.setOnClickListener(mFlipCardListener);

    mTextBarRed = (TextView) findViewById(R.id.red_number);
    mTextBarBlack = (TextView) findViewById(R.id.black_number);
    mTextBarBlue = (TextView) findViewById(R.id.blue_number);

    if (!mShowRemainingCardCount) {
        mTextBarRed.setVisibility(View.GONE);
        mTextBarBlack.setVisibility(View.GONE);
        mTextBarBlue.setVisibility(View.GONE);
    }

    if (mShowProgressBars) {
        mSessionProgressTotalBar = (View) findViewById(R.id.daily_bar);
        mSessionProgressBar = (View) findViewById(R.id.session_progress);
        mProgressBars = (LinearLayout) findViewById(R.id.progress_bars);
    }

    mCardTimer = (Chronometer) findViewById(R.id.card_time);
    if (mShowProgressBars && mProgressBars.getVisibility() != View.VISIBLE) {
        //            switchVisibility(mProgressBars, View.VISIBLE);
    }

    mChosenAnswer = (TextView) findViewById(R.id.choosen_answer);

    if (mPrefWhiteboard) {
        mWhiteboard = new Whiteboard(this, mInvertedColors, mBlackWhiteboard);
        FrameLayout.LayoutParams lp2 = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT);
        mWhiteboard.setLayoutParams(lp2);
        FrameLayout fl = (FrameLayout) findViewById(R.id.whiteboard);
        fl.addView(mWhiteboard);

        mWhiteboard.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (mShowWhiteboard) {
                    return false;
                }
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        });
    }
    mAnswerField = (EditText) findViewById(R.id.answer_field);

    mNextTimeTextColor = getResources().getColor(R.color.next_time_usual_color);
    mNextTimeTextRecomColor = getResources().getColor(R.color.next_time_recommended_color);
    mForegroundColor = getResources().getColor(R.color.next_time_usual_color);
    if (mInvertedColors) {
        invertColors(true);
    }

    mLookUpIcon = findViewById(R.id.lookup_button);
    mLookUpIcon.setVisibility(View.GONE);
    mLookUpIcon.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            if (clipboardHasText()) {
                lookUp();
            }
        }

    });
    initControls();
}

From source file:com.android.dialer.calllog.DefaultVoicemailNotifier.java

/**
 * Updates the notification and notifies of the call with the given URI.
 *
 * Clears the notification if there are no new voicemails, and notifies if the given URI
 * corresponds to a new voicemail./* www  . j a  v a 2s .c  om*/
 *
 * It is not safe to call this method from the main thread.
 */
public void updateNotification(Uri newCallUri) {
    // Lookup the list of new voicemails to include in the notification.
    // TODO: Move this into a service, to avoid holding the receiver up.
    final List<NewCall> newCalls = CallLogNotificationsHelper.getInstance(mContext).getNewVoicemails();

    if (newCalls == null) {
        // Query failed, just return.
        return;
    }

    if (newCalls.isEmpty()) {
        // No voicemails to notify about: clear the notification.
        getNotificationManager().cancel(NOTIFICATION_TAG, NOTIFICATION_ID);
        return;
    }

    Resources resources = mContext.getResources();

    // This represents a list of names to include in the notification.
    String callers = null;

    // Maps each number into a name: if a number is in the map, it has already left a more
    // recent voicemail.
    final Map<String, String> names = Maps.newHashMap();

    // Determine the call corresponding to the new voicemail we have to notify about.
    NewCall callToNotify = null;

    // Iterate over the new voicemails to determine all the information above.
    Iterator<NewCall> itr = newCalls.iterator();
    while (itr.hasNext()) {
        NewCall newCall = itr.next();

        // Skip notifying for numbers which are blocked.
        if (FilteredNumbersUtil.shouldBlockVoicemail(mContext, newCall.number, newCall.countryIso,
                newCall.dateMs)) {
            itr.remove();

            // Delete the voicemail.
            mContext.getContentResolver().delete(newCall.voicemailUri, null, null);
            continue;
        }

        // Check if we already know the name associated with this number.
        String name = names.get(newCall.number);
        if (name == null) {
            name = CallLogNotificationsHelper.getInstance(mContext).getName(newCall.number,
                    newCall.numberPresentation, newCall.countryIso);
            names.put(newCall.number, name);
            // This is a new caller. Add it to the back of the list of callers.
            if (TextUtils.isEmpty(callers)) {
                callers = name;
            } else {
                callers = resources.getString(R.string.notification_voicemail_callers_list, callers, name);
            }
        }
        // Check if this is the new call we need to notify about.
        if (newCallUri != null && newCall.voicemailUri != null
                && ContentUris.parseId(newCallUri) == ContentUris.parseId(newCall.voicemailUri)) {
            callToNotify = newCall;
        }
    }

    // All the potential new voicemails have been removed, e.g. if they were spam.
    if (newCalls.isEmpty()) {
        return;
    }

    // If there is only one voicemail, set its transcription as the "long text".
    String transcription = null;
    if (newCalls.size() == 1) {
        transcription = newCalls.get(0).transcription;
    }

    if (newCallUri != null && callToNotify == null) {
        Log.e(TAG, "The new call could not be found in the call log: " + newCallUri);
    }

    // Determine the title of the notification and the icon for it.
    final String title = resources.getQuantityString(R.plurals.notification_voicemail_title, newCalls.size(),
            newCalls.size());
    // TODO: Use the photo of contact if all calls are from the same person.
    final int icon = android.R.drawable.stat_notify_voicemail;

    Pair<Uri, Integer> info = getNotificationInfo(callToNotify);

    Notification.Builder notificationBuilder = new Notification.Builder(mContext).setSmallIcon(icon)
            .setContentTitle(title).setContentText(callers)
            .setStyle(new Notification.BigTextStyle().bigText(transcription))
            .setColor(resources.getColor(R.color.dialer_theme_color)).setSound(info.first)
            .setDefaults(info.second).setDeleteIntent(createMarkNewVoicemailsAsOldIntent()).setAutoCancel(true);

    // Determine the intent to fire when the notification is clicked on.
    final Intent contentIntent;
    // Open the call log.
    contentIntent = new Intent(mContext, DialtactsActivity.class);
    contentIntent.putExtra(DialtactsActivity.EXTRA_SHOW_TAB, ListsFragment.TAB_INDEX_VOICEMAIL);
    notificationBuilder.setContentIntent(
            PendingIntent.getActivity(mContext, 0, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT));

    // The text to show in the ticker, describing the new event.
    if (callToNotify != null) {
        CharSequence msg = ContactDisplayUtils.getTtsSpannedPhoneNumber(resources,
                R.string.notification_new_voicemail_ticker, names.get(callToNotify.number));
        notificationBuilder.setTicker(msg);
    }
    Log.i(TAG, "Creating voicemail notification");
    getNotificationManager().notify(NOTIFICATION_TAG, NOTIFICATION_ID, notificationBuilder.build());
}