Skip to content

Commit

Permalink
fix: allow clickable views inside list items on Samsung devices
Browse files Browse the repository at this point in the history
  • Loading branch information
sAleksovski committed Jan 4, 2024
1 parent 74a3137 commit b2322c4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Allow clickable views inside list items on Samsung devices

## [0.11.0] - 2024-01-03

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,7 @@ public RemoteViews getViewAt(int position) {
// Set a fill-intent which will be used to fill-in the pending intent template
// which is set on the collection view in RNWidget.
if (bundle.getString("clickAction", null) != null) {
Bundle extras = new Bundle();
extras.putInt("widgetId", mAppWidgetId);

extras.putString("clickAction", bundle.getString("clickAction"));
extras.putBundle("clickActionData", bundle.getBundle("clickActionData"));

Intent fillInIntent = new Intent();
fillInIntent.putExtras(extras);
Intent fillInIntent = createFillInIntent(bundle);
listItemView.setOnClickFillInIntent(R.id.rn_widget_list_item, fillInIntent);
}

Expand Down Expand Up @@ -164,9 +157,24 @@ private void addClickableArea(RemoteViews widgetView, Bundle clickableArea, int
PendingIntent pendingIntent = createPendingIntent(clickableArea);
clickableRemoteView.setOnClickPendingIntent(R.id.rn_widget_clickable_area, pendingIntent);

Intent fillInIntent = createFillInIntent(clickableArea);
clickableRemoteView.setOnClickFillInIntent(R.id.rn_widget_clickable_area, fillInIntent);

widgetView.addView(R.id.rn_widget_list_item_clickable_container, clickableRemoteView);
}

private Intent createFillInIntent(Bundle bundle) {
Bundle extras = new Bundle();
extras.putInt("widgetId", mAppWidgetId);

extras.putString("clickAction", bundle.getString("clickAction"));
extras.putBundle("clickActionData", bundle.getBundle("clickActionData"));

Intent fillInIntent = new Intent();
fillInIntent.putExtras(extras);
return fillInIntent;
}

private PendingIntent createPendingIntent(Bundle clickableArea) {
Intent intent = new Intent(mContext.getPackageName() + ".WIDGET_CLICK");
intent.setComponent(new ComponentName(mContext, RNWidgetUtil.getWidgetProviderClassName(mContext, widgetName)));
Expand Down

0 comments on commit b2322c4

Please sign in to comment.