android.widget.RemoteViews Java Examples
The following examples show how to use
android.widget.RemoteViews.
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: PendIntentCompat.java From container with GNU General Public License v3.0 | 6 votes |
private void setIntentByViewGroup(RemoteViews remoteViews, ViewGroup viewGroup, List<RectInfo> list) { int count = viewGroup.getChildCount(); for (int i = 0; i < count; i++) { View v = viewGroup.getChildAt(i); if (v instanceof ViewGroup) { // linearlayout setIntentByViewGroup(remoteViews, (ViewGroup) v, list); } else if (v instanceof TextView) { // textview Rect rect = new Rect(); v.getHitRect(rect); // height修正 rect.top += viewGroup.getTop(); rect.bottom += viewGroup.getTop(); PendingIntent pendingIntent = findIntent(rect, list); if (pendingIntent != null) { remoteViews.setOnClickPendingIntent(v.getId(), pendingIntent); } } } }
Example #2
Source File: APWidget.java From Android-Wifi-Hotspot-Manager-Class with Apache License 2.0 | 6 votes |
@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { // TODO: Implement this method lg("on update"); lg("Status: " + state); for (int i = 0; i < appWidgetIds.length; i++) { int currentId = appWidgetIds[i]; lg("id: " + currentId); Intent intent = new Intent(context, APWidget.class); intent.putExtra(STATE, true); PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget); rv.setImageViewResource(R.id.widgetButton1, toggleButton()); //rv.setTextViewText(R.id.widgetButton1,gettext(state)); //rv.setTextColor(R.id.widgetButton1,getColor(!state)); //rv.setTextColor(R.id.widgetTextView1,getColor(state)); //rv.setTextViewText(R.id.widgetTextView1,getStatus(state)); rv.setOnClickPendingIntent(R.id.widgetButton1, pi); //Intent tetherSettings = new Intent(); //tetherSettings.setClassName(context, "com.android.settings.TetherSettings"); rv.setOnClickPendingIntent(R.id.widgetLinearLayout1, tphs(context)); appWidgetManager.updateAppWidget(currentId, rv); lg("Updated"); } super.onUpdate(context, appWidgetManager, appWidgetIds); }
Example #3
Source File: OngoingNotificationsReceiver.java From prayer-times-android with Apache License 2.0 | 6 votes |
private void extractDefaultTextColor() { if (mDefaultTextColor != null) return; ; try { Notification.Builder builder = new Notification.Builder(getContext()); builder.setContentTitle("COLOR_SEARCH_1ST"); Notification ntf = builder.build(); LinearLayout group = new LinearLayout(getContext()); RemoteViews contentView = ntf.contentView; if (contentView == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { contentView = Notification.Builder.recoverBuilder(getContext(), ntf).createContentView(); } ViewGroup event = (ViewGroup) contentView.apply(getContext(), group); recurseGroup(event); group.removeAllViews(); } catch (Exception e) { e.printStackTrace(); } }
Example #4
Source File: StackWidgetService.java From GitJourney with Apache License 2.0 | 6 votes |
@Override public RemoteViews getViewAt(int position) { Log.v(TAG, "getViewAt: position = " + position); // Construct a remote views item based on the app widget item XML file, // and set the text based on the position. RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_list_item); Intent fillInIntent = new Intent(); fillInIntent.putExtra(EXTRA_LIST_VIEW_ROW_NUMBER, position); rv.setOnClickFillInIntent(R.id.main_list_item, fillInIntent); rv.setTextViewText(R.id.w_author_name, widgetDatas.get(position).getAuthorName()); rv.setTextViewText(R.id.w_title, widgetDatas.get(position).getTitle()); Picasso pic = Picasso.with(context); try { Bitmap map = pic.load(widgetDatas.get(position).getAvatar()).get(); rv.setImageViewBitmap(R.id.w_github_user_image, map); } catch (IOException e) { Log.e(TAG, "", e); } return rv; }
Example #5
Source File: UrlDeviceDiscoveryService.java From physical-web with Apache License 2.0 | 6 votes |
private void updateSummaryNotificationRemoteViewsFirstBeacon(PwPair pwPair, RemoteViews remoteViews) { PwsResult pwsResult = pwPair.getPwsResult(); remoteViews.setImageViewBitmap( R.id.icon_firstBeacon, Utils.getBitmapIcon(mPwCollection, pwsResult)); remoteViews.setTextViewText(R.id.title_firstBeacon, pwsResult.getTitle()); remoteViews.setTextViewText(R.id.url_firstBeacon, pwsResult.getSiteUrl()); remoteViews.setTextViewText(R.id.description_firstBeacon, pwsResult.getDescription()); // Recolor notifications to have light text for non-Lollipop devices if (!(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)) { remoteViews.setTextColor(R.id.title_firstBeacon, NON_LOLLIPOP_NOTIFICATION_TITLE_COLOR); remoteViews.setTextColor(R.id.url_firstBeacon, NON_LOLLIPOP_NOTIFICATION_URL_COLOR); remoteViews.setTextColor(R.id.description_firstBeacon, NON_LOLLIPOP_NOTIFICATION_SNIPPET_COLOR); } // Create an intent that will open the browser to the beacon's url // if the user taps the notification remoteViews.setOnClickPendingIntent(R.id.first_beacon_main_layout, Utils.createNavigateToUrlPendingIntent(pwsResult, this)); remoteViews.setViewVisibility(R.id.firstBeaconLayout, View.VISIBLE); }
Example #6
Source File: RokuAppWidgetProvider.java From RoMote with Apache License 2.0 | 6 votes |
/** * Initialize given widgets to default state, where we launch Music on default click * and hide actions if service not running. */ private void defaultAppWidget(Context context, int[] appWidgetIds) { Device device = null; try { device = PreferenceUtils.getConnectedDevice(context); } catch (Exception ex) { return; } final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.roku_appwidget); views.setTextViewText(R.id.model_name_text, device.getModelName()); linkButtons(context, views, false /* not playing */); Intent intent = new Intent(context, MainActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0 /* no requestCode */, intent, 0 /* no flags */); views.setOnClickPendingIntent(R.id.info_layout, pendingIntent); pushUpdate(context, appWidgetIds, views); }
Example #7
Source File: NewsWidgetProvider.java From android-news-app with Apache License 2.0 | 6 votes |
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) { // Get sample news story strings CharSequence sampleNewStoryOne = context.getString(R.string.sample_news_story_1); CharSequence sampleNewStoryTwo = context.getString(R.string.sample_news_story_2); CharSequence sampleNewStoryThree = context.getString(R.string.sample_news_story_3); // Construct the RemoteViews object RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.news_widget); views.setTextViewText(R.id.appwidget_tv_1, sampleNewStoryOne); views.setTextViewText(R.id.appwidget_tv_2, sampleNewStoryTwo); views.setTextViewText(R.id.appwidget_tv_3, sampleNewStoryThree); // Widget click open app Intent intent = new Intent(context, MainActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.news_widget_container, pendingIntent); // Instruct the widget manager to update the widget appWidgetManager.updateAppWidget(appWidgetId, views); }
Example #8
Source File: ClockDayHorizontalWidgetIMP.java From GeometricWeather with GNU Lesser General Public License v3.0 | 6 votes |
public static void updateWidgetView(Context context, Location location) { WidgetConfig config = getWidgetConfig( context, context.getString(R.string.sp_widget_clock_day_horizontal_setting) ); RemoteViews views = getRemoteViews( context, location, config.cardStyle, config.cardAlpha, config.textColor, config.textSize, config.clockFont, config.hideLunar ); AppWidgetManager.getInstance(context).updateAppWidget( new ComponentName(context, WidgetClockDayHorizontalProvider.class), views ); }
Example #9
Source File: CustomTabBottomBarDelegate.java From 365browser with Apache License 2.0 | 6 votes |
private void showRemoteViews(RemoteViews remoteViews) { final View inflatedView = remoteViews.apply(mActivity, getBottomBarView()); if (mClickableIDs != null && mClickPendingIntent != null) { for (int id: mClickableIDs) { if (id < 0) return; View view = inflatedView.findViewById(id); if (view != null) view.setOnClickListener(mBottomBarClickListener); } } getBottomBarView().addView(inflatedView, 1); inflatedView.addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { inflatedView.removeOnLayoutChangeListener(this); mFullscreenManager.setBottomControlsHeight(v.getHeight()); } }); }
Example #10
Source File: Mp3PlayerService.java From ampdroid with MIT License | 6 votes |
private void setNotifiction() { RemoteViews notificationView = new RemoteViews(this.getPackageName(), R.layout.player_notification); notificationView.setTextViewText(R.id.notificationSongArtist, getArtist()); notificationView.setTextViewText(R.id.notificationSongTitle, getCurrentTitle()); /* 1. Setup Notification Builder */ Notification.Builder builder = new Notification.Builder(this); /* 2. Configure Notification Alarm */ builder.setSmallIcon(R.drawable.ic_stat_notify).setAutoCancel(true).setWhen(System.currentTimeMillis()) .setTicker(getCurrentTitle()); Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent notifIntent = PendingIntent.getActivity(this, 0, intent, 0); builder.setContentIntent(notifIntent); builder.setContent(notificationView); /* 4. Create Notification and use Manager to launch it */ Notification notification = builder.build(); String ns = Context.NOTIFICATION_SERVICE; notifManager = (NotificationManager) getSystemService(ns); notifManager.notify(NOTIFICATION_ID, notification); startForeground(NOTIFICATION_ID, notification); }
Example #11
Source File: PendingHostUpdate.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private PendingHostUpdate(Parcel in) { appWidgetId = in.readInt(); type = in.readInt(); switch (type) { case TYPE_VIEWS_UPDATE: if (0 != in.readInt()) { views = new RemoteViews(in); } break; case TYPE_PROVIDER_CHANGED: if (0 != in.readInt()) { widgetInfo = new AppWidgetProviderInfo(in); } break; case TYPE_VIEW_DATA_CHANGED: viewId = in.readInt(); } }
Example #12
Source File: SunLayout_1x1_1.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
@Override public void updateViews(Context context, int appWidgetId, RemoteViews views, SuntimesRiseSetData data) { super.updateViews(context, appWidgetId, views, data); boolean showSeconds = WidgetSettings.loadShowSecondsPref(context, appWidgetId); WidgetSettings.RiseSetOrder order = WidgetSettings.loadRiseSetOrderPref(context, appWidgetId); Calendar event = data.sunriseCalendar(1); if (order != WidgetSettings.RiseSetOrder.TODAY) { Calendar now = Calendar.getInstance(); if (now.after(event)) { event = data.sunriseCalendar(2); } } updateViewsSunriseText(context, views, event, showSeconds); }
Example #13
Source File: ExtLocationWithForecastGraphWidgetProvider.java From your-local-weather with GNU General Public License v3.0 | 6 votes |
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 #14
Source File: NoiseService.java From chromadoze with GNU General Public License v3.0 | 6 votes |
private RemoteViews addButtonToNotification(Notification n) { // Create a new RV with a Stop button. RemoteViews rv = new RemoteViews( getPackageName(), R.layout.notification_with_stop_button); PendingIntent pendingIntent = PendingIntent.getService( this, 0, newStopIntent(this, R.string.stop_reason_notification), PendingIntent.FLAG_CANCEL_CURRENT); rv.setOnClickPendingIntent(R.id.stop_button, pendingIntent); // Pre-render the original RV, and copy some of the colors. RemoteViews oldRV = getContentView(this, n); final View inflated = oldRV.apply(this, new FrameLayout(this)); final TextView titleText = findTextView(inflated, getString(R.string.app_name)); final TextView defaultText = findTextView(inflated, getString(R.string.notification_text)); rv.setInt(R.id.divider, "setBackgroundColor", defaultText.getTextColors().getDefaultColor()); rv.setInt(R.id.stop_button_square, "setBackgroundColor", titleText.getTextColors().getDefaultColor()); // Insert a copy of the original RV into the new one. rv.addView(R.id.notification_insert, oldRV.clone()); return rv; }
Example #15
Source File: WidgetTransfer.java From fingen with Apache License 2.0 | 6 votes |
@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_transfer); Intent configIntent = new Intent(context, ActivityEditTransaction.class); Transaction transaction = new Transaction(PrefUtils.getDefDepID(context)); transaction.setTransactionType(Transaction.TRANSACTION_TYPE_TRANSFER); configIntent.putExtra("transaction", transaction); configIntent.putExtra("update_date", true); configIntent.putExtra("EXIT", true); configIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Uri data = Uri.withAppendedPath(Uri.parse("ABCD" + "://widget/id/"),String.valueOf(appWidgetIds[0])); configIntent.setData(data); PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, configIntent, 0); remoteViews.setOnClickPendingIntent(R.id.widgetContainer, configPendingIntent); appWidgetManager.updateAppWidget(appWidgetIds, remoteViews); }
Example #16
Source File: Widget.java From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 | 6 votes |
@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { super.onUpdate(context, appWidgetManager, appWidgetIds); for (int appWidgetId : appWidgetIds) { Intent svcIntent = new Intent(context, WidgetService.class); svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME))); RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.widget_profile); widget.setRemoteAdapter(R.id.profile_list, svcIntent); widget.setPendingIntentTemplate(R.id.profile_list, getPendingIntent(context, LIST_ITEM_CLICK)); appWidgetManager.updateAppWidget(appWidgetId, widget); } }
Example #17
Source File: PlayingNotificationImpl.java From RetroMusicPlayer with GNU General Public License v3.0 | 6 votes |
private void linkButtons(final RemoteViews notificationLayout, final RemoteViews notificationLayoutBig) { PendingIntent pendingIntent; final ComponentName serviceName = new ComponentName(service, MusicService.class); // Previous track pendingIntent = buildPendingIntent(service, ACTION_REWIND, serviceName); notificationLayout.setOnClickPendingIntent(R.id.action_prev, pendingIntent); notificationLayoutBig.setOnClickPendingIntent(R.id.action_prev, pendingIntent); // Play and pause pendingIntent = buildPendingIntent(service, ACTION_TOGGLE_PAUSE, serviceName); notificationLayout.setOnClickPendingIntent(R.id.action_play_pause, pendingIntent); notificationLayoutBig.setOnClickPendingIntent(R.id.action_play_pause, pendingIntent); // Next track pendingIntent = buildPendingIntent(service, ACTION_SKIP, serviceName); notificationLayout.setOnClickPendingIntent(R.id.action_next, pendingIntent); notificationLayoutBig.setOnClickPendingIntent(R.id.action_next, pendingIntent); }
Example #18
Source File: MasterSwitchWidget.java From MaxLock with GNU General Public License v3.0 | 6 votes |
@SuppressLint("WorldReadableFiles") @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { Intent intent = new Intent(context, ActionActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(ActionsHelper.ACTION_EXTRA_KEY, ActionsHelper.ACTION_TOGGLE_MASTER_SWITCH); PendingIntent pending = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); boolean masterSwitchOn = MLPreferences.getPrefsApps(context).getBoolean(Common.MASTER_SWITCH_ON, true); for (int appWidgetId : appWidgetIds) { RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.master_switch_widget); views.setImageViewResource(R.id.widget_master_switch_icon, masterSwitchOn ? R.drawable.ic_lock_48dp : R.drawable.ic_lock_open_48dp); views.setOnClickPendingIntent(R.id.widget_background, pending); appWidgetManager.updateAppWidget(appWidgetId, views); } }
Example #19
Source File: WidgetProvider.java From DebugPurge with MIT License | 6 votes |
private RemoteViews updateWidgetListView(Context context, int appWidgetId) { //which layout to show on widget RemoteViews remoteViews = new RemoteViews( context.getPackageName(),R.layout.widget_layout); //RemoteViews Service needed to provide adapter for ListView Intent intent = new Intent(context, WidgetService.class); //passing app widget id to that RemoteViews Service intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); intent.setData(Uri.parse( intent.toUri(Intent.URI_INTENT_SCHEME))); remoteViews.setRemoteAdapter(appWidgetId, R.id.listView, intent); remoteViews.setEmptyView(R.id.listView, R.id.emptyView); Intent toastIntent = new Intent(context, WidgetProvider.class); toastIntent.setAction(WidgetProvider.UNINSTALL_ACTION); toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); PendingIntent toastPendingIntent = PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setPendingIntentTemplate(R.id.listView, toastPendingIntent); return remoteViews; }
Example #20
Source File: MoonLayout.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
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 #21
Source File: PlacesWidgetProvider.java From protrip with MIT License | 6 votes |
@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { super.onUpdate(context, appWidgetManager, appWidgetIds); for (int i = 0; i < appWidgetIds.length; i++) { RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_collection); Intent intent = new Intent(context, PlacesWidgetRemoteViewsService.class); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]); intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); views.setRemoteAdapter(R.id.widget_list, intent); Intent toastIntent = new Intent(context, PlacesWidgetRemoteViewsService.class); toastIntent.setAction(PlacesWidgetProvider.TOAST_ACTION); toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]); intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); PendingIntent toastPendingIntent = PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT); views.setPendingIntentTemplate(R.id.widget_list, toastPendingIntent); appWidgetManager.updateAppWidget(appWidgetIds[i], views); } super.onUpdate(context, appWidgetManager, appWidgetIds); }
Example #22
Source File: MoonLayout.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
protected void themeViewsMoonPhase(Context context, RemoteViews views, SuntimesTheme theme) { int waningColor = theme.getMoonWaningColor(); int waxingColor = theme.getMoonWaxingColor(); phaseColors.put(MoonPhaseDisplay.FIRST_QUARTER, waxingColor); phaseColors.put(MoonPhaseDisplay.WAXING_CRESCENT, waxingColor); phaseColors.put(MoonPhaseDisplay.WAXING_GIBBOUS, waxingColor); phaseColors.put(MoonPhaseDisplay.NEW, theme.getMoonNewColor()); phaseColors.put(MoonPhaseDisplay.FULL, theme.getMoonFullColor()); phaseColors.put(MoonPhaseDisplay.THIRD_QUARTER, waningColor); phaseColors.put(MoonPhaseDisplay.WANING_CRESCENT, waningColor); phaseColors.put(MoonPhaseDisplay.WANING_GIBBOUS, waningColor); }
Example #23
Source File: NotificationListenerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Populates remote views for pre-N targeting apps. */ private void maybePopulateRemoteViews(Notification notification) { if (getContext().getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.N) { Builder builder = Builder.recoverBuilder(getContext(), notification); // Some styles wrap Notification's contentView, bigContentView and headsUpContentView. // First inflate them all, only then set them to avoid recursive wrapping. RemoteViews content = builder.createContentView(); RemoteViews big = builder.createBigContentView(); RemoteViews headsUp = builder.createHeadsUpContentView(); notification.contentView = content; notification.bigContentView = big; notification.headsUpContentView = headsUp; } }
Example #24
Source File: RokuAppWidgetProvider.java From RoMote with Apache License 2.0 | 6 votes |
/** * Link up various button actions using {@link PendingIntents}. * * @param playerActive True if player is active in background, which means * widget click will launch {@link MainActivity}, * otherwise we launch {@link MainActivity}. */ private void linkButtons(Context context, RemoteViews views, boolean playerActive) { Log.d(TAG, "linkButtons called"); linkButton(context, views, KeypressKeyValues.BACK, R.id.back_button, 0); linkButton(context, views, KeypressKeyValues.UP, R.id.up_button, 1); linkButton(context, views, KeypressKeyValues.HOME, R.id.home_button, 2); linkButton(context, views, KeypressKeyValues.LEFT, R.id.left_button, 3); linkButton(context, views, KeypressKeyValues.SELECT, R.id.ok_button, 4); linkButton(context, views, KeypressKeyValues.RIGHT, R.id.right_button, 5); linkButton(context, views, KeypressKeyValues.INTANT_REPLAY, R.id.instant_replay_button, 6); linkButton(context, views, KeypressKeyValues.DOWN, R.id.down_button, 7); linkButton(context, views, KeypressKeyValues.INFO, R.id.info_button, 8); linkButton(context, views, KeypressKeyValues.REV, R.id.rev_button, 9); linkButton(context, views, KeypressKeyValues.PLAY, R.id.play_button, 10); linkButton(context, views, KeypressKeyValues.FWD, R.id.fwd_button, 11); }
Example #25
Source File: OpenNotificationJellyBean.java From HeadsUp with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public boolean hasIdenticalIds(@Nullable OpenNotification n) { if (n == null) { return false; } EqualsBuilder builder = new EqualsBuilder(); RemoteViews cv = getNotification().contentView; RemoteViews cv2 = n.getNotification().contentView; if (cv != null && cv2 != null) { builder.append(cv.getLayoutId(), cv2.getLayoutId()); } return builder .append(getNotification().ledARGB, n.getNotification().ledARGB) .append(getPackageName(), n.getPackageName()) .append(titleText, n.titleText) .isEquals(); }
Example #26
Source File: xDripWidget.java From xDrip-Experimental with GNU General Public License v3.0 | 5 votes |
private static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) { RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.x_drip_widget); Log.d(TAG, "Update widget signal received"); //Add behaviour: open xDrip on click Intent intent = new Intent(context, Home.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.xDripwidget, pendingIntent);; displayCurrentInfo(appWidgetManager, appWidgetId, context, views); appWidgetManager.updateAppWidget(appWidgetId, views); }
Example #27
Source File: DayWidgetConfigActivity.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
@Override public RemoteViews getRemoteViews() { return DayWidgetIMP.getRemoteViews( this, getLocationNow(), viewTypeValueNow, cardStyleValueNow, cardAlpha, textColorValueNow, textSize, hideSubtitle, subtitleDataValueNow ); }
Example #28
Source File: CallNotification.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public void createNotification() { NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); for (int i = 0; i <= 10; i++) { Notification notification = new Notification(R.drawable.icon, "A new notification", System.currentTimeMillis()); // Wir setzen das Flag, dass sie Notification nach Selektion // verschwindet notification.flags |= Notification.FLAG_AUTO_CANCEL; RemoteViews view = new RemoteViews(getPackageName(), R.layout.main); int done = i * 10; view.setProgressBar(R.id.progressBar1, 100, done, false); view.setTextViewText(R.id.textView1, "Das ist die Nachricht. Wir sind " + done + " % fertig"); notification.contentView = view; Intent intent = new Intent(this, TargetActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); notification.contentIntent = pendingIntent; notificationManager.notify(0, notification); // Wir simulieren mal eine lange Aktion try { Thread.sleep(1000); } catch (InterruptedException e) { } } }
Example #29
Source File: Widget.java From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 | 5 votes |
@Override public RemoteViews getViewAt(int position) { RemoteViews row = new RemoteViews(mContext.getPackageName(), R.layout.widget_profile_item); row.setTextViewText(R.id.text, mItems.get(position).getName()); Intent i = new Intent(); Bundle extras = new Bundle(); extras.putInt(ITEM_ARG, position); i.putExtras(extras); row.setOnClickFillInIntent(R.id.text, i); return (row); }
Example #30
Source File: ListViewService.java From DongWeather with Apache License 2.0 | 5 votes |
@Override public RemoteViews getViewAt(int position) { Log.d(TAG, "getViewAt: " + position); RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.widget_item); Log.d(TAG, "getViewAt: RemoteViews Succeed"); //设置viewlist中的单项的值 HeWeather5 heWeather5 = heWeather5List.get(position); if (null != heWeather5.basic) { views.setTextViewText(R.id.widget_countyname_tv, heWeather5.basic.cityName); } try { String filename = heWeather5.now.cond.code + ".png"; views.setImageViewBitmap(R.id.widget_weather_im, BitmapFactory.decodeStream(getAssets().open(filename))); } catch (IOException e) { e.printStackTrace(); } views.setTextViewText(R.id.widget_temperature_tv, heWeather5.now.tmp + "º"); Log.d(TAG, "getViewAt: add succeed"); Bundle extras = new Bundle(); extras.putInt(ListViewService.INITENT_DATA, position); Intent skipIntent = new Intent(); skipIntent.setAction(WidgetProvider.SKIP_COUNTY_WEATHER); skipIntent.putExtras(extras); views.setOnClickFillInIntent(R.id.widget_item_id, skipIntent); return views; }