List of usage examples for android.content.res Resources getInteger
public int getInteger(@IntegerRes int id) throws NotFoundException
From source file:com.fairphone.fplauncher3.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 w w . j ava 2 s . c o m 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) { 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.soma.Launcher.java
/** * Zoom the camera back into the workspace, hiding 'fromView'. * This is the opposite of showAppsCustomizeHelper. * @param animated If true, the transition will be animated. *///w w w . j a va 2 s . com private void hideAppsCustomizeHelper(Workspace.State toState, final boolean animated, final boolean springLoaded, final Runnable onCompleteRunnable) { if (mStateAnimation != null) { mStateAnimation.setDuration(0); mStateAnimation.cancel(); mStateAnimation = null; } Resources res = getResources(); final int duration = res.getInteger(R.integer.config_appsCustomizeZoomOutTime); final int fadeOutDuration = res.getInteger(R.integer.config_appsCustomizeFadeOutTime); final float scaleFactor = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor); final View fromView = mAppsCustomizeTabHost; final View toView = mWorkspace; Animator workspaceAnim = null; if (toState == Workspace.State.NORMAL) { int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger); workspaceAnim = mWorkspace.getChangeStateAnimation(toState, animated, stagger, -1); } else if (toState == Workspace.State.SPRING_LOADED || toState == Workspace.State.OVERVIEW) { workspaceAnim = mWorkspace.getChangeStateAnimation(toState, animated); } setPivotsForZoom(fromView, scaleFactor); showHotseat(animated); if (animated) { final LauncherViewPropertyAnimator scaleAnim = new LauncherViewPropertyAnimator(fromView); scaleAnim.scaleX(scaleFactor).scaleY(scaleFactor).setDuration(duration) .setInterpolator(new Workspace.ZoomInInterpolator()); final ObjectAnimator alphaAnim = LauncherAnimUtils.ofFloat(fromView, "alpha", 1f, 0f) .setDuration(fadeOutDuration); alphaAnim.setInterpolator(new AccelerateDecelerateInterpolator()); alphaAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float t = 1f - (Float) animation.getAnimatedValue(); dispatchOnLauncherTransitionStep(fromView, t); dispatchOnLauncherTransitionStep(toView, t); } }); mStateAnimation = LauncherAnimUtils.createAnimatorSet(); dispatchOnLauncherTransitionPrepare(fromView, animated, true); dispatchOnLauncherTransitionPrepare(toView, animated, true); mAppsCustomizeContent.pauseScrolling(); mStateAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { fromView.setVisibility(View.GONE); dispatchOnLauncherTransitionEnd(fromView, animated, true); dispatchOnLauncherTransitionEnd(toView, animated, true); if (onCompleteRunnable != null) { onCompleteRunnable.run(); } mAppsCustomizeContent.updateCurrentPageScroll(); mAppsCustomizeContent.resumeScrolling(); } }); mStateAnimation.playTogether(scaleAnim, alphaAnim); if (workspaceAnim != null) { mStateAnimation.play(workspaceAnim); } dispatchOnLauncherTransitionStart(fromView, animated, true); dispatchOnLauncherTransitionStart(toView, animated, true); LauncherAnimUtils.startAnimationAfterNextDraw(mStateAnimation, toView); } else { fromView.setVisibility(View.GONE); dispatchOnLauncherTransitionPrepare(fromView, animated, true); dispatchOnLauncherTransitionStart(fromView, animated, true); dispatchOnLauncherTransitionEnd(fromView, animated, true); dispatchOnLauncherTransitionPrepare(toView, animated, true); dispatchOnLauncherTransitionStart(toView, animated, true); dispatchOnLauncherTransitionEnd(toView, animated, true); } }
From source file:xyz.klinker.blur.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.//ww w . ja va 2 s . co 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 = res.getInteger(R.integer.config_workspaceOverviewShrinkPercentage) / 100f; 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.android.soma.Launcher.java
private void showAppsCustomizeHelper(final boolean animated, final boolean springLoaded, final AppsCustomizePagedView.ContentType contentType) { if (mStateAnimation != null) { mStateAnimation.setDuration(0);/*from w w w . j a va2 s . com*/ mStateAnimation.cancel(); mStateAnimation = null; } final Resources res = getResources(); final int duration = res.getInteger(R.integer.config_appsCustomizeZoomInTime); final int fadeDuration = res.getInteger(R.integer.config_appsCustomizeFadeInTime); final float scale = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor); final View fromView = mWorkspace; final AppsCustomizeTabHost toView = mAppsCustomizeTabHost; final int startDelay = res.getInteger(R.integer.config_workspaceAppsCustomizeAnimationStagger); setPivotsForZoom(toView, scale); // Shrink workspaces away if going to AppsCustomize from workspace Animator workspaceAnim = mWorkspace.getChangeStateAnimation(Workspace.State.SMALL, animated); if (!AppsCustomizePagedView.DISABLE_ALL_APPS) { // Set the content type for the all apps space mAppsCustomizeTabHost.setContentTypeImmediate(contentType); } if (animated) { toView.setScaleX(scale); toView.setScaleY(scale); final LauncherViewPropertyAnimator scaleAnim = new LauncherViewPropertyAnimator(toView); scaleAnim.scaleX(1f).scaleY(1f).setDuration(duration) .setInterpolator(new Workspace.ZoomOutInterpolator()); toView.setVisibility(View.VISIBLE); toView.setAlpha(0f); final ObjectAnimator alphaAnim = LauncherAnimUtils.ofFloat(toView, "alpha", 0f, 1f) .setDuration(fadeDuration); alphaAnim.setInterpolator(new DecelerateInterpolator(1.5f)); alphaAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (animation == null) { throw new RuntimeException("animation is null"); } float t = (Float) animation.getAnimatedValue(); dispatchOnLauncherTransitionStep(fromView, t); dispatchOnLauncherTransitionStep(toView, t); } }); // toView should appear right at the end of the workspace shrink // animation mStateAnimation = LauncherAnimUtils.createAnimatorSet(); mStateAnimation.play(scaleAnim).after(startDelay); mStateAnimation.play(alphaAnim).after(startDelay); mStateAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { // Prepare the position toView.setTranslationX(0.0f); toView.setTranslationY(0.0f); toView.setVisibility(View.VISIBLE); toView.bringToFront(); } @Override public void onAnimationEnd(Animator animation) { dispatchOnLauncherTransitionEnd(fromView, animated, false); dispatchOnLauncherTransitionEnd(toView, animated, false); // Hide the search bar if (mSearchDropTargetBar != null) { mSearchDropTargetBar.hideSearchBar(false); } } }); if (workspaceAnim != null) { mStateAnimation.play(workspaceAnim); } boolean delayAnim = false; dispatchOnLauncherTransitionPrepare(fromView, animated, false); dispatchOnLauncherTransitionPrepare(toView, animated, false); // If any of the objects being animated haven't been measured/laid out // yet, delay the animation until we get a layout pass if ((((LauncherTransitionable) toView).getContent().getMeasuredWidth() == 0) || (mWorkspace.getMeasuredWidth() == 0) || (toView.getMeasuredWidth() == 0)) { delayAnim = true; } final AnimatorSet stateAnimation = mStateAnimation; final Runnable startAnimRunnable = new Runnable() { public void run() { // Check that mStateAnimation hasn't changed while // we waited for a layout/draw pass if (mStateAnimation != stateAnimation) return; setPivotsForZoom(toView, scale); dispatchOnLauncherTransitionStart(fromView, animated, false); dispatchOnLauncherTransitionStart(toView, animated, false); LauncherAnimUtils.startAnimationAfterNextDraw(mStateAnimation, toView); } }; if (delayAnim) { final ViewTreeObserver observer = toView.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { public void onGlobalLayout() { startAnimRunnable.run(); toView.getViewTreeObserver().removeOnGlobalLayoutListener(this); } }); } else { startAnimRunnable.run(); } } else { toView.setTranslationX(0.0f); toView.setTranslationY(0.0f); toView.setScaleX(1.0f); toView.setScaleY(1.0f); toView.setVisibility(View.VISIBLE); toView.bringToFront(); if (!springLoaded && !LauncherAppState.getInstance().isScreenLarge()) { // Hide the search bar if (mSearchDropTargetBar != null) { mSearchDropTargetBar.hideSearchBar(false); } } dispatchOnLauncherTransitionPrepare(fromView, animated, false); dispatchOnLauncherTransitionStart(fromView, animated, false); dispatchOnLauncherTransitionEnd(fromView, animated, false); dispatchOnLauncherTransitionPrepare(toView, animated, false); dispatchOnLauncherTransitionStart(toView, animated, false); dispatchOnLauncherTransitionEnd(toView, animated, false); } }
From source file:com.android.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);/*from w ww . j a v a2 s . co m*/ 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) { 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.phonemetra.turbo.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 ww . j a v a 2 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(); mShowSearchBar = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH, R.bool.preferences_interface_homescreen_search_default); mShowOutlines = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_PAGE_OUTLINES, R.bool.preferences_interface_homescreen_scrolling_page_outlines_default); mHideIconLabels = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS, R.bool.preferences_interface_homescreen_hide_icon_labels_default); mWorkspaceFadeInAdjacentScreens = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_FADE_ADJACENT, R.bool.preferences_interface_homescreen_scrolling_fade_adjacent_default); TransitionEffect.setFromString(this, SettingsProvider.getString(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_TRANSITION_EFFECT, R.string.preferences_interface_homescreen_scrolling_transition_effect)); mLauncher = (Launcher) context; final Resources res = getResources(); mFadeInAdjacentScreens = false; mWallpaperManager = WallpaperManager.getInstance(context); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0); mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f; mOverviewModeShrinkFactor = grid.getOverviewModeScale(); mCameraDistance = res.getInteger(R.integer.config_cameraDistance); mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1); mDefaultScreenId = SettingsProvider.getLongCustomDefault(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_DEFAULT_SCREEN_ID, -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.android.launcher2.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 a va2 s. co m */ public Workspace(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mContentIsRefreshable = false; mOriginalPageSpacing = mPageSpacing; 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); int cellCountX = DEFAULT_CELL_COUNT_X; int cellCountY = DEFAULT_CELL_COUNT_Y; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0); if (LauncherApplication.isScreenLarge()) { // Determine number of rows/columns dynamically // TODO: This code currently fails on tablets with an aspect ratio < 1.3. // Around that ratio we should make cells the same size in portrait and // landscape TypedArray actionBarSizeTypedArray = context .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize }); final float actionBarHeight = actionBarSizeTypedArray.getDimension(0, 0f); Point minDims = new Point(); Point maxDims = new Point(); DisplayCompt.getCurrentSizeRange(mLauncher.getWindowManager().getDefaultDisplay(), minDims, maxDims); cellCountX = 1; while (CellLayout.widthInPortrait(res, cellCountX + 1) <= minDims.x) { cellCountX++; } cellCountY = 1; while (actionBarHeight + CellLayout.heightInLandscape(res, cellCountY + 1) <= minDims.y) { cellCountY++; } } mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f; mSpringLoadedPageSpacing = res.getDimensionPixelSize(R.dimen.workspace_spring_loaded_page_spacing); mCameraDistance = res.getInteger(R.integer.config_cameraDistance); // if the value is manually specified, use that instead cellCountX = a.getInt(R.styleable.Workspace_cellCountX, cellCountX); cellCountY = a.getInt(R.styleable.Workspace_cellCountY, cellCountY); mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1); a.recycle(); setOnHierarchyChangeListener(this); LauncherModel.updateWorkspaceLayoutCells(cellCountX, cellCountY); setHapticFeedbackEnabled(false); initWorkspace(); // Disable multitouch across the workspace/all apps/customize tray setMotionEventSplittingEnabled(true); // Unless otherwise specified this view is important for accessibility. if (ViewCompat.getImportantForAccessibility(this) == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { ViewCompat.setImportantForAccessibility(this, View.IMPORTANT_FOR_ACCESSIBILITY_YES); } }
From source file:com.zyk.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.//from w ww.ja v a 2 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 = LauncherAppState.getInstance().getDynamicGrid().getDeviceProfile() .shouldFadeAdjacentWorkspaceScreens(); mFadeInAdjacentScreens = false; mWallpaperManager = WallpaperManager.getInstance(context); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0); mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f; mOverviewModeShrinkFactor = grid.getOverviewModeScale(); 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); mDragUtils = new DragUtils(mLauncher, this); }
From source file:com.android.mail.utils.NotificationUtils.java
private static void configureLatestEventInfoFromConversation(final Context context, final Account account, final FolderPreferences folderPreferences, final NotificationCompat.Builder notificationBuilder, final NotificationCompat.WearableExtender wearableExtender, final Map<Integer, NotificationBuilders> msgNotifications, final int summaryNotificationId, final Cursor conversationCursor, final PendingIntent clickIntent, final Intent notificationIntent, final int unreadCount, final int unseenCount, final Folder folder, final long when, final ContactFetcher contactFetcher) { final Resources res = context.getResources(); final boolean multipleUnseen = unseenCount > 1; LogUtils.i(LOG_TAG, "Showing notification with unreadCount of %d and unseenCount of %d", unreadCount, unseenCount);//from www. j a v a2 s . c om 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 (multipleUnseen) { // Build the string that describes the number of new messages final String newMessagesString = createTitle(context, unseenCount); // The ticker initially start as the new messages string. notificationTicker = newMessagesString; // The title of the notification is the new messages string notificationBuilder.setContentTitle(newMessagesString); // TODO(skennedy) Can we remove this check? if (com.android.mail.utils.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. notificationBuilder.setSubText(isInbox ? account.getDisplayName() : notificationLabelName); final NotificationCompat.InboxStyle digest = new NotificationCompat.InboxStyle(notificationBuilder); // Group by account and folder final String notificationGroupKey = createGroupKey(account, folder); // Track all senders to later tag them along with the digest notification final HashSet<String> senderAddressesSet = new HashSet<String>(); notificationBuilder.setGroup(notificationGroupKey).setGroupSummary(true); ConfigResult firstResult = null; 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); addEmailAddressToSet(fromAddress, senderAddressesSet); } while (messageCursor.moveToPosition(messageCursor.getPosition() - 1)) { final Message message = messageCursor.getMessage(); if (!message.read && !fromAddress.contentEquals(message.getFrom())) { multipleUnreadThread = true; addEmailAddressToSet(message.getFrom(), senderAddressesSet); } } final SpannableStringBuilder sendersBuilder; if (multipleUnreadThread) { final int sendersLength = res.getInteger(R.integer.swipe_senders_length); sendersBuilder = getStyledSenders(context, conversationCursor, sendersLength, account); } else { sendersBuilder = new SpannableStringBuilder(getWrappedFromString(from)); } final CharSequence digestLine = getSingleMessageInboxLine(context, sendersBuilder.toString(), ConversationItemView.filterTag(context, conversation.subject), conversation.getSnippet()); digest.addLine(digestLine); numDigestItems++; // Adding conversation notification for Wear. NotificationCompat.Builder conversationNotif = new NotificationCompat.Builder(context); conversationNotif.setCategory(NotificationCompat.CATEGORY_EMAIL); conversationNotif.setSmallIcon(R.drawable.ic_notification_multiple_mail_24dp); if (com.android.mail.utils.Utils.isRunningLOrLater()) { conversationNotif .setColor(context.getResources().getColor(R.color.notification_icon_color)); } conversationNotif.setContentText(digestLine); Intent conversationNotificationIntent = createViewConversationIntent(context, account, folder, conversationCursor); PendingIntent conversationClickIntent = createClickPendingIntent(context, conversationNotificationIntent); conversationNotif.setContentIntent(conversationClickIntent); conversationNotif.setAutoCancel(true); // Conversations are sorted in descending order, but notification sort // key is in ascending order. Invert the order key to get the right // order. Left pad 19 zeros because it's a long. String groupSortKey = String.format("%019d", (Long.MAX_VALUE - conversation.orderKey)); conversationNotif.setGroup(notificationGroupKey); conversationNotif.setSortKey(groupSortKey); conversationNotif.setWhen(conversation.dateMs); int conversationNotificationId = getNotificationId(summaryNotificationId, conversation.hashCode()); final NotificationCompat.WearableExtender conversationWearExtender = new NotificationCompat.WearableExtender(); final ConfigResult result = configureNotifForOneConversation(context, account, folderPreferences, conversationNotif, conversationWearExtender, conversationCursor, notificationIntent, folder, when, res, isInbox, notificationLabelName, conversationNotificationId, contactFetcher); msgNotifications.put(conversationNotificationId, NotificationBuilders.of(conversationNotif, conversationWearExtender)); if (firstResult == null) { firstResult = result; } } finally { if (messageCursor != null) { messageCursor.close(); } if (cursor != null) { cursor.close(); } } } } while (numDigestItems <= maxNumDigestItems && conversationCursor.moveToNext()); // Tag main digest notification with the senders tagNotificationsWithPeople(notificationBuilder, senderAddressesSet); if (firstResult != null && firstResult.contactIconInfo != null) { wearableExtender.setBackground(firstResult.contactIconInfo.wearableBg); } else { LogUtils.w(LOG_TAG, "First contact icon is null!"); wearableExtender.setBackground(getDefaultWearableBg(context)); } } else { // The body of the notification is the account name, or the label name. notificationBuilder.setContentText(isInbox ? account.getDisplayName() : 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 ConfigResult result = configureNotifForOneConversation(context, account, folderPreferences, notificationBuilder, wearableExtender, conversationCursor, notificationIntent, folder, when, res, isInbox, notificationLabelName, summaryNotificationId, contactFetcher); notificationTicker = result.notificationTicker; if (result.contactIconInfo != null) { wearableExtender.setBackground(result.contactIconInfo.wearableBg); } else { wearableExtender.setBackground(getDefaultWearableBg(context)); } } // 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 notificationBuilder.setTicker(notificationTicker); } // Set the number in the notification if (unreadCount > 1) { notificationBuilder.setNumber(unreadCount); } notificationBuilder.setContentIntent(clickIntent); }
From source file:io.github.runassudo.launchert.Workspace.java
/** * Used to inflate the Workspace from XML. * * @param context/*from ww w. j av a 2s .c om*/ * The application's context. * @param attrs * The attributes set containing the Workspace's customization * values. * @param defStyle * Unused. */ 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 = LauncherAppState.getInstance().getDynamicGrid().getDeviceProfile() .shouldFadeAdjacentWorkspaceScreens(); mFadeInAdjacentScreens = false; mWallpaperManager = WallpaperManager.getInstance(context); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0); mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f; mOverviewModeShrinkFactor = grid.getOverviewModeScale(); mCameraDistance = res.getInteger(R.integer.config_cameraDistance); //(LauncherT) Custom default page. // mOriginalDefaultPage = mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); mOriginalDefaultPage = mDefaultPage = Integer.parseInt(sharedPref.getString("desktop_default_screen", "0")); a.recycle(); setOnHierarchyChangeListener(this); setHapticFeedbackEnabled(false); initWorkspace(); // Disable multitouch across the workspace/all apps/customize tray setMotionEventSplittingEnabled(true); setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); }