kopia lustrzana https://github.com/ge0rg/aprsdroid
Add Setting for Metric or Imperial.
rodzic
8d7a6757e9
commit
a8c771f0d2
|
@ -85,6 +85,10 @@
|
|||
<item>12</item> <item>13</item> <item>14</item> <item>15</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="p_units_ev">
|
||||
<item>1</item> <item>2</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="ages">
|
||||
<item>@string/age_30</item>
|
||||
<item>@string/age_2h</item>
|
||||
|
|
|
@ -168,6 +168,9 @@
|
|||
<string name="p_ssid">SSID</string>
|
||||
<string name="p_ssid_summary">Station type (1..15; 9=Mobile, 10=APRS-IS)</string>
|
||||
<string name="p_ssid_entry">Enter the SSID for your station</string>
|
||||
<string name="p_units_title">Distance Units</string>
|
||||
<string name="p_units">Unit Preference</string>
|
||||
<string name="p_units_entry">Select Distance Unit</string>
|
||||
<!-- array of station types (SSID) -->
|
||||
<string-array name="p_ssid_e">
|
||||
<item>(none) Primary Station</item>
|
||||
|
@ -187,6 +190,12 @@
|
|||
<item>14: Freight vehicle</item>
|
||||
<item>15: Generic additional station</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="p_units_e">
|
||||
<item>Metric</item>
|
||||
<item>Imperial</item>
|
||||
</string-array>
|
||||
|
||||
<string name="p_symbol">APRS symbol</string>
|
||||
<string name="p_symbol_summary">Your symbol for map display</string>
|
||||
<string name="p_symbol_overlay">Overlay:</string>
|
||||
|
|
|
@ -50,6 +50,20 @@
|
|||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/p_units_title">
|
||||
|
||||
<de.duenndns.ListPreferenceWithValue
|
||||
android:key="p.units"
|
||||
android:title="@string/p_units"
|
||||
android:entries="@array/p_units_e"
|
||||
android:entryValues="@array/p_units_ev"
|
||||
android:defaultValue="1"
|
||||
android:dialogTitle="@string/p_units_entry" />
|
||||
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/p__position">
|
||||
<PreferenceScreen
|
||||
|
|
|
@ -21,7 +21,10 @@ class PrefsWrapper(val context : Context) {
|
|||
def isAckDupeEnabled(): Boolean = {
|
||||
prefs.getBoolean("p.ackdupetoggle", false)
|
||||
}
|
||||
|
||||
def isMetric(): Boolean = {
|
||||
prefs.getString("p.units", "1") == "1" // "1" for metric, "2" for imperial
|
||||
}
|
||||
|
||||
// safely read integers
|
||||
def getStringInt(key : String, defValue : Int) = {
|
||||
try { prefs.getString(key, null).trim.toInt } catch { case _ : Throwable => defValue }
|
||||
|
|
|
@ -83,9 +83,20 @@ class StationListAdapter(context : Context, prefs : PrefsWrapper,
|
|||
val qrg_visible = if (qrg != null && qrg != "") View.VISIBLE else View.GONE
|
||||
view.findViewById(R.id.station_qrg).asInstanceOf[View].setVisibility(qrg_visible)
|
||||
val MCD = 1000000.0
|
||||
android.location.Location.distanceBetween(my_lat/MCD, my_lon/MCD,
|
||||
lat/MCD, lon/MCD, dist)
|
||||
distage.setText("%1.1f km %s\n%s".format(dist(0)/1000.0, getBearing(dist(1)), age))
|
||||
android.location.Location.distanceBetween(my_lat/MCD, my_lon/MCD, lat/MCD, lon/MCD, dist)
|
||||
|
||||
// Determine whether to use metric or imperial based on user preference
|
||||
val isMetric = prefs.isMetric() // Assuming isMetric() returns true for metric, false for imperial
|
||||
val distanceText: String = if (isMetric) {
|
||||
val distanceInKm = dist(0) / 1000.0
|
||||
"%1.1f km %s\n%s".format(distanceInKm, getBearing(dist(1)), age)
|
||||
} else {
|
||||
val distanceInMiles = dist(0) / 1000.0 * 0.621371
|
||||
"%1.1f mi %s\n%s".format(distanceInMiles, getBearing(dist(1)), age)
|
||||
}
|
||||
|
||||
distage.setText(distanceText)
|
||||
|
||||
view.findViewById(R.id.station_symbol).asInstanceOf[SymbolView].setSymbol(symbol)
|
||||
super.bindView(view, context, cursor)
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue