List of usage examples for android.widget RemoteViews setTextColor
public void setTextColor(int viewId, @ColorInt ColorStateList colors)
From source file:org.openbitcoinwidget.WidgetProvider.java
private static void updateViewsWithError(RemoteViews views, WidgetPreferences preferences) { views.setTextViewText(R.id.appwidget_last, "N/A"); views.setTextColor(R.id.appwidget_last, getColor(preferences.getColorMode(), WidgetColor.Warning)); views.setTextViewText(R.id.appwidget_updated, "@ " + dateFormat.format(new Date())); views.setTextColor(R.id.appwidget_updated, getColor(preferences.getColorMode(), WidgetColor.Normal)); }
From source file:barqsoft.footballscores.utils.FootballUtils.java
/** * method to set fixture view information * * @param context application context * @param views remote view to set the data. * @param cursor having information from database *//* ww w . ja v a 2 s .c om*/ public static void setFixtureView(Context context, RemoteViews views, Cursor cursor) { setPicasso(context, views, R.id.home_crest, cursor.getString(cursor.getColumnIndex(DatabaseContract.scores_table.HOME_LOGO_COL))); String homeTeamName = cursor.getString(cursor.getColumnIndex(DatabaseContract.scores_table.HOME_COL)); views.setTextViewText(R.id.home_name, homeTeamName); views.setTextColor(R.id.home_name, ContextCompat.getColor(context, R.color.secondary_text)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { Utility.setImageContentDescription(views, R.id.home_crest, homeTeamName); } // score and match time views.setTextViewText(R.id.score_textview, Utility.getScores( cursor.getInt(cursor.getColumnIndex(DatabaseContract.scores_table.HOME_GOALS_COL)), cursor.getInt(cursor.getColumnIndex(DatabaseContract.scores_table.AWAY_GOALS_COL)))); views.setTextColor(R.id.score_textview, ContextCompat.getColor(context, R.color.secondary_text)); views.setTextViewText(R.id.date_textview, cursor.getString(cursor.getColumnIndex(DatabaseContract.scores_table.TIME_COL))); views.setTextColor(R.id.date_textview, ContextCompat.getColor(context, R.color.secondary_text)); // away team logo and name setPicasso(context, views, R.id.away_crest, cursor.getString(cursor.getColumnIndex(DatabaseContract.scores_table.AWAY_LOGO_COL))); String awayTeamName = cursor.getString(cursor.getColumnIndex(DatabaseContract.scores_table.AWAY_COL)); views.setTextViewText(R.id.away_name, awayTeamName); views.setTextColor(R.id.away_name, ContextCompat.getColor(context, R.color.secondary_text)); // set content description on away team logo if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { Utility.setImageContentDescription(views, R.id.away_crest, awayTeamName); } }
From source file:st.brothas.mtgoxwidget.MtGoxWidgetProvider.java
private static void updateViews(RemoteViews views, MtGoxTickerData prevData, MtGoxTickerData newData, WidgetPreferences preferences) { String updated = "@ " + dateFormat.format(newData.getTimestamp()); String lastRounded = round(newData.getLast()); String lowRounded = round(newData.getLow()); String highRounded = round(newData.getHigh()); views.setTextViewText(R.id.appwidget_last, preferences.getCurrencyConversion().symbol + lastRounded); views.setTextColor(R.id.appwidget_updated, getColor(preferences.getColorMode(), WidgetColor.Normal)); if (newData.getTimestamp().before(getDateMinutesAgo(DATA_IS_CONSIDERED_OLD_AFTER_MINUTES))) { // Data is old, show it by "old" and "warning" colors views.setTextColor(R.id.appwidget_last, Color.GRAY); views.setTextColor(R.id.appwidget_updated, getColor(preferences.getColorMode(), WidgetColor.Warning)); } else if (prevData != null) { // We have previous data, compare to get the color views.setTextColor(R.id.appwidget_last, getColorFromValueChange(prevData.getLast(), newData.getLast(), preferences.getColorMode())); } else {/*from www . ja v a2 s. c o m*/ // No previous data, set standard color views.setTextColor(R.id.appwidget_last, getColor(preferences.getColorMode(), WidgetColor.StartValue)); } views.setTextViewText(R.id.appwidget_high, highRounded); views.setTextViewText(R.id.appwidget_low, lowRounded); views.setTextViewText(R.id.appwidget_updated, updated); //aws if (preferences.getCurrencyConversion().toString().contains("LTC_")) { views.setImageViewResource(R.id.appwidget_logo, R.drawable.lc_logo_32); } //else default which is bitcoin logo }
From source file:org.openbitcoinwidget.WidgetProvider.java
private static void updateViews(RemoteViews views, TickerData prevData, TickerData newData, WidgetPreferences preferences) { String updated = "@ " + dateFormat.format(newData.getTimestamp()); String lastRounded = round(newData.getLast(), preferences); String lowRounded = round(newData.getLow(), preferences); String highRounded = round(newData.getHigh(), preferences); views.setTextViewText(R.id.appwidget_last, preferences.getCurrencyConversion().symbol + lastRounded); views.setTextColor(R.id.appwidget_updated, getColor(preferences.getColorMode(), WidgetColor.Normal)); if (newData.getTimestamp().before(getDateMinutesAgo(DATA_IS_CONSIDERED_OLD_AFTER_MINUTES))) { // Data is old, show it by "old" and "warning" colors views.setTextColor(R.id.appwidget_last, Color.GRAY); views.setTextColor(R.id.appwidget_updated, getColor(preferences.getColorMode(), WidgetColor.Warning)); } else if (prevData != null) { // We have previous data, compare to get the color views.setTextColor(R.id.appwidget_last, getColorFromValueChange(prevData.getLast(), newData.getLast(), preferences.getColorMode())); } else {/*from w w w.j a v a 2 s .c o m*/ // No previous data, set standard color views.setTextColor(R.id.appwidget_last, getColor(preferences.getColorMode(), WidgetColor.StartValue)); } views.setTextViewText(R.id.appwidget_high, highRounded); views.setTextViewText(R.id.appwidget_low, lowRounded); views.setTextViewText(R.id.appwidget_updated, updated); // Set Litecoin logo if that is the chosen currency. switch (preferences.getCurrencyConversion().digitalCurrency) { case LITECOIN: views.setImageViewResource(R.id.appwidget_logo, R.drawable.logo); break; // The Bitcoin logo is default in the layout. } }
From source file:org.cowboycoders.cyclisimo.widgets.TrackWidgetProvider.java
/** * Updates recording status./*from www . j a v a 2 s . co m*/ * * @param context the context * @param remoteViews the remote views * @param isRecording true if recording * @param recordingTrackPaused true if recording track is paused */ private static void updateRecordStatus(Context context, RemoteViews remoteViews, boolean isRecording, boolean recordingTrackPaused) { String status; int colorId; if (isRecording) { status = context.getString(recordingTrackPaused ? R.string.generic_paused : R.string.generic_recording); colorId = recordingTrackPaused ? android.R.color.white : R.color.red; } else { status = ""; colorId = android.R.color.white; } remoteViews.setTextColor(R.id.track_widget_record_status, context.getResources().getColor(colorId)); remoteViews.setTextViewText(R.id.track_widget_record_status, status); }
From source file:br.com.bioscada.apps.biotracks.widgets.TrackWidgetProvider.java
/** * Updates recording status.//w w w.j a va 2 s .c o m * * @param context the context * @param remoteViews the remote views * @param isRecording true if recording * @param recordingTrackPaused true if recording track is paused */ private static void updateRecordStatus(Context context, RemoteViews remoteViews, boolean isRecording, boolean recordingTrackPaused) { String status; int colorId; if (isRecording) { status = context.getString(recordingTrackPaused ? R.string.generic_paused : R.string.generic_recording); colorId = recordingTrackPaused ? android.R.color.white : R.color.recording_text; } else { status = ""; colorId = android.R.color.white; } remoteViews.setTextColor(R.id.track_widget_record_status, context.getResources().getColor(colorId)); remoteViews.setTextViewText(R.id.track_widget_record_status, status); }
From source file:com.dmbstream.android.util.Util.java
public static void showPlayingNotification(final Context context, final DownloadServiceImpl downloadService, Handler handler, Track song) { // Use the same text for the ticker and the expanded notification String title = song.title;/*from w w w. j ava 2s . c o m*/ String text = song.artist; // Set the icon, scrolling text and timestamp final Notification notification = new Notification(R.drawable.notify_playing, title, System.currentTimeMillis()); notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.partial_notification); // set the text for the notifications contentView.setTextViewText(R.id.notification_title, title); contentView.setTextViewText(R.id.notification_artist, text); Pair<Integer, Integer> colors = getNotificationTextColors(context); if (colors.getFirst() != null) { contentView.setTextColor(R.id.notification_title, colors.getFirst()); } if (colors.getSecond() != null) { contentView.setTextColor(R.id.notification_artist, colors.getSecond()); } notification.contentView = contentView; // Send them to the main menu when if they click the notification // TODO: Send them to the concert, playlist, compilation details or chat page? Intent notificationIntent = new Intent(context, MainMenuActivity.class); notification.contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); // Send the notification and put the service in the foreground. handler.post(new Runnable() { @Override public void run() { startForeground(downloadService, Constants.NOTIFICATION_ID_PLAYING, notification); } }); // Update widget DmbstreamAppWidgetProvider.getInstance().notifyChange(context, downloadService, true); }
From source file:com.calendaridex.widget.WidgetViewsFactory.java
@Override public RemoteViews getViewAt(int position) { RemoteViews row = new RemoteViews(ctxt.getPackageName(), R.layout.widget_list_item); Event event = items.get(position); row.setTextViewText(R.id.text1, event.getTitle()); if (event.getAdminEvent()) { row.setTextColor(R.id.text1, ContextCompat.getColor(ctxt, R.color.colorPrimaryDark)); } else {//from w ww . j a v a 2 s .c o m row.setTextColor(R.id.text1, ContextCompat.getColor(ctxt, android.R.color.holo_green_dark)); } // Intent i=new Intent(); // Bundle extras=new Bundle(); // // extras.putString(CalendarWidget.EXTRA_WORD, event.getTitle()); // i.putExtras(extras); // row.setOnClickFillInIntent(android.R.id.text1, i); return row; }
From source file:dk.cafeanalog.AnalogWidget.java
private void handleIsOpen(final Context mContext, final OpeningStatus openingStatus) { final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext); final int[] appWidgetIds = appWidgetManager .getAppWidgetIds(new ComponentName(mContext, AnalogWidget.class)); final RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.analog_widget); views.setTextViewText(R.id.appwidget_text, mContext.getText(R.string.refreshing_analog)); views.setTextColor(R.id.appwidget_text, ContextCompat.getColor(mContext, android.R.color.primary_text_dark)); // Instruct the widget manager to update the widget for (int appWidgetId : appWidgetIds) { appWidgetManager.updateAppWidget(appWidgetId, views); }// w w w.j a va2s .c om CharSequence widgetText; if (openingStatus.open) { widgetText = mContext.getString(R.string.widget_open_analog); views.setTextColor(R.id.appwidget_text, ContextCompat.getColor(mContext, R.color.openColor)); } else { widgetText = mContext.getString(R.string.widget_closed_analog); views.setTextColor(R.id.appwidget_text, ContextCompat.getColor(mContext, R.color.closedColor)); } views.setTextViewText(R.id.appwidget_text, widgetText); views.setOnClickPendingIntent(R.id.appwidget_text, getPendingSelfIntent(mContext)); // Instruct the widget manager to update the widget for (int appWidgetId : appWidgetIds) { appWidgetManager.updateAppWidget(appWidgetId, views); } }
From source file:com.ultrafunk.network_info.receiver.WifiStatusReceiver.java
private void setStateColor(Context context, RemoteViews remoteViews, int state) { int color = (state == STATE_ON) ? ContextCompat.getColor(context, android.R.color.white) : ContextCompat.getColor(context, R.color.medium_gray); remoteViews.setTextColor(R.id.wifiNameTextView, color); remoteViews.setInt(R.id.wifiHeaderSpacerTextView, "setBackgroundColor", color); remoteViews.setTextColor(R.id.wifiInfoTopTextView, color); remoteViews.setTextColor(R.id.wifiInfoBottomTextView, color); }