Skip to content

Commit

Permalink
Show charts for all Sitemap widgets (openhab#3636)
Browse files Browse the repository at this point in the history
Add an entry to the context menu that allows showing a chart on a new screen. It's possible to display charts for all Items in Main UI settings and this is quite useful. The word 'Analyze' is also taken from Main UI.

Signed-off-by: mueller-ma <[email protected]>
  • Loading branch information
mueller-ma authored Apr 4, 2024
1 parent b382bd5 commit fbe22b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,24 @@ class WidgetListFragment :

// Offer widget for all Items. For read-only Items the "Show state" widget is useful.
if (widget.item != null) {
menu.add(
Menu.NONE,
CONTEXT_MENU_ID_SHOW_CHART,
Menu.NONE,
R.string.analyse
).setOnMenuItemClickListener {
val mainActivity = activity as MainActivity
val intent = Intent(mainActivity, ChartWidgetActivity::class.java)
intent.putExtra(ChartWidgetActivity.EXTRA_WIDGET, widget)
intent.putExtra(ChartWidgetActivity.EXTRA_SERVER_FLAGS, mainActivity.serverProperties?.flags)
mainActivity.startActivity(intent)
return@setOnMenuItemClickListener true
}


val widgetMenu = menu.addSubMenu(
Menu.NONE, CONTEXT_MENU_ID_CREATE_HOME_SCREEN_WIDGET,
Menu.NONE,
CONTEXT_MENU_ID_CREATE_HOME_SCREEN_WIDGET,
Menu.NONE,
R.string.create_home_screen_widget_title
)
Expand Down Expand Up @@ -648,6 +664,7 @@ class WidgetListFragment :
private const val CONTEXT_MENU_ID_PIN_HOME_BLACK = 1005
private const val CONTEXT_MENU_ID_OPEN_IN_MAPS = 1006
private const val CONTEXT_MENU_ID_COPY_ITEM_NAME = 1007
private const val CONTEXT_MENU_ID_SHOW_CHART = 1008
private const val CONTEXT_MENU_ID_WRITE_CUSTOM_TAG = 10000
private const val CONTEXT_MENU_ID_WRITE_DEVICE_ID = 10001

Expand Down
1 change: 1 addition & 0 deletions mobile/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@
<string name="create_home_screen_widget_title">Create widget</string>
<string name="create_home_screen_widget_no_command">Show current state</string>
<string name="create_home_screen_widget_not_supported">Please go to the widget menu on your home screen and create a widget from there</string>
<string name="analyse">Analyze</string>

<!-- Data saver -->
<string name="data_saver_title">Data saver</string>
Expand Down

0 comments on commit fbe22b8

Please sign in to comment.