Skip to content

Commit

Permalink
add: more DD places
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza417 committed Mar 2, 2025
1 parent ca892d7 commit ce94576
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CoordinatesFormat : CustomBottomSheetDialogFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.dialog_coordinates_format, container, false)

dd = view.findViewById(R.id.dd_ddd)
dd = view.findViewById(R.id.dd_dddddd)
ddm = view.findViewById(R.id.dd_mm_mmm)
dms = view.findViewById(R.id.dd_mm_ss_sss)

Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/app/simple/positional/ui/panels/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class Settings : ScopedFragment(), CoordinatesCallback, PopupMenuCallback {
if (isChecked) {
startActivity(Intent(requireActivity(), CustomLocationsActivity::class.java))
} else {
MainPreferences.setCustomCoordinates(isChecked)
MainPreferences.setCustomCoordinates(false)
}
}
}
Expand Down Expand Up @@ -293,8 +293,8 @@ class Settings : ScopedFragment(), CoordinatesCallback, PopupMenuCallback {

legalNotes.setOnClickListener {
val popupMenu = LegalNotesPopupMenu(LayoutInflater.from(requireContext()).inflate(R.layout.popup_legal_notes,
PopupLinearLayout(context),
true), legalNotes, xOff, yOff)
PopupLinearLayout(context),
true), legalNotes, xOff, yOff)
popupMenu.popupMenuCallback = this
}

Expand Down Expand Up @@ -365,9 +365,9 @@ class Settings : ScopedFragment(), CoordinatesCallback, PopupMenuCallback {
permissionNotification()
} else {
permissionContracts.launch(
arrayOf(
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION))
arrayOf(
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION))
}
}

Expand Down Expand Up @@ -419,7 +419,7 @@ class Settings : ScopedFragment(), CoordinatesCallback, PopupMenuCallback {

private fun setCoordinatesFormat() {
coordinatesFormat.text = when (MainPreferences.getCoordinatesFormat()) {
0 -> getString(R.string.dd_ddd)
0 -> getString(R.string.dd_dddddd)
1 -> getString(R.string.dd_mm_mmm)
2 -> getString(R.string.dd_mm_ss_sss)
else -> "Unknown Format Selected!!" // Unreachable
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/app/simple/positional/util/DMSConverter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import kotlin.math.abs

object DMSConverter {

private const val DD_DDDDDD_PLACES = 6

fun getFormattedCoordinates(location: Location, context: Context): Array<String> {
return when (MainPreferences.getCoordinatesFormat()) {
0 -> { // DD
Expand Down Expand Up @@ -122,16 +124,16 @@ object DMSConverter {

fun latitudeAsDD(latitude: Double): String {
return if (latitude > 0)
"${MathExtensions.round(latitude, 3)}°"
"${MathExtensions.round(latitude, DD_DDDDDD_PLACES)}°"
else
"${MathExtensions.round(latitude, 3)}°"
"${MathExtensions.round(latitude, DD_DDDDDD_PLACES)}°"
}

fun longitudeAsDD(longitude: Double): String {
return if (longitude > 0)
"${MathExtensions.round(longitude, 3)}°"
"${MathExtensions.round(longitude, DD_DDDDDD_PLACES)}°"
else
"${MathExtensions.round(longitude, 3)}°"
"${MathExtensions.round(longitude, DD_DDDDDD_PLACES)}°"
}

fun latitudeAsDM(lat: Double, context: Context): String {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/dialog_coordinates_format.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
android:layout_marginStart="@dimen/options_text_margin_start"
android:layout_weight="1"
android:fontFamily="@font/regular"
android:text="@string/dd_ddd"
android:text="@string/dd_dddddd"
android:textColor="@color/textPrimary"
android:textSize="@dimen/options_item_text_size" />

<app.simple.positional.decorations.views.CustomRadioButton
android:id="@+id/dd_ddd"
android:id="@+id/dd_dddddd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:buttonTint="@color/iconColor" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/non_translatable_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<string name="fused_location_provider" translatable="false">Fused Location Provider</string>
<string name="android_location_provider" translatable="false">Android Location Provider</string>
<string name="coordinates_format" translatable="false">%1$s | %2$s</string>
<string name="dd_ddd" translatable="false">DD.DDD°</string>
<string name="dd_dddddd" translatable="false">DD.DDDDDD°</string>
<string name="dd_mm_mmm" translatable="false">DD°MM.MMM</string>
<string name="dd_mm_ss_sss" translatable="false">DD°MM\'SS.SSS</string>
<string name="inure_app_manager" translatable="false">Inure App Manager</string>
Expand Down

0 comments on commit ce94576

Please sign in to comment.