Java Code Examples for android.widget.RemoteViews#setTextColor()

The following examples show how to use android.widget.RemoteViews#setTextColor() . 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: SolsticeLayout_1x1_0.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void themeViews(Context context, RemoteViews views, SuntimesTheme theme)
{
    super.themeViews(context, views, theme);

    timeColor = theme.getTimeColor();
    int textColor = theme.getTextColor();
    int eventColor = theme.getSeasonColor(timeMode);
    boldTime = theme.getTimeBold();

    views.setTextColor(R.id.text_time_event_note, textColor);
    views.setTextColor(R.id.text_time_event, eventColor);
    views.setTextColor(R.id.text_time_event_label, eventColor);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
        float textSize = theme.getTextSizeSp();
        float timeSize = theme.getTimeSizeSp();

        views.setTextViewTextSize(R.id.text_time_event_label, TypedValue.COMPLEX_UNIT_DIP, textSize);
        views.setTextViewTextSize(R.id.text_time_event_note, TypedValue.COMPLEX_UNIT_DIP, textSize);
        views.setTextViewTextSize(R.id.text_time_event, TypedValue.COMPLEX_UNIT_DIP, timeSize);
    }
}
 
Example 2
Source File: WeatherAppWidget.java    From LittleFreshWeather with Apache License 2.0 6 votes vote down vote up
private void renderTime() {
    ComponentName thisWidget = new ComponentName(mContext, WeatherAppWidget.class);
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
    int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
    for (int i = 0; i < appWidgetIds.length; ++i) {
        int appWidgetId = appWidgetIds[i];
        RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.app_widget_layout);

        if (mDataDate != null && mDataDate.compareToIgnoreCase(StringUtil.getCurrentDateTime("yyyy-MM-dd")) != 0) {
            views.setTextColor(R.id.tv_app_widget_weather_desc, mContext.getApplicationContext().getResources().getColor(R.color.colorAirFour));
            views.setTextViewText(R.id.tv_app_widget_weather_desc, mContext.getApplicationContext().getString(R.string.data_out_of_date));
        }

        views.setTextViewText(R.id.tv_app_widget_time, StringUtil.getCurrentDateTime("HH:mm"));
        views.setTextViewText(R.id.tv_app_widget_dayofweek, StringUtil.getCurrentDateTime("EEEE"));
        views.setTextViewText(R.id.tv_app_widget_date, StringUtil.getCurrentDateTime("M月d日"));

        appWidgetManager.updateAppWidget(appWidgetId, views);
    }

    renderData(mEntity);

    updateTimeSequence();
    LogUtil.e(TAG, "renderTime");
}
 
Example 3
Source File: ExtLocationWithForecastGraphWidgetProvider.java    From your-local-weather with GNU General Public License v3.0 6 votes vote down vote up
public static void setWidgetTheme(Context context, RemoteViews remoteViews, int widgetId) {
    appendLog(context, TAG, "setWidgetTheme:start");
    int textColorId = AppPreference.getTextColor(context);
    int backgroundColorId = AppPreference.getWidgetBackgroundColor(context);
    int windowHeaderBackgroundColorId = AppPreference.getWindowHeaderBackgroundColorId(context);

    remoteViews.setInt(R.id.widget_ext_loc_forecast_graph_3x3_widget_root, "setBackgroundColor", backgroundColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_graph_3x3_widget_temperature, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_graph_3x3_widget_description, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_graph_3x3_widget_description, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_graph_3x3_widget_second_temperature, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_graph_3x3_forecast_1_widget_day, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_graph_3x3_forecast_1_widget_temperatures, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_graph_3x3_forecast_2_widget_day, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_graph_3x3_forecast_2_widget_temperatures, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_graph_3x3_forecast_3_widget_day, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_graph_3x3_forecast_3_widget_temperatures, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_graph_3x3_forecast_4_widget_day, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_graph_3x3_forecast_4_widget_temperatures, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_graph_3x3_forecast_5_widget_day, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_graph_3x3_forecast_5_widget_temperatures, textColorId);
    remoteViews.setInt(R.id.widget_ext_loc_forecast_graph_3x3_header_layout, "setBackgroundColor", windowHeaderBackgroundColorId);

    appendLog(context, TAG, "setWidgetTheme:end");
}
 
Example 4
Source File: ExtLocationWithForecastWidgetProvider.java    From your-local-weather with GNU General Public License v3.0 6 votes vote down vote up
public static void setWidgetTheme(Context context, RemoteViews remoteViews, int widgetId) {
    appendLog(context, TAG, "setWidgetTheme:start");
    int textColorId = AppPreference.getTextColor(context);
    int backgroundColorId = AppPreference.getWidgetBackgroundColor(context);
    int windowHeaderBackgroundColorId = AppPreference.getWindowHeaderBackgroundColorId(context);

    remoteViews.setInt(R.id.widget_ext_loc_forecast_3x3_widget_root, "setBackgroundColor", backgroundColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_3x3_widget_temperature, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_3x3_widget_description, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_3x3_widget_description, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_3x3_widget_second_temperature, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_3x3_forecast_1_widget_day, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_3x3_forecast_1_widget_temperatures, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_3x3_forecast_2_widget_day, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_3x3_forecast_2_widget_temperatures, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_3x3_forecast_3_widget_day, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_3x3_forecast_3_widget_temperatures, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_3x3_forecast_4_widget_day, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_3x3_forecast_4_widget_temperatures, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_3x3_forecast_5_widget_day, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_forecast_3x3_forecast_5_widget_temperatures, textColorId);
    remoteViews.setInt(R.id.widget_ext_loc_forecast_3x3_header_layout, "setBackgroundColor", windowHeaderBackgroundColorId);

    appendLog(context, TAG, "setWidgetTheme:end");
}
 
Example 5
Source File: TrackWidgetProvider.java    From mytracks with Apache License 2.0 6 votes vote down vote up
/**
 * Updates recording status.
 * 
 * @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);
}
 
Example 6
Source File: SunLayout_1x1_1.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void themeViews(Context context, RemoteViews views, SuntimesTheme theme)
{
    super.themeViews(context, views, theme);

    int sunriseColor = theme.getSunriseTextColor();
    int suffixColor = theme.getTimeSuffixColor();
    views.setTextColor(R.id.text_time_rise_suffix, suffixColor);
    views.setTextColor(R.id.text_time_rise, sunriseColor);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
        views.setTextViewTextSize(R.id.text_time_rise_suffix, TypedValue.COMPLEX_UNIT_DIP, theme.getTimeSuffixSizeSp());
        views.setTextViewTextSize(R.id.text_time_rise, TypedValue.COMPLEX_UNIT_DIP, theme.getTimeSizeSp());
    }

    Bitmap sunriseIcon = SuntimesUtils.layerDrawableToBitmap(context, R.drawable.ic_sunrise_large0, theme.getSunriseIconColor(), theme.getSunriseIconStrokeColor(), theme.getSunriseIconStrokePixels(context));
    views.setImageViewBitmap(R.id.icon_time_sunrise, sunriseIcon);
}
 
Example 7
Source File: MoonLayout.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
protected void themeViewsMoonRiseSetText(Context context, RemoteViews views, SuntimesTheme theme)
{
    int moonriseColor = theme.getMoonriseTextColor();
    int suffixColor = theme.getTimeSuffixColor();
    views.setTextColor(R.id.text_time_moonrise_suffix, suffixColor);
    views.setTextColor(R.id.text_time_moonrise, moonriseColor);

    int moonsetColor = theme.getMoonsetTextColor();
    views.setTextColor(R.id.text_time_moonset_suffix, suffixColor);
    views.setTextColor(R.id.text_time_moonset, moonsetColor);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
        float timeSize = theme.getTimeSizeSp();
        float suffSize = theme.getTimeSuffixSizeSp();

        views.setTextViewTextSize(R.id.text_time_moonrise_suffix, TypedValue.COMPLEX_UNIT_DIP, suffSize);
        views.setTextViewTextSize(R.id.text_time_moonrise, TypedValue.COMPLEX_UNIT_DIP, timeSize);

        views.setTextViewTextSize(R.id.text_time_moonset, TypedValue.COMPLEX_UNIT_DIP, timeSize);
        views.setTextViewTextSize(R.id.text_time_moonset_suffix, TypedValue.COMPLEX_UNIT_DIP, suffSize);
    }
}
 
Example 8
Source File: MoonLayout_1x1_4.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void themeViews(Context context, RemoteViews views, SuntimesTheme theme)
{
    super.themeViews(context, views, theme);
    themeViewsMoonPhase(context, views, theme);
    themeViewsMoonPhaseIcons(context, views, theme);

    int timeColor = theme.getTimeColor();
    views.setTextColor(R.id.moonphase_major_date, timeColor);

    int textColor = theme.getTextColor();
    views.setTextColor(R.id.moonphase_major_label, textColor);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
        float timeSize = theme.getTimeSizeSp();
        views.setTextViewTextSize(R.id.moonphase_major_date, TypedValue.COMPLEX_UNIT_DIP, timeSize);

        float textSize = theme.getTextSizeSp();
        views.setTextViewTextSize(R.id.moonphase_major_label, TypedValue.COMPLEX_UNIT_DIP, textSize);
    }
}
 
Example 9
Source File: MoonLayout_1x1_6.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void themeViews(Context context, RemoteViews views, SuntimesTheme theme)
{
    super.themeViews(context, views, theme);

    highlightColor = theme.getTimeColor();
    suffixColor = theme.getTimeSuffixColor();
    int textColor = theme.getTextColor();
    views.setTextColor(R.id.info_moon_rightascension_current_label, textColor);
    views.setTextColor(R.id.info_moon_declination_current_label, textColor);
    views.setTextColor(R.id.info_moon_rightascension_current, textColor);
    views.setTextColor(R.id.info_moon_declination_current, textColor);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
        float textSize = theme.getTextSizeSp();
        views.setTextViewTextSize(R.id.info_moon_rightascension_current_label, TypedValue.COMPLEX_UNIT_DIP, textSize);
        views.setTextViewTextSize(R.id.info_moon_declination_current_label, TypedValue.COMPLEX_UNIT_DIP, textSize);

        float timeSize = theme.getTimeSizeSp();
        views.setTextViewTextSize(R.id.info_moon_rightascension_current, TypedValue.COMPLEX_UNIT_DIP, timeSize);
        views.setTextViewTextSize(R.id.info_moon_declination_current, TypedValue.COMPLEX_UNIT_DIP, timeSize);
    }
}
 
Example 10
Source File: NotifyManager.java    From LLApp with Apache License 2.0 6 votes vote down vote up
/**
 * 折叠式
 *
 * @param context
 */
public static void shwoNotify(Context context,int flag) {
    //先设定RemoteViews
    RemoteViews view_custom = new RemoteViews(context.getPackageName(), R.layout.notification);
    //设置对应IMAGEVIEW的ID的资源图片
    view_custom.setImageViewResource(R.id.image, R.mipmap.ic_launcher);
    view_custom.setTextViewText(R.id.bbs_type_Title, "今日头条");
    view_custom.setTextColor(R.id.text, Color.BLACK);
    view_custom.setTextViewText(R.id.text, "金州勇士官方宣布球队已经解雇了主帅马克-杰克逊,随后宣布了最后的结果。");
    view_custom.setTextColor(R.id.bbs_type_Title, Color.BLACK);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
    mBuilder.setContent(view_custom)
            .setContentIntent(PendingIntent.getActivity(context, 4, new Intent(context, MainActivity.class), PendingIntent.FLAG_CANCEL_CURRENT))
            .setWhen(System.currentTimeMillis())// 通知产生的时间,会在通知信息里显示
            .setTicker("有新资讯")
            .setPriority(Notification.PRIORITY_HIGH)// 设置该通知优先级
            .setOngoing(false)//不是正在进行的   true为正在进行  效果和.flag一样
            .setSmallIcon(R.mipmap.ic_launcher);
    Notification notify = mBuilder.build();
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
    notificationManager.notify(flag, notify);
}
 
Example 11
Source File: MoonLayout.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
protected void themeViewsMoonPhaseText(Context context, RemoteViews views, SuntimesTheme theme)
{
    int textColor = theme.getTextColor();
    views.setTextColor(R.id.text_info_moonillum, textColor);
    views.setTextColor(R.id.text_info_moonphase, textColor);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        float textSize = theme.getTextSizeSp();
        views.setTextViewTextSize(R.id.text_info_moonphase, TypedValue.COMPLEX_UNIT_DIP, textSize);
        views.setTextViewTextSize(R.id.text_info_moonillum, TypedValue.COMPLEX_UNIT_DIP, textSize);
    }
}
 
Example 12
Source File: ServiceToggle.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);

    if (TOGGLE_CLICKED.equals(intent.getAction())) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.service_toggle_widget);
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        if (NLService.isEnabled()) {
            preferences.edit().putBoolean(context.getString(R.string.notification_listener_service_state_key), false).apply();
            NLService.setEnabled(false);
            views.setImageViewResource(R.id.widgetToggleButton, R.drawable.ic_speaker_notes_off_white_48dp);
            views.setInt(R.id.widgetToggleButton, "setBackgroundResource", R.drawable.round_rectangle_red);
            views.setTextViewText(R.id.widgetToggleText, context.getString(R.string.widget_off_text));
            views.setTextColor(R.id.widgetToggleText, ContextCompat.getColor(context, R.color.red));
        } else {
            preferences.edit().putBoolean(context.getString(R.string.notification_listener_service_state_key), true).apply();
            NLService.setEnabled(true);
            views.setImageViewResource(R.id.widgetToggleButton,R.drawable.ic_speaker_notes_white_48dp);
            views.setInt(R.id.widgetToggleButton, "setBackgroundResource", R.drawable.round_rectangle_green);
            views.setTextViewText(R.id.widgetToggleText, context.getString(R.string.widget_on_text));
            views.setTextColor(R.id.widgetToggleText, ContextCompat.getColor(context, R.color.green));
        }

        views.setOnClickPendingIntent(
                R.id.widgetToggleButton,
                getPendingSelfIntent(context, 0, TOGGLE_CLICKED));

        ComponentName componentName = new ComponentName(context, ServiceToggle.class);
        appWidgetManager.updateAppWidget(componentName, views);
    }
}
 
Example 13
Source File: ExtLocationWidgetProvider.java    From your-local-weather with GNU General Public License v3.0 5 votes vote down vote up
public static void setWidgetTheme(Context context, RemoteViews remoteViews) {
    appendLog(context, TAG, "setWidgetTheme:start");
    int textColorId = AppPreference.getTextColor(context);
    int backgroundColorId = AppPreference.getWidgetBackgroundColor(context);
    int windowHeaderBackgroundColorId = AppPreference.getWindowHeaderBackgroundColorId(context);

    remoteViews.setInt(R.id.widget_ext_loc_3x3_widget_root, "setBackgroundColor", backgroundColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_3x3_widget_temperature, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_3x3_widget_description, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_3x3_widget_description, textColorId);
    remoteViews.setTextColor(R.id.widget_ext_loc_3x3_widget_second_temperature, textColorId);
    remoteViews.setInt(R.id.widget_ext_loc_3x3_header_layout, "setBackgroundColor", windowHeaderBackgroundColorId);
    appendLog(context, TAG, "setWidgetTheme:end");
}
 
Example 14
Source File: SunLayout_1x1_0.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void themeViews(Context context, RemoteViews views, SuntimesTheme theme)
{
    super.themeViews(context, views, theme);

    int sunriseColor = theme.getSunriseTextColor();
    int suffixColor = theme.getTimeSuffixColor();
    views.setTextColor(R.id.text_time_rise_suffix, suffixColor);
    views.setTextColor(R.id.text_time_rise, sunriseColor);

    int sunsetColor = theme.getSunsetTextColor();
    views.setTextColor(R.id.text_time_set_suffix, suffixColor);
    views.setTextColor(R.id.text_time_set, sunsetColor);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
        float timeSize = theme.getTimeSizeSp();
        float suffSize = theme.getTimeSuffixSizeSp();

        views.setTextViewTextSize(R.id.text_time_rise_suffix, TypedValue.COMPLEX_UNIT_DIP, suffSize);
        views.setTextViewTextSize(R.id.text_time_rise, TypedValue.COMPLEX_UNIT_DIP, timeSize);

        views.setTextViewTextSize(R.id.text_time_set, TypedValue.COMPLEX_UNIT_DIP, timeSize);
        views.setTextViewTextSize(R.id.text_time_set_suffix, TypedValue.COMPLEX_UNIT_DIP, suffSize);
    }

    Bitmap sunriseIcon = SuntimesUtils.layerDrawableToBitmap(context, R.drawable.ic_sunrise0, theme.getSunriseIconColor(), theme.getSunriseIconStrokeColor(), theme.getSunriseIconStrokePixels(context));
    views.setImageViewBitmap(R.id.icon_time_sunrise, sunriseIcon);

    Bitmap sunsetIcon = SuntimesUtils.layerDrawableToBitmap(context, R.drawable.ic_sunset0, theme.getSunsetIconColor(), theme.getSunsetIconStrokeColor(), theme.getSunsetIconStrokePixels(context));
    views.setImageViewBitmap(R.id.icon_time_sunset, sunsetIcon);
}
 
Example 15
Source File: MoonLayout_1x1_8.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void themeViews(Context context, RemoteViews views, SuntimesTheme theme)
{
    super.themeViews(context, views, theme);

    timeColor = theme.getTimeColor();
    suffixColor = theme.getTimeSuffixColor();
    int textColor = theme.getTextColor();
    risingColor = theme.getMoonriseTextColor();
    settingColor = theme.getMoonsetTextColor();

    views.setTextColor(R.id.moonapsis_apogee_label, textColor);
    views.setTextColor(R.id.moonapsis_apogee_date, timeColor);
    views.setTextColor(R.id.moonapsis_apogee_note, textColor);
    views.setTextColor(R.id.moonapsis_apogee_distance, textColor);

    views.setTextColor(R.id.moonapsis_perigee_label, textColor);
    views.setTextColor(R.id.moonapsis_perigee_date, timeColor);
    views.setTextColor(R.id.moonapsis_perigee_note, textColor);
    views.setTextColor(R.id.moonapsis_perigee_distance, textColor);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
        float textSize = theme.getTextSizeSp();
        views.setTextViewTextSize(R.id.moonapsis_apogee_label, TypedValue.COMPLEX_UNIT_DIP, textSize);
        views.setTextViewTextSize(R.id.moonapsis_apogee_note, TypedValue.COMPLEX_UNIT_DIP, textSize);
        views.setTextViewTextSize(R.id.moonapsis_apogee_distance, TypedValue.COMPLEX_UNIT_DIP, textSize);

        views.setTextViewTextSize(R.id.moonapsis_perigee_label, TypedValue.COMPLEX_UNIT_DIP, textSize);
        views.setTextViewTextSize(R.id.moonapsis_perigee_note, TypedValue.COMPLEX_UNIT_DIP, textSize);
        views.setTextViewTextSize(R.id.moonapsis_perigee_distance, TypedValue.COMPLEX_UNIT_DIP, textSize);

        float timeSize = theme.getTimeSizeSp();
        views.setTextViewTextSize(R.id.moonapsis_apogee_date, TypedValue.COMPLEX_UNIT_DIP, timeSize);
        views.setTextViewTextSize(R.id.moonapsis_perigee_date, TypedValue.COMPLEX_UNIT_DIP, timeSize);
    }
}
 
Example 16
Source File: CalenderWidgetAdapter.java    From MuslimMateAndroid with GNU General Public License v3.0 4 votes vote down vote up
@Override
public RemoteViews getViewAt(int position) {
    RemoteViews row = new RemoteViews(context.getPackageName(),
            R.layout.calender_cell);

    CalendarCell cell = daysList.get(position);

    Intent islamicIntent = new Intent();
    Bundle islamicIntentExtras = new Bundle();
    islamicIntentExtras.putString("islamic_day",
            NumbersLocal.convertNumberType(context, cell.day + ""));
    islamicIntent.putExtras(islamicIntentExtras);

    Intent gregorianIntent = new Intent();
    Bundle gregorianIntentExtras = new Bundle();
    gregorianIntentExtras.putString("gregorian_day",
            NumbersLocal.convertNumberType(context, cell.dayOther + ""));
    gregorianIntent.putExtras(gregorianIntentExtras);

    //not empty date
    if (cell.day != -1) {

        //set dates in calender
        row.setViewVisibility(R.id.textView31, View.VISIBLE);
        row.setViewVisibility(R.id.textView30, View.VISIBLE);
        row.setTextViewText(R.id.textView31, NumbersLocal.convertToNumberTypeSystem(context, cell.dayOther + ""));
        row.setTextViewText(R.id.textView30, NumbersLocal.convertToNumberTypeSystem(context, cell.day + ""));

        //get current day
        HGDate hgDate = new HGDate();
        hgDate.toHigri();

        //check if that is the current day or not
        if (cell.day == hgDate.getDay()) {
            row.setTextColor(R.id.textView31, Color.WHITE);
            row.setTextColor(R.id.textView30, Color.WHITE);
            row.setInt(R.id.textView31, "setBackgroundColor", Color.argb(255, 73, 138, 127));
            row.setInt(R.id.textView30, "setBackgroundColor", Color.argb(255, 73, 138, 127));
        } else {
            row.setTextColor(R.id.textView31, Color.GRAY);
            row.setTextColor(R.id.textView30, Color.BLACK);
            row.setInt(R.id.textView31, "setBackgroundColor", Color.WHITE);
            row.setInt(R.id.textView30, "setBackgroundColor", Color.WHITE);
        }


        //check if the day one of the islamic events
        for (Event event : eventList) {
            String[] date = event.hejriDate.split("-");
            if (cell.day == Integer.parseInt(date[0]) && cell.hijriMonth == Integer.parseInt(date[1])) {
                row.setInt(R.id.textView31, "setBackgroundColor", Color.YELLOW);
                row.setInt(R.id.textView30, "setBackgroundColor", Color.YELLOW);
            }
        }


    } else {
        //hide empty cellls
        row.setViewVisibility(R.id.textView31, View.GONE);
        row.setViewVisibility(R.id.textView30, View.GONE);
    }

    row.setOnClickFillInIntent(R.id.textView31, gregorianIntent);
    row.setOnClickFillInIntent(R.id.textView30, islamicIntent);

    return (row);
}
 
Example 17
Source File: WidgetHelper.java    From iSCAU-Android with GNU General Public License v3.0 4 votes vote down vote up
private void setTextViewFontColorWithConfig(RemoteViews parentView,int viewId,int type){
    parentView.setFloat(viewId,"setTextSize",getTextFontSizeBy(type));
    parentView.setTextColor(viewId,config.widgetFontColor().get());
}
 
Example 18
Source File: ReceiverWidgetProvider.java    From PowerSwitch_Android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    Log.d("Updating Receiver Widgets...");
    // Perform this loop procedure for each App Widget that belongs to this provider
    for (int i = 0; i < appWidgetIds.length; i++) {
        int appWidgetId = appWidgetIds[i];
        RemoteViews remoteViews = new RemoteViews(context.getResources()
                .getString(eu.power_switch.shared.R.string.PACKAGE_NAME), R.layout.widget_receiver);

        try {
            ReceiverWidget receiverWidget = DatabaseHandler.getReceiverWidget(appWidgetId);
            Room room = DatabaseHandler.getRoom(receiverWidget.getRoomId());
            if (room != null) {
                Receiver receiver = DatabaseHandler.getReceiver(receiverWidget.getReceiverId());

                if (receiver != null) {
                    Apartment apartment = DatabaseHandler.getApartment(room.getApartmentId());
                    // update UI
                    remoteViews.setTextViewText(R.id.textView_receiver_widget_name, apartment.getName() + ": " + room.getName() + ": " + receiver.getName());

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

                    // remove all previous buttons
                    remoteViews.removeAllViews(R.id.linearlayout_receiver_widget);

                    // add buttons from database
                    int buttonOffset = 0;
                    for (Button button : buttons) {
                        // set button action
                        RemoteViews buttonView = new RemoteViews(context.getResources()
                                .getString(eu.power_switch.shared.R.string.PACKAGE_NAME), R.layout.widget_receiver_button_layout);
                        SpannableString s = new SpannableString(button.getName());
                        s.setSpan(new StyleSpan(Typeface.BOLD), 0, button.getName().length(), 0);
                        buttonView.setTextViewText(R.id.button_widget_universal, s);
                        if (SmartphonePreferencesHandler.getHighlightLastActivatedButton() &&
                                receiver.getLastActivatedButtonId().equals(button.getId())) {
                            buttonView.setTextColor(R.id.button_widget_universal,
                                    ContextCompat.getColor(context, R.color.color_light_blue_a700));
                        }

                        PendingIntent intent = WidgetIntentReceiver.buildReceiverWidgetActionPendingIntent(context, apartment, room,
                                receiver, button, appWidgetId * 15 + buttonOffset);
                        buttonView.setOnClickPendingIntent(R.id.button_widget_universal, intent);

                        remoteViews.addView(R.id.linearlayout_receiver_widget, buttonView);
                        buttonOffset++;
                    }
                    remoteViews.setViewVisibility(R.id.linearlayout_receiver_widget, View.VISIBLE);
                } else {
                    remoteViews.setTextViewText(R.id.textView_receiver_widget_name, context.getString(R.string.receiver_not_found));
                    remoteViews.removeAllViews(R.id.linearlayout_receiver_widget);
                    remoteViews.setViewVisibility(R.id.linearlayout_receiver_widget, View.GONE);
                }
            } else {
                remoteViews.setTextViewText(R.id.textView_receiver_widget_name, context.getString(R.string.room_not_found));
                remoteViews.removeAllViews(R.id.linearlayout_receiver_widget);
                remoteViews.setViewVisibility(R.id.linearlayout_receiver_widget, View.GONE);
            }
        } catch (Exception e) {
            Log.e(e);
            remoteViews.setTextViewText(R.id.textView_receiver_widget_name, context.getString(R.string.unknown_error));
            remoteViews.removeAllViews(R.id.linearlayout_receiver_widget);
            remoteViews.setViewVisibility(R.id.linearlayout_receiver_widget, View.GONE);
        }
        appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
Example 19
Source File: ListViewWidgetService.java    From Slide with GNU General Public License v3.0 4 votes vote down vote up
public RemoteViews getViewAt(int position) {
    // position will always range from 0 to getCount() - 1.
    // Construct a RemoteViews item based on the app widget item XML file, and set the
    // text based on the position.
    int view = R.layout.submission_widget_light;
    switch (SubredditWidgetProvider.getViewType(id, mContext)) {
        case 1:
        case 0:
            if (SubredditWidgetProvider.getThemeFromId(id, mContext) == 2) {
                view = R.layout.submission_widget_light;
            } else {
                view = R.layout.submission_widget;
            }

            break;
        case 2:
            if (SubredditWidgetProvider.getThemeFromId(id, mContext) == 2) {
                view = R.layout.submission_widget_compact_light;
            } else {
                view = R.layout.submission_widget_compact;
            }
            break;
    }
    final RemoteViews rv = new RemoteViews(mContext.getPackageName(), view);
    try {

        // feed row
        Submission data = records.get(position);

        rv.setTextViewText(R.id.title, Html.fromHtml(data.getTitle()));
        rv.setTextViewText(R.id.score, data.getScore() + "");
        rv.setTextViewText(R.id.comments, data.getCommentCount() + "");
        rv.setTextViewText(R.id.information,
                data.getAuthor() + " " + TimeUtils.getTimeAgo(data.getCreated().getTime(),
                        mContext));
        rv.setTextViewText(R.id.subreddit, data.getSubredditName());
        rv.setTextColor(R.id.subreddit, Palette.getColor(data.getSubredditName()));
        if (SubredditWidgetProvider.getViewType(id, mContext) == 1) {
            Thumbnails s = data.getThumbnails();
            rv.setViewVisibility(R.id.thumbimage2, View.GONE);
            if (s != null && s.getVariations() != null && s.getSource() != null) {
                rv.setImageViewBitmap(R.id.bigpic,
                        ((Reddit) mContext.getApplicationContext()).getImageLoader()
                                .loadImageSync(
                                        Html.fromHtml(data.getThumbnails().getSource().getUrl())
                                                .toString()));
                rv.setViewVisibility(R.id.bigpic, View.VISIBLE);
            } else {
                rv.setViewVisibility(R.id.bigpic, View.GONE);
            }
        } else {
            if (SubredditWidgetProvider.getViewType(id, mContext) != 2) {
                rv.setViewVisibility(R.id.bigpic, View.GONE);
            }
            if (data.getThumbnailType() == Submission.ThumbnailType.URL) {
                rv.setImageViewBitmap(R.id.thumbimage2,
                        ((Reddit) mContext.getApplicationContext()).getImageLoader()
                                .loadImageSync(data.getThumbnail()));
                rv.setViewVisibility(R.id.thumbimage2, View.VISIBLE);
            } else {
                rv.setViewVisibility(R.id.thumbimage2, View.GONE);
            }
        }
        switch (SubredditWidgetProvider.getViewType(id, mContext)) {
            case 1:
            case 0:
                if (SubredditWidgetProvider.getThemeFromId(id, mContext) == 2) {
                } else {
                    rv.setTextColor(R.id.title, Color.WHITE);
                    rv.setTextColor(R.id.score, Color.WHITE);
                    rv.setTextColor(R.id.comments, Color.WHITE);
                    rv.setTextColor(R.id.information, Color.WHITE);
                }

                break;
            case 2:
                if (SubredditWidgetProvider.getThemeFromId(id, mContext) == 2) {
                } else {
                    rv.setTextColor(R.id.title, Color.WHITE);
                    rv.setTextColor(R.id.score, Color.WHITE);
                    rv.setTextColor(R.id.comments, Color.WHITE);
                    rv.setTextColor(R.id.information, Color.WHITE);
                }
                break;
        }

        Bundle infos = new Bundle();
        infos.putString(OpenContent.EXTRA_URL, data.getPermalink());
        infos.putBoolean("popup", true);
        final Intent activityIntent = new Intent();
        activityIntent.putExtras(infos);
        activityIntent.setAction(data.getTitle());
        rv.setOnClickFillInIntent(R.id.card, activityIntent);
    } catch (Exception e) {

    }
    return rv;
}
 
Example 20
Source File: MiracastWidgetProvider.java    From miracast-widget with Apache License 2.0 4 votes vote down vote up
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
       final int length = appWidgetIds.length;

       for (int i = 0; i < length; i++) {
           int appWidgetId = appWidgetIds[i];

           Intent intent = new Intent(context, MainActivity.class);
           intent.putExtra(MainActivity.EXTRA_WIDGET_LAUNCH, true);
           PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
                                                   intent, PendingIntent.FLAG_UPDATE_CURRENT);

           final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.miracast_widget);
           views.setOnClickPendingIntent(R.id.widget_layout_parent, pendingIntent);
           final DisplayManager displayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);

           Display[] displays = displayManager.getDisplays();
           boolean displaySet = false;
           int currentDisplay = -1;
           for(int j = 0; j < displays.length; j++){
           	Display display = displays[j];
           	if(display.getDisplayId() != Display.DEFAULT_DISPLAY){
                   views.setTextViewText(R.id.widget_text, display.getName());
                   views.setTextColor(R.id.widget_text, context.getResources().getColor(android.R.color.holo_blue_bright));
                   currentDisplay = display.getDisplayId();
                   displaySet = true;

                   // Track this
                   MiracastApplication application
                           = (MiracastApplication) context.getApplicationContext();
                   Tracker tracker = application.getDefaultTracker();
                   sendEventDisplayFound(tracker);
           	}
           }
           
           if(!displaySet){
               views.setTextViewText(R.id.widget_text, "Cast Screen");
               views.setTextColor(R.id.widget_text, context.getResources().getColor(android.R.color.white));
           }

           MiracastDisplayListener displayListener = new MiracastDisplayListener(currentDisplay, views, displayManager, appWidgetManager, appWidgetId, context);
           displayManager.registerDisplayListener(displayListener, null);

           // Tell the AppWidgetManager to perform an update on the current app widget
           appWidgetManager.updateAppWidget(appWidgetId, views);
       }
   }