Skip to content

Commit

Permalink
Fix non working setting for hiding topbar
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed Jan 29, 2021
1 parent d176e07 commit f77d8af
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/com/cyb3rko/logviewerforopenhab/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ internal const val CRASHLYTICS_COLLECTION = "crashlytics_collection"
internal const val DATA_DELETION = "data_deletion"
internal const val FIRST_START = "first_start"
internal const val FIRST_START_WEB = "first_start_web"
internal const val HIDE_TOPBAR = "hide_topbar"
internal const val HOSTNAME_CHECK = "hostname_check"
internal const val HOSTNAME_STRING = "hostname_string"
internal const val LINK = "link"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class PreferenceFragment : PreferenceFragmentCompat() {
private lateinit var analyticsCollectionSwitch: SwitchPreferenceCompat
private lateinit var connectionOverviewSwitch: SwitchPreferenceCompat
private lateinit var crashlyticsCollectionSwitch: SwitchPreferenceCompat
private lateinit var hideTopbarSwitch: SwitchPreferenceCompat
private lateinit var mySPR: SharedPreferences
private lateinit var nightModeList: ListPreference
private lateinit var orientationList: ListPreference
Expand All @@ -40,12 +41,14 @@ class PreferenceFragment : PreferenceFragmentCompat() {
orientationList = findPreference(ORIENTATION)!!
connectionOverviewSwitch = findPreference(CONNECTION_OVERVIEW_ENABLED)!!
nightModeList = findPreference(NIGHTMODE)!!
hideTopbarSwitch = findPreference(HIDE_TOPBAR)!!
analyticsCollectionSwitch = findPreference(ANALYTICS_COLLECTION)!!
crashlyticsCollectionSwitch = findPreference(CRASHLYTICS_COLLECTION)!!

orientationList.value = mySPR.getString(ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED.toString())
connectionOverviewSwitch.isChecked = mySPR.getBoolean(CONNECTION_OVERVIEW_ENABLED, true)
nightModeList.value = mySPR.getString(NIGHTMODE, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM.toString())
hideTopbarSwitch.isChecked = mySPR.getBoolean(HIDE_TOPBAR, false)
analyticsCollectionSwitch.isChecked = mySPR.getBoolean(ANALYTICS_COLLECTION, true)
crashlyticsCollectionSwitch.isChecked = mySPR.getBoolean(CRASHLYTICS_COLLECTION, true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class WebViewFragment : Fragment() {
}

override fun onPageFinished(view: WebView?, url: String?) {
if (mySPR.getBoolean("hide_toolbar", false)) {
if (mySPR.getBoolean(HIDE_TOPBAR, false)) {
view?.loadUrl("javascript:document.getElementsByClassName(\"topbar navbar navbar-inverse navbar-fixed-top\")[0].setAttribute" +
"(\"style\",\"display:none;\");")
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
android:summary="@string/settings_hide_topbar_summary"
app:iconSpaceReserved="false"
android:defaultValue="false"
android:key="hide_toolbar" />
android:key="hide_topbar" />

</PreferenceCategory>

Expand Down

0 comments on commit f77d8af

Please sign in to comment.