Example usage for android.graphics Typeface BOLD

List of usage examples for android.graphics Typeface BOLD

Introduction

In this page you can find the example usage for android.graphics Typeface BOLD.

Prototype

int BOLD

To view the source code for android.graphics Typeface BOLD.

Click Source Link

Usage

From source file:com.libreteam.driver.Driver_RideOffer.java

private void initComponents(View v) {
    countDownTimer = new MyCountDownTimer(startTime, interval);
    new Handler().post(new Runnable() {
        @Override//from   w ww.j av  a2  s. c o  m
        public void run() {
            countDownTimer.start();
        }
    });

    ((TextView) v.findViewById(R.id.no1)).setText(Taxi_System.getSystem(context, Taxi_Constants.GOOD));
    ((TextView) v.findViewById(R.id.no2)).setText(Taxi_System.getSystem(context, Taxi_Constants.BAD));

    Taxi_System.applyFonts(v, Taxi_System.faceType(getActivity()));
    Taxi_System.setContent((LinearLayout) v.findViewById(R.id.header), context, 1, (float) 0.07);

    LinearLayout thirdsection = (LinearLayout) v.findViewById(R.id.thirdsection);
    Taxi_System.setContent(thirdsection, context, (float) 0.125, (float) 0.07);
    ImageView thirdimg = (ImageView) v.findViewById(R.id.thirdimg);
    Taxi_System.setContent(thirdimg, context, (float) 0.06, (float) 0.04);

    LinearLayout logosection = (LinearLayout) v.findViewById(R.id.logosection);
    Taxi_System.setContent(logosection, context, (float) 0.25, (float) 0.07);
    ImageView logo = (ImageView) v.findViewById(R.id.logo);
    Taxi_System.setContentLogo(logo, context, (float) 0.25, (float) 0.07);

    LinearLayout border = (LinearLayout) v.findViewById(R.id.border);
    Taxi_System.setContent(border, context, (float) 0.5, (float) 0.05);

    txtMeter = (TextView) v.findViewById(R.id.meter);
    txtMeter.setTypeface(null, Typeface.BOLD);

    txtCountDown = (TextView) v.findViewById(R.id.countdown);
    txtCountDown.setTypeface(null, Typeface.BOLD);

    //((TextView)v.findViewById(R.id.countdown)).setTextSize(100);
    ((TextView) v.findViewById(R.id.address)).setText(address);

    Button reject = (Button) v.findViewById(R.id.reject);
    reject.setTypeface(null, Typeface.BOLD);
    reject.setOnClickListener(this);

    btnAccept = (Button) v.findViewById(R.id.accept);
    btnAccept.setTypeface(null, Typeface.BOLD);
    btnAccept.setOnClickListener(this);

    if (mMapFragment == null) {
        mMapFragment = CustomMapFragment.newInstance();
        getChildFragmentManager().beginTransaction().setCustomAnimations(R.anim.abc_fade_in, 0)
                .replace(R.id.map, mMapFragment, "boarding").commitAllowingStateLoss();
    }
}

From source file:com.appeaser.sublimenavigationviewlibrary.SublimeNavigationView.java

public SublimeNavigationView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.SublimeNavigationView, defStyleAttr,
            R.style.SnvSublimeNavigationView);

    try {/*from w  w w.j ava2s .c om*/
        // Used for creating default resources
        SublimeThemer.DefaultTheme defaultTheme = SublimeThemer.DefaultTheme.LIGHT;

        if (a.hasValue(R.styleable.SublimeNavigationView_snvDefaultTheme)) {
            defaultTheme = a.getInt(R.styleable.SublimeNavigationView_snvDefaultTheme, 0) == 0
                    ? SublimeThemer.DefaultTheme.LIGHT
                    : SublimeThemer.DefaultTheme.DARK;
        }

        mThemer = new SublimeThemer(getContext(), defaultTheme);

        mThemer.setDrawerBackground(a.getDrawable(R.styleable.SublimeNavigationView_android_background));

        if (a.hasValue(R.styleable.SublimeNavigationView_elevation)) {
            mThemer.setElevation(
                    (float) a.getDimensionPixelSize(R.styleable.SublimeNavigationView_elevation, 0));
        }

        ViewCompat.setFitsSystemWindows(this,
                a.getBoolean(R.styleable.SublimeNavigationView_android_fitsSystemWindows, false));
        mMaxWidth = a.getDimensionPixelSize(R.styleable.SublimeNavigationView_android_maxWidth, 0);

        if (a.hasValue(R.styleable.SublimeNavigationView_snvItemIconTint)) {
            mThemer.setIconTintList(a.getColorStateList(R.styleable.SublimeNavigationView_snvItemIconTint));
        }

        mThemer.setGroupExpandDrawable(a.getDrawable(R.styleable.SublimeNavigationView_snvGroupExpandDrawable));

        mThemer.setGroupCollapseDrawable(
                a.getDrawable(R.styleable.SublimeNavigationView_snvGroupCollapseDrawable));

        // Text style profiles for Item, Hint, SubheaderItem & SubheaderHint
        ColorStateList itemTextColor = null, hintTextColor = null, subheaderItemTextColor = null,
                subheaderHintTextColor = null, badgeTextColor = null;
        Typeface itemTypeface = null, hintTypeface = null, subheaderItemTypeface = null,
                subheaderHintTypeface = null, badgeTypeface = null;
        int itemTypefaceStyle = 0, hintTypefaceStyle = 0, subheaderItemTypefaceStyle = 0,
                subheaderHintTypefaceStyle = 0, badgeTypefaceStyle = 0;

        if (a.hasValue(R.styleable.SublimeNavigationView_snvItemTextColor)) {
            itemTextColor = a.getColorStateList(R.styleable.SublimeNavigationView_snvItemTextColor);
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvHintTextColor)) {
            hintTextColor = a.getColorStateList(R.styleable.SublimeNavigationView_snvHintTextColor);
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderItemTextColor)) {
            subheaderItemTextColor = a
                    .getColorStateList(R.styleable.SublimeNavigationView_snvSubheaderItemTextColor);
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderHintTextColor)) {
            subheaderHintTextColor = a
                    .getColorStateList(R.styleable.SublimeNavigationView_snvSubheaderHintTextColor);
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvBadgeTextColor)) {
            badgeTextColor = a.getColorStateList(R.styleable.SublimeNavigationView_snvBadgeTextColor);
        }

        try { // Catch the RuntimeException thrown if
              // the Typeface filename is incorrect
            if (a.hasValue(R.styleable.SublimeNavigationView_snvItemTypefaceFilename)) {
                String itemTypefaceFilename = a
                        .getString(R.styleable.SublimeNavigationView_snvItemTypefaceFilename);
                if (!TextUtils.isEmpty(itemTypefaceFilename)) {
                    itemTypeface = Typeface.createFromAsset(context.getAssets(), itemTypefaceFilename);
                }
            }

            if (a.hasValue(R.styleable.SublimeNavigationView_snvHintTypefaceFilename)) {
                String hintTypefaceFilename = a
                        .getString(R.styleable.SublimeNavigationView_snvHintTypefaceFilename);
                if (!TextUtils.isEmpty(hintTypefaceFilename)) {
                    hintTypeface = Typeface.createFromAsset(context.getAssets(), hintTypefaceFilename);
                }
            }

            if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderItemTypefaceFilename)) {
                String subheaderItemTypefaceFilename = a
                        .getString(R.styleable.SublimeNavigationView_snvSubheaderItemTypefaceFilename);
                if (!TextUtils.isEmpty(subheaderItemTypefaceFilename)) {
                    subheaderItemTypeface = Typeface.createFromAsset(context.getAssets(),
                            subheaderItemTypefaceFilename);
                }
            }

            if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderHintTypefaceFilename)) {
                String subheaderHintTypefaceFilename = a
                        .getString(R.styleable.SublimeNavigationView_snvSubheaderHintTypefaceFilename);
                if (!TextUtils.isEmpty(subheaderHintTypefaceFilename)) {
                    subheaderHintTypeface = Typeface.createFromAsset(context.getAssets(),
                            subheaderHintTypefaceFilename);
                }
            }

            if (a.hasValue(R.styleable.SublimeNavigationView_snvBadgeTypefaceFilename)) {
                String badgeTypefaceFilename = a
                        .getString(R.styleable.SublimeNavigationView_snvBadgeTypefaceFilename);
                if (!TextUtils.isEmpty(badgeTypefaceFilename)) {
                    badgeTypeface = Typeface.createFromAsset(context.getAssets(), badgeTypefaceFilename);
                }
            }
        } catch (RuntimeException re) {
            Log.e(TAG,
                    "Error loading Typeface from Assets. " + "Confirm that the Typeface filename is correct:\n"
                            + "    - filename should include the extension\n"
                            + "    - filename is case-sensitive");
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvItemTypefaceStyle)) {
            itemTypefaceStyle = a.getInt(R.styleable.SublimeNavigationView_snvItemTypefaceStyle,
                    Typeface.NORMAL);

            switch (itemTypefaceStyle) {
            case 1:
                itemTypefaceStyle = Typeface.BOLD;
                break;
            case 2:
                itemTypefaceStyle = Typeface.ITALIC;
                break;
            case 3:
                itemTypefaceStyle = Typeface.BOLD_ITALIC;
                break;
            default:
                // case 0: NORMAL
                itemTypefaceStyle = Typeface.NORMAL;
                break;
            }
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvHintTypefaceStyle)) {
            hintTypefaceStyle = a.getInt(R.styleable.SublimeNavigationView_snvHintTypefaceStyle,
                    Typeface.NORMAL);

            switch (hintTypefaceStyle) {
            case 1:
                hintTypefaceStyle = Typeface.BOLD;
                break;
            case 2:
                hintTypefaceStyle = Typeface.ITALIC;
                break;
            case 3:
                hintTypefaceStyle = Typeface.BOLD_ITALIC;
                break;
            default:
                // case 0: NORMAL
                hintTypefaceStyle = Typeface.NORMAL;
                break;
            }
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderItemTypefaceStyle)) {
            subheaderItemTypefaceStyle = a
                    .getInt(R.styleable.SublimeNavigationView_snvSubheaderItemTypefaceStyle, Typeface.NORMAL);

            switch (subheaderItemTypefaceStyle) {
            case 1:
                subheaderItemTypefaceStyle = Typeface.BOLD;
                break;
            case 2:
                subheaderItemTypefaceStyle = Typeface.ITALIC;
                break;
            case 3:
                subheaderItemTypefaceStyle = Typeface.BOLD_ITALIC;
                break;
            default:
                // case 0: NORMAL
                subheaderItemTypefaceStyle = Typeface.NORMAL;
                break;
            }
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderHintTypefaceStyle)) {
            subheaderHintTypefaceStyle = a
                    .getInt(R.styleable.SublimeNavigationView_snvSubheaderHintTypefaceStyle, Typeface.NORMAL);

            switch (subheaderHintTypefaceStyle) {
            case 1:
                subheaderHintTypefaceStyle = Typeface.BOLD;
                break;
            case 2:
                subheaderHintTypefaceStyle = Typeface.ITALIC;
                break;
            case 3:
                subheaderHintTypefaceStyle = Typeface.BOLD_ITALIC;
                break;
            default:
                // case 0: NORMAL
                subheaderHintTypefaceStyle = Typeface.NORMAL;
                break;
            }
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvBadgeTypefaceStyle)) {
            badgeTypefaceStyle = a.getInt(R.styleable.SublimeNavigationView_snvBadgeTypefaceStyle,
                    Typeface.NORMAL);

            switch (badgeTypefaceStyle) {
            case 1:
                badgeTypefaceStyle = Typeface.BOLD;
                break;
            case 2:
                badgeTypefaceStyle = Typeface.ITALIC;
                break;
            case 3:
                badgeTypefaceStyle = Typeface.BOLD_ITALIC;
                break;
            default:
                // case 0: NORMAL
                badgeTypefaceStyle = Typeface.NORMAL;
                break;
            }
        }

        // Item text styling
        TextViewStyleProfile itemStyleProfile = new TextViewStyleProfile(context, defaultTheme);
        itemStyleProfile.setTextColor(itemTextColor).setTypeface(itemTypeface)
                .setTypefaceStyle(itemTypefaceStyle);
        mThemer.setItemStyleProfile(itemStyleProfile);

        // Hint text styling
        TextViewStyleProfile hintStyleProfile = new TextViewStyleProfile(context, defaultTheme);
        hintStyleProfile.setTextColor(hintTextColor).setTypeface(hintTypeface)
                .setTypefaceStyle(hintTypefaceStyle);
        mThemer.setItemHintStyleProfile(hintStyleProfile);

        // Sub-header item text styling
        TextViewStyleProfile subheaderItemStyleProfile = new TextViewStyleProfile(context, defaultTheme);
        subheaderItemStyleProfile.setTextColor(subheaderItemTextColor).setTypeface(subheaderItemTypeface)
                .setTypefaceStyle(subheaderItemTypefaceStyle);
        mThemer.setSubheaderStyleProfile(subheaderItemStyleProfile);

        // Sub-header hint text styling
        TextViewStyleProfile subheaderHintStyleProfile = new TextViewStyleProfile(context, defaultTheme);
        subheaderHintStyleProfile.setTextColor(subheaderHintTextColor).setTypeface(subheaderHintTypeface)
                .setTypefaceStyle(subheaderHintTypefaceStyle);
        mThemer.setSubheaderHintStyleProfile(subheaderHintStyleProfile);

        // Badge text styling
        TextViewStyleProfile badgeStyleProfile = new TextViewStyleProfile(context, defaultTheme);
        badgeStyleProfile.setTextColor(badgeTextColor).setTypeface(badgeTypeface)
                .setTypefaceStyle(badgeTypefaceStyle);
        mThemer.setBadgeStyleProfile(badgeStyleProfile);

        mThemer.setItemBackground(a.getDrawable(R.styleable.SublimeNavigationView_snvItemBackground));

        if (a.hasValue(R.styleable.SublimeNavigationView_snvMenu)) {
            int menuResId = a.getResourceId(R.styleable.SublimeNavigationView_snvMenu, -1);

            if (menuResId == -1) {
                throw new RuntimeException("Passed menuResId was not valid");
            }

            mMenu = new SublimeMenu(menuResId);
            inflateMenu(menuResId);
        }

        mMenu.setCallback(new SublimeMenu.Callback() {
            public boolean onMenuItemSelected(SublimeMenu menu, SublimeBaseMenuItem item,
                    OnNavigationMenuEventListener.Event event) {
                return SublimeNavigationView.this.mEventListener != null
                        && SublimeNavigationView.this.mEventListener.onNavigationMenuEvent(event, item);
            }
        });

        mPresenter = new SublimeMenuPresenter();
        applyThemer();

        mMenu.setMenuPresenter(getContext(), mPresenter);
        addView(mPresenter.getMenuView(this));

        if (a.hasValue(R.styleable.SublimeNavigationView_snvHeaderLayout)) {
            inflateHeaderView(a.getResourceId(R.styleable.SublimeNavigationView_snvHeaderLayout, 0));
        }
    } finally {
        a.recycle();
    }

    // Upon creation, and until initializations are done,
    // SublimeMenuPresenter blocks all calls for invalidation.
    // We can now finalize the initialization phase to allow
    // invalidation of the menu when required.
    mPresenter.setInitializationDone();
}

From source file:com.zulip.android.util.CustomHtmlToSpannedConverter.java

private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("div")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("strong")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("b")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("em")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("cite")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("dfn")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("i")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("big")) {
        end(mSpannableStringBuilder, Big.class, new RelativeSizeSpan(1.25f));
    } else if (tag.equalsIgnoreCase("small")) {
        end(mSpannableStringBuilder, Small.class, new RelativeSizeSpan(0.8f));
    } else if (tag.equalsIgnoreCase("font")) {
        endFont(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("blockquote")) {
        handleP(mSpannableStringBuilder);
        end(mSpannableStringBuilder, Blockquote.class, new CustomQuoteSpan());
    } else if (tag.equalsIgnoreCase("tt")) {
        end(mSpannableStringBuilder, Monospace.class, new TypefaceSpan(MONOSPACE));
    } else if (tag.equalsIgnoreCase("a")) {
        endA(mSpannableStringBuilder);//w ww.  ja va  2s.  co  m
    } else if (tag.equalsIgnoreCase("span")) {
        endSpan(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("u")) {
        end(mSpannableStringBuilder, Underline.class, new UnderlineSpan());
    } else if (tag.equalsIgnoreCase("sup")) {
        end(mSpannableStringBuilder, Super.class, new SuperscriptSpan());
    } else if (tag.equalsIgnoreCase("sub")) {
        end(mSpannableStringBuilder, Sub.class, new SubscriptSpan());
    } else if (tag.equalsIgnoreCase("code")) {
        endMultiple(mSpannableStringBuilder, InlineCode.class,
                new Object[] { new TypefaceSpan(MONOSPACE), new ForegroundColorSpan(0xffdd1144) // pink
                });
    } else if (tag.equalsIgnoreCase("pre")) {
        end(mSpannableStringBuilder, CodeBlock.class, new TypefaceSpan(MONOSPACE));
    } else if (tag.length() == 2 && Character.toLowerCase(tag.charAt(0)) == 'h' && tag.charAt(1) >= '1'
            && tag.charAt(1) <= '6') {
        handleP(mSpannableStringBuilder);
        endHeader(mSpannableStringBuilder);
    } else if (mTagHandler != null) {
        mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader);
    }
}

From source file:im.neon.util.NotificationUtils.java

/**
 * Build a message notification.//ww  w. ja  va 2 s  . co m
 * @param context the context
 * @param from the sender
 * @param matrixId the user account id;
 * @param displayMatrixId true to display the matrix id
 * @param largeIcon the notification icon
 * @param unseenNotifiedRoomsCount the number of notified rooms
 * @param body the message body
 * @param roomId the room id
 * @param roomName the room name
 * @param shouldPlaySound true when the notification as sound.
 * @param isInvitationEvent true if it is an invitation notification
 * @return the notification
 */
public static Notification buildMessageNotification(Context context, String from, String matrixId,
        boolean displayMatrixId, Bitmap largeIcon, int unseenNotifiedRoomsCount, String body, String roomId,
        String roomName, boolean shouldPlaySound, boolean isInvitationEvent) {

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setWhen(System.currentTimeMillis());

    if (!TextUtils.isEmpty(from)) {
        // don't display the room name for 1:1 room notifications.
        if (!TextUtils.isEmpty(roomName) && !roomName.equals(from)) {
            builder.setContentTitle(from + " (" + roomName + ")");
        } else {
            builder.setContentTitle(from);
        }
    } else {
        builder.setContentTitle(roomName);
    }

    builder.setContentText(body);
    builder.setAutoCancel(true);
    builder.setSmallIcon(R.drawable.message_notification_transparent);

    if (null != largeIcon) {
        largeIcon = createSquareBitmap(largeIcon);

        // add a bubble in the top right
        if (0 != unseenNotifiedRoomsCount) {
            try {
                android.graphics.Bitmap.Config bitmapConfig = largeIcon.getConfig();

                // set default bitmap config if none
                if (bitmapConfig == null) {
                    bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
                }

                // setLargeIcon must used a 64 * 64 pixels bitmap
                // rescale to have the same text UI.
                float densityScale = context.getResources().getDisplayMetrics().density;
                int side = (int) (64 * densityScale);

                Bitmap bitmapCopy = Bitmap.createBitmap(side, side, bitmapConfig);
                Canvas canvas = new Canvas(bitmapCopy);

                // resize the bitmap to fill in size
                int bitmapWidth = largeIcon.getWidth();
                int bitmapHeight = largeIcon.getHeight();

                float scale = Math.min((float) canvas.getWidth() / (float) bitmapWidth,
                        (float) canvas.getHeight() / (float) bitmapHeight);

                int scaledWidth = (int) (bitmapWidth * scale);
                int scaledHeight = (int) (bitmapHeight * scale);

                Bitmap rescaledBitmap = Bitmap.createScaledBitmap(largeIcon, scaledWidth, scaledHeight, true);
                canvas.drawBitmap(rescaledBitmap, (side - scaledWidth) / 2, (side - scaledHeight) / 2, null);

                String text = "" + unseenNotifiedRoomsCount;

                // prepare the text drawing
                Paint textPaint = new Paint();
                textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
                textPaint.setColor(Color.WHITE);
                textPaint.setTextSize(10 * densityScale);

                // get its size
                Rect textBounds = new Rect();

                if (-1 == mUnreadBubbleWidth) {
                    textPaint.getTextBounds("99", 0, 2, textBounds);
                    mUnreadBubbleWidth = textBounds.width();
                }

                textPaint.getTextBounds(text, 0, text.length(), textBounds);

                // draw a red circle
                int radius = mUnreadBubbleWidth;
                Paint paint = new Paint();
                paint.setStyle(Paint.Style.FILL);
                paint.setColor(Color.RED);
                canvas.drawCircle(canvas.getWidth() - radius, radius, radius, paint);

                // draw the text
                canvas.drawText(text,
                        canvas.getWidth() - textBounds.width() - (radius - (textBounds.width() / 2)),
                        -textBounds.top + (radius - (-textBounds.top / 2)), textPaint);

                // get the new bitmap
                largeIcon = bitmapCopy;
            } catch (Exception e) {
                Log.e(LOG_TAG, "## buildMessageNotification(): Exception Msg=" + e.getMessage());
            }
        }

        builder.setLargeIcon(largeIcon);
    }

    String name = ": ";
    if (!TextUtils.isEmpty(roomName)) {
        name = " (" + roomName + "): ";
    }

    if (displayMatrixId) {
        from = "[" + matrixId + "]\n" + from;
    }

    builder.setTicker(from + name + body);

    TaskStackBuilder stackBuilder;
    Intent intent;

    intent = new Intent(context, VectorRoomActivity.class);
    intent.putExtra(VectorRoomActivity.EXTRA_ROOM_ID, roomId);

    if (null != matrixId) {
        intent.putExtra(VectorRoomActivity.EXTRA_MATRIX_ID, matrixId);
    }

    stackBuilder = TaskStackBuilder.create(context).addParentStack(VectorRoomActivity.class)
            .addNextIntent(intent);

    // android 4.3 issue
    // use a generator for the private requestCode.
    // When using 0, the intent is not created/launched when the user taps on the notification.
    //
    PendingIntent pendingIntent = stackBuilder.getPendingIntent((new Random()).nextInt(1000),
            PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(pendingIntent);

    // display the message with more than 1 lines when the device supports it
    NotificationCompat.BigTextStyle textStyle = new NotificationCompat.BigTextStyle();
    textStyle.bigText(from + ":" + body);
    builder.setStyle(textStyle);

    // do not offer to quick respond if the user did not dismiss the previous one
    if (!LockScreenActivity.isDisplayingALockScreenActivity()) {
        if (!isInvitationEvent) {
            // offer to type a quick answer (i.e. without launching the application)
            Intent quickReplyIntent = new Intent(context, LockScreenActivity.class);
            quickReplyIntent.putExtra(LockScreenActivity.EXTRA_ROOM_ID, roomId);
            quickReplyIntent.putExtra(LockScreenActivity.EXTRA_SENDER_NAME, from);
            quickReplyIntent.putExtra(LockScreenActivity.EXTRA_MESSAGE_BODY, body);

            if (null != matrixId) {
                quickReplyIntent.putExtra(LockScreenActivity.EXTRA_MATRIX_ID, matrixId);
            }

            // the action must be unique else the parameters are ignored
            quickReplyIntent.setAction(QUICK_LAUNCH_ACTION + ((int) (System.currentTimeMillis())));
            PendingIntent pIntent = PendingIntent.getActivity(context, 0, quickReplyIntent, 0);
            builder.addAction(R.drawable.vector_notification_quick_reply,
                    context.getString(R.string.action_quick_reply), pIntent);
        } else {
            {
                // offer to type a quick reject button
                Intent leaveIntent = new Intent(context, JoinScreenActivity.class);
                leaveIntent.putExtra(JoinScreenActivity.EXTRA_ROOM_ID, roomId);
                leaveIntent.putExtra(JoinScreenActivity.EXTRA_MATRIX_ID, matrixId);
                leaveIntent.putExtra(JoinScreenActivity.EXTRA_REJECT, true);

                // the action must be unique else the parameters are ignored
                leaveIntent.setAction(QUICK_LAUNCH_ACTION + ((int) (System.currentTimeMillis())));
                PendingIntent pIntent = PendingIntent.getActivity(context, 0, leaveIntent, 0);
                builder.addAction(R.drawable.vector_notification_reject_invitation,
                        context.getString(R.string.reject), pIntent);
            }

            {
                // offer to type a quick accept button
                Intent acceptIntent = new Intent(context, JoinScreenActivity.class);
                acceptIntent.putExtra(JoinScreenActivity.EXTRA_ROOM_ID, roomId);
                acceptIntent.putExtra(JoinScreenActivity.EXTRA_MATRIX_ID, matrixId);
                acceptIntent.putExtra(JoinScreenActivity.EXTRA_JOIN, true);

                // the action must be unique else the parameters are ignored
                acceptIntent.setAction(QUICK_LAUNCH_ACTION + ((int) (System.currentTimeMillis())));
                PendingIntent pIntent = PendingIntent.getActivity(context, 0, acceptIntent, 0);
                builder.addAction(R.drawable.vector_notification_accept_invitation,
                        context.getString(R.string.join), pIntent);
            }
        }

        // Build the pending intent for when the notification is clicked
        Intent roomIntentTap;
        if (isInvitationEvent) {
            // for invitation the room preview must be displayed
            roomIntentTap = CommonActivityUtils.buildIntentPreviewRoom(matrixId, roomId, context,
                    VectorFakeRoomPreviewActivity.class);
        } else {
            roomIntentTap = new Intent(context, VectorRoomActivity.class);
            roomIntentTap.putExtra(VectorRoomActivity.EXTRA_ROOM_ID, roomId);
        }
        // the action must be unique else the parameters are ignored
        roomIntentTap.setAction(TAP_TO_VIEW_ACTION + ((int) (System.currentTimeMillis())));

        // Recreate the back stack
        TaskStackBuilder stackBuilderTap = TaskStackBuilder.create(context)
                .addParentStack(VectorRoomActivity.class).addNextIntent(roomIntentTap);

        builder.addAction(R.drawable.vector_notification_open, context.getString(R.string.action_open),
                stackBuilderTap.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT));
    }

    //extendForCar(context, builder, roomId, roomName, from, body);

    Notification n = builder.build();
    n.flags |= Notification.FLAG_SHOW_LIGHTS;
    n.defaults |= Notification.DEFAULT_LIGHTS;

    if (shouldPlaySound) {
        n.defaults |= Notification.DEFAULT_SOUND;
    }

    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        // some devices crash if this field is not set
        // even if it is deprecated

        // setLatestEventInfo() is deprecated on Android M, so we try to use
        // reflection at runtime, to avoid compiler error: "Cannot resolve method.."
        try {
            Method deprecatedMethod = n.getClass().getMethod("setLatestEventInfo", Context.class,
                    CharSequence.class, CharSequence.class, PendingIntent.class);
            deprecatedMethod.invoke(n, context, from, body, pendingIntent);
        } catch (Exception ex) {
            Log.e(LOG_TAG,
                    "## buildMessageNotification(): Exception - setLatestEventInfo() Msg=" + ex.getMessage());
        }
    }

    return n;
}

From source file:fr.cph.chicago.core.activity.StationActivity.java

@SuppressWarnings("unchecked")
private void setUpStopLayouts(@NonNull final Map<TrainLine, List<Stop>> stopByLines) {
    Stream.of(stopByLines.entrySet()).forEach(entry -> {
        final TrainLine line = entry.getKey();
        final List<Stop> stops = entry.getValue();
        final View lineTitleView = getLayoutInflater().inflate(R.layout.activity_station_line_title, viewGroup,
                false);/*from   w w w. j av  a2 s.com*/

        final TextView testView = (TextView) lineTitleView.findViewById(R.id.train_line_title);
        testView.setText(line.toStringWithLine());
        testView.setBackgroundColor(line.getColor());
        if (line == TrainLine.YELLOW) {
            testView.setBackgroundColor(yellowLine);
        }

        stopsView.addView(lineTitleView);

        Stream.of(stops).sorted().forEach(stop -> {
            final LinearLayout linearLayout = new LinearLayout(this);
            linearLayout.setOrientation(LinearLayout.HORIZONTAL);
            linearLayout.setLayoutParams(paramsStop);

            final AppCompatCheckBox checkBox = new AppCompatCheckBox(this);
            checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> Preferences
                    .saveTrainFilter(getApplicationContext(), stationId, line, stop.getDirection(), isChecked));
            checkBox.setOnClickListener(v -> {
                if (checkBox.isChecked()) {
                    trainArrivalObservable.subscribe(new SubscriberTrainArrival(this, swipeRefreshLayout));
                }
            });
            checkBox.setChecked(
                    Preferences.getTrainFilter(getApplicationContext(), stationId, line, stop.getDirection()));
            checkBox.setTypeface(checkBox.getTypeface(), Typeface.BOLD);
            checkBox.setText(stop.getDirection().toString());
            checkBox.setTextColor(grey);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                checkBox.setBackgroundTintList(ColorStateList.valueOf(line.getColor()));
                checkBox.setButtonTintList(ColorStateList.valueOf(line.getColor()));
                if (line == TrainLine.YELLOW) {
                    checkBox.setBackgroundTintList(ColorStateList.valueOf(yellowLine));
                    checkBox.setButtonTintList(ColorStateList.valueOf(yellowLine));
                }
            }
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                checkBox.setForegroundTintList(ColorStateList.valueOf(line.getColor()));
                if (line == TrainLine.YELLOW) {
                    checkBox.setForegroundTintList(ColorStateList.valueOf(yellowLine));
                }
            }

            linearLayout.addView(checkBox);

            final LinearLayout arrivalTrainsLayout = new LinearLayout(this);
            arrivalTrainsLayout.setOrientation(LinearLayout.VERTICAL);
            arrivalTrainsLayout.setLayoutParams(paramsStop);
            int id = Util.generateViewId();
            arrivalTrainsLayout.setId(id);
            ids.put(line.toString() + "_" + stop.getDirection().toString(), id);

            linearLayout.addView(arrivalTrainsLayout);
            stopsView.addView(linearLayout);
        });
    });
}

From source file:eu.power_switch.widget.activity.ConfigureReceiverWidgetActivity.java

private void saveCurrentConfiguration() {
    try {/*from   w  w  w . j a  v a  2  s .  co m*/
        // First, get the App Widget ID from the Intent that launched the Activity:
        Intent intent = getIntent();
        Bundle extras = intent.getExtras();
        if (extras != null && extras.containsKey(AppWidgetManager.EXTRA_APPWIDGET_ID)) {
            int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
                    AppWidgetManager.INVALID_APPWIDGET_ID);
            // Perform your App Widget configuration:
            Apartment selectedApartment = getSelectedApartment();
            Room selectedRoom = selectedApartment.getRoom(spinnerRoom.getSelectedItem().toString());
            Receiver selectedReceiver = selectedRoom.getReceiver(spinnerReceiver.getSelectedItem().toString());

            // save new widget data to database
            ReceiverWidget receiverWidget = new ReceiverWidget(appWidgetId, selectedRoom.getId(),
                    selectedReceiver.getId());
            DatabaseHandler.addReceiverWidget(receiverWidget);
            // When the configuration is complete, get an instance of
            // the AppWidgetManager by calling getInstance(Context):
            AppWidgetManager appWidgetManager = AppWidgetManager
                    .getInstance(ConfigureReceiverWidgetActivity.this);
            // Update the App Widget with a RemoteViews layout by
            // calling updateAppWidget(int, RemoteViews):
            RemoteViews remoteViews = new RemoteViews(getString(eu.power_switch.shared.R.string.PACKAGE_NAME),
                    R.layout.widget_receiver);

            LinkedList<Button> buttons = selectedReceiver.getButtons();

            remoteViews.setTextViewText(R.id.textView_receiver_widget_name, selectedApartment.getName() + ": "
                    + selectedRoom.getName() + ": " + selectedReceiver.getName());

            int buttonOffset = 0;
            for (Button button : buttons) {
                // set button action
                RemoteViews buttonView = new RemoteViews(
                        getString(eu.power_switch.shared.R.string.PACKAGE_NAME),
                        R.layout.widget_receiver_button_layout);
                SpannableString s = new SpannableString(button.getName());
                s.setSpan(new StyleSpan(Typeface.BOLD), 0, button.getName().length(), 0);
                buttonView.setTextViewText(R.id.button_widget_universal, s);

                if (SmartphonePreferencesHandler.getHighlightLastActivatedButton()
                        && selectedReceiver.getLastActivatedButtonId().equals(button.getId())) {
                    buttonView.setTextColor(R.id.button_widget_universal,
                            ContextCompat.getColor(getApplicationContext(), R.color.color_light_blue_a700));
                }

                PendingIntent pendingIntent = WidgetIntentReceiver.buildReceiverWidgetActionPendingIntent(
                        getApplicationContext(), selectedApartment, selectedRoom, selectedReceiver, button,
                        appWidgetId * 15 + buttonOffset);

                buttonView.setOnClickPendingIntent(R.id.button_widget_universal, pendingIntent);

                remoteViews.addView(R.id.linearlayout_receiver_widget, buttonView);
                buttonOffset++;
            }

            appWidgetManager.updateAppWidget(appWidgetId, remoteViews);

            // Finally, create the return Intent, set it with the
            // Activity result, and finish the Activity:
            Intent resultValue = new Intent();
            resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            setResult(RESULT_OK, resultValue);
            finish();
        }
    } catch (Exception e) {
        StatusMessageHandler.showErrorMessage(this, e);
    }
}

From source file:fr.tvbarthel.attempt.googlyzooapp.MainActivity.java

@Override
public void onNavigationDrawerItemSelected(GooglyPetEntry petSelected) {
    final int googlyName = petSelected.getName();
    mSelectedGooglyPet = petSelected.getPetId();

    final String petName = getResources().getString(googlyName);
    final String oogly = getResources().getString(R.string.googly_name_ext);
    mTitle = new SpannableString(getResources().getString(googlyName) + oogly);
    mTitle.setSpan(new StyleSpan(Typeface.BOLD), 0, petName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    mTitle.setSpan(new TypefaceSpan("sans-serif-light"), petName.length() - 1, mTitle.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    mActionBarIcon = petSelected.getBlackAndWhiteIcon();

    if (mPetTrackerFragment != null) {
        mPetTrackerFragment.setGooglyPet(mSelectedGooglyPet);
    }/*from  ww w . j  ava2s .co  m*/
}

From source file:com.justsmartapps.myvault.view.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        if (v instanceof FlatTextView) {
            FlatTextView tab = (FlatTextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setBackgroundResource(tabBackgroundResId);
            tab.setTextColor(textColor);
            tab.setTypeface(tab.getTypeface(), Typeface.BOLD);
            // setAllCaps() is only available from API 14, so the upper case
            // is made manually if we are on a
            // pre-ICS-build
        }/*www  . j a v  a2s  . co  m*/
    }
}

From source file:com.customdatepicker.date.MonthView.java

/**
 * Sets up the text and style properties for painting. Override this if you
 * want to use a different paint.//w w w.j  a  v  a 2  s. c  o m
 */
protected void initView() {
    mMonthTitlePaint = new Paint();
    mMonthTitlePaint.setFakeBoldText(true);
    mMonthTitlePaint.setAntiAlias(true);
    mMonthTitlePaint.setTextSize(MONTH_LABEL_TEXT_SIZE);
    mMonthTitlePaint.setTypeface(Typeface.create(mMonthTitleTypeface, Typeface.BOLD));
    mMonthTitlePaint.setColor(mDayTextColor);
    mMonthTitlePaint.setTextAlign(Align.CENTER);
    mMonthTitlePaint.setStyle(Style.FILL);

    mSelectedCirclePaint = new Paint();
    mSelectedCirclePaint.setFakeBoldText(true);
    mSelectedCirclePaint.setAntiAlias(true);
    mSelectedCirclePaint.setColor(mTodayNumberColor);
    mSelectedCirclePaint.setTextAlign(Align.CENTER);
    mSelectedCirclePaint.setStyle(Style.FILL);
    mSelectedCirclePaint.setAlpha(SELECTED_CIRCLE_ALPHA);

    mMonthDayLabelPaint = new Paint();
    mMonthDayLabelPaint.setAntiAlias(true);
    mMonthDayLabelPaint.setTextSize(MONTH_DAY_LABEL_TEXT_SIZE);
    mMonthDayLabelPaint.setColor(mMonthDayTextColor);
    mMonthTitlePaint.setTypeface(Typeface.create(mDayOfWeekTypeface, Typeface.BOLD));
    mMonthDayLabelPaint.setStyle(Style.FILL);
    mMonthDayLabelPaint.setTextAlign(Align.CENTER);
    mMonthDayLabelPaint.setFakeBoldText(true);

    mMonthNumPaint = new Paint();
    mMonthNumPaint.setAntiAlias(true);
    mMonthNumPaint.setTextSize(MINI_DAY_NUMBER_TEXT_SIZE);
    mMonthNumPaint.setStyle(Style.FILL);
    mMonthNumPaint.setTextAlign(Align.CENTER);
    mMonthNumPaint.setFakeBoldText(false);
}

From source file:es.ugr.swad.swadroid.modules.groups.EnrollmentExpandableListAdapter.java

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
        ViewGroup parent) {/*from   www  .  ja v a2s .  com*/
    ChildHolder holder;
    if (convertView == null) {
        convertView = mInflater.inflate(layoutChild, parent, false);
        holder = new ChildHolder();
        holder.linearLayout = (LinearLayout) convertView.findViewById(R.id.groupsLayout);
        holder.imagePadlock = (ImageView) convertView.findViewById(R.id.padlockIcon);
        holder.checkBox = (CheckBox) convertView.findViewById(R.id.checkBox);
        holder.checkBox.setOnClickListener(checkListener);
        holder.radioButton = (RadioButton) convertView.findViewById(R.id.radioButton);
        holder.vacantsText = (TextView) convertView.findViewById(R.id.vacantsText);
        holder.nStudentText = (TextView) convertView.findViewById(R.id.nStudentText);
        holder.maxStudentText = (TextView) convertView.findViewById(R.id.maxStudentText);
        convertView.setTag(holder);
    } else {
        holder = (ChildHolder) convertView.getTag();
    }

    Long groupTypeCode = groups.get(groupPosition).getId();
    int multiple = ((GroupType) groups.get(groupPosition)).getMultiple();

    ArrayList<Group> children = this.children.get(groupTypeCode);
    Group group = children.get(childPosition);

    boolean isCurrentMember = realMembership.get(groupTypeCode)[childPosition];
    if (isCurrentMember) {
        holder.linearLayout.setBackgroundColor(context.getResources().getColor(R.color.lightskyblue));
    } else {
        holder.linearLayout.setBackgroundColor(context.getResources().getColor(android.R.color.white));
    }

    //Data from Group
    String groupName = group.getGroupName();
    int maxStudents = group.getMaxStudents();
    int students = group.getCurrentStudents();
    int open = group.getOpen();
    int member = group.getMember();

    // Para porde hacer click en el checkbox
    Group g = (Group) getChild(groupPosition, childPosition);
    holder.checkBox.setTag(g);

    boolean freeSpot = false;
    if (maxStudents != -1) {
        if (group.getCurrentStudents() < maxStudents)
            freeSpot = true;
    } else { //if maxStudent == -1, there is not limit of students in this groups
        freeSpot = true;
    }

    if (open != 0) {
        holder.imagePadlock.setImageResource(R.drawable.padlock_green);
    } else {
        holder.imagePadlock.setImageResource(R.drawable.padlock_red);
    }

    if ((open != 0 && freeSpot) || role == Constants.TEACHER_TYPE_CODE) { //Teachers can enroll even on closed groups
        holder.checkBox.setEnabled(true);
        holder.checkBox.setTextColor(context.getResources().getColor(android.R.color.black));
        holder.imagePadlock.setEnabled(true);
        holder.nStudentText.setEnabled(true);
        holder.nStudentText.setTextColor(context.getResources().getColor(R.color.sgilight_gray_32));
        holder.maxStudentText.setEnabled(true);
        holder.maxStudentText.setTextColor(context.getResources().getColor(R.color.sgilight_gray_32));
        holder.radioButton.setEnabled(true);
        holder.radioButton.setTextColor(context.getResources().getColor(android.R.color.black));
        holder.linearLayout.setEnabled(true);
        holder.vacantsText.setEnabled(true);
        holder.vacantsText.setTextColor(context.getResources().getColor(R.color.sgilight_gray_32));
    } else {
        holder.checkBox.setEnabled(false);
        holder.checkBox.setTextColor(context.getResources().getColor(R.color.sgilight_gray));
        holder.imagePadlock.setEnabled(false);
        holder.nStudentText.setEnabled(false);
        holder.nStudentText.setTextColor(context.getResources().getColor(R.color.sgilight_gray));
        holder.maxStudentText.setEnabled(false);
        holder.maxStudentText.setTextColor(context.getResources().getColor(R.color.sgilight_gray));
        holder.radioButton.setEnabled(false);
        holder.radioButton.setTextColor(context.getResources().getColor(R.color.sgilight_gray));
        holder.linearLayout.setEnabled(false);
        holder.vacantsText.setEnabled(false);
        holder.vacantsText.setTextColor(context.getResources().getColor(R.color.sgilight_gray));
    }
    //for multiple inscriptions the groups should be checkboxes to allow multiple choice
    //otherwise the groups should be radio button to allow just a single choice
    //Teachers can enroll in multiple groups even if the enrollment type for the group type is single
    if (multiple == 0 && role != Constants.TEACHER_TYPE_CODE) { //single inscriptions:
        holder.checkBox.setVisibility(View.GONE);
        holder.radioButton.setVisibility(View.VISIBLE);

        holder.radioButton.setText(groupName);
        if (member != 0) {
            holder.radioButton.setChecked(true);
        } else {
            holder.radioButton.setChecked(false);
        }
    } else { //multiple inscriptions :

        holder.checkBox.setVisibility(View.VISIBLE);
        holder.radioButton.setVisibility(View.GONE);

        holder.checkBox.setText(groupName);
        if (member != 0) {
            holder.checkBox.setChecked(true);
        } else {
            holder.checkBox.setChecked(false);
        }
    }

    holder.nStudentText.setText(context.getString(R.string.numStudent) + ": " + String.valueOf(students));

    if (maxStudents != -1) {
        int vacants = maxStudents - students;
        holder.maxStudentText
                .setText(context.getString(R.string.maxStudent) + ": " + String.valueOf(maxStudents));
        holder.vacantsText.setText(context.getString(R.string.vacants) + ": " + String.valueOf(vacants));
        if (vacants == 0) {
            holder.vacantsText.setTextColor(context.getResources().getColor(R.color.sgi_salmon));
            holder.vacantsText.setTypeface(null, Typeface.BOLD);
        } else
            holder.vacantsText.setTypeface(null, Typeface.NORMAL);

    } else {
        holder.maxStudentText.setVisibility(View.GONE);
        holder.vacantsText
                .setText(context.getString(R.string.vacants) + ": " + context.getString(R.string.withoutLimit));
        holder.vacantsText.setTypeface(null, Typeface.NORMAL);
    }

    return convertView;
}