Skip to content

Commit 47aea3e

Browse files
committed
docs: add docs about packageName
1 parent 9ee9e56 commit 47aea3e

4 files changed

Lines changed: 289 additions & 385 deletions

File tree

docs/docs/tutorial/register-widget-expo.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
6767
});
6868
```
6969

70+
:::note
71+
By default the widget Java class will be put inside `<app-package-name>.widget`
72+
73+
If for any reason (for example you already have an app that is not using react-native-android-widget and want to replace existing widgets with react-native-android-widgets, but you already have providers in a different package), you can customize the widget java class package with `packageName` property for the widget
74+
:::
75+
7076
## Build Dev Client
7177

7278
Build an [Expo Dev Client](https://docs.expo.dev/development/create-development-builds/) that will include `react-native-android-widget` and the new widget

docs/docs/tutorial/register-widget.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ In order to register our widget so that it can be selected from the launchers wi
1010

1111
Create a new package `widget` in the native android app.
1212

13+
:::info
14+
Technically you can put the widget in any package that is inside your app, but you will need to update the widget receiver name.
15+
:::
16+
1317
import Tabs from '@theme/Tabs';
1418
import TabItem from '@theme/TabItem';
1519

@@ -161,9 +165,15 @@ In `AndroidManifest.xml`, add a receiver for the widget
161165

162166
For the receiver
163167

164-
- `android:name` myst be `.widget.WidgetName` (same as the Java class extending `RNWidgetProvider`)
168+
- `android:name` (same as the Java class extending `RNWidgetProvider`)
165169
- `android:label` will be shown in the widget picker
166170

171+
:::note
172+
`android:name` should reflect the package name of the provider, minus the package name of the app.
173+
174+
If you put the widget provider class in a `widgets` package, the `android:name` must be `.widget.<WidgetName>`
175+
:::
176+
167177
## Add custom fonts used in widgets
168178

169179
If we used a custom font in our widget, we must copy the font file(s) to `android/app/src/main/assets/fonts`. The `fontFamily` style prop will match the file by name.

example-expo/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"start": "expo start",
77
"android": "expo start --android",
8-
"build:lib": "rm -f ./react-native-android-widget* && yarn remove react-native-android-widget && rm -rf node_modules/react-native-android-widget && cd .. && yarn prepare && npm pack && pwd && mv react-native-android-widget-* ./example-expo/react-native-android-widget-$(shuf -i 10000-100000 -n1).tgz && cd example-expo && yarn add ./react-native-android-widget*",
8+
"build:lib": "rm -rf node_modules/react-native-android-widget && cd .. && yarn prepare && npm pack && pwd && mv react-native-android-widget-* ./example-expo/react-native-android-widget-$(shuf -i 10000-100000 -n1).tgz && cd example-expo && yarn add ./react-native-android-widget*",
99
"prebuild:dev-client": "yarn build:lib",
1010
"build:dev-client": "EAS_BUILD_PROFILE=development eas build --profile development --platform android",
1111
"prebuild:apk": "yarn build:lib",
@@ -15,18 +15,18 @@
1515
"@react-native-async-storage/async-storage": "^2.1.2",
1616
"@react-navigation/native": "^6.1.14",
1717
"@react-navigation/native-stack": "^6.9.22",
18-
"expo": "53.0.0-preview.1",
19-
"expo-dev-client": "5.1.1",
20-
"expo-splash-screen": "0.30.1",
18+
"expo": "53.0.9",
19+
"expo-dev-client": "~5.1.8",
20+
"expo-splash-screen": "~0.30.8",
2121
"react": "19.0.0",
22-
"react-native": "~0.79.0",
23-
"react-native-android-widget": "./react-native-android-widget-83316.tgz",
24-
"react-native-safe-area-context": "~5.3.0",
22+
"react-native": "~0.79.2",
23+
"react-native-android-widget": "./react-native-android-widget-59399.tgz",
24+
"react-native-safe-area-context": "~5.4.0",
2525
"react-native-screens": "~4.10.0"
2626
},
2727
"devDependencies": {
2828
"@babel/core": "^7.26.0",
29-
"@types/react": "^19.0.0",
29+
"@types/react": "~19.0.0",
3030
"typescript": "~5.8.3"
3131
},
3232
"private": true,

0 commit comments

Comments
 (0)