Skip to content

Commit

Permalink
Use 'Main UI' in code
Browse files Browse the repository at this point in the history
Except for key that would change existing widgets/settings.

Signed-off-by: mueller-ma <[email protected]>
  • Loading branch information
mueller-ma committed Jan 23, 2024
1 parent ccc8149 commit 6a286e3
Show file tree
Hide file tree
Showing 25 changed files with 43 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ data class ServerProperties(val flags: Int, val sitemaps: List<Sitemap>) : Parce
const val SERVER_FLAG_HABPANEL_INSTALLED = 1 shl 4
const val SERVER_FLAG_SITEMAP_HAS_INVISIBLE_WIDGETS = 1 shl 5
const val SERVER_FLAG_SUPPORTS_ANY_FORMAT_ICON = 1 shl 6
const val SERVER_FLAG_OH3_UI = 1 shl 7
const val SERVER_FLAG_MAIN_UI = 1 shl 7
const val SERVER_FLAG_TRANSPARENT_CHARTS = 1 shl 8

private sealed interface FlagsResult
Expand Down Expand Up @@ -101,7 +101,7 @@ data class ServerProperties(val flags: Int, val sitemaps: List<Sitemap>) : Parce
flags = flags or SERVER_FLAG_SUPPORTS_ANY_FORMAT_ICON
}
if (version >= 4) {
flags = flags or SERVER_FLAG_OH3_UI
flags = flags or SERVER_FLAG_MAIN_UI
}
if (version >= 5) {
flags = flags or SERVER_FLAG_TRANSPARENT_CHARTS
Expand Down
8 changes: 4 additions & 4 deletions mobile/src/main/java/org/openhab/habdroid/model/WebViewUi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package org.openhab.habdroid.model
import org.openhab.habdroid.ui.activity.AbstractWebViewFragment
import org.openhab.habdroid.ui.activity.FrontailWebViewFragment
import org.openhab.habdroid.ui.activity.HabpanelWebViewFragment
import org.openhab.habdroid.ui.activity.Oh3UiWebViewFragment
import org.openhab.habdroid.ui.activity.MainUiWebViewFragment

data class WebViewUi(
val serverFlag: Int,
Expand All @@ -28,9 +28,9 @@ data class WebViewUi(
HabpanelWebViewFragment::class.java
)

val OH3_UI = WebViewUi(
ServerProperties.SERVER_FLAG_OH3_UI,
Oh3UiWebViewFragment::class.java
val MAIN_UI = WebViewUi(
ServerProperties.SERVER_FLAG_MAIN_UI,
MainUiWebViewFragment::class.java
)

val FRONTAIL = WebViewUi(
Expand Down
16 changes: 8 additions & 8 deletions mobile/src/main/java/org/openhab/habdroid/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -813,12 +813,12 @@ class MainActivity : AbstractBaseActivity(), ConnectionFactory.UpdateListener {
val notificationId = intent.getStringExtra(EXTRA_PERSISTED_NOTIFICATION_ID).orEmpty()
executeActionIfPossible(PendingAction.OpenNotification(notificationId, true))
}
ACTION_HABPANEL_SELECTED, ACTION_OH3_UI_SELECTED, ACTION_FRONTAIL_SELECTED -> {
ACTION_HABPANEL_SELECTED, ACTION_MAIN_UI_SELECTED, ACTION_FRONTAIL_SELECTED -> {
val serverId = intent.getIntExtra(EXTRA_SERVER_ID, prefs.getActiveServerId())
val ui = when (intent.action) {
ACTION_HABPANEL_SELECTED -> WebViewUi.HABPANEL
ACTION_FRONTAIL_SELECTED -> WebViewUi.FRONTAIL
else -> WebViewUi.OH3_UI
else -> WebViewUi.MAIN_UI
}
val subpage = intent.getStringExtra(EXTRA_SUBPAGE)
executeOrStoreAction(PendingAction.OpenWebViewUi(ui, serverId, subpage))
Expand Down Expand Up @@ -901,8 +901,8 @@ class MainActivity : AbstractBaseActivity(), ConnectionFactory.UpdateListener {
openWebViewUi(WebViewUi.HABPANEL, false, null)
handled = true
}
R.id.oh3_ui -> {
openWebViewUi(WebViewUi.OH3_UI, false, null)
R.id.main_ui -> {
openWebViewUi(WebViewUi.MAIN_UI, false, null)
handled = true
}
R.id.frontail -> {
Expand Down Expand Up @@ -1054,9 +1054,9 @@ class MainActivity : AbstractBaseActivity(), ConnectionFactory.UpdateListener {
prefs.getBoolean(PrefKeys.DRAWER_ENTRY_HABPANEL, true)
manageHabPanelShortcut(serverProperties?.hasWebViewUiInstalled(WebViewUi.HABPANEL) == true)

val oh3UiItem = drawerMenu.findItem(R.id.oh3_ui)
oh3UiItem.isVisible = serverProperties?.hasWebViewUiInstalled(WebViewUi.OH3_UI) == true &&
prefs.getBoolean(PrefKeys.DRAWER_ENTRY_OH3_UI, true)
val mainUiItem = drawerMenu.findItem(R.id.main_ui)
mainUiItem.isVisible = serverProperties?.hasWebViewUiInstalled(WebViewUi.MAIN_UI) == true &&
prefs.getBoolean(PrefKeys.DRAWER_ENTRY_MAIN_UI, true)

val frontailItem = drawerMenu.findItem(R.id.frontail)
frontailItem.isVisible = serverProperties != null &&
Expand Down Expand Up @@ -1499,7 +1499,7 @@ class MainActivity : AbstractBaseActivity(), ConnectionFactory.UpdateListener {
companion object {
const val ACTION_NOTIFICATION_SELECTED = "org.openhab.habdroid.action.NOTIFICATION_SELECTED"
const val ACTION_HABPANEL_SELECTED = "org.openhab.habdroid.action.HABPANEL_SELECTED"
const val ACTION_OH3_UI_SELECTED = "org.openhab.habdroid.action.OH3_UI_SELECTED"
const val ACTION_MAIN_UI_SELECTED = "org.openhab.habdroid.action.OH3_UI_SELECTED"
const val ACTION_FRONTAIL_SELECTED = "org.openhab.habdroid.action.FRONTAIL"
const val ACTION_VOICE_RECOGNITION_SELECTED = "org.openhab.habdroid.action.VOICE_SELECTED"
const val ACTION_SITEMAP_SELECTED = "org.openhab.habdroid.action.SITEMAP_SELECTED"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import okhttp3.HttpUrl
import org.openhab.habdroid.R
import org.openhab.habdroid.ui.MainActivity

class Oh3UiWebViewFragment : AbstractWebViewFragment() {
override val titleRes = R.string.mainmenu_openhab_oh3_ui
override val errorMessageRes = R.string.oh3_ui_error
class MainUiWebViewFragment : AbstractWebViewFragment() {
override val titleRes = R.string.mainmenu_openhab_main_ui
override val errorMessageRes = R.string.main_ui_error
override val urlToLoad = "/"
override val pathForError = "/"
override val lockDrawer = true
override val shortcutIcon = R.mipmap.ic_shortcut_oh3_ui
override val shortcutAction = MainActivity.ACTION_OH3_UI_SELECTED
override val shortcutIcon = R.mipmap.ic_shortcut_main_ui
override val shortcutAction = MainActivity.ACTION_MAIN_UI_SELECTED

override fun modifyUrl(orig: HttpUrl): HttpUrl {
if (orig.host == "myopenhab.org") {
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/main/java/org/openhab/habdroid/util/PrefKeys.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ object PrefKeys {
const val DEBUG_MESSAGES = "default_openhab_debug_messages"
const val LOG = "default_openhab_log"

const val DRAWER_ENTRY_OH3_UI = "show_oh3_ui"
const val DRAWER_ENTRY_MAIN_UI = "show_oh3_ui"
const val DRAWER_ENTRY_HABPANEL = "show_habpanel"
const val DRAWER_ENTRY_NFC = "show_nfc"
const val DRAWER_ENTRY_FRONTAIL = "show_frontail"
Expand Down
4 changes: 2 additions & 2 deletions mobile/src/main/res/menu/left_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
android:id="@+id/options"
android:checkableBehavior="none">
<item
android:id="@+id/oh3_ui"
android:id="@+id/main_ui"
android:icon="@drawable/ic_outline_looks_3_grey_24dp"
android:title="@string/mainmenu_openhab_oh3_ui"
android:title="@string/mainmenu_openhab_main_ui"
android:menuCategory="system" />
<item
android:id="@+id/habpanel"
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!-- %1$s: Name of a UI, %2$s: Server name. Example: HABPanel (House). Use the source string as translation if the punctuation rules are the same as in English. -->
<string name="app_notifications">Известия</string>
<string name="habpanel_error">Грешка при зареждане на HABPanel</string>
<string name="oh3_ui_error">Грешка при зареждане на Main UI</string>
<string name="main_ui_error">Грешка при зареждане на Main UI</string>
<string name="mainmenu_openhab_selectsitemap">Избери сайткарта по подразбиране</string>
<string name="mainmenu_openhab_clearcache">Изчисти кеша на изображенията</string>
<!-- App settings strings -->
Expand Down
4 changes: 2 additions & 2 deletions mobile/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<string name="mainmenu_openhab_sitemaps">Sitemaps</string>
<string name="mainmenu_openhab_preferences">Einstellungen</string>
<string name="mainmenu_openhab_habpanel">HABPanel</string>
<string name="mainmenu_openhab_oh3_ui">Main UI</string>
<string name="mainmenu_openhab_main_ui">Main UI</string>
<string name="mainmenu_openhab_frontail">Frontail</string>
<!-- %1$s: Name of a UI, %2$s: Server name. Example: HABPanel (House). Use the source string as translation if the punctuation rules are the same as in English. -->
<string name="ui_on_server">%1$s (%2$s)</string>
<string name="app_notifications">Benachrichtigungen</string>
<string name="habpanel_error">Beim Laden von HABPanel ist ein Fehler aufgetreten</string>
<string name="oh3_ui_error">Beim Laden der Main UI ist ein Fehler aufgetreten</string>
<string name="main_ui_error">Beim Laden der Main UI ist ein Fehler aufgetreten</string>
<string name="frontail_error">Beim Laden von Frontail ist ein Fehler aufgetreten. Bitte beachten Sie, dass Frontail nicht über openHAB Cloud verfügbar ist.</string>
<string name="mainmenu_openhab_selectsitemap">Standard-Sitemap auswählen</string>
<string name="mainmenu_openhab_clearcache">Bilder-Cache leeren</string>
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/main/res/values-es-rUS/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<string name="mainmenu_openhab_sitemaps">Sitemaps</string>
<string name="mainmenu_openhab_preferences">Configuración</string>
<string name="mainmenu_openhab_habpanel">HABPanel</string>
<string name="mainmenu_openhab_oh3_ui">Main UI</string>
<string name="mainmenu_openhab_main_ui">Main UI</string>
<string name="mainmenu_openhab_frontail">Frontail</string>
<!-- %1$s: Name of a UI, %2$s: Server name. Example: HABPanel (House). Use the source string as translation if the punctuation rules are the same as in English. -->
<string name="ui_on_server">%1$s (%2$s)</string>
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<string name="mainmenu_openhab_sitemaps">Sitemaps</string>
<string name="mainmenu_openhab_preferences">Configuración</string>
<string name="mainmenu_openhab_habpanel">HABPanel</string>
<string name="mainmenu_openhab_oh3_ui">Main UI</string>
<string name="mainmenu_openhab_main_ui">Main UI</string>
<string name="mainmenu_openhab_frontail">Frontail</string>
<!-- %1$s: Name of a UI, %2$s: Server name. Example: HABPanel (House). Use the source string as translation if the punctuation rules are the same as in English. -->
<string name="ui_on_server">%1$s (%2$s)</string>
Expand Down
4 changes: 2 additions & 2 deletions mobile/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<string name="mainmenu_openhab_sitemaps">Felületek</string>
<string name="mainmenu_openhab_preferences">Beállítások</string>
<string name="mainmenu_openhab_habpanel">HABPanel</string>
<string name="mainmenu_openhab_oh3_ui">Főképernyő</string>
<string name="mainmenu_openhab_main_ui">Főképernyő</string>
<string name="mainmenu_openhab_frontail">Frontail</string>
<!-- %1$s: Name of a UI, %2$s: Server name. Example: HABPanel (House). Use the source string as translation if the punctuation rules are the same as in English. -->
<string name="ui_on_server">%1$s (%2$s)</string>
<string name="app_notifications">Értesítések</string>
<string name="habpanel_error">Hiba történt a HABPanel betöltése során</string>
<string name="oh3_ui_error">Hiba lépett fel az főképernyő (Main UI) beöltésekor</string>
<string name="main_ui_error">Hiba lépett fel az főképernyő (Main UI) beöltésekor</string>
<string name="frontail_error">Hiba történt a Frontail betöltése közben. Vegye figyelembe, hogy openHAB Cloud-n keresztül nem elérhető.</string>
<string name="mainmenu_openhab_selectsitemap">Válassza ki az alapértelmezett felületet</string>
<string name="mainmenu_openhab_clearcache">Gyorsítótári képek törlése</string>
Expand Down
4 changes: 2 additions & 2 deletions mobile/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<string name="mainmenu_openhab_sitemaps">Sitemaps</string>
<string name="mainmenu_openhab_preferences">Impostazioni</string>
<string name="mainmenu_openhab_habpanel">HABPanel</string>
<string name="mainmenu_openhab_oh3_ui">Main UI</string>
<string name="mainmenu_openhab_main_ui">Main UI</string>
<string name="mainmenu_openhab_frontail">Frontail</string>
<!-- %1$s: Name of a UI, %2$s: Server name. Example: HABPanel (House). Use the source string as translation if the punctuation rules are the same as in English. -->
<string name="ui_on_server">%1$s (%2$s)</string>
<string name="app_notifications">Notifiche</string>
<string name="habpanel_error">Si è verificato un errore caricando HABPanel</string>
<string name="oh3_ui_error">Si è verificato un errore durante il caricamento dell\'interfaccia utente principale Main UI</string>
<string name="main_ui_error">Si è verificato un errore durante il caricamento dell\'interfaccia utente principale Main UI</string>
<string name="frontail_error">Si è verificato un errore durante il caricamento di Frontail. Nota che non è disponibile tramite openHAB Cloud.</string>
<string name="mainmenu_openhab_selectsitemap">Seleziona Sitemap predefinito</string>
<string name="mainmenu_openhab_clearcache">Pulisci cache immagini</string>
Expand Down
4 changes: 2 additions & 2 deletions mobile/src/main/res/values-iw/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<string name="mainmenu_openhab_sitemaps">תצורות מערכת</string>
<string name="mainmenu_openhab_preferences">הגדרות</string>
<string name="mainmenu_openhab_habpanel">HABPanel</string>
<string name="mainmenu_openhab_oh3_ui">ממשק משתמש ראשי</string>
<string name="mainmenu_openhab_main_ui">ממשק משתמש ראשי</string>
<string name="mainmenu_openhab_frontail">Frontail</string>
<!-- %1$s: Name of a UI, %2$s: Server name. Example: HABPanel (House). Use the source string as translation if the punctuation rules are the same as in English. -->
<string name="ui_on_server">%1$s (%2$s)</string>
<string name="app_notifications">התראות</string>
<string name="habpanel_error">אירעה שגיאה בעת טעינת HABPanel</string>
<string name="oh3_ui_error">אירעה שגיאה בעת טעינת ממשק המשתמש הראשי</string>
<string name="main_ui_error">אירעה שגיאה בעת טעינת ממשק המשתמש הראשי</string>
<string name="frontail_error">אירעה שגיאה בעת טעינת Frontail. שים לב שהוא אינו זמין דרך openHAB Cloud.</string>
<string name="mainmenu_openhab_selectsitemap">בחר את ברירת המחדל של תצורת המערכת</string>
<string name="mainmenu_openhab_clearcache">נקה מטמון תמונות</string>
Expand Down
4 changes: 2 additions & 2 deletions mobile/src/main/res/values-nb/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<string name="mainmenu_openhab_sitemaps">Sitemaps</string>
<string name="mainmenu_openhab_preferences">Innstillinger</string>
<string name="mainmenu_openhab_habpanel">HABPanel</string>
<string name="mainmenu_openhab_oh3_ui">Main UI</string>
<string name="mainmenu_openhab_main_ui">Main UI</string>
<string name="mainmenu_openhab_frontail">Frontail</string>
<!-- %1$s: Name of a UI, %2$s: Server name. Example: HABPanel (House). Use the source string as translation if the punctuation rules are the same as in English. -->
<string name="ui_on_server">%1$s (%2$s)</string>
<string name="app_notifications">Varslinger</string>
<string name="habpanel_error">Det oppstod en feil under innlasting av HABPanel</string>
<string name="oh3_ui_error">En feil oppstod under lasting av Main UI</string>
<string name="main_ui_error">En feil oppstod under lasting av Main UI</string>
<string name="frontail_error">Det oppstod en feil under lasting av Frontail. Vær oppmerksom på at det ikke er tilgjengelig via openHAB Cloud.</string>
<string name="mainmenu_openhab_selectsitemap">Velg standard Sitemap</string>
<string name="mainmenu_openhab_clearcache">Tøm bildebuffer</string>
Expand Down
4 changes: 2 additions & 2 deletions mobile/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<string name="mainmenu_openhab_sitemaps">Sitemaps</string>
<string name="mainmenu_openhab_preferences">Настройки</string>
<string name="mainmenu_openhab_habpanel">HABPanel</string>
<string name="mainmenu_openhab_oh3_ui">Main UI</string>
<string name="mainmenu_openhab_main_ui">Main UI</string>
<string name="mainmenu_openhab_frontail">Frontail</string>
<!-- %1$s: Name of a UI, %2$s: Server name. Example: HABPanel (House). Use the source string as translation if the punctuation rules are the same as in English. -->
<string name="ui_on_server">%1$s (%2$s)</string>
<string name="app_notifications">Уведомления</string>
<string name="habpanel_error">Произошла ошибка при загрузке HABPanel</string>
<string name="oh3_ui_error">Произошла ошибка при загрузке Main UI</string>
<string name="main_ui_error">Произошла ошибка при загрузке Main UI</string>
<string name="frontail_error">Произошла ошибка при загрузке Frontail. Пожалуйста, обратите внимание, что она недоступна через облако openHAB.</string>
<string name="mainmenu_openhab_selectsitemap">Выбрать Sitemap по умолчанию</string>
<string name="mainmenu_openhab_clearcache">Очистить кэш изображений</string>
Expand Down
4 changes: 2 additions & 2 deletions mobile/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<string name="mainmenu_openhab_sitemaps">系统布局</string>
<string name="mainmenu_openhab_preferences">设置</string>
<string name="mainmenu_openhab_habpanel">HAB 面板</string>
<string name="mainmenu_openhab_oh3_ui">主界面</string>
<string name="mainmenu_openhab_main_ui">主界面</string>
<string name="mainmenu_openhab_frontail">Frontail</string>
<!-- %1$s: Name of a UI, %2$s: Server name. Example: HABPanel (House). Use the source string as translation if the punctuation rules are the same as in English. -->
<string name="ui_on_server">%1$s (%2$s)</string>
<string name="app_notifications">通知</string>
<string name="habpanel_error">载入 HAB 面板时出错</string>
<string name="oh3_ui_error">加载主界面时发生错误</string>
<string name="main_ui_error">加载主界面时发生错误</string>
<string name="frontail_error">加载正面时发生错误。请注意它无法通过 openHAB云访问。</string>
<string name="mainmenu_openhab_selectsitemap">选择默认系统布局</string>
<string name="mainmenu_openhab_clearcache">清除图像缓存</string>
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
<string-array name="start_page">
<item>@string/mainmenu_openhab_sitemaps</item>
<item>@string/mainmenu_openhab_habpanel</item>
<item>@string/mainmenu_openhab_oh3_ui</item>
<item>@string/mainmenu_openhab_main_ui</item>
<item>@string/mainmenu_openhab_frontail</item>
</string-array>

Expand Down
4 changes: 2 additions & 2 deletions mobile/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
<string name="mainmenu_openhab_sitemaps">Sitemaps</string>
<string name="mainmenu_openhab_preferences">Settings</string>
<string name="mainmenu_openhab_habpanel">HABPanel</string>
<string name="mainmenu_openhab_oh3_ui">Main UI</string>
<string name="mainmenu_openhab_main_ui">Main UI</string>
<string name="mainmenu_openhab_frontail">Frontail</string>
<!-- %1$s: Name of a UI, %2$s: Server name. Example: HABPanel (House). Use the source string as translation if the punctuation rules are the same as in English. -->
<string name="ui_on_server">%1$s (%2$s)</string>
<string name="app_notifications">Notifications</string>
<string name="habpanel_error">An error occurred while loading HABPanel</string>
<string name="oh3_ui_error">An error occurred while loading Main UI</string>
<string name="main_ui_error">An error occurred while loading Main UI</string>
<string name="frontail_error">An error occurred while loading Frontail. Please note that it\'s not available via openHAB Cloud.</string>
<string name="mainmenu_openhab_selectsitemap">Select default Sitemap</string>
<string name="mainmenu_openhab_clearcache">Clear images cache</string>
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/main/res/xml/preferences_drawer_entries.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
android:defaultValue="true"
android:key="show_oh3_ui"
android:icon="@drawable/ic_outline_looks_3_grey_24dp"
android:title="@string/mainmenu_openhab_oh3_ui"
android:title="@string/mainmenu_openhab_main_ui"
android:widgetLayout="@layout/preference_material_switch" />
<SwitchPreferenceCompat
android:defaultValue="true"
Expand Down

0 comments on commit 6a286e3

Please sign in to comment.