Java Code Examples for android.widget.RemoteViews#setViewPadding()
The following examples show how to use
android.widget.RemoteViews#setViewPadding() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WidgetV24.java From prayer-times-android with Apache License 2.0 | 6 votes |
static void updateSilenter(Context context, AppWidgetManager appWidgetManager, int widgetId) { Theme theme = WidgetUtils.getTheme(widgetId); WidgetUtils.Size size = WidgetUtils.getSize(context, appWidgetManager, widgetId, 1); int s = size.width; if (s <= 0) return; RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_1x1_silenter); remoteViews.setInt(R.id.widget_layout, "setBackgroundResource", theme.background); remoteViews.setViewPadding(R.id.padder, s / 2, s / 2, s / 2, s / 2); Intent i = new Intent(context, SilenterPrompt.class); remoteViews.setOnClickPendingIntent(R.id.widget, PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT)); remoteViews.setTextViewText(R.id.text, context.getString(R.string.silent)); remoteViews.setTextViewTextSize(R.id.text, TypedValue.COMPLEX_UNIT_PX, s / 4f); remoteViews.setTextColor(R.id.text, theme.textcolor); appWidgetManager.updateAppWidget(widgetId, remoteViews); }
Example 2
Source File: WidgetV24.java From prayer-times-android with Apache License 2.0 | 6 votes |
static void updateSilenter(Context context, AppWidgetManager appWidgetManager, int widgetId) { Theme theme = WidgetUtils.getTheme(widgetId); WidgetUtils.Size size = WidgetUtils.getSize(context, appWidgetManager, widgetId, 1); int s = size.width; if (s <= 0) return; RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_1x1_silenter); remoteViews.setInt(R.id.widget_layout, "setBackgroundResource", theme.background); remoteViews.setViewPadding(R.id.padder, s / 2, s / 2, s / 2, s / 2); Intent i = new Intent(context, SilenterPrompt.class); remoteViews.setOnClickPendingIntent(R.id.widget, PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT)); remoteViews.setTextViewText(R.id.text, context.getString(R.string.silent)); remoteViews.setTextViewTextSize(R.id.text, TypedValue.COMPLEX_UNIT_PX, s / 4f); remoteViews.setTextColor(R.id.text, theme.textcolor); appWidgetManager.updateAppWidget(widgetId, remoteViews); }
Example 3
Source File: SuntimesLayout.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
/** * Apply the provided theme to the RemoteViews this layout knows about. * @param context the android application context * @param views the RemoteViews to apply the theme to * @param theme the theme object to apply to the views */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public void themeViews(Context context, RemoteViews views, SuntimesTheme theme) { SuntimesUtils.initDisplayStrings(context); // theme background SuntimesTheme.ThemeBackground background = theme.getBackground(); if (background.supportsCustomColors()) { views.setInt(R.id.widgetframe_inner, "setBackgroundColor", theme.getBackgroundColor()); } else { views.setInt(R.id.widgetframe_inner, "setBackgroundResource", background.getResID()); // BUG: setting background screws up padding; pre jellybean versions can't correct for it! // either live w/ it, or move this call into if statement below .. however then the background // doesn't update for pre jellybean versions, confusing users into thinking themes don't work // at all (and they really don't considering the background is 90% of the theme). } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { // fix theme padding (setting background resets padding to 0 for some reason) int[] padding = theme.getPaddingPixels(context); views.setViewPadding(R.id.widgetframe_inner, padding[0], padding[1], padding[2], padding[3]); // theme title text size views.setTextViewTextSize(R.id.text_title, TypedValue.COMPLEX_UNIT_DIP, theme.getTitleSizeSp()); } // theme title and text int titleColor = theme.getTitleColor(); views.setTextColor(R.id.text_title, titleColor); boldTitle = theme.getTitleBold(); boldTime = theme.getTimeBold(); }
Example 4
Source File: LeanplumNotificationHelper.java From Leanplum-Android-SDK with Apache License 2.0 | 5 votes |
/** * Gets Notification.BigPictureStyle with 2 lines text. * * @param message Push notification Bundle. * @param bigPicture Bitmap for BigPictureStyle notification. * @param title String with title for push notification. * @param messageText String with text for push notification. * @return Notification.BigPictureStyle or null. */ @TargetApi(16) static Notification.BigPictureStyle getBigPictureStyle(Bundle message, Bitmap bigPicture, String title, final String messageText) { if (Build.VERSION.SDK_INT < 16 || message == null || bigPicture == null) { return null; } Notification.BigPictureStyle bigPictureStyle = new Notification.BigPictureStyle() { @Override protected RemoteViews getStandardView(int layoutId) { RemoteViews remoteViews = super.getStandardView(layoutId); if (messageText != null && messageText.length() >= MAX_ONE_LINE_TEXT_LENGTH) { // Modifications of standard push RemoteView. try { int id = Resources.getSystem().getIdentifier("text", "id", "android"); remoteViews.setBoolean(id, "setSingleLine", false); remoteViews.setInt(id, "setLines", 2); if (Build.VERSION.SDK_INT < 23) { // Make text smaller. remoteViews.setViewPadding(id, 0, BIGPICTURE_TEXT_TOP_PADDING, 0, 0); remoteViews.setTextViewTextSize(id, TypedValue.COMPLEX_UNIT_SP, BIGPICTURE_TEXT_SIZE); } } catch (Throwable throwable) { Log.e("Cannot modify push notification layout."); } } return remoteViews; } }; bigPictureStyle.bigPicture(bigPicture) .setBigContentTitle(title) .setSummaryText(message.getString(Constants.Keys.PUSH_MESSAGE_TEXT)); return bigPictureStyle; }
Example 5
Source File: CustomNotificationBuilder.java From 365browser with Apache License 2.0 | 5 votes |
private void configureSettingsButton(RemoteViews bigView) { if (mSettingsAction == null) { bigView.setViewVisibility(R.id.origin_settings_icon, View.GONE); int rightPadding = dpToPx(BUTTON_ICON_PADDING_DP, mContext.getResources().getDisplayMetrics()); int leftPadding = Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP ? rightPadding : 0; bigView.setViewPadding(R.id.origin, leftPadding, 0, rightPadding, 0); return; } bigView.setOnClickPendingIntent(R.id.origin, mSettingsAction.intent); if (useMaterial()) { bigView.setInt(R.id.origin_settings_icon, "setColorFilter", BUTTON_ICON_COLOR_MATERIAL); } }
Example 6
Source File: CustomNotificationBuilder.java From AndroidChromium with Apache License 2.0 | 4 votes |
@Override public Notification build() { // A note about RemoteViews and updating notifications. When a notification is passed to the // {@code NotificationManager} with the same tag and id as a previous notification, an // in-place update will be performed. In that case, the actions of all new // {@link RemoteViews} will be applied to the views of the old notification. This is safe // for actions that overwrite old values such as setting the text of a {@code TextView}, but // care must be taken for additive actions. Especially in the case of // {@link RemoteViews#addView} the result could be to append new views below stale ones. In // that case {@link RemoteViews#removeAllViews} must be called before adding new ones. RemoteViews compactView = new RemoteViews(mContext.getPackageName(), R.layout.web_notification); RemoteViews bigView = new RemoteViews(mContext.getPackageName(), R.layout.web_notification_big); float fontScale = mContext.getResources().getConfiguration().fontScale; bigView.setInt(R.id.body, "setMaxLines", calculateMaxBodyLines(fontScale)); int scaledPadding = calculateScaledPadding(fontScale, mContext.getResources().getDisplayMetrics()); String formattedTime = ""; // Temporarily allowing disk access. TODO: Fix. See http://crbug.com/577185 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); try { long time = SystemClock.elapsedRealtime(); formattedTime = DateFormat.getTimeFormat(mContext).format(new Date()); RecordHistogram.recordTimesHistogram("Android.StrictMode.NotificationUIBuildTime", SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS); } finally { StrictMode.setThreadPolicy(oldPolicy); } for (RemoteViews view : new RemoteViews[] {compactView, bigView}) { view.setTextViewText(R.id.time, formattedTime); view.setTextViewText(R.id.title, mTitle); view.setTextViewText(R.id.body, mBody); view.setTextViewText(R.id.origin, mOrigin); view.setImageViewBitmap(R.id.icon, getNormalizedLargeIcon()); view.setViewPadding(R.id.title, 0, scaledPadding, 0, 0); view.setViewPadding(R.id.body_container, 0, scaledPadding, 0, scaledPadding); addWorkProfileBadge(view); int smallIconId = useMaterial() ? R.id.small_icon_overlay : R.id.small_icon_footer; view.setViewVisibility(smallIconId, View.VISIBLE); if (mSmallIconBitmap != null) { view.setImageViewBitmap(smallIconId, mSmallIconBitmap); } else { view.setImageViewResource(smallIconId, mSmallIconId); } } addActionButtons(bigView); configureSettingsButton(bigView); // Note: this is not a NotificationCompat builder so be mindful of the // API level of methods you call on the builder. Notification.Builder builder = new Notification.Builder(mContext); builder.setTicker(mTickerText); builder.setContentIntent(mContentIntent); builder.setDeleteIntent(mDeleteIntent); builder.setDefaults(mDefaults); builder.setVibrate(mVibratePattern); builder.setWhen(mTimestamp); builder.setOnlyAlertOnce(!mRenotify); builder.setContent(compactView); // Some things are duplicated in the builder to ensure the notification shows correctly on // Wear devices and custom lock screens. builder.setContentTitle(mTitle); builder.setContentText(mBody); builder.setSubText(mOrigin); builder.setLargeIcon(getNormalizedLargeIcon()); setSmallIconOnBuilder(builder, mSmallIconId, mSmallIconBitmap); for (Action action : mActions) { addActionToBuilder(builder, action); } if (mSettingsAction != null) { addActionToBuilder(builder, mSettingsAction); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Notification.Builder.setPublicVersion was added in Android L. builder.setPublicVersion(createPublicNotification(mContext)); } Notification notification = builder.build(); notification.bigContentView = bigView; return notification; }
Example 7
Source File: CustomNotificationBuilder.java From 365browser with Apache License 2.0 | 4 votes |
/** * If there are actions, shows the button related views, and adds a button for each action. */ private void addActionButtons(RemoteViews bigView) { // Remove the existing buttons in case an existing notification is being updated. bigView.removeAllViews(R.id.buttons); // Always set the visibility of the views associated with the action buttons. The current // visibility state is not known as perhaps an existing notification is being updated. int visibility = mActions.isEmpty() ? View.GONE : View.VISIBLE; bigView.setViewVisibility(R.id.button_divider, visibility); bigView.setViewVisibility(R.id.buttons, visibility); Resources resources = mContext.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); for (Action action : mActions) { RemoteViews view = new RemoteViews(mContext.getPackageName(), R.layout.web_notification_button); // If there is an icon then set it and add some padding. if (action.iconBitmap != null || action.iconId != 0) { if (useMaterial()) { view.setInt(R.id.button_icon, "setColorFilter", BUTTON_ICON_COLOR_MATERIAL); } int iconWidth = 0; if (action.iconBitmap != null) { view.setImageViewBitmap(R.id.button_icon, action.iconBitmap); iconWidth = action.iconBitmap.getWidth(); } else if (action.iconId != 0) { view.setImageViewResource(R.id.button_icon, action.iconId); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(resources, action.iconId, options); iconWidth = options.outWidth; } iconWidth = dpToPx( Math.min(pxToDp(iconWidth, metrics), MAX_ACTION_ICON_WIDTH_DP), metrics); // Set the padding of the button so the text does not overlap with the icon. Flip // between left and right manually as RemoteViews does not expose a method that sets // padding in a writing-direction independent way. int buttonPadding = dpToPx(BUTTON_PADDING_START_DP + BUTTON_ICON_PADDING_DP, metrics) + iconWidth; int buttonPaddingLeft = LocalizationUtils.isLayoutRtl() ? 0 : buttonPadding; int buttonPaddingRight = LocalizationUtils.isLayoutRtl() ? buttonPadding : 0; view.setViewPadding(R.id.button, buttonPaddingLeft, 0, buttonPaddingRight, 0); } view.setTextViewText(R.id.button, action.title); view.setOnClickPendingIntent(R.id.button, action.intent); bigView.addView(R.id.buttons, view); } }
Example 8
Source File: CustomNotificationBuilder.java From 365browser with Apache License 2.0 | 4 votes |
@Override public Notification build() { // A note about RemoteViews and updating notifications. When a notification is passed to the // {@code NotificationManager} with the same tag and id as a previous notification, an // in-place update will be performed. In that case, the actions of all new // {@link RemoteViews} will be applied to the views of the old notification. This is safe // for actions that overwrite old values such as setting the text of a {@code TextView}, but // care must be taken for additive actions. Especially in the case of // {@link RemoteViews#addView} the result could be to append new views below stale ones. In // that case {@link RemoteViews#removeAllViews} must be called before adding new ones. RemoteViews compactView = new RemoteViews(mContext.getPackageName(), R.layout.web_notification); RemoteViews bigView = new RemoteViews(mContext.getPackageName(), R.layout.web_notification_big); float fontScale = mContext.getResources().getConfiguration().fontScale; bigView.setInt(R.id.body, "setMaxLines", calculateMaxBodyLines(fontScale)); int scaledPadding = calculateScaledPadding(fontScale, mContext.getResources().getDisplayMetrics()); String formattedTime = ""; // Temporarily allowing disk access. TODO: Fix. See http://crbug.com/577185 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); try { long time = SystemClock.elapsedRealtime(); formattedTime = DateFormat.getTimeFormat(mContext).format(new Date()); RecordHistogram.recordTimesHistogram("Android.StrictMode.NotificationUIBuildTime", SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS); } finally { StrictMode.setThreadPolicy(oldPolicy); } for (RemoteViews view : new RemoteViews[] {compactView, bigView}) { view.setTextViewText(R.id.time, formattedTime); view.setTextViewText(R.id.title, mTitle); view.setTextViewText(R.id.body, mBody); view.setTextViewText(R.id.origin, mOrigin); view.setImageViewBitmap(R.id.icon, getNormalizedLargeIcon()); view.setViewPadding(R.id.title, 0, scaledPadding, 0, 0); view.setViewPadding(R.id.body_container, 0, scaledPadding, 0, scaledPadding); addWorkProfileBadge(view); int smallIconId = useMaterial() ? R.id.small_icon_overlay : R.id.small_icon_footer; view.setViewVisibility(smallIconId, View.VISIBLE); if (mSmallIconBitmap != null) { view.setImageViewBitmap(smallIconId, mSmallIconBitmap); } else { view.setImageViewResource(smallIconId, mSmallIconId); } } addActionButtons(bigView); configureSettingsButton(bigView); // Note: under the hood this is not a NotificationCompat builder so be mindful of the // API level of methods you call on the builder. // TODO(crbug.com/697104) We should probably use a Compat builder. ChromeNotificationBuilder builder = NotificationBuilderFactory.createChromeNotificationBuilder( false /* preferCompat */, mChannelId); builder.setTicker(mTickerText); builder.setContentIntent(mContentIntent); builder.setDeleteIntent(mDeleteIntent); builder.setDefaults(mDefaults); builder.setVibrate(mVibratePattern); builder.setWhen(mTimestamp); builder.setOnlyAlertOnce(!mRenotify); builder.setContent(compactView); // Some things are duplicated in the builder to ensure the notification shows correctly on // Wear devices and custom lock screens. builder.setContentTitle(mTitle); builder.setContentText(mBody); builder.setSubText(mOrigin); builder.setLargeIcon(getNormalizedLargeIcon()); setSmallIconOnBuilder(builder, mSmallIconId, mSmallIconBitmap); for (Action action : mActions) { addActionToBuilder(builder, action); } if (mSettingsAction != null) { addActionToBuilder(builder, mSettingsAction); } setGroupOnBuilder(builder, mOrigin); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Public versions only supported since L, and createPublicNotification requires L+. builder.setPublicVersion(createPublicNotification(mContext)); } return builder.buildWithBigContentView(bigView); }
Example 9
Source File: WidgetV24.java From prayer-times-android with Apache License 2.0 | 4 votes |
static void update1x1(Context context, AppWidgetManager appWidgetManager, int widgetId) { Theme theme = WidgetUtils.getTheme(widgetId); Times times = WidgetUtils.getTimes(widgetId); if (times == null) { WidgetUtils.showNoCityWidget(context, appWidgetManager, widgetId); return; } WidgetUtils.Size size = WidgetUtils.getSize(context, appWidgetManager, widgetId, 1); int s = size.width; if (s <= 0) return; RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_1x1); remoteViews.setInt(R.id.widget_layout, "setBackgroundResource", theme.background); remoteViews.setViewPadding(R.id.padder, s / 2, s / 2, s / 2, s / 2); int next = times.getNextTime(); String name = times.getName(); remoteViews.setOnClickPendingIntent(R.id.widget_layout, TimesFragment.getPendingIntent(times)); if (Preferences.COUNTDOWN_TYPE.get().equals(Preferences.COUNTDOWN_TYPE_SHOW_SECONDS)) remoteViews .setChronometer(R.id.countdown, times.getTime(LocalDate.now(), next).toDateTime().getMillis() - (System.currentTimeMillis() - SystemClock.elapsedRealtime()), null, true); else { String txt = LocaleUtils.formatPeriod(LocalDateTime.now(), times.getTime(LocalDate.now(), next), false); remoteViews.setString(R.id.countdown, "setFormat", txt); remoteViews.setChronometer(R.id.countdown, 0, txt, false); } remoteViews.setTextViewTextSize(R.id.countdown, TypedValue.COMPLEX_UNIT_PX, s / 4f); remoteViews.setTextViewText(R.id.city, name); remoteViews.setTextViewText(R.id.time, Vakit.getByIndex(next - 1).getString()); remoteViews.setTextColor(R.id.city, theme.textcolor); remoteViews.setTextColor(R.id.countdown, theme.textcolor); remoteViews.setTextColor(R.id.time, theme.textcolor); remoteViews.setTextViewTextSize(R.id.city, TypedValue.COMPLEX_UNIT_PX, (float) Math.min(s / 5f, 1.5 * s / name.length())); remoteViews.setTextViewTextSize(R.id.time, TypedValue.COMPLEX_UNIT_PX, s / 5f); remoteViews.setViewPadding(R.id.countdown, 0, -s / 16, 0, -s / 16); appWidgetManager.updateAppWidget(widgetId, remoteViews); }
Example 10
Source File: WidgetV24.java From prayer-times-android with Apache License 2.0 | 4 votes |
static void update2x2(Context context, AppWidgetManager appWidgetManager, int widgetId) { Theme theme = WidgetUtils.getTheme(widgetId); Times times = WidgetUtils.getTimes(widgetId); if (times == null) { WidgetUtils.showNoCityWidget(context, appWidgetManager, widgetId); return; } WidgetUtils.Size size = WidgetUtils.getSize(context, appWidgetManager, widgetId, 130f / 160f); int w = size.width; int h = size.height; if (w <= 0 || h <= 0) return; float scale = w / 10.5f; RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_2x2); remoteViews.setInt(R.id.widget_layout, "setBackgroundResource", theme.background); remoteViews.setViewPadding(R.id.padder, w / 2, h / 2, w / 2, h / 2); LocalDate date = LocalDate.now(); LocalDateTime[] daytimes = {times.getTime(date, Vakit.FAJR.ordinal()), times.getTime(date, Vakit.SUN.ordinal()), times.getTime(date, Vakit.DHUHR.ordinal()), times.getTime(date, Vakit.ASR.ordinal()), times.getTime(date, Vakit.MAGHRIB.ordinal()), times.getTime(date, Vakit.ISHAA.ordinal())}; remoteViews.setOnClickPendingIntent(R.id.widget_layout, TimesFragment.getPendingIntent(times)); remoteViews.setTextViewText(R.id.city, times.getName()); remoteViews.setTextColor(R.id.city, theme.textcolor); int current = times.getCurrentTime(); int next = current + 1; int indicator = current; if ("next".equals(Preferences.VAKIT_INDICATOR_TYPE.get())) indicator = indicator + 1; int[] idsText = {R.id.fajrText, R.id.sunText, R.id.zuhrText, R.id.asrText, R.id.maghribText, R.id.ishaaText}; int[] ids = {R.id.fajr, R.id.sun, R.id.zuhr, R.id.asr, R.id.maghrib, R.id.ishaa}; boolean rtl = Utils.isRTL(context); for (Vakit v : Vakit.values()) { int i = v.ordinal(); remoteViews.setTextViewTextSize(idsText[i], TypedValue.COMPLEX_UNIT_PX, scale * 1f); remoteViews.setTextViewTextSize(ids[i], TypedValue.COMPLEX_UNIT_PX, scale * 1f); remoteViews.setTextColor(idsText[i], theme.textcolor); remoteViews.setTextColor(ids[i], theme.textcolor); String name = Vakit.getByIndex(i).getString(); String time = LocaleUtils.formatTime(daytimes[i].toLocalTime()); if (Preferences.CLOCK_12H.get()) { time = time.replace(" ", "<sup><small>") + "</small></sup>"; } if (Preferences.SHOW_ALT_WIDGET_HIGHLIGHT.get()) { if (v.ordinal() == indicator) { name = "<b><i>" + name + "</i></b>"; time = "<b><i>" + time + "</i></b>"; } remoteViews.setInt(idsText[i], "setBackgroundColor", 0); remoteViews.setInt(ids[i], "setBackgroundColor", 0); } else { if (v.ordinal() == indicator) { remoteViews.setInt(idsText[i], "setBackgroundColor", theme.hovercolor); remoteViews.setInt(ids[i], "setBackgroundColor", theme.hovercolor); } else { remoteViews.setInt(idsText[i], "setBackgroundColor", 0); remoteViews.setInt(ids[i], "setBackgroundColor", 0); } } remoteViews.setTextViewText(idsText[i], Html.fromHtml(!rtl ? name : time)); remoteViews.setTextViewText(ids[i], Html.fromHtml(!rtl ? time : name)); remoteViews.setViewPadding(idsText[i], (int) ((Preferences.CLOCK_12H.get() ? 1.25 : 1.75) * scale), 0, (int) scale / 4, 0); remoteViews.setViewPadding(ids[i], 0, 0, (int) ((Preferences.CLOCK_12H.get() ? 1.25 : 1.75) * scale), 0); } remoteViews.setTextViewTextSize(R.id.city, TypedValue.COMPLEX_UNIT_PX, scale * 1.3f); remoteViews.setTextColor(R.id.countdown, theme.textcolor); remoteViews.setViewPadding(R.id.city, (int) scale / 2, 0, (int) scale / 2, (int) scale / 4); if (Preferences.COUNTDOWN_TYPE.get().equals(Preferences.COUNTDOWN_TYPE_SHOW_SECONDS)) remoteViews .setChronometer(R.id.countdown, times.getTime(LocalDate.now(), next).toDateTime().getMillis() - (System.currentTimeMillis() - SystemClock.elapsedRealtime()), null, true); else { String txt = LocaleUtils.formatPeriod(LocalDateTime.now(), times.getTime(LocalDate.now(), next), false); remoteViews.setString(R.id.countdown, "setFormat", txt); remoteViews.setChronometer(R.id.countdown, 0, txt, false); } remoteViews.setTextViewTextSize(R.id.countdown, TypedValue.COMPLEX_UNIT_PX, scale * 1.3f); appWidgetManager.updateAppWidget(widgetId, remoteViews); }
Example 11
Source File: CustomNotificationBuilder.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * If there are actions, shows the button related views, and adds a button for each action. */ private void addActionButtons(RemoteViews bigView) { // Remove the existing buttons in case an existing notification is being updated. bigView.removeAllViews(R.id.buttons); // Always set the visibility of the views associated with the action buttons. The current // visibility state is not known as perhaps an existing notification is being updated. int visibility = mActions.isEmpty() ? View.GONE : View.VISIBLE; bigView.setViewVisibility(R.id.button_divider, visibility); bigView.setViewVisibility(R.id.buttons, visibility); Resources resources = mContext.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); for (Action action : mActions) { RemoteViews view = new RemoteViews(mContext.getPackageName(), R.layout.web_notification_button); // If there is an icon then set it and add some padding. if (action.iconBitmap != null || action.iconId != 0) { if (useMaterial()) { view.setInt(R.id.button_icon, "setColorFilter", BUTTON_ICON_COLOR_MATERIAL); } int iconWidth = 0; if (action.iconBitmap != null) { view.setImageViewBitmap(R.id.button_icon, action.iconBitmap); iconWidth = action.iconBitmap.getWidth(); } else if (action.iconId != 0) { view.setImageViewResource(R.id.button_icon, action.iconId); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(resources, action.iconId, options); iconWidth = options.outWidth; } iconWidth = dpToPx( Math.min(pxToDp(iconWidth, metrics), MAX_ACTION_ICON_WIDTH_DP), metrics); // Set the padding of the button so the text does not overlap with the icon. Flip // between left and right manually as RemoteViews does not expose a method that sets // padding in a writing-direction independent way. int buttonPadding = dpToPx(BUTTON_PADDING_START_DP + BUTTON_ICON_PADDING_DP, metrics) + iconWidth; int buttonPaddingLeft = LocalizationUtils.isLayoutRtl() ? 0 : buttonPadding; int buttonPaddingRight = LocalizationUtils.isLayoutRtl() ? buttonPadding : 0; view.setViewPadding(R.id.button, buttonPaddingLeft, 0, buttonPaddingRight, 0); } view.setTextViewText(R.id.button, action.title); view.setOnClickPendingIntent(R.id.button, action.intent); bigView.addView(R.id.buttons, view); } }
Example 12
Source File: WidgetUnified.java From FairEmail with GNU General Public License v3.0 | 4 votes |
@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); for (int appWidgetId : appWidgetIds) { String name = prefs.getString("widget." + appWidgetId + ".name", null); long account = prefs.getLong("widget." + appWidgetId + ".account", -1L); long folder = prefs.getLong("widget." + appWidgetId + ".folder", -1L); String type = prefs.getString("widget." + appWidgetId + ".type", null); boolean semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true); int font = prefs.getInt("widget." + appWidgetId + ".font", 0); int padding = prefs.getInt("widget." + appWidgetId + ".padding", 0); Intent view = new Intent(context, ActivityView.class); view.setAction("folder:" + folder); view.putExtra("account", account); view.putExtra("type", type); view.putExtra("refresh", true); view.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); PendingIntent pi = PendingIntent.getActivity(context, appWidgetId, view, PendingIntent.FLAG_UPDATE_CURRENT); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_unified); if (!semi) views.setInt(R.id.widget, "setBackgroundColor", Color.TRANSPARENT); if (font > 0) views.setTextViewTextSize(R.id.title, TypedValue.COMPLEX_UNIT_SP, getFontSizeSp(font)); if (padding > 0) { int px = getPaddingPx(padding, context); views.setViewPadding(R.id.title, px, px, px, px); } if (name == null) views.setTextViewText(R.id.title, context.getString(R.string.title_folder_unified)); else views.setTextViewText(R.id.title, name); views.setOnClickPendingIntent(R.id.title, pi); Intent service = new Intent(context, WidgetUnifiedService.class); service.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); service.setData(Uri.parse(service.toUri(Intent.URI_INTENT_SCHEME))); views.setRemoteAdapter(R.id.lv, service); Intent thread = new Intent(context, ActivityView.class); thread.setAction("widget"); thread.putExtra("filter_archive", !EntityFolder.ARCHIVE.equals(type)); thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent piItem = PendingIntent.getActivity( context, ActivityView.REQUEST_WIDGET, thread, PendingIntent.FLAG_UPDATE_CURRENT); views.setPendingIntentTemplate(R.id.lv, piItem); appWidgetManager.updateAppWidget(appWidgetId, views); } }
Example 13
Source File: WidgetV24.java From prayer-times-android with Apache License 2.0 | 4 votes |
static void update1x1(Context context, AppWidgetManager appWidgetManager, int widgetId) { Theme theme = WidgetUtils.getTheme(widgetId); Times times = WidgetUtils.getTimes(widgetId); if (times == null) { WidgetUtils.showNoCityWidget(context, appWidgetManager, widgetId); return; } WidgetUtils.Size size = WidgetUtils.getSize(context, appWidgetManager, widgetId, 1); int s = size.width; if (s <= 0) return; RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_1x1); remoteViews.setInt(R.id.widget_layout, "setBackgroundResource", theme.background); remoteViews.setViewPadding(R.id.padder, s / 2, s / 2, s / 2, s / 2); int next = times.getNextTime(); String name = times.getName(); remoteViews.setOnClickPendingIntent(R.id.widget_layout, TimesFragment.getPendingIntent(times)); if (Preferences.COUNTDOWN_TYPE.get().equals(Preferences.COUNTDOWN_TYPE_SHOW_SECONDS)) remoteViews .setChronometer(R.id.countdown, times.getTime(LocalDate.now(), next).toDateTime().getMillis() - (System.currentTimeMillis() - SystemClock.elapsedRealtime()), null, true); else { String txt = LocaleUtils.formatPeriod(LocalDateTime.now(), times.getTime(LocalDate.now(), next), false); remoteViews.setString(R.id.countdown, "setFormat", txt); remoteViews.setChronometer(R.id.countdown, 0, txt, false); } remoteViews.setTextViewTextSize(R.id.countdown, TypedValue.COMPLEX_UNIT_PX, s / 4f); remoteViews.setTextViewText(R.id.city, name); remoteViews.setTextViewText(R.id.time, Vakit.getByIndex(next - 1).getString()); remoteViews.setTextColor(R.id.city, theme.textcolor); remoteViews.setTextColor(R.id.countdown, theme.textcolor); remoteViews.setTextColor(R.id.time, theme.textcolor); remoteViews.setTextViewTextSize(R.id.city, TypedValue.COMPLEX_UNIT_PX, (float) Math.min(s / 5f, 1.5 * s / name.length())); remoteViews.setTextViewTextSize(R.id.time, TypedValue.COMPLEX_UNIT_PX, s / 5f); remoteViews.setViewPadding(R.id.countdown, 0, -s / 16, 0, -s / 16); appWidgetManager.updateAppWidget(widgetId, remoteViews); }
Example 14
Source File: WidgetV24.java From prayer-times-android with Apache License 2.0 | 4 votes |
static void update2x2(Context context, AppWidgetManager appWidgetManager, int widgetId) { Theme theme = WidgetUtils.getTheme(widgetId); Times times = WidgetUtils.getTimes(widgetId); if (times == null) { WidgetUtils.showNoCityWidget(context, appWidgetManager, widgetId); return; } WidgetUtils.Size size = WidgetUtils.getSize(context, appWidgetManager, widgetId, 130f / 160f); int w = size.width; int h = size.height; if (w <= 0 || h <= 0) return; float scale = w / 10.5f; RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_2x2); remoteViews.setInt(R.id.widget_layout, "setBackgroundResource", theme.background); remoteViews.setViewPadding(R.id.padder, w / 2, h / 2, w / 2, h / 2); LocalDate date = LocalDate.now(); LocalDateTime[] daytimes = {times.getTime(date, Vakit.FAJR.ordinal()), times.getTime(date, Vakit.SUN.ordinal()), times.getTime(date, Vakit.DHUHR.ordinal()), times.getTime(date, Vakit.ASR.ordinal()), times.getTime(date, Vakit.MAGHRIB.ordinal()), times.getTime(date, Vakit.ISHAA.ordinal())}; remoteViews.setOnClickPendingIntent(R.id.widget_layout, TimesFragment.getPendingIntent(times)); remoteViews.setTextViewText(R.id.city, times.getName()); remoteViews.setTextColor(R.id.city, theme.textcolor); int current = times.getCurrentTime(); int next = current + 1; int indicator = current; if ("next".equals(Preferences.VAKIT_INDICATOR_TYPE.get())) indicator = indicator + 1; int[] idsText = {R.id.fajrText, R.id.sunText, R.id.zuhrText, R.id.asrText, R.id.maghribText, R.id.ishaaText}; int[] ids = {R.id.fajr, R.id.sun, R.id.zuhr, R.id.asr, R.id.maghrib, R.id.ishaa}; boolean rtl = Utils.isRTL(context); for (Vakit v : Vakit.values()) { int i = v.ordinal(); remoteViews.setTextViewTextSize(idsText[i], TypedValue.COMPLEX_UNIT_PX, scale * 1f); remoteViews.setTextViewTextSize(ids[i], TypedValue.COMPLEX_UNIT_PX, scale * 1f); remoteViews.setTextColor(idsText[i], theme.textcolor); remoteViews.setTextColor(ids[i], theme.textcolor); String name = Vakit.getByIndex(i).getString(); String time = LocaleUtils.formatTime(daytimes[i].toLocalTime()); if (Preferences.CLOCK_12H.get()) { time = time.replace(" ", "<sup><small>") + "</small></sup>"; } if (Preferences.SHOW_ALT_WIDGET_HIGHLIGHT.get()) { if (v.ordinal() == indicator) { name = "<b><i>" + name + "</i></b>"; time = "<b><i>" + time + "</i></b>"; } remoteViews.setInt(idsText[i], "setBackgroundColor", 0); remoteViews.setInt(ids[i], "setBackgroundColor", 0); } else { if (v.ordinal() == indicator) { remoteViews.setInt(idsText[i], "setBackgroundColor", theme.hovercolor); remoteViews.setInt(ids[i], "setBackgroundColor", theme.hovercolor); } else { remoteViews.setInt(idsText[i], "setBackgroundColor", 0); remoteViews.setInt(ids[i], "setBackgroundColor", 0); } } remoteViews.setTextViewText(idsText[i], Html.fromHtml(!rtl ? name : time)); remoteViews.setTextViewText(ids[i], Html.fromHtml(!rtl ? time : name)); remoteViews.setViewPadding(idsText[i], (int) ((Preferences.CLOCK_12H.get() ? 1.25 : 1.75) * scale), 0, (int) scale / 4, 0); remoteViews.setViewPadding(ids[i], 0, 0, (int) ((Preferences.CLOCK_12H.get() ? 1.25 : 1.75) * scale), 0); } remoteViews.setTextViewTextSize(R.id.city, TypedValue.COMPLEX_UNIT_PX, scale * 1.3f); remoteViews.setTextColor(R.id.countdown, theme.textcolor); remoteViews.setViewPadding(R.id.city, (int) scale / 2, 0, (int) scale / 2, (int) scale / 4); if (Preferences.COUNTDOWN_TYPE.get().equals(Preferences.COUNTDOWN_TYPE_SHOW_SECONDS)) remoteViews .setChronometer(R.id.countdown, times.getTime(LocalDate.now(), next).toDateTime().getMillis() - (System.currentTimeMillis() - SystemClock.elapsedRealtime()), null, true); else { String txt = LocaleUtils.formatPeriod(LocalDateTime.now(), times.getTime(LocalDate.now(), next), false); remoteViews.setString(R.id.countdown, "setFormat", txt); remoteViews.setChronometer(R.id.countdown, 0, txt, false); } remoteViews.setTextViewTextSize(R.id.countdown, TypedValue.COMPLEX_UNIT_PX, scale * 1.3f); appWidgetManager.updateAppWidget(widgetId, remoteViews); }
Example 15
Source File: CustomNotificationBuilder.java From delion with Apache License 2.0 | 4 votes |
/** * If there are actions, shows the button related views, and adds a button for each action. */ private void addActionButtons(RemoteViews bigView) { // Remove the existing buttons in case an existing notification is being updated. bigView.removeAllViews(R.id.buttons); // Always set the visibility of the views associated with the action buttons. The current // visibility state is not known as perhaps an existing notification is being updated. int visibility = mActions.isEmpty() ? View.GONE : View.VISIBLE; bigView.setViewVisibility(R.id.button_divider, visibility); bigView.setViewVisibility(R.id.buttons, visibility); Resources resources = mContext.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); for (Action action : mActions) { RemoteViews view = new RemoteViews(mContext.getPackageName(), R.layout.web_notification_button); // If there is an icon then set it and add some padding. if (action.iconBitmap != null || action.iconId != 0) { if (useMaterial()) { view.setInt(R.id.button_icon, "setColorFilter", BUTTON_ICON_COLOR_MATERIAL); } int iconWidth = 0; if (action.iconBitmap != null) { view.setImageViewBitmap(R.id.button_icon, action.iconBitmap); iconWidth = action.iconBitmap.getWidth(); } else if (action.iconId != 0) { view.setImageViewResource(R.id.button_icon, action.iconId); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(resources, action.iconId, options); iconWidth = options.outWidth; } iconWidth = dpToPx( Math.min(pxToDp(iconWidth, metrics), MAX_ACTION_ICON_WIDTH_DP), metrics); // Set the padding of the button so the text does not overlap with the icon. Flip // between left and right manually as RemoteViews does not expose a method that sets // padding in a writing-direction independent way. int buttonPadding = dpToPx(BUTTON_PADDING_START_DP + BUTTON_ICON_PADDING_DP, metrics) + iconWidth; int buttonPaddingLeft = LocalizationUtils.isLayoutRtl() ? 0 : buttonPadding; int buttonPaddingRight = LocalizationUtils.isLayoutRtl() ? buttonPadding : 0; view.setViewPadding(R.id.button, buttonPaddingLeft, 0, buttonPaddingRight, 0); } view.setTextViewText(R.id.button, action.title); view.setOnClickPendingIntent(R.id.button, action.intent); bigView.addView(R.id.buttons, view); } }
Example 16
Source File: CustomNotificationBuilder.java From delion with Apache License 2.0 | 4 votes |
@Override public Notification build() { // A note about RemoteViews and updating notifications. When a notification is passed to the // {@code NotificationManager} with the same tag and id as a previous notification, an // in-place update will be performed. In that case, the actions of all new // {@link RemoteViews} will be applied to the views of the old notification. This is safe // for actions that overwrite old values such as setting the text of a {@code TextView}, but // care must be taken for additive actions. Especially in the case of // {@link RemoteViews#addView} the result could be to append new views below stale ones. In // that case {@link RemoteViews#removeAllViews} must be called before adding new ones. RemoteViews compactView = new RemoteViews(mContext.getPackageName(), R.layout.web_notification); RemoteViews bigView = new RemoteViews(mContext.getPackageName(), R.layout.web_notification_big); float fontScale = mContext.getResources().getConfiguration().fontScale; bigView.setInt(R.id.body, "setMaxLines", calculateMaxBodyLines(fontScale)); int scaledPadding = calculateScaledPadding(fontScale, mContext.getResources().getDisplayMetrics()); String formattedTime = ""; // Temporarily allowing disk access. TODO: Fix. See http://crbug.com/577185 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); try { long time = SystemClock.elapsedRealtime(); formattedTime = DateFormat.getTimeFormat(mContext).format(new Date()); RecordHistogram.recordTimesHistogram("Android.StrictMode.NotificationUIBuildTime", SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS); } finally { StrictMode.setThreadPolicy(oldPolicy); } for (RemoteViews view : new RemoteViews[] {compactView, bigView}) { view.setTextViewText(R.id.time, formattedTime); view.setTextViewText(R.id.title, mTitle); view.setTextViewText(R.id.body, mBody); view.setTextViewText(R.id.origin, mOrigin); view.setImageViewBitmap(R.id.icon, mLargeIcon); view.setViewPadding(R.id.title, 0, scaledPadding, 0, 0); view.setViewPadding(R.id.body_container, 0, scaledPadding, 0, scaledPadding); addWorkProfileBadge(view); int smallIconId = useMaterial() ? R.id.small_icon_overlay : R.id.small_icon_footer; view.setViewVisibility(smallIconId, View.VISIBLE); if (mSmallIconBitmap != null) { view.setImageViewBitmap(smallIconId, mSmallIconBitmap); } else { view.setImageViewResource(smallIconId, mSmallIconId); } } addActionButtons(bigView); configureSettingsButton(bigView); // Note: this is not a NotificationCompat builder so be mindful of the // API level of methods you call on the builder. Notification.Builder builder = new Notification.Builder(mContext); builder.setTicker(mTickerText); builder.setContentIntent(mContentIntent); builder.setDeleteIntent(mDeleteIntent); builder.setDefaults(mDefaults); builder.setVibrate(mVibratePattern); builder.setWhen(mTimestamp); builder.setOnlyAlertOnce(!mRenotify); builder.setContent(compactView); // Some things are duplicated in the builder to ensure the notification shows correctly on // Wear devices and custom lock screens. builder.setContentTitle(mTitle); builder.setContentText(mBody); builder.setSubText(mOrigin); builder.setLargeIcon(mLargeIcon); setSmallIconOnBuilder(builder, mSmallIconId, mSmallIconBitmap); for (Action action : mActions) { addActionToBuilder(builder, action); } if (mSettingsAction != null) { addActionToBuilder(builder, mSettingsAction); } Notification notification = builder.build(); notification.bigContentView = bigView; return notification; }
Example 17
Source File: NotificationFixer.java From container with GNU General Public License v3.0 | 4 votes |
void fixIconImage(Resources resources, RemoteViews remoteViews, boolean hasIconBitmap, Notification notification) { if (remoteViews == null) return; if (!mNotificationCompat.isSystemLayout(remoteViews)) { VLog.w(TAG, "ignore not system contentView"); return; } // if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { try { //noinspection deprecation int id = R_Hide.id.icon.get(); if (!hasIconBitmap) { Drawable drawable = resources.getDrawable(android.R.drawable.sym_def_app_icon);//notification.icon); drawable.setLevel(notification.iconLevel); Bitmap bitmap = drawableToBitMap(drawable); // Log.i(NotificationHandler.TAG, "den" + resources.getConfiguration().densityDpi); remoteViews.setImageViewBitmap(id, bitmap); } if (Build.VERSION.SDK_INT >= 21) { remoteViews.setInt(id, "setBackgroundColor", Color.TRANSPARENT); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { remoteViews.setViewPadding(id, 0, 0, 0, 0); } } catch (Exception e) { e.printStackTrace(); VLog.w(TAG, "fix icon", e); } // } else { // try { // int id = R_Hide.id.icon.get(); // Icon icon = notification.getLargeIcon(); // if (icon == null) { // icon = notification.getSmallIcon(); // } // remoteViews.setImageViewIcon(id, icon); // if (Build.VERSION.SDK_INT >= 21) { // remoteViews.setInt(id, "setBackgroundColor", Color.TRANSPARENT); // } // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { // remoteViews.setViewPadding(id, 0, 0, 0, 0); // } // } catch (Exception e) { // e.printStackTrace(); // } // } }
Example 18
Source File: WidgetUnifiedRemoteViewsFactory.java From FairEmail with GNU General Public License v3.0 | 4 votes |
@Override public RemoteViews getViewAt(int position) { RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.item_widget_unified); int idFrom = (subject_top ? R.id.tvSubject : R.id.tvFrom); int idTime = (subject_top ? R.id.tvAccount : R.id.tvTime); int idSubject = (subject_top ? R.id.tvFrom : R.id.tvSubject); int idAccount = (subject_top ? R.id.tvTime : R.id.tvAccount); if (font > 0) { int sp = WidgetUnified.getFontSizeSp(font); views.setTextViewTextSize(idFrom, TypedValue.COMPLEX_UNIT_SP, sp); views.setTextViewTextSize(idTime, TypedValue.COMPLEX_UNIT_SP, sp); views.setTextViewTextSize(idSubject, TypedValue.COMPLEX_UNIT_SP, sp); views.setTextViewTextSize(idAccount, TypedValue.COMPLEX_UNIT_SP, sp); } if (padding > 0) { int px = WidgetUnified.getPaddingPx(padding, context); views.setViewPadding(R.id.llMessage, px, px, px, px); } if (position >= messages.size()) return views; try { TupleMessageWidget message = messages.get(position); Intent thread = new Intent(context, ActivityView.class); thread.putExtra("account", message.account); thread.putExtra("folder", message.folder); thread.putExtra("thread", message.thread); thread.putExtra("id", message.id); views.setOnClickFillInIntent(R.id.llMessage, thread); int colorBackground = (message.accountColor == null || !pro ? colorSeparator : message.accountColor); views.setInt(R.id.stripe, "setBackgroundColor", colorBackground); views.setViewVisibility(R.id.stripe, hasColor && color_stripe ? View.VISIBLE : View.GONE); SpannableString ssFrom = new SpannableString(pro ? MessageHelper.formatAddressesShort(message.from) : context.getString(R.string.title_pro_feature)); SpannableString ssTime = new SpannableString( Helper.getRelativeTimeSpanString(context, message.received)); SpannableString ssSubject = new SpannableString(pro ? TextUtils.isEmpty(message.subject) ? "" : message.subject : context.getString(R.string.title_pro_feature)); SpannableString ssAccount = new SpannableString( TextUtils.isEmpty(message.accountName) ? "" : message.accountName); if (message.ui_seen) { if (subject_italic) ssSubject.setSpan(new StyleSpan(Typeface.ITALIC), 0, ssSubject.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); } else { ssFrom.setSpan(new StyleSpan(Typeface.BOLD), 0, ssFrom.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); ssTime.setSpan(new StyleSpan(Typeface.BOLD), 0, ssTime.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); ssSubject.setSpan(new StyleSpan(subject_italic ? Typeface.BOLD_ITALIC : Typeface.BOLD), 0, ssSubject.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); ssAccount.setSpan(new StyleSpan(Typeface.BOLD), 0, ssAccount.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); } views.setTextViewText(idFrom, ssFrom); views.setTextViewText(idTime, ssTime); views.setTextViewText(idSubject, ssSubject); views.setTextViewText(idAccount, ssAccount); views.setTextColor(idFrom, message.ui_seen ? colorWidgetRead : colorWidgetForeground); views.setTextColor(idTime, message.ui_seen ? colorWidgetRead : colorWidgetForeground); views.setTextColor(idSubject, message.ui_seen ? colorWidgetRead : colorWidgetForeground); views.setTextColor(idAccount, message.ui_seen ? colorWidgetRead : colorWidgetForeground); views.setViewVisibility(idAccount, account < 0 ? View.VISIBLE : View.GONE); } catch (Throwable ex) { Log.e(ex); } return views; }