Example usage for android.content.res Resources getInteger

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

Introduction

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

Prototype

public int getInteger(@IntegerRes int id) throws NotFoundException 

Source Link

Document

Return an integer associated with a particular resource ID.

Usage

From source file:com.klinker.android.launcher.launcher3.Workspace.java

public void animateWidgetDrop(ItemInfo info, CellLayout cellLayout, DragView dragView,
        final Runnable onCompleteRunnable, int animationType, final View finalView, boolean external) {
    Rect from = new Rect();
    mLauncher.getDragLayer().getViewRectRelativeToSelf(dragView, from);

    int[] finalPos = new int[2];
    float scaleXY[] = new float[2];
    boolean scalePreview = !(info instanceof PendingAddShortcutInfo);
    getFinalPositionForDropAnimation(finalPos, scaleXY, dragView, cellLayout, info, mTargetCell, external,
            scalePreview);//  w ww  .j  a va 2  s  .  c om

    Resources res = mLauncher.getResources();
    final int duration = res.getInteger(R.integer.config_dropAnimMaxDuration) - 200;

    // In the case where we've prebound the widget, we remove it from the DragLayer
    if (finalView instanceof AppWidgetHostView && external) {
        mLauncher.getDragLayer().removeView(finalView);
    }

    boolean isWidget = info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET
            || info.itemType == LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
    if ((animationType == ANIMATE_INTO_POSITION_AND_RESIZE || external) && finalView != null) {
        Bitmap crossFadeBitmap = createWidgetBitmap(info, finalView);
        dragView.setCrossFadeBitmap(crossFadeBitmap);
        dragView.crossFade((int) (duration * 0.8f));
    } else if (isWidget && external) {
        scaleXY[0] = scaleXY[1] = Math.min(scaleXY[0], scaleXY[1]);
    }

    DragLayer dragLayer = mLauncher.getDragLayer();
    if (animationType == CANCEL_TWO_STAGE_WIDGET_DROP_ANIMATION) {
        mLauncher.getDragLayer().animateViewIntoPosition(dragView, finalPos, 0f, 0.1f, 0.1f,
                DragLayer.ANIMATION_END_DISAPPEAR, onCompleteRunnable, duration);
    } else {
        int endStyle;
        if (animationType == ANIMATE_INTO_POSITION_AND_REMAIN) {
            endStyle = DragLayer.ANIMATION_END_REMAIN_VISIBLE;
        } else {
            endStyle = DragLayer.ANIMATION_END_DISAPPEAR;
            ;
        }

        Runnable onComplete = new Runnable() {
            @Override
            public void run() {
                if (finalView != null) {
                    finalView.setVisibility(VISIBLE);
                }
                if (onCompleteRunnable != null) {
                    onCompleteRunnable.run();
                }
            }
        };
        dragLayer.animateViewIntoPosition(dragView, from.left, from.top, finalPos[0], finalPos[1], 1, 1, 1,
                scaleXY[0], scaleXY[1], onComplete, endStyle, duration, this);
    }
}

From source file:com.aidy.launcher3.ui.workspace.Workspace.java

public void animateWidgetDrop(ItemInfoBean info, CellLayout cellLayout, DragView dragView,
        final Runnable onCompleteRunnable, int animationType, final View finalView, boolean external) {
    Rect from = new Rect();
    mLauncher.getDragLayer().getViewRectRelativeToSelf(dragView, from);

    int[] finalPos = new int[2];
    float scaleXY[] = new float[2];
    boolean scalePreview = !(info instanceof PendingAddShortcutInfo);
    getFinalPositionForDropAnimation(finalPos, scaleXY, dragView, cellLayout, info, mTargetCell, external,
            scalePreview);/* w ww. ja v  a 2 s.c o  m*/

    Resources res = mLauncher.getResources();
    int duration = res.getInteger(R.integer.config_dropAnimMaxDuration) - 200;

    // In the case where we've prebound the widget, we remove it from the
    // DragLayer
    if (finalView instanceof AppWidgetHostView && external) {
        Log.d(TAG, "6557954 Animate widget drop, final view is appWidgetHostView");
        mLauncher.getDragLayer().removeView(finalView);
    }
    if ((animationType == ANIMATE_INTO_POSITION_AND_RESIZE || external) && finalView != null) {
        Bitmap crossFadeBitmap = createWidgetBitmap(info, finalView);
        dragView.setCrossFadeBitmap(crossFadeBitmap);
        dragView.crossFade((int) (duration * 0.8f));
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET && external) {
        scaleXY[0] = scaleXY[1] = Math.min(scaleXY[0], scaleXY[1]);
    }

    DragLayer dragLayer = mLauncher.getDragLayer();
    if (animationType == CANCEL_TWO_STAGE_WIDGET_DROP_ANIMATION) {
        mLauncher.getDragLayer().animateViewIntoPosition(dragView, finalPos, 0f, 0.1f, 0.1f,
                DragLayer.ANIMATION_END_DISAPPEAR, onCompleteRunnable, duration);
    } else {
        int endStyle;
        if (animationType == ANIMATE_INTO_POSITION_AND_REMAIN) {
            endStyle = DragLayer.ANIMATION_END_REMAIN_VISIBLE;
        } else {
            endStyle = DragLayer.ANIMATION_END_DISAPPEAR;
            ;
        }

        Runnable onComplete = new Runnable() {
            @Override
            public void run() {
                if (finalView != null) {
                    finalView.setVisibility(VISIBLE);
                }
                if (onCompleteRunnable != null) {
                    onCompleteRunnable.run();
                }
            }
        };
        dragLayer.animateViewIntoPosition(dragView, from.left, from.top, finalPos[0], finalPos[1], 1, 1, 1,
                scaleXY[0], scaleXY[1], onComplete, endStyle, duration, this);
    }
}

From source file:com.android.ex.chips.RecipientEditTextView.java

private void setChipDimensions(final Context context, final AttributeSet attrs) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RecipientEditTextView, 0, 0);
    final Resources r = getContext().getResources();
    mChipBackground = a.getDrawable(R.styleable.RecipientEditTextView_chipBackground);
    if (mChipBackground == null)
        mChipBackground = ContextCompat.getDrawable(context, R.drawable.circle_background_chips);
    mChipBackgroundPressed = a.getDrawable(R.styleable.RecipientEditTextView_chipBackgroundPressed);
    if (mChipBackgroundPressed == null)
        mChipBackgroundPressed = ContextCompat.getDrawable(context, R.drawable.chip_background_selected);
    mChipDelete = a.getDrawable(R.styleable.RecipientEditTextView_chipDelete);
    if (mChipDelete == null)
        mChipDelete = ContextCompat.getDrawable(context, R.drawable.chip_delete);
    mChipPadding = a.getDimensionPixelSize(R.styleable.RecipientEditTextView_chipPadding, -1);
    if (mChipPadding == -1)
        mChipPadding = (int) r.getDimension(R.dimen.chip_padding);
    mAlternatesLayout = a.getResourceId(R.styleable.RecipientEditTextView_chipAlternatesLayout, -1);
    if (mAlternatesLayout == -1)
        mAlternatesLayout = R.layout.chips_alternate_item;
    mDefaultContactPhoto = BitmapFactory.decodeResource(r, R.drawable.ic_contact_picture);
    mMoreItem = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.more_item, null);
    mChipHeight = a.getDimensionPixelSize(R.styleable.RecipientEditTextView_chipHeight, -1);
    if (mChipHeight == -1)
        mChipHeight = r.getDimension(R.dimen.chip_height);
    mChipFontSize = a.getDimensionPixelSize(R.styleable.RecipientEditTextView_chipFontSize, -1);
    if (mChipFontSize == -1)
        mChipFontSize = r.getDimension(R.dimen.chip_text_size);
    mInvalidChipBackground = a.getDrawable(R.styleable.RecipientEditTextView_invalidChipBackground);
    if (mInvalidChipBackground == null)
        mInvalidChipBackground = ContextCompat.getDrawable(context, R.drawable.chip_background_invalid);
    mLineSpacingExtra = r.getDimension(R.dimen.line_spacing_extra);
    mMaxLines = r.getInteger(R.integer.chips_max_lines);
    final TypedValue tv = new TypedValue();
    if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
        mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
    a.recycle();//from  w  w w  . j a  va2 s  . c om
}

From source file:com.chen.mail.utils.NotificationUtils.java

private static void configureLatestEventInfoFromConversation(final Context context, final Account account,
        final FolderPreferences folderPreferences, final NotificationCompat.Builder notification,
        final Cursor conversationCursor, final PendingIntent clickIntent, final Intent notificationIntent,
        final int unreadCount, final int unseenCount, final Folder folder, final long when) {
    final Resources res = context.getResources();
    final String notificationAccount = account.name;

    LogUtils.i(LOG_TAG, "Showing notification with unreadCount of %d and unseenCount of %d", unreadCount,
            unseenCount);//w ww.j av a 2 s .  c  o m

    String notificationTicker = null;

    // Boolean indicating that this notification is for a non-inbox label.
    final boolean isInbox = folder.folderUri.fullUri.equals(account.settings.defaultInbox);

    // Notification label name for user label notifications.
    final String notificationLabelName = isInbox ? null : folder.name;

    if (unseenCount > 1) {
        // Build the string that describes the number of new messages
        final String newMessagesString = res.getString(R.string.new_messages, unseenCount);

        // Use the default notification icon
        notification
                .setLargeIcon(getDefaultNotificationIcon(context, folder, true /* multiple new messages */));

        // The ticker initially start as the new messages string.
        notificationTicker = newMessagesString;

        // The title of the notification is the new messages string
        notification.setContentTitle(newMessagesString);

        // TODO(skennedy) Can we remove this check?
        if (Utils.isRunningJellybeanOrLater()) {
            // For a new-style notification
            final int maxNumDigestItems = context.getResources()
                    .getInteger(R.integer.max_num_notification_digest_items);

            // The body of the notification is the account name, or the label name.
            notification.setSubText(isInbox ? notificationAccount : notificationLabelName);

            final NotificationCompat.InboxStyle digest = new NotificationCompat.InboxStyle(notification);

            int numDigestItems = 0;
            do {
                final Conversation conversation = new Conversation(conversationCursor);

                if (!conversation.read) {
                    boolean multipleUnreadThread = false;
                    // TODO(cwren) extract this pattern into a helper

                    Cursor cursor = null;
                    MessageCursor messageCursor = null;
                    try {
                        final Uri.Builder uriBuilder = conversation.messageListUri.buildUpon();
                        uriBuilder.appendQueryParameter(UIProvider.LABEL_QUERY_PARAMETER,
                                notificationLabelName);
                        cursor = context.getContentResolver().query(uriBuilder.build(),
                                UIProvider.MESSAGE_PROJECTION, null, null, null);
                        messageCursor = new MessageCursor(cursor);

                        String from = "";
                        String fromAddress = "";
                        if (messageCursor.moveToPosition(messageCursor.getCount() - 1)) {
                            final Message message = messageCursor.getMessage();
                            fromAddress = message.getFrom();
                            if (fromAddress == null) {
                                fromAddress = "";
                            }
                            from = getDisplayableSender(fromAddress);
                        }
                        while (messageCursor.moveToPosition(messageCursor.getPosition() - 1)) {
                            final Message message = messageCursor.getMessage();
                            if (!message.read && !fromAddress.contentEquals(message.getFrom())) {
                                multipleUnreadThread = true;
                                break;
                            }
                        }
                        final SpannableStringBuilder sendersBuilder;
                        if (multipleUnreadThread) {
                            final int sendersLength = res.getInteger(R.integer.swipe_senders_length);

                            sendersBuilder = getStyledSenders(context, conversationCursor, sendersLength,
                                    notificationAccount);
                        } else {
                            sendersBuilder = new SpannableStringBuilder(getWrappedFromString(from));
                        }
                        final CharSequence digestLine = getSingleMessageInboxLine(context,
                                sendersBuilder.toString(), conversation.subject, conversation.snippet);
                        digest.addLine(digestLine);
                        numDigestItems++;
                    } finally {
                        if (messageCursor != null) {
                            messageCursor.close();
                        }
                        if (cursor != null) {
                            cursor.close();
                        }
                    }
                }
            } while (numDigestItems <= maxNumDigestItems && conversationCursor.moveToNext());
        } else {
            // The body of the notification is the account name, or the label name.
            notification.setContentText(isInbox ? notificationAccount : notificationLabelName);
        }
    } else {
        // For notifications for a single new conversation, we want to get the information from
        // the conversation

        // Move the cursor to the most recent unread conversation
        seekToLatestUnreadConversation(conversationCursor);

        final Conversation conversation = new Conversation(conversationCursor);

        Cursor cursor = null;
        MessageCursor messageCursor = null;
        boolean multipleUnseenThread = false;
        String from = null;
        try {
            final Uri uri = conversation.messageListUri.buildUpon()
                    .appendQueryParameter(UIProvider.LABEL_QUERY_PARAMETER, folder.persistentId).build();
            cursor = context.getContentResolver().query(uri, UIProvider.MESSAGE_PROJECTION, null, null, null);
            messageCursor = new MessageCursor(cursor);
            // Use the information from the last sender in the conversation that triggered
            // this notification.

            String fromAddress = "";
            if (messageCursor.moveToPosition(messageCursor.getCount() - 1)) {
                final Message message = messageCursor.getMessage();
                fromAddress = message.getFrom();
                from = getDisplayableSender(fromAddress);
                notification.setLargeIcon(getContactIcon(context, from, getSenderAddress(fromAddress), folder));
            }

            // Assume that the last message in this conversation is unread
            int firstUnseenMessagePos = messageCursor.getPosition();
            while (messageCursor.moveToPosition(messageCursor.getPosition() - 1)) {
                final Message message = messageCursor.getMessage();
                final boolean unseen = !message.seen;
                if (unseen) {
                    firstUnseenMessagePos = messageCursor.getPosition();
                    if (!multipleUnseenThread && !fromAddress.contentEquals(message.getFrom())) {
                        multipleUnseenThread = true;
                    }
                }
            }

            // TODO(skennedy) Can we remove this check?
            if (Utils.isRunningJellybeanOrLater()) {
                // For a new-style notification

                if (multipleUnseenThread) {
                    // The title of a single conversation is the list of senders.
                    int sendersLength = res.getInteger(R.integer.swipe_senders_length);

                    final SpannableStringBuilder sendersBuilder = getStyledSenders(context, conversationCursor,
                            sendersLength, notificationAccount);

                    notification.setContentTitle(sendersBuilder);
                    // For a single new conversation, the ticker is based on the sender's name.
                    notificationTicker = sendersBuilder.toString();
                } else {
                    from = getWrappedFromString(from);
                    // The title of a single message the sender.
                    notification.setContentTitle(from);
                    // For a single new conversation, the ticker is based on the sender's name.
                    notificationTicker = from;
                }

                // The notification content will be the subject of the conversation.
                notification.setContentText(getSingleMessageLittleText(context, conversation.subject));

                // The notification subtext will be the subject of the conversation for inbox
                // notifications, or will based on the the label name for user label
                // notifications.
                notification.setSubText(isInbox ? notificationAccount : notificationLabelName);

                if (multipleUnseenThread) {
                    notification.setLargeIcon(getDefaultNotificationIcon(context, folder, true));
                }
                final NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle(
                        notification);

                // Seek the message cursor to the first unread message
                final Message message;
                if (messageCursor.moveToPosition(firstUnseenMessagePos)) {
                    message = messageCursor.getMessage();
                    bigText.bigText(getSingleMessageBigText(context, conversation.subject, message));
                } else {
                    LogUtils.e(LOG_TAG, "Failed to load message");
                    message = null;
                }

                if (message != null) {
                    final Set<String> notificationActions = folderPreferences.getNotificationActions(account);

                    final int notificationId = getNotificationId(account.getAccountManagerAccount(), folder);

                    NotificationActionUtils.addNotificationActions(context, notificationIntent, notification,
                            account, conversation, message, folder, notificationId, when, notificationActions);
                }
            } else {
                // For an old-style notification

                // The title of a single conversation notification is built from both the sender
                // and subject of the new message.
                notification.setContentTitle(
                        getSingleMessageNotificationTitle(context, from, conversation.subject));

                // The notification content will be the subject of the conversation for inbox
                // notifications, or will based on the the label name for user label
                // notifications.
                notification.setContentText(isInbox ? notificationAccount : notificationLabelName);

                // For a single new conversation, the ticker is based on the sender's name.
                notificationTicker = from;
            }
        } finally {
            if (messageCursor != null) {
                messageCursor.close();
            }
            if (cursor != null) {
                cursor.close();
            }
        }
    }

    // Build the notification ticker
    if (notificationLabelName != null && notificationTicker != null) {
        // This is a per label notification, format the ticker with that information
        notificationTicker = res.getString(R.string.label_notification_ticker, notificationLabelName,
                notificationTicker);
    }

    if (notificationTicker != null) {
        // If we didn't generate a notification ticker, it will default to account name
        notification.setTicker(notificationTicker);
    }

    // Set the number in the notification
    if (unreadCount > 1) {
        notification.setNumber(unreadCount);
    }

    notification.setContentIntent(clickIntent);
}

From source file:com.bang.launcher3.Workspace.java

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attributes set containing the Workspace's customization values.
 * @param defStyle Unused.//from  ww  w.ja  va 2 s .  c o m
 */
public Workspace(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mContentIsRefreshable = false;

    mOutlineHelper = HolographicOutlineHelper.obtain(context);

    mDragEnforcer = new DropTarget.DragEnforcer(context);
    // With workspace, data is available straight from the get-go
    setDataIsReady();

    mLauncher = (Launcher) context;
    final Resources res = getResources();
    mWorkspaceFadeInAdjacentScreens = res.getBoolean(R.bool.config_workspaceFadeAdjacentScreens);
    mFadeInAdjacentScreens = false;
    mWallpaperManager = WallpaperManager.getInstance(context);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0);
    mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
    mOverviewModeShrinkFactor = res.getInteger(R.integer.config_workspaceOverviewShrinkPercentage) / 100.0f;
    mOverviewModePageOffset = res.getDimensionPixelSize(R.dimen.overview_mode_page_offset);
    mCameraDistance = res.getInteger(R.integer.config_cameraDistance);
    mOriginalDefaultPage = mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1);
    a.recycle();

    setOnHierarchyChangeListener(this);
    setHapticFeedbackEnabled(false);

    initWorkspace();

    // Disable multitouch across the workspace/all apps/customize tray
    setMotionEventSplittingEnabled(true);
    setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
}

From source file:cc.flydev.launcher.Workspace.java

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attributes set containing the Workspace's customization values.
 * @param defStyle Unused./*  w w w  . j  av a2 s  .co  m*/
 */
public Workspace(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mContentIsRefreshable = false;

    mOutlineHelper = HolographicOutlineHelper.obtain(context);

    mDragEnforcer = new DropTarget.DragEnforcer(context);
    // With workspace, data is available straight from the get-go
    setDataIsReady();

    mLauncher = (Launcher) context;
    final Resources res = getResources();
    mWorkspaceFadeInAdjacentScreens = res.getBoolean(R.bool.config_workspaceFadeAdjacentScreens);
    mFadeInAdjacentScreens = false;
    mWallpaperManager = WallpaperManager.getInstance(context);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0);
    mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
    mOverviewModeShrinkFactor = res.getInteger(R.integer.config_workspaceOverviewShrinkPercentage) / 100.0f;
    mOverviewModePageOffset = res.getDimensionPixelSize(R.dimen.overview_mode_page_offset);
    mCameraDistance = res.getInteger(R.integer.config_cameraDistance);
    mOriginalDefaultPage = mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1);
    a.recycle();

    setOnHierarchyChangeListener(this);
    setHapticFeedbackEnabled(false);

    initWorkspace();

    // Disable multitouch across the workspace/all apps/customize tray
    setMotionEventSplittingEnabled(true);
    setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}

From source file:com.tct.mail.browse.ConversationItemView.java

private static synchronized void getItemViewResources(Context context) {
    if (sConfigurationChangedReceiver == null) {
        sConfigurationChangedReceiver = new BroadcastReceiver() {
            @Override/*w w w  .  ja va2s  . c  om*/
            public void onReceive(Context context, Intent intent) {
                STAR_OFF = null;
                //[BUGFIX]-Mod-BEGIN by TCTNB.caixia.chen,01/07/2015,PR 893304
                getItemViewResources(context.getApplicationContext());
                //[BUGFIX]-Mod-END by TCTNB.caixia.chen
            }
        };
        context.registerReceiver(sConfigurationChangedReceiver,
                new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED));
    }
    if (STAR_OFF == null) {
        final Resources res = context.getResources();
        // Initialize static bitmaps.
        //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 MOD-S
        // star off will not show in list item.
        //STAR_OFF = BitmapFactory.decodeResource(res, R.drawable.ic_star_outline_20dp);
        STAR_OFF = BitmapFactory.decodeResource(res, R.drawable.ic_importance_normal);
        //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 MOD-S
        STAR_ON = BitmapFactory.decodeResource(res, R.drawable.ic_star_20dp);
        ATTACHMENT = BitmapFactory.decodeResource(res, R.drawable.ic_attach_file_20dp);
        ONLY_TO_ME = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_double);
        TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_single);
        IMPORTANT_ONLY_TO_ME = BitmapFactory.decodeResource(res,
                R.drawable.ic_email_caret_double_important_unread);
        IMPORTANT_TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res,
                R.drawable.ic_email_caret_single_important_unread);
        IMPORTANT = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_none_important_unread);
        STATE_REPLIED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_reply_holo_light);
        STATE_FORWARDED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_forward_holo_light);
        STATE_REPLIED_AND_FORWARDED = BitmapFactory.decodeResource(res,
                R.drawable.ic_badge_reply_forward_holo_light);
        STATE_CALENDAR_INVITE = BitmapFactory.decodeResource(res, R.drawable.ic_badge_invite_holo_light);
        VISIBLE_CONVERSATION_HIGHLIGHT = res.getDrawable(R.drawable.visible_conversation_highlight);
        RIGHT_EDGE_TABLET = res.getDrawable(R.drawable.list_edge_tablet);
        //[FEATURE]-Add-BEGIN by TSCD.chao zhang,04/17/2014,FR 631895(porting from FR514398)
        sHighPriorityIcon = BitmapFactory.decodeResource(res, R.drawable.ic_high_priority);
        sLowPriorityIcon = BitmapFactory.decodeResource(res, R.drawable.ic_low_priority);
        sNormalPriorityIcon = BitmapFactory.decodeResource(res, R.drawable.ic_importance_normal);
        //[FEATURE]-Add-END by TSCD.chao zhang

        // Initialize colors.
        sActivatedTextSpan = CharacterStyle
                .wrap(new ForegroundColorSpan(res.getColor(R.color.senders_text_color)));
        sSendersTextColor = res.getColor(R.color.senders_text_color);
        sSubjectTextUnreadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceUnreadStyle);
        sSubjectTextReadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceReadStyle);

        sBadgeTextSpan = new TextAppearanceSpan(context, R.style.BadgeTextStyle);
        sBadgeBackgroundSpan = new BackgroundColorSpan(res.getColor(R.color.badge_background_color));
        sDateTextColorRead = res.getColor(R.color.date_text_color_read);
        sDateTextColorUnread = res.getColor(R.color.date_text_color_unread);
        sStarTouchSlop = res.getDimensionPixelSize(R.dimen.star_touch_slop);
        sSenderImageTouchSlop = res.getDimensionPixelSize(R.dimen.sender_image_touch_slop);
        sShrinkAnimationDuration = res.getInteger(R.integer.shrink_animation_duration);
        sSlideAnimationDuration = res.getInteger(R.integer.slide_animation_duration);
        // Initialize static color.
        sSendersSplitToken = res.getString(R.string.senders_split_token);
        sElidedPaddingToken = res.getString(R.string.elided_padding_token);
        sScrollSlop = res.getInteger(R.integer.swipeScrollSlop);
        sFoldersStartPadding = res.getDimensionPixelOffset(R.dimen.folders_start_padding);
        sFoldersInnerPadding = res.getDimensionPixelOffset(R.dimen.folder_cell_content_padding);
        sFoldersMaxCount = res.getInteger(R.integer.conversation_list_max_folder_count);
        sFoldersOverflowGradientPadding = res.getDimensionPixelOffset(R.dimen.folders_gradient_padding);
        sCabAnimationDuration = res.getInteger(R.integer.conv_item_view_cab_anim_duration);
        sBadgePaddingExtraWidth = res.getDimensionPixelSize(R.dimen.badge_padding_extra_width);
        sBadgeRoundedCornerRadius = res.getDimensionPixelSize(R.dimen.badge_rounded_corner_radius);
        sFolderRoundedCornerRadius = res.getDimensionPixelOffset(R.dimen.folder_rounded_corner_radius);
        sDividerColor = res.getColor(R.color.conversation_list_divider_color);
        sDividerInset = res.getDimensionPixelSize(R.dimen.conv_list_divider_inset);
        sDividerHeight = res.getDimensionPixelSize(R.dimen.divider_height);
    }
}

From source file:xyz.klinker.blur.launcher3.Workspace.java

public void animateWidgetDrop(ItemInfo info, CellLayout cellLayout, final DragView dragView,
        final Runnable onCompleteRunnable, int animationType, final View finalView, boolean external) {
    Rect from = new Rect();
    mLauncher.getDragLayer().getViewRectRelativeToSelf(dragView, from);

    int[] finalPos = new int[2];
    float scaleXY[] = new float[2];
    boolean scalePreview = !(info instanceof PendingAddShortcutInfo);
    getFinalPositionForDropAnimation(finalPos, scaleXY, dragView, cellLayout, info, mTargetCell, scalePreview);

    Resources res = mLauncher.getResources();
    final int duration = res.getInteger(R.integer.config_dropAnimMaxDuration) - 200;

    boolean isWidget = info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET
            || info.itemType == LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
    if ((animationType == ANIMATE_INTO_POSITION_AND_RESIZE || external) && finalView != null) {
        Bitmap crossFadeBitmap = createWidgetBitmap(info, finalView);
        dragView.setCrossFadeBitmap(crossFadeBitmap);
        dragView.crossFade((int) (duration * 0.8f));
    } else if (isWidget && external) {
        scaleXY[0] = scaleXY[1] = Math.min(scaleXY[0], scaleXY[1]);
    }//w w w  . j  ava2  s. c om

    DragLayer dragLayer = mLauncher.getDragLayer();
    if (animationType == CANCEL_TWO_STAGE_WIDGET_DROP_ANIMATION) {
        mLauncher.getDragLayer().animateViewIntoPosition(dragView, finalPos, 0f, 0.1f, 0.1f,
                DragLayer.ANIMATION_END_DISAPPEAR, onCompleteRunnable, duration);
    } else {
        int endStyle;
        if (animationType == ANIMATE_INTO_POSITION_AND_REMAIN) {
            endStyle = DragLayer.ANIMATION_END_REMAIN_VISIBLE;
        } else {
            endStyle = DragLayer.ANIMATION_END_DISAPPEAR;
        }

        Runnable onComplete = new Runnable() {
            @Override
            public void run() {
                if (finalView != null) {
                    finalView.setVisibility(VISIBLE);
                }
                if (onCompleteRunnable != null) {
                    onCompleteRunnable.run();
                }
            }
        };
        dragLayer.animateViewIntoPosition(dragView, from.left, from.top, finalPos[0], finalPos[1], 1, 1, 1,
                scaleXY[0], scaleXY[1], onComplete, endStyle, duration, this);
    }
}

From source file:com.klinker.android.launcher.launcher3.Workspace.java

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attributes set containing the Workspace's customization values.
 * @param defStyle Unused.//from  ww w.j av a 2  s  . c o m
 */
public Workspace(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mOutlineHelper = HolographicOutlineHelper.obtain(context);

    mLauncher = (Launcher) context;
    mStateTransitionAnimation = new WorkspaceStateTransitionAnimation(mLauncher, this);
    final Resources res = getResources();
    DeviceProfile grid = mLauncher.getDeviceProfile();
    mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
    mFadeInAdjacentScreens = false;
    mWallpaperManager = WallpaperManager.getInstance(context);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0);
    mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
    mOverviewModeShrinkFactor = grid.getOverviewModeScale(mIsRtl);
    mOriginalDefaultPage = mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1);
    a.recycle();

    setOnHierarchyChangeListener(this);
    setHapticFeedbackEnabled(false);

    initWorkspace();

    // Disable multitouch across the workspace/all apps/customize tray
    setMotionEventSplittingEnabled(true);

    mDetector = new GestureDetectorCompat(context, new MyGestureListener());
}

From source file:com.androzic.Androzic.java

public void onCreateEx() {
    try {/*from  w  w  w.j a  va2 s  .c om*/
        (new File(Environment.getExternalStorageDirectory(), WordManager.FOLDER)).mkdirs();
        (new File(Environment.getExternalStorageDirectory(), WordManager.FOLDER + "/ghiam")).mkdirs();
    } catch (Throwable e) {
    }

    if (initialized)
        return;

    AndroidGraphicFactory.createInstance(this);
    try {
        OzfDecoder.useNativeCalls();
    } catch (UnsatisfiedLinkError e) {
        Toast.makeText(Androzic.this, "Failed to initialize native library: " + e.getMessage(),
                Toast.LENGTH_LONG).show();
    }

    Resources resources = getResources();
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    Configuration config = resources.getConfiguration();

    renderingThread = new HandlerThread("RenderingThread");
    renderingThread.start();

    longOperationsThread = new HandlerThread("LongOperationsThread");
    longOperationsThread.setPriority(Thread.MIN_PRIORITY);
    longOperationsThread.start();

    uiHandler = new Handler();
    mapsHandler = new Handler(longOperationsThread.getLooper());

    // We silently initialize data uri to let location service restart after crash
    File datadir = new File(
            settings.getString(getString(R.string.pref_folder_data), Environment.getExternalStorageDirectory()
                    + File.separator + resources.getString(R.string.def_folder_data)));
    setDataPath(Androzic.PATH_DATA, datadir.getAbsolutePath());

    setInstance(this);

    String intentToCheck = "com.androzic.donate";
    String myPackageName = getPackageName();
    PackageManager pm = getPackageManager();
    PackageInfo pi;
    try {
        pi = pm.getPackageInfo(intentToCheck, 0);
        isPaid = (pm.checkSignatures(myPackageName, pi.packageName) == PackageManager.SIGNATURE_MATCH);
    } catch (NameNotFoundException e) {
        //         e.printStackTrace();
    }

    File sdcard = Environment.getExternalStorageDirectory();
    Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this, sdcard.getAbsolutePath()));

    DisplayMetrics displayMetrics = new DisplayMetrics();

    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    if (wm != null) {
        wm.getDefaultDisplay().getMetrics(displayMetrics);
    } else {
        displayMetrics.setTo(resources.getDisplayMetrics());
    }
    BaseMap.viewportWidth = displayMetrics.widthPixels;
    BaseMap.viewportHeight = displayMetrics.heightPixels;

    charset = settings.getString(getString(R.string.pref_charset), "UTF-8");
    String lang = settings.getString(getString(R.string.pref_locale), "");
    if (!"".equals(lang) && !config.locale.getLanguage().equals(lang)) {
        locale = new Locale(lang);
        Locale.setDefault(locale);
        config.locale = locale;
        resources.updateConfiguration(config, resources.getDisplayMetrics());
    }

    magInterval = resources.getInteger(R.integer.def_maginterval) * 1000;

    overlayManager = new OverlayManager(longOperationsThread.getLooper());
    TooltipManager.initialize(this);

    onSharedPreferenceChanged(settings, getString(R.string.pref_unitcoordinate));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitdistance));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitspeed));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitelevation));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitangle));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitanglemagnetic));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitprecision));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitsunrise));
    onSharedPreferenceChanged(settings, getString(R.string.pref_mapadjacent));
    onSharedPreferenceChanged(settings, getString(R.string.pref_vectormap_textscale));
    onSharedPreferenceChanged(settings, getString(R.string.pref_onlinemapprescalefactor));
    onSharedPreferenceChanged(settings, getString(R.string.pref_onlinemapexpiration));
    onSharedPreferenceChanged(settings, getString(R.string.pref_mapcropborder));
    onSharedPreferenceChanged(settings, getString(R.string.pref_mapdrawborder));
    onSharedPreferenceChanged(settings, getString(R.string.pref_showwaypoints));
    onSharedPreferenceChanged(settings, getString(R.string.pref_showcurrenttrack));
    onSharedPreferenceChanged(settings, getString(R.string.pref_showaccuracy));
    onSharedPreferenceChanged(settings, getString(R.string.pref_showdistance_int));

    settings.registerOnSharedPreferenceChangeListener(this);

    initialized = true;
}