Skip to content

Commit

Permalink
Fixed: Show Open Termux:Widget app to refresh widget message instea…
Browse files Browse the repository at this point in the history
…d of `No files in ~/.shortcuts/` message when initial layout of widget is being shown so that it is not confused with shortcuts directory being empty

In this stuck state which may happen after app updates or if app process gets killed without being restarted by Android, the widgets must be refreshed by starting the Termux:Widget app or with the refresh button in the main activity.

If the widget was successfully refreshed/updated and shortcuts directory was empty, only then the `No files in ~/.shortcuts/` message will be shown.
  • Loading branch information
agnostic-apollo committed Jan 16, 2025
1 parent d4cfdb2 commit de8c1a6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public static void updateAppWidgetRemoteViews(@NonNull Context context, @NonNull
// The empty view is displayed when the collection has no items. It should be a sibling
// of the collection view:
remoteViews.setEmptyView(R.id.widget_list, R.id.empty_view);
remoteViews.setTextViewText(R.id.empty_view, context.getString(R.string.msg_no_shortcut_scripts));

// Setup intent which points to the TermuxWidgetService which will provide the views for this collection.
Intent intent = new Intent(context, TermuxWidgetService.class);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/widget_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
android:layout_below="@id/top_row"
android:background="@android:color/white"
android:padding="6dp"
android:text="@string/msg_no_shortcut_scripts"
android:text="@string/msg_refresh_widget_from_app"
android:textColor="@android:color/black" />
</RelativeLayout>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"Open &TERMUX_WIDGET_APP_NAME; app to refresh widget" message instead of showing the
shortcuts. In this state, the refresh buttons of the widgets itself will not work. Just
launching the &TERMUX_WIDGET_APP_NAME; app will also refresh the widget.</string>
<string name="msg_refresh_widget_from_app">Open &TERMUX_WIDGET_APP_NAME; app to refresh widget</string>
<string name="action_refresh_all_widgets">Refresh Widgets</string>

<!-- ShortcutFile -->
Expand Down

0 comments on commit de8c1a6

Please sign in to comment.