类android.widget.RemoteViews源码实例Demo

下面列出了怎么用android.widget.RemoteViews的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: fingen   文件: WidgetTransfer.java
@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);
}
 
源代码2 项目: RoMote   文件: RokuAppWidgetProvider.java
/**
 * 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);
}
 
源代码3 项目: GitJourney   文件: StackWidgetService.java
@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;
}
 
@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);
}
 
源代码5 项目: SuntimesWidget   文件: SunLayout_1x1_1.java
@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);
}
 
源代码6 项目: chromadoze   文件: NoiseService.java
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;
}
 
源代码7 项目: SuntimesWidget   文件: MoonLayout.java
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);
}
 
源代码8 项目: DebugPurge   文件: WidgetProvider.java
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;
}
 
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);
}
 
源代码10 项目: MTweaks-KernelAdiutorMOD   文件: Widget.java
@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);
    }
}
 
源代码11 项目: container   文件: PendIntentCompat.java
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);
			}
		}
	}
}
 
源代码12 项目: MaxLock   文件: MasterSwitchWidget.java
@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);
    }
}
 
源代码13 项目: SuntimesWidget   文件: MoonLayout.java
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);
    }
}
 
源代码14 项目: protrip   文件: PlacesWidgetProvider.java
@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);
}
 
/**
 * 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;
    }
}
 
源代码16 项目: RoMote   文件: RokuAppWidgetProvider.java
/**
 * 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);
}
 
源代码17 项目: HeadsUp   文件: OpenNotificationJellyBean.java
/**
 * {@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();

}
 
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");
}
 
源代码19 项目: android_9.0.0_r45   文件: PendingHostUpdate.java
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();
    }
}
 
源代码20 项目: ampdroid   文件: Mp3PlayerService.java
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);
}
 
源代码21 项目: 365browser   文件: CustomTabBottomBarDelegate.java
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());
        }
    });
}
 
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();
    }
}
 
源代码23 项目: physical-web   文件: UrlDeviceDiscoveryService.java
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);
}
 
源代码24 项目: android-news-app   文件: NewsWidgetProvider.java
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);
}
 
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
    );
}
 
源代码26 项目: DongWeather   文件: ListViewService.java
@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;

}
 
源代码27 项目: Android-Audio-Recorder   文件: RecordingService.java
public void showNotificationAlarm(boolean show) {
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    if (!show) {
        notificationManager.cancel(NOTIFICATION_RECORDING_ICON);
    } else {
        PendingIntent main = PendingIntent.getService(this, 0,
                new Intent(this, RecordingService.class).setAction(SHOW_ACTIVITY),
                PendingIntent.FLAG_UPDATE_CURRENT);

        PendingIntent pe = PendingIntent.getService(this, 0,
                new Intent(this, RecordingService.class).setAction(PAUSE_BUTTON),
                PendingIntent.FLAG_UPDATE_CURRENT);

        RemoteViews view = new RemoteViews(getPackageName(), MainApplication.getTheme(getBaseContext(),
                R.layout.notifictaion_recording_light,
                R.layout.notifictaion_recording_dark));

        view.setOnClickPendingIntent(R.id.status_bar_latest_event_content, main);
        view.setTextViewText(R.id.notification_text, ".../" + targetFile);
        view.setOnClickPendingIntent(R.id.notification_pause, pe);
        view.setImageViewResource(R.id.notification_pause, !recording ? R.drawable.play : R.drawable.pause);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                .setOngoing(true)
                .setContentTitle(getString(R.string.recording_title))
                .setSmallIcon(R.drawable.ic_mic_24dp)
                .setContent(view);

        if (Build.VERSION.SDK_INT >= 21)
            builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);

        notificationManager.notify(NOTIFICATION_RECORDING_ICON, builder.build());
    }
}
 
源代码28 项目: FimiX8-RE   文件: DownloadApkService.java
public void onCreate() {
    super.onCreate();
    this.notificationManager = (NotificationManager) getSystemService("notification");
    PendingIntent pendIntent = PendingIntent.getActivity(this, 0, new Intent(), 0);
    this.notification = new Notification();
    this.notification.icon = R.drawable.ic_launcher;
    this.notification.tickerText = getString(R.string.fimi_sdk_apk_downing) + getString(R.string.app_product_name);
    this.notification.contentIntent = pendIntent;
    this.notification.contentView = new RemoteViews(getPackageName(), R.layout.fimisdk_apk_download_notification);
    this.notification.contentView.setProgressBar(R.id.download_bar, 100, 0, false);
    this.notification.contentView.setTextViewText(R.id.text_download_title, getString(R.string.fimi_sdk_apk_downing) + " " + getString(R.string.app_product_name));
    this.notification.contentView.setTextViewText(R.id.text_download_process, "0%");
}
 
源代码29 项目: input-samples   文件: ResponseAdapter.java
public FillResponse buildResponseForFocusedNode(String datasetName, FilledAutofillField field,
        FieldType fieldType) {
    FillResponse.Builder responseBuilder = new FillResponse.Builder();
    RemoteViews remoteViews = RemoteViewsHelper.viewsWithNoAuth(
            mPackageName, datasetName);
    Dataset dataset = mDatasetAdapter.buildDatasetForFocusedNode(field, fieldType, remoteViews);
    if (dataset != null) {
        responseBuilder.addDataset(dataset);
        return responseBuilder.build();
    } else {
        return null;
    }
}
 
源代码30 项目: input-samples   文件: RemoteViewsHelper.java
private static RemoteViews simpleRemoteViews(String packageName, String remoteViewsText,
        @DrawableRes int drawableId) {
    RemoteViews presentation = new RemoteViews(packageName,
            R.layout.multidataset_service_list_item);
    presentation.setTextViewText(R.id.text, remoteViewsText);
    presentation.setImageViewResource(R.id.icon, drawableId);
    return presentation;
}
 
 类所在包
 同包方法