kopia lustrzana https://github.com/rt-bishop/Look4Sat
rodzic
378c3ac4bf
commit
9529f74c48
|
@ -8,20 +8,17 @@ plugins {
|
|||
|
||||
android {
|
||||
compileSdkVersion 31
|
||||
buildToolsVersion "31.0.0"
|
||||
buildToolsVersion '31.0.0'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.rtbishop.look4sat"
|
||||
minSdk 21
|
||||
targetSdk 31
|
||||
versionCode 303
|
||||
versionName "3.0.3"
|
||||
resConfigs "en,ru"
|
||||
versionCode 310
|
||||
versionName '3.1.0'
|
||||
resConfigs 'en,ru,zh_CN'
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
useSupportLibrary true
|
||||
}
|
||||
|
||||
kapt {
|
||||
arguments {
|
||||
|
@ -42,7 +39,7 @@ android {
|
|||
}
|
||||
}
|
||||
buildFeatures {
|
||||
compose true
|
||||
// compose true
|
||||
viewBinding true
|
||||
}
|
||||
composeOptions {
|
||||
|
@ -85,16 +82,16 @@ dependencies {
|
|||
kapt "com.google.dagger:hilt-compiler:$hilt_version"
|
||||
implementation "org.osmdroid:osmdroid-android:$osmdroid_version"
|
||||
|
||||
implementation "androidx.compose.ui:ui:$compose_version"
|
||||
implementation "androidx.compose.ui:ui-tooling:$compose_version"
|
||||
implementation "androidx.compose.animation:animation:$compose_version"
|
||||
implementation "androidx.compose.foundation:foundation:$compose_version"
|
||||
implementation "androidx.activity:activity-compose:$activity_compose_version"
|
||||
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
|
||||
implementation "androidx.compose.material:material:$compose_version"
|
||||
implementation "androidx.compose.material:material-icons-extended:$compose_version"
|
||||
implementation "com.google.android.material:compose-theme-adapter:$material_adapter_version"
|
||||
// implementation "androidx.compose.ui:ui:$compose_version"
|
||||
// implementation "androidx.compose.ui:ui-tooling:$compose_version"
|
||||
// implementation "androidx.compose.animation:animation:$compose_version"
|
||||
// implementation "androidx.compose.foundation:foundation:$compose_version"
|
||||
// implementation "androidx.activity:activity-compose:$activity_compose_version"
|
||||
// implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
|
||||
// implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
|
||||
// implementation "androidx.compose.material:material:$compose_version"
|
||||
// implementation "androidx.compose.material:material-icons-extended:$compose_version"
|
||||
// implementation "com.google.android.material:compose-theme-adapter:$material_adapter_version"
|
||||
|
||||
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
|
||||
debugImplementation "androidx.fragment:fragment-testing:$fragment_test_version"
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH"
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission
|
||||
android:name="android.permission.BLUETOOTH"
|
||||
android:maxSdkVersion="30" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
|
|
@ -134,5 +134,6 @@ class LocationManager @Inject constructor(
|
|||
|
||||
override fun onProviderDisabled(provider: String) {}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) {}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import javax.inject.Singleton
|
|||
class SettingsManager @Inject constructor(private val prefs: SharedPreferences) : ISettingsManager {
|
||||
|
||||
companion object {
|
||||
const val keyFirstEverLaunch = "isFirstEverLaunch"
|
||||
const val keyDataSources = "dataSources"
|
||||
const val keyModes = "satModes"
|
||||
const val keyCompass = "compass"
|
||||
|
@ -48,6 +49,14 @@ class SettingsManager @Inject constructor(private val prefs: SharedPreferences)
|
|||
const val keySelection = "selection"
|
||||
}
|
||||
|
||||
override fun isFirstEverLaunchDone(): Boolean {
|
||||
return prefs.getBoolean(keyFirstEverLaunch, false)
|
||||
}
|
||||
|
||||
override fun setFirstEverLaunchDone() {
|
||||
prefs.edit { putBoolean(keyFirstEverLaunch, true) }
|
||||
}
|
||||
|
||||
override fun loadStationLocator(): String {
|
||||
return prefs.getString(keyLocator, null) ?: "null"
|
||||
}
|
||||
|
@ -177,6 +186,7 @@ class SettingsManager @Inject constructor(private val prefs: SharedPreferences)
|
|||
override fun setBTDeviceAddr(value: String) {
|
||||
prefs.edit { putString(keyBTDeviceAddr, value) }
|
||||
}
|
||||
|
||||
override fun getBTDeviceName(): String {
|
||||
return prefs.getString(keyBTDeviceName, null) ?: "Default"
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@ package com.rtbishop.look4sat.presentation.entriesScreen
|
|||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.AdapterView
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
|
@ -69,29 +68,10 @@ class EntriesFragment : Fragment(R.layout.fragment_entries) {
|
|||
}
|
||||
entriesBtnSelect.clickWithDebounce { viewModel.selectCurrentItems(true) }
|
||||
entriesBtnClear.clickWithDebounce { viewModel.selectCurrentItems(false) }
|
||||
|
||||
val spinnerListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(
|
||||
parent: AdapterView<*>, view: View?,
|
||||
position: Int, id: Long
|
||||
) {
|
||||
viewModel.setSatType(parent.getItemAtPosition(position).toString())
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>) {
|
||||
viewModel.setSatType(String())
|
||||
}
|
||||
}
|
||||
ArrayAdapter(
|
||||
requireContext(),
|
||||
android.R.layout.simple_spinner_item,
|
||||
viewModel.satTypes
|
||||
).also { adapter ->
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
entriesSpinner.onItemSelectedListener = spinnerListener
|
||||
entriesSpinner.adapter = adapter
|
||||
}
|
||||
|
||||
val typeMessageFormat = requireContext().getString(R.string.types_message)
|
||||
val type = if (viewModel.getSatType().isNullOrBlank()) "All" else viewModel.getSatType()
|
||||
entriesTypeMessage.text = String.format(typeMessageFormat, type)
|
||||
entriesTypeCard.setOnClickListener { showSelectTypeDialog() }
|
||||
}
|
||||
viewModel.satData.observe(viewLifecycleOwner) { satData ->
|
||||
handleSatData(satData, entriesAdapter)
|
||||
|
@ -117,4 +97,21 @@ class EntriesFragment : Fragment(R.layout.fragment_entries) {
|
|||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showSelectTypeDialog() {
|
||||
val satelliteTypes = viewModel.satTypes.toTypedArray()
|
||||
val selectedValue = satelliteTypes.indexOf(viewModel.getSatType())
|
||||
val typeFormat = requireContext().getString(R.string.types_message)
|
||||
AlertDialog.Builder(requireContext()).apply {
|
||||
setTitle(R.string.types_title)
|
||||
setSingleChoiceItems(satelliteTypes, selectedValue) { dialog, index ->
|
||||
val selectedItem = satelliteTypes[index]
|
||||
binding.entriesTypeMessage.text = String.format(typeFormat, selectedItem)
|
||||
viewModel.setSatType(selectedItem)
|
||||
dialog.dismiss()
|
||||
}
|
||||
create()
|
||||
show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,8 @@ class EntriesViewModel @Inject constructor(
|
|||
val satData = itemsWithQuery.map { items -> DataState.Success(items) }
|
||||
val satTypes: List<String> = settings.sourcesMap.keys.sorted()
|
||||
|
||||
fun getSatType(): String? = satType.value
|
||||
|
||||
fun setSatType(type: String) {
|
||||
satType.value = type
|
||||
}
|
||||
|
@ -93,6 +95,7 @@ class EntriesViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun filterByType(items: List<SatItem>, type: String): List<SatItem> {
|
||||
if (type == "All") return items
|
||||
val catnums = settings.loadSatType(type)
|
||||
if (catnums.isEmpty()) return items
|
||||
return items.filter { item -> item.catnum in catnums }
|
||||
|
|
|
@ -42,7 +42,6 @@ class PassesFragment : Fragment(R.layout.fragment_passes), PassesAdapter.PassesC
|
|||
private val viewModel: PassesViewModel by viewModels()
|
||||
private val passesAdapter = PassesAdapter(this)
|
||||
private var binding: FragmentPassesBinding? = null
|
||||
// private var refreshAnimator: ValueAnimator? = null
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
@ -74,7 +73,6 @@ class PassesFragment : Fragment(R.layout.fragment_passes), PassesAdapter.PassesC
|
|||
val dir = PassesFragmentDirections.globalToSettings()
|
||||
findNavController().navigate(dir)
|
||||
}
|
||||
// setupAnimator()
|
||||
setupObservers()
|
||||
}
|
||||
}
|
||||
|
@ -92,15 +90,6 @@ class PassesFragment : Fragment(R.layout.fragment_passes), PassesAdapter.PassesC
|
|||
super.onDestroyView()
|
||||
}
|
||||
|
||||
// private fun setupAnimator() {
|
||||
// refreshAnimator = ValueAnimator.ofFloat(0f, -360f).apply {
|
||||
// duration = 875
|
||||
// interpolator = LinearInterpolator()
|
||||
// repeatCount = ValueAnimator.INFINITE
|
||||
// addUpdateListener { binding?.passesBtnRefresh?.rotation = animatedValue as Float }
|
||||
// }
|
||||
// }
|
||||
|
||||
private fun setupObservers() {
|
||||
viewModel.entriesTotal.observe(viewLifecycleOwner) { number ->
|
||||
handleEntriesTotal(number)
|
||||
|
@ -147,8 +136,6 @@ class PassesFragment : Fragment(R.layout.fragment_passes), PassesAdapter.PassesC
|
|||
}
|
||||
}
|
||||
is DataState.Loading -> {
|
||||
// refreshAnimator?.start()
|
||||
// passesBtnRefresh.isEnabled = false
|
||||
passesEmpty.visibility = View.INVISIBLE
|
||||
passesProgress.visibility = View.VISIBLE
|
||||
passesTimer.text = 0L.toTimerString()
|
||||
|
@ -175,7 +162,6 @@ class PassesFragment : Fragment(R.layout.fragment_passes), PassesAdapter.PassesC
|
|||
passesTimer.text = 0L.toTimerString()
|
||||
}
|
||||
passesBtnRefresh.isEnabled = true
|
||||
// refreshAnimator?.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,12 @@ class PassesViewModel @Inject constructor(
|
|||
val entriesTotal: LiveData<Int> = repository.getEntriesTotal().asLiveData()
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
if (!settings.isFirstEverLaunchDone()) {
|
||||
repository.updateFromWebNew()
|
||||
settings.setFirstEverLaunchDone()
|
||||
}
|
||||
}
|
||||
viewModelScope.launch {
|
||||
satelliteManager.calculatedPasses.collect { passes ->
|
||||
passesProcessing?.cancelAndJoin()
|
||||
|
|
|
@ -38,20 +38,47 @@
|
|||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/entries_spinner"
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/entries_type_card"
|
||||
style="@style/SurfaceCard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_marginStart="@dimen/view_default_margin"
|
||||
android:layout_marginTop="60dp"
|
||||
android:layout_marginEnd="@dimen/view_default_margin" />
|
||||
android:layout_marginEnd="@dimen/view_default_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/entries_type_message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:paddingStart="14dp"
|
||||
android:paddingEnd="14dp"
|
||||
android:text="@string/types_title"
|
||||
android:textColor="@color/accent"
|
||||
android:textSize="@dimen/text_size_mediumLarge" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/entries_type_img"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:contentDescription="@string/types_title"
|
||||
android:paddingStart="14dp"
|
||||
android:paddingEnd="14dp"
|
||||
android:src="@drawable/ic_next"
|
||||
app:tint="@color/accent" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
style="@style/SurfaceCard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="@dimen/view_default_margin"
|
||||
android:layout_marginTop="98dp"
|
||||
android:layout_marginTop="108dp"
|
||||
android:layout_marginEnd="@dimen/view_default_margin"
|
||||
android:layout_marginBottom="@dimen/surface_margin_bot">
|
||||
|
||||
|
|
|
@ -55,6 +55,9 @@
|
|||
<string name="sources_title">Источники данных</string>
|
||||
<string name="sources_hint">Протокол HTTPS</string>
|
||||
|
||||
<string name="types_title">Выберите тип спутника</string>
|
||||
<string name="types_message">Выбран тип: %s</string>
|
||||
|
||||
<!--Fragments-->
|
||||
|
||||
<string name="entries_search_hint">Поиск по Имени / Id</string>
|
||||
|
|
|
@ -56,6 +56,9 @@
|
|||
<string name="sources_title">Manage data sources</string>
|
||||
<string name="sources_hint">HTTPS Source</string>
|
||||
|
||||
<string name="types_title">Select satellite type</string>
|
||||
<string name="types_message">Selected type: %s</string>
|
||||
|
||||
<!--Fragments-->
|
||||
|
||||
<string name="entries_search_hint">Search by Name / Id</string>
|
||||
|
|
|
@ -57,6 +57,10 @@ interface ISettingsManager {
|
|||
"X-Comm" to "https://celestrak.com/NORAD/elements/gp.php?GROUP=x-comm&FORMAT=csv"
|
||||
)
|
||||
|
||||
fun isFirstEverLaunchDone(): Boolean
|
||||
|
||||
fun setFirstEverLaunchDone()
|
||||
|
||||
fun loadStationLocator(): String
|
||||
|
||||
fun saveStationLocator(locator: String)
|
||||
|
|
22
build.gradle
22
build.gradle
|
@ -1,28 +1,28 @@
|
|||
buildscript {
|
||||
ext {
|
||||
hilt_version = '2.41'
|
||||
hilt_version = '2.42'
|
||||
safe_args_version = '2.4.1'
|
||||
application_version = '7.1.3'
|
||||
application_version = '7.2.1'
|
||||
library_version = '7.1.2'
|
||||
kotlin_android_version = '1.6.10'
|
||||
core_ktx_version = '1.7.0'
|
||||
core_splashscreen_version = '1.0.0-beta02'
|
||||
constraint_version = '2.1.3'
|
||||
core_ktx_version = '1.8.0'
|
||||
core_splashscreen_version = '1.0.0-rc01'
|
||||
constraint_version = '2.1.4'
|
||||
lifecycle_version = '2.4.1'
|
||||
navigation_version = '2.4.2'
|
||||
room_version = '2.4.2'
|
||||
material_version = '1.5.0'
|
||||
osmdroid_version = '6.1.11'
|
||||
material_version = '1.6.1'
|
||||
osmdroid_version = '6.1.13'
|
||||
json_version = '20220320'
|
||||
compose_version = '1.1.1'
|
||||
activity_compose_version = '1.4.0'
|
||||
material_adapter_version = '1.1.7'
|
||||
material_adapter_version = '1.1.10'
|
||||
fragment_test_version = '1.4.1'
|
||||
leakcanary_version = '2.9.1'
|
||||
junit_version = '4.13.2'
|
||||
mockito_version = '4.5.1'
|
||||
robolectric_version = '4.8'
|
||||
coroutines_test_version = '1.6.1-native-mt'
|
||||
mockito_version = '4.6.0'
|
||||
robolectric_version = '4.8.1'
|
||||
coroutines_test_version = '1.6.2'
|
||||
androidx_test_version = '1.4.0'
|
||||
androidx_junit_version = '1.1.3'
|
||||
espresso_version = '3.4.0'
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
Integrated AJohns bluetooth reporting function
|
||||
Ref - https://github.com/rt-bishop/Look4Sat/pull/87
|
||||
Integrated BA7LWN Simplified Chinese translation
|
||||
Ref - https://github.com/rt-bishop/Look4Sat/pull/92
|
||||
Added satellites sorting by their reported categories
|
||||
Removed custom sources dialog, use file import instead
|
|
@ -1,2 +1,6 @@
|
|||
Minor correcting release
|
||||
Fixed a crash in the map fragment
|
||||
Integrated AJohns bluetooth reporting function
|
||||
Ref - https://github.com/rt-bishop/Look4Sat/pull/87
|
||||
Integrated BA7LWN Simplified Chinese translation
|
||||
Ref - https://github.com/rt-bishop/Look4Sat/pull/92
|
||||
Added satellites sorting by their reported categories
|
||||
Removed custom sources dialog, use file import instead
|
Ładowanie…
Reference in New Issue