Skip to content

Commit bac5bca

Browse files
committed
show debug info (opt in)
1 parent 343baf0 commit bac5bca

4 files changed

Lines changed: 40 additions & 1 deletion

File tree

app/src/main/kotlin/org/btcmap/settings/SettingsFragment.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class SettingsFragment : Fragment() {
5959
refreshAllColors()
6060
}
6161

62+
binding.showDebugInfo.isChecked = prefs.showDebugInfo
63+
binding.showDebugInfo.setOnCheckedChangeListener { _, isChecked ->
64+
prefs.showDebugInfo = isChecked
65+
}
66+
6267
initMarkerBackgroundButton()
6368
initMarkerIconButton()
6469

app/src/main/kotlin/org/btcmap/settings/SharedPreferencesExt.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.content.Context.MODE_PRIVATE
55
import android.content.SharedPreferences
66
import android.content.res.Configuration
77
import androidx.core.content.edit
8+
import org.btcmap.BuildConfig
89
import org.btcmap.R
910
import org.maplibre.android.geometry.LatLngBounds
1011
import androidx.core.graphics.toColorInt
@@ -365,4 +366,12 @@ var SharedPreferences.authToken: String?
365366
}
366367

367368
val SharedPreferences.authorized: Boolean
368-
get() = !getString(KEY_AUTH_TOKEN, null).isNullOrBlank()
369+
get() = !getString(KEY_AUTH_TOKEN, null).isNullOrBlank()
370+
371+
private const val KEY_SHOW_DEBUG_INFO = "show_debug_info"
372+
373+
var SharedPreferences.showDebugInfo: Boolean
374+
get() = getBoolean(KEY_SHOW_DEBUG_INFO, BuildConfig.DEBUG)
375+
set(value) {
376+
edit { putBoolean(KEY_SHOW_DEBUG_INFO, value) }
377+
}

app/src/main/res/layout/settings_fragment.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,30 @@
360360

361361
</LinearLayout>
362362

363+
<LinearLayout
364+
android:layout_width="match_parent"
365+
android:layout_height="wrap_content"
366+
android:gravity="center_vertical"
367+
android:minHeight="64dp"
368+
android:orientation="horizontal"
369+
android:paddingStart="16dp"
370+
android:paddingEnd="16dp">
371+
372+
<TextView
373+
android:layout_width="0dp"
374+
android:layout_height="wrap_content"
375+
android:layout_weight="1"
376+
android:text="@string/show_debug_info"
377+
android:textColor="?colorOnSurface"
378+
android:textSize="16sp" />
379+
380+
<com.google.android.material.materialswitch.MaterialSwitch
381+
android:id="@+id/showDebugInfo"
382+
android:layout_width="wrap_content"
383+
android:layout_height="wrap_content" />
384+
385+
</LinearLayout>
386+
363387
<Space
364388
android:layout_width="match_parent"
365389
android:layout_height="40dp" />

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,5 @@
9797
<string name="click_to_see_your_profile" tools:ignore="MissingTranslation">Click to see your profile</string>
9898
<string name="delete" tools:ignore="MissingTranslation">Delete</string>
9999
<string name="upcoming_events" tools:ignore="MissingTranslation">Upcoming events</string>
100+
<string name="show_debug_info" tools:ignore="MissingTranslation">Show debug info</string>
100101
</resources>

0 commit comments

Comments
 (0)