Skip to content

Commit 84990c1

Browse files
committed
use main/java not main/kotlin & support responsive feature
1 parent 6999d1f commit 84990c1

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

lib/commands/widget.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,11 +1062,18 @@ export class WidgetAndroidCommand extends WidgetCommand {
10621062
result = await prompts.prompt({
10631063
type: "text",
10641064
name: "initialLayout",
1065-
message: `What initial layout would you like for this widget? (Default is 'ns_remote_views_linear_layout' which is an empty linear layout. You can customize this with your own custom layout)`,
1065+
message: `What initial layout would you like for this widget? (Default is 'ns_remote_views_root_layout' which is an empty linear layout. You can customize this with your own custom layout)`,
10661066
});
10671067

1068-
const initialLayout =
1069-
result.initialLayout || "ns_remote_views_linear_layout";
1068+
result = await prompts.prompt({
1069+
type: "text",
1070+
name: "widgetFeatures",
1071+
message: `Enable responsive layout features for this widget? (Default is 'Y')`,
1072+
});
1073+
1074+
const widgetFeatures = result.widgetFeatures || "Y";
1075+
1076+
const initialLayout = result.initialLayout || "ns_remote_views_root_layout";
10701077

10711078
const bundleId = this.$projectConfigService.getValue(`id`, "");
10721079

@@ -1096,6 +1103,7 @@ export class WidgetAndroidCommand extends WidgetCommand {
10961103
minWidth,
10971104
minHeight,
10981105
initialLayout,
1106+
widgetFeatures === "N" ? false : true,
10991107
);
11001108

11011109
await this.generateWidget(
@@ -1153,6 +1161,7 @@ export class WidgetAndroidCommand extends WidgetCommand {
11531161
minWidth: string,
11541162
minHeight: string,
11551163
initialLayout: string,
1164+
enableWidgetFeatures: boolean,
11561165
) {
11571166
const appResourcePath = this.$projectData.appResourcesDirectoryPath;
11581167
const widgetInfoPath = path.join(
@@ -1177,7 +1186,8 @@ export class WidgetAndroidCommand extends WidgetCommand {
11771186
android:minHeight="${minHeight}"
11781187
android:resizeMode="${resizeMode}"
11791188
android:updatePeriodMillis="0"
1180-
android:widgetCategory="home_screen" />${EOL}`;
1189+
android:widgetCategory="home_screen"
1190+
${enableWidgetFeatures ? ' android:widgetFeatures="reconfigurable|configuration_optional"' : ""} />${EOL}`;
11811191

11821192
fs.writeFileSync(widgetInfoPath, content);
11831193
}
@@ -1194,7 +1204,7 @@ export class WidgetAndroidCommand extends WidgetCommand {
11941204
"Android",
11951205
"src",
11961206
"main",
1197-
"kotlin",
1207+
"java",
11981208
packageName.replace(/\./g, "/"),
11991209
`${widgetClassName}.kt`,
12001210
);

0 commit comments

Comments
 (0)