-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restored manual location input functionality #40
- Loading branch information
Showing
10 changed files
with
196 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
app/src/main/java/com/rtbishop/look4sat/presentation/settingsScreen/LocationDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.rtbishop.look4sat.presentation.settingsScreen | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.view.WindowManager | ||
import androidx.appcompat.app.AppCompatDialogFragment | ||
import com.rtbishop.look4sat.R | ||
import com.rtbishop.look4sat.databinding.DialogLocationBinding | ||
import com.rtbishop.look4sat.domain.ILocationHandler | ||
import com.rtbishop.look4sat.presentation.setNavResult | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import javax.inject.Inject | ||
|
||
@AndroidEntryPoint | ||
class LocationDialog : AppCompatDialogFragment() { | ||
|
||
@Inject | ||
lateinit var locationHandler: ILocationHandler | ||
|
||
override fun onCreateView(inflater: LayoutInflater, group: ViewGroup?, state: Bundle?): View? { | ||
return inflater.inflate(R.layout.dialog_location, group, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, state: Bundle?) { | ||
super.onViewCreated(view, state) | ||
DialogLocationBinding.bind(view).run { | ||
dialog?.window?.setBackgroundDrawableResource(R.color.transparent) | ||
dialog?.window?.setLayout( | ||
(resources.displayMetrics.widthPixels * 0.94).toInt(), | ||
WindowManager.LayoutParams.WRAP_CONTENT | ||
) | ||
val location = locationHandler.getStationPosition() | ||
locationLatEdit.setText(location.latitude.toString()) | ||
locationLonEdit.setText(location.longitude.toString()) | ||
locationPosBtn.setOnClickListener { | ||
val latitude = try { | ||
locationLatEdit.text.toString().toDouble() | ||
} catch (exception: Exception) { | ||
180.0 | ||
} | ||
val longitude = try { | ||
locationLonEdit.text.toString().toDouble() | ||
} catch (exception: Exception) { | ||
400.0 | ||
} | ||
setNavResult("location", Pair(latitude, longitude)) | ||
dismiss() | ||
} | ||
locationNegBtn.setOnClickListener { dismiss() } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
style="@style/SurfaceCard" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<TextView | ||
android:id="@+id/location_title" | ||
style="@style/DialogTitle" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="4dp" | ||
android:minHeight="48dp" | ||
android:text="@string/dialog_filter_passes" | ||
app:layout_constraintBottom_toTopOf="@+id/location_lat_layout" | ||
app:layout_constraintEnd_toEndOf="@+id/location_pos_btn" | ||
app:layout_constraintStart_toStartOf="@+id/location_neg_btn" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<com.google.android.material.textfield.TextInputLayout | ||
android:id="@+id/location_lat_layout" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="4dp" | ||
android:layout_marginEnd="4dp" | ||
android:hint="@string/pref_hours_ahead_hint" | ||
android:importantForAutofill="no" | ||
android:inputType="number" | ||
android:minHeight="48dp" | ||
app:endIconMode="clear_text" | ||
app:layout_constraintBottom_toTopOf="@+id/location_lon_layout" | ||
app:layout_constraintEnd_toEndOf="@+id/location_title" | ||
app:layout_constraintStart_toStartOf="@+id/location_title" | ||
app:layout_constraintTop_toBottomOf="@+id/location_title"> | ||
|
||
<com.google.android.material.textfield.TextInputEditText | ||
android:id="@+id/location_lat_edit" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:inputType="textUri" /> | ||
|
||
</com.google.android.material.textfield.TextInputLayout> | ||
|
||
<com.google.android.material.textfield.TextInputLayout | ||
android:id="@+id/location_lon_layout" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
android:hint="@string/pref_min_el_hint" | ||
android:importantForAutofill="no" | ||
android:inputType="number|numberDecimal" | ||
android:minHeight="48dp" | ||
app:endIconMode="clear_text" | ||
app:layout_constraintBottom_toTopOf="@+id/location_neg_btn" | ||
app:layout_constraintEnd_toEndOf="@+id/location_lat_layout" | ||
app:layout_constraintStart_toStartOf="@+id/location_lat_layout" | ||
app:layout_constraintTop_toBottomOf="@+id/location_lat_layout"> | ||
|
||
<com.google.android.material.textfield.TextInputEditText | ||
android:id="@+id/location_lon_edit" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:inputType="textUri" /> | ||
|
||
</com.google.android.material.textfield.TextInputLayout> | ||
|
||
<Button | ||
android:id="@+id/location_neg_btn" | ||
style="@style/NormalButton" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="12dp" | ||
android:layout_marginBottom="8dp" | ||
android:text="@string/btn_cancel" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toStartOf="@+id/location_pos_btn" | ||
app:layout_constraintHorizontal_bias="0.5" | ||
app:layout_constraintHorizontal_chainStyle="spread_inside" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/location_lon_layout" /> | ||
|
||
<Button | ||
android:id="@+id/location_pos_btn" | ||
style="@style/NormalButton" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="8dp" | ||
android:text="@string/btn_accept" | ||
app:layout_constraintBaseline_toBaselineOf="@+id/location_neg_btn" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.5" | ||
app:layout_constraintStart_toEndOf="@+id/location_neg_btn" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
</androidx.cardview.widget.CardView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters