From a0a95ce372872dd879e97c06b485448991695ff2 Mon Sep 17 00:00:00 2001 From: Arty Bishop Date: Tue, 18 May 2021 10:02:18 +0100 Subject: [PATCH] Reverted TLE source update screen, fixed location setting bug #53 #54 --- app/build.gradle | 4 +- .../look4sat/framework/PreferencesProvider.kt | 34 ++++++++ .../look4sat/injection/SatDataModule.kt | 5 +- .../appSettingsScreen/AppSettingsFragment.kt | 22 +++-- .../satItemScreen/SatItemFragment.kt | 13 ++- .../satItemScreen/SatItemViewModel.kt | 8 +- .../satPassScreen/SatPassViewModel.kt | 2 +- .../satSourcesScreen/SourcesAdapter.kt | 69 +++++++++++++++ .../satSourcesScreen/SourcesDialog.kt | 67 +++++++++++++++ .../satSourcesScreen/TleSource.kt | 20 +++++ .../rtbishop/look4sat/utility/Extensions.kt | 27 ++++++ .../res/drawable/ic_baseline_cached_24.xml | 9 -- .../main/res/drawable/ic_baseline_link_24.xml | 9 -- .../main/res/drawable/ic_baseline_sync_24.xml | 9 -- app/src/main/res/drawable/ic_check.xml | 9 -- app/src/main/res/drawable/ic_update_web.xml | 2 +- app/src/main/res/layout/dialog_sources.xml | 83 +++++++++++++++++++ app/src/main/res/layout/fragment_entries.xml | 14 +--- app/src/main/res/layout/item_tle_source.xml | 31 +++++++ app/src/main/res/navigation/nav_graph.xml | 11 +++ app/src/main/res/values-ru/strings.xml | 5 +- app/src/main/res/values/strings.xml | 5 +- .../look4sat/data/PreferencesSource.kt | 6 ++ .../look4sat/data/SatDataRepository.kt | 8 +- .../metadata/android/en-US/changelogs/251.txt | 7 ++ .../android/en-US/whatsnew/whatsnew-en-US | 3 +- 26 files changed, 404 insertions(+), 78 deletions(-) create mode 100644 app/src/main/java/com/rtbishop/look4sat/presentation/satSourcesScreen/SourcesAdapter.kt create mode 100644 app/src/main/java/com/rtbishop/look4sat/presentation/satSourcesScreen/SourcesDialog.kt create mode 100644 app/src/main/java/com/rtbishop/look4sat/presentation/satSourcesScreen/TleSource.kt delete mode 100644 app/src/main/res/drawable/ic_baseline_cached_24.xml delete mode 100644 app/src/main/res/drawable/ic_baseline_link_24.xml delete mode 100644 app/src/main/res/drawable/ic_baseline_sync_24.xml delete mode 100644 app/src/main/res/drawable/ic_check.xml create mode 100644 app/src/main/res/layout/dialog_sources.xml create mode 100644 app/src/main/res/layout/item_tle_source.xml create mode 100644 fastlane/metadata/android/en-US/changelogs/251.txt diff --git a/app/build.gradle b/app/build.gradle index 3129ee7c..2d65f8fd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { applicationId "com.rtbishop.look4sat" minSdkVersion 21 targetSdkVersion 30 - versionCode 250 - versionName "2.5.0" + versionCode 251 + versionName "2.5.1" } buildTypes { diff --git a/app/src/main/java/com/rtbishop/look4sat/framework/PreferencesProvider.kt b/app/src/main/java/com/rtbishop/look4sat/framework/PreferencesProvider.kt index 70d20e55..2fde6483 100644 --- a/app/src/main/java/com/rtbishop/look4sat/framework/PreferencesProvider.kt +++ b/app/src/main/java/com/rtbishop/look4sat/framework/PreferencesProvider.kt @@ -25,15 +25,49 @@ import com.rtbishop.look4sat.data.PreferencesSource import com.rtbishop.look4sat.domain.predict4kotlin.QthConverter import com.rtbishop.look4sat.domain.predict4kotlin.StationPosition import com.rtbishop.look4sat.utility.round +import com.squareup.moshi.Moshi +import com.squareup.moshi.Types import javax.inject.Inject class PreferencesProvider @Inject constructor( + moshi: Moshi, private val qthConverter: QthConverter, private val locationManager: LocationManager, private val preferences: SharedPreferences ) : PreferencesSource { + private val sourcesType = Types.newParameterizedType(List::class.java, String::class.java) + private val sourcesAdapter = moshi.adapter>(sourcesType) + + override fun loadTleSources(): List { + return try { + val sourcesString = preferences.getString(keySources, String()) + if (sourcesString.isNullOrEmpty()) { + loadDefaultSources() + } else { + sourcesAdapter.fromJson(sourcesString) ?: loadDefaultSources() + } + } catch (exception: ClassCastException) { + loadDefaultSources() + } + } + + override fun saveTleSources(sources: List) { + val sourcesJson = sourcesAdapter.toJson(sources) + preferences.edit { putString(keySources, sourcesJson) } + } + + override fun loadDefaultSources(): List { + return listOf( + "https://celestrak.com/NORAD/elements/active.txt", + "https://amsat.org/tle/current/nasabare.txt", + "https://www.prismnet.com/~mmccants/tles/classfd.zip", + "https://www.prismnet.com/~mmccants/tles/inttles.zip" + ) + } + companion object { + const val keySources = "sourcesListJson" const val keyModes = "satModes" const val keyCompass = "compass" const val keyTextLabels = "shouldUseTextLabels" diff --git a/app/src/main/java/com/rtbishop/look4sat/injection/SatDataModule.kt b/app/src/main/java/com/rtbishop/look4sat/injection/SatDataModule.kt index fe9beb6e..30180a0b 100644 --- a/app/src/main/java/com/rtbishop/look4sat/injection/SatDataModule.kt +++ b/app/src/main/java/com/rtbishop/look4sat/injection/SatDataModule.kt @@ -27,9 +27,9 @@ import com.rtbishop.look4sat.framework.PreferencesProvider import com.rtbishop.look4sat.framework.api.SatDataRemote import com.rtbishop.look4sat.framework.api.SatDataService import com.rtbishop.look4sat.framework.db.RoomConverters -import com.rtbishop.look4sat.framework.db.SatDataLocal import com.rtbishop.look4sat.framework.db.SatDataDao import com.rtbishop.look4sat.framework.db.SatDataDb +import com.rtbishop.look4sat.framework.db.SatDataLocal import com.squareup.moshi.Moshi import dagger.Module import dagger.Provides @@ -58,11 +58,12 @@ object SatDataModule { @Provides @Singleton fun providePreferenceSource( + moshi: Moshi, qthConverter: QthConverter, locationManager: LocationManager, preferences: SharedPreferences ): PreferencesSource { - return PreferencesProvider(qthConverter, locationManager, preferences) + return PreferencesProvider(moshi, qthConverter, locationManager, preferences) } @Provides diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/appSettingsScreen/AppSettingsFragment.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/appSettingsScreen/AppSettingsFragment.kt index 2f3ce3cf..db9571dc 100644 --- a/app/src/main/java/com/rtbishop/look4sat/presentation/appSettingsScreen/AppSettingsFragment.kt +++ b/app/src/main/java/com/rtbishop/look4sat/presentation/appSettingsScreen/AppSettingsFragment.kt @@ -28,10 +28,10 @@ import androidx.core.content.ContextCompat import androidx.preference.EditTextPreference import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat +import com.google.android.material.snackbar.Snackbar import com.rtbishop.look4sat.R import com.rtbishop.look4sat.data.PreferencesSource import com.rtbishop.look4sat.framework.PreferencesProvider -import com.rtbishop.look4sat.utility.showSnack import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject @@ -46,7 +46,7 @@ class AppSettingsFragment : PreferenceFragmentCompat() { if (isGranted) { updatePositionFromGPS() } else { - requireView().showSnack(getString(R.string.pref_pos_gps_error)) + showSnack(getString(R.string.pref_pos_gps_error)) } } @@ -75,7 +75,7 @@ class AppSettingsFragment : PreferenceFragmentCompat() { if (Patterns.IP_ADDRESS.matcher(newValue.toString()).matches()) { return@setOnPreferenceChangeListener true } else { - requireView().showSnack(getString(R.string.tracking_rotator_address_invalid)) + showSnack(getString(R.string.tracking_rotator_address_invalid)) return@setOnPreferenceChangeListener false } } @@ -88,7 +88,7 @@ class AppSettingsFragment : PreferenceFragmentCompat() { if (portValue.isNotEmpty() && portValue.toInt() in 1024..65535) { return@setOnPreferenceChangeListener true } else { - requireView().showSnack(getString(R.string.tracking_rotator_port_invalid)) + showSnack(getString(R.string.tracking_rotator_port_invalid)) return@setOnPreferenceChangeListener false } } @@ -97,10 +97,10 @@ class AppSettingsFragment : PreferenceFragmentCompat() { private fun updatePositionFromQth(qthString: String): Boolean { return if (preferencesSource.updatePositionFromQTH(qthString)) { - requireView().showSnack(getString(R.string.pref_pos_success)) + showSnack(getString(R.string.pref_pos_success)) true } else { - requireView().showSnack(getString(R.string.pref_pos_qth_error)) + showSnack(getString(R.string.pref_pos_qth_error)) false } } @@ -110,10 +110,16 @@ class AppSettingsFragment : PreferenceFragmentCompat() { val locPermResult = ContextCompat.checkSelfPermission(requireContext(), locPermString) if (locPermResult == PackageManager.PERMISSION_GRANTED) { if (preferencesSource.updatePositionFromGPS()) { - requireView().showSnack(getString(R.string.pref_pos_success)) + showSnack(getString(R.string.pref_pos_success)) } else { - requireView().showSnack(getString(R.string.pref_pos_gps_null)) + showSnack(getString(R.string.pref_pos_gps_null)) } } else requestPermissionLauncher.launch(locPermString) } + + private fun showSnack(message: String) { + Snackbar.make(requireView(), message, Snackbar.LENGTH_SHORT).apply { + setAnchorView(R.id.nav_bottom) + }.show() + } } diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/satItemScreen/SatItemFragment.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/satItemScreen/SatItemFragment.kt index 44435893..9dece856 100644 --- a/app/src/main/java/com/rtbishop/look4sat/presentation/satItemScreen/SatItemFragment.kt +++ b/app/src/main/java/com/rtbishop/look4sat/presentation/satItemScreen/SatItemFragment.kt @@ -24,6 +24,7 @@ import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AlertDialog import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels +import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.SimpleItemAnimator import com.google.android.material.dialog.MaterialAlertDialogBuilder @@ -33,6 +34,8 @@ import com.rtbishop.look4sat.databinding.FragmentEntriesBinding import com.rtbishop.look4sat.domain.model.SatItem import com.rtbishop.look4sat.framework.model.Result import com.rtbishop.look4sat.utility.RecyclerDivider +import com.rtbishop.look4sat.utility.getNavResult +import com.rtbishop.look4sat.utility.navigateSafe import com.rtbishop.look4sat.utility.showSnack import dagger.hilt.android.AndroidEntryPoint @@ -62,8 +65,11 @@ class SatItemFragment : Fragment(R.layout.fragment_entries) { (itemAnimator as SimpleItemAnimator).supportsChangeAnimations = false addItemDecoration(RecyclerDivider(R.drawable.rec_divider_light)) } - importWeb.setOnClickListener { viewModel.updateEntriesFromWeb(null) } - importSource.setOnClickListener { showSourceDialog() } + importWeb.setOnClickListener { +// viewModel.updateEntriesFromWeb(null) + findNavController().navigateSafe(R.id.action_entries_to_sources) + } +// importSource.setOnClickListener { showSourceDialog() } importFile.setOnClickListener { filePicker.launch("*/*") } selectMode.setOnClickListener { showModesDialog() } selectAll.setOnClickListener { viewModel.selectCurrentItems() } @@ -72,6 +78,9 @@ class SatItemFragment : Fragment(R.layout.fragment_entries) { viewModel.satData.observe(viewLifecycleOwner, { satData -> handleSatData(satData, binding, entriesAdapter) }) + getNavResult>(R.id.nav_entries, "sources") { sources -> + viewModel.updateEntriesFromWeb(sources) + } } private fun handleSatData( diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/satItemScreen/SatItemViewModel.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/satItemScreen/SatItemViewModel.kt index 85744139..b0c15a57 100644 --- a/app/src/main/java/com/rtbishop/look4sat/presentation/satItemScreen/SatItemViewModel.kt +++ b/app/src/main/java/com/rtbishop/look4sat/presentation/satItemScreen/SatItemViewModel.kt @@ -21,6 +21,7 @@ import android.content.ContentResolver import android.net.Uri import android.widget.SearchView import androidx.lifecycle.* +import com.rtbishop.look4sat.data.PreferencesSource import com.rtbishop.look4sat.data.SatDataRepository import com.rtbishop.look4sat.domain.model.SatItem import com.rtbishop.look4sat.framework.model.Result @@ -32,6 +33,7 @@ import javax.inject.Inject @HiltViewModel class SatItemViewModel @Inject constructor( + private val preferencesSource: PreferencesSource, private val resolver: ContentResolver, private val satDataRepository: SatDataRepository, ) : ViewModel(), SatItemAdapter.EntriesClickListener, SearchView.OnQueryTextListener { @@ -61,12 +63,12 @@ class SatItemViewModel @Inject constructor( } } - fun updateEntriesFromWeb(sources: List?) { + fun updateEntriesFromWeb(sources: List) { viewModelScope.launch { _satData.value = Result.InProgress runCatching { - if (sources == null) satDataRepository.updateEntriesFromWeb() - else satDataRepository.updateEntriesFromWeb(sources) + preferencesSource.saveTleSources(sources) + satDataRepository.updateEntriesFromWeb(sources) }.onFailure { _satData.value = Result.Error(it) } } } diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/satPassScreen/SatPassViewModel.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/satPassScreen/SatPassViewModel.kt index a6376024..836cfd74 100644 --- a/app/src/main/java/com/rtbishop/look4sat/presentation/satPassScreen/SatPassViewModel.kt +++ b/app/src/main/java/com/rtbishop/look4sat/presentation/satPassScreen/SatPassViewModel.kt @@ -65,8 +65,8 @@ class SatPassViewModel @Inject constructor( preferencesSource.updatePositionFromGPS() viewModelScope.launch { _passes.postValue(Result.InProgress) - satDataRepository.updateEntriesFromWeb() val defaultCatNums = listOf(43700, 25544, 25338, 28654, 33591, 40069, 27607, 24278) + satDataRepository.updateEntriesFromWeb(preferencesSource.loadDefaultSources()) satDataRepository.updateEntriesSelection(defaultCatNums, true) satPassRepository.forceCalculation(satDataRepository.getSelectedSatellites()) preferencesSource.setSetupDone() diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/satSourcesScreen/SourcesAdapter.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/satSourcesScreen/SourcesAdapter.kt new file mode 100644 index 00000000..10bd3f5f --- /dev/null +++ b/app/src/main/java/com/rtbishop/look4sat/presentation/satSourcesScreen/SourcesAdapter.kt @@ -0,0 +1,69 @@ +/* + * Look4Sat. Amateur radio satellite tracker and pass predictor. + * Copyright (C) 2019-2021 Arty Bishop (bishop.arty@gmail.com) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.rtbishop.look4sat.presentation.satSourcesScreen + +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.core.widget.doOnTextChanged +import androidx.recyclerview.widget.RecyclerView +import com.rtbishop.look4sat.databinding.ItemTleSourceBinding + +class SourcesAdapter(private val sources: MutableList = mutableListOf()) : + RecyclerView.Adapter() { + + fun getSources(): List { + return sources.filter { it.url.contains("https://") } + } + + fun setSources(list: List) { + sources.clear() + sources.addAll(list) + } + + fun addSource() { + sources.add(TleSource()) + notifyItemInserted(itemCount - 1) + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TleSourceHolder { + val binding = ItemTleSourceBinding + .inflate(LayoutInflater.from(parent.context), parent, false) + return TleSourceHolder(binding) + } + + override fun onBindViewHolder(holder: TleSourceHolder, position: Int) { + holder.bind(sources[position]) + } + + override fun getItemCount(): Int { + return sources.size + } + + inner class TleSourceHolder(private val binding: ItemTleSourceBinding) : + RecyclerView.ViewHolder(binding.root) { + + fun bind(source: TleSource) { + binding.tleSourceUrl.setText(source.url) + binding.tleSourceUrl.doOnTextChanged { text, _, _, _ -> source.url = text.toString() } + binding.tleSourceInputLayout.setEndIconOnClickListener { + sources.remove(source) + notifyItemRemoved(adapterPosition) + } + } + } +} diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/satSourcesScreen/SourcesDialog.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/satSourcesScreen/SourcesDialog.kt new file mode 100644 index 00000000..0d9a0a3c --- /dev/null +++ b/app/src/main/java/com/rtbishop/look4sat/presentation/satSourcesScreen/SourcesDialog.kt @@ -0,0 +1,67 @@ +/* + * Look4Sat. Amateur radio satellite tracker and pass predictor. + * Copyright (C) 2019-2021 Arty Bishop (bishop.arty@gmail.com) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.rtbishop.look4sat.presentation.satSourcesScreen + +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 androidx.recyclerview.widget.LinearLayoutManager +import com.rtbishop.look4sat.R +import com.rtbishop.look4sat.data.PreferencesSource +import com.rtbishop.look4sat.databinding.DialogSourcesBinding +import com.rtbishop.look4sat.utility.setNavResult +import dagger.hilt.android.AndroidEntryPoint +import javax.inject.Inject + +@AndroidEntryPoint +class SourcesDialog : AppCompatDialogFragment() { + + @Inject + lateinit var prefsManager: PreferencesSource + + override fun onCreateView(inflater: LayoutInflater, group: ViewGroup?, state: Bundle?): View? { + return inflater.inflate(R.layout.dialog_sources, group, false) + } + + override fun onViewCreated(view: View, state: Bundle?) { + super.onViewCreated(view, state) + val sources = prefsManager.loadTleSources().map { TleSource(it) } + val sourcesAdapter = SourcesAdapter().apply { setSources(sources) } + DialogSourcesBinding.bind(view).apply { + dialog?.window?.setLayout( + WindowManager.LayoutParams.MATCH_PARENT, + WindowManager.LayoutParams.WRAP_CONTENT + ) + sourcesRecycler.apply { + adapter = sourcesAdapter + layoutManager = LinearLayoutManager(requireContext()) + } + sourceBtnAdd.setOnClickListener { + sourcesAdapter.addSource() + } + sourcesBtnPos.setOnClickListener { + setNavResult("sources", sourcesAdapter.getSources().map { it.url }) + dismiss() + } + sourcesBtnNeg.setOnClickListener { dismiss() } + } + } +} diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/satSourcesScreen/TleSource.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/satSourcesScreen/TleSource.kt new file mode 100644 index 00000000..339f16d7 --- /dev/null +++ b/app/src/main/java/com/rtbishop/look4sat/presentation/satSourcesScreen/TleSource.kt @@ -0,0 +1,20 @@ +/* + * Look4Sat. Amateur radio satellite tracker and pass predictor. + * Copyright (C) 2019-2021 Arty Bishop (bishop.arty@gmail.com) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.rtbishop.look4sat.presentation.satSourcesScreen + +class TleSource(var url: String = String()) diff --git a/app/src/main/java/com/rtbishop/look4sat/utility/Extensions.kt b/app/src/main/java/com/rtbishop/look4sat/utility/Extensions.kt index e66e67c8..4e0bd5ad 100644 --- a/app/src/main/java/com/rtbishop/look4sat/utility/Extensions.kt +++ b/app/src/main/java/com/rtbishop/look4sat/utility/Extensions.kt @@ -20,9 +20,13 @@ package com.rtbishop.look4sat.utility import android.os.Bundle import android.view.View import androidx.annotation.IdRes +import androidx.fragment.app.Fragment +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleEventObserver import androidx.navigation.NavController import androidx.navigation.NavOptions import androidx.navigation.Navigator +import androidx.navigation.fragment.findNavController import com.google.android.material.snackbar.Snackbar import com.rtbishop.look4sat.R import java.util.concurrent.TimeUnit @@ -58,3 +62,26 @@ fun NavController.navigateSafe( navigate(resId, args, navOptions, navExtras) } } + +fun Fragment.setNavResult(key: String, value: T) { + findNavController().previousBackStackEntry?.savedStateHandle?.set(key, value) +} + +fun Fragment.getNavResult(@IdRes id: Int, key: String, onResult: (result: T) -> Unit) { + val navBackStackEntry = findNavController().getBackStackEntry(id) + val observer = LifecycleEventObserver { _, event -> + if (event == Lifecycle.Event.ON_RESUME + && navBackStackEntry.savedStateHandle.contains(key) + ) { + val result = navBackStackEntry.savedStateHandle.get(key) + result?.let(onResult) + navBackStackEntry.savedStateHandle.remove(key) + } + } + navBackStackEntry.lifecycle.addObserver(observer) + viewLifecycleOwner.lifecycle.addObserver(LifecycleEventObserver { _, event -> + if (event == Lifecycle.Event.ON_DESTROY) { + navBackStackEntry.lifecycle.removeObserver(observer) + } + }) +} diff --git a/app/src/main/res/drawable/ic_baseline_cached_24.xml b/app/src/main/res/drawable/ic_baseline_cached_24.xml deleted file mode 100644 index a96341a9..00000000 --- a/app/src/main/res/drawable/ic_baseline_cached_24.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_baseline_link_24.xml b/app/src/main/res/drawable/ic_baseline_link_24.xml deleted file mode 100644 index 1b02e601..00000000 --- a/app/src/main/res/drawable/ic_baseline_link_24.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_baseline_sync_24.xml b/app/src/main/res/drawable/ic_baseline_sync_24.xml deleted file mode 100644 index 07125691..00000000 --- a/app/src/main/res/drawable/ic_baseline_sync_24.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_check.xml b/app/src/main/res/drawable/ic_check.xml deleted file mode 100644 index c0b2060a..00000000 --- a/app/src/main/res/drawable/ic_check.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_update_web.xml b/app/src/main/res/drawable/ic_update_web.xml index 09972f82..a96341a9 100644 --- a/app/src/main/res/drawable/ic_update_web.xml +++ b/app/src/main/res/drawable/ic_update_web.xml @@ -5,5 +5,5 @@ android:viewportHeight="24"> + android:pathData="M19,8l-4,4h3c0,3.31 -2.69,6 -6,6 -1.01,0 -1.97,-0.25 -2.8,-0.7l-1.46,1.46C8.97,19.54 10.43,20 12,20c4.42,0 8,-3.58 8,-8h3l-4,-4zM6,12c0,-3.31 2.69,-6 6,-6 1.01,0 1.97,0.25 2.8,0.7l1.46,-1.46C15.03,4.46 13.57,4 12,4c-4.42,0 -8,3.58 -8,8H1l4,4 4,-4H6z" /> diff --git a/app/src/main/res/layout/dialog_sources.xml b/app/src/main/res/layout/dialog_sources.xml new file mode 100644 index 00000000..fa07f49b --- /dev/null +++ b/app/src/main/res/layout/dialog_sources.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_entries.xml b/app/src/main/res/layout/fragment_entries.xml index 90883910..a3abb5d6 100644 --- a/app/src/main/res/layout/fragment_entries.xml +++ b/app/src/main/res/layout/fragment_entries.xml @@ -30,19 +30,7 @@ android:backgroundTint="@color/greyDark" android:contentDescription="@string/placeholder" android:elevation="4dp" - android:src="@drawable/ic_baseline_cached_24" - app:layout_constraintBottom_toBottomOf="@+id/import_file" - app:layout_constraintEnd_toStartOf="@+id/import_source" - app:layout_constraintTop_toTopOf="@+id/import_file" /> - - diff --git a/app/src/main/res/layout/item_tle_source.xml b/app/src/main/res/layout/item_tle_source.xml new file mode 100644 index 00000000..1a58481f --- /dev/null +++ b/app/src/main/res/layout/item_tle_source.xml @@ -0,0 +1,31 @@ + + + + + + + + + diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 296e46b8..3a2c1fa4 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -16,6 +16,13 @@ app:exitAnim="@anim/nav_default_exit_anim" app:popEnterAnim="@anim/nav_default_pop_enter_anim" app:popExitAnim="@anim/nav_default_pop_exit_anim" /> + + diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 05ec7edd..cbe29640 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -2,6 +2,8 @@ Да Нет + Отмена + Обновить Спутники Пролеты @@ -9,8 +11,9 @@ Настройки Инфо - Введите HTTPS адрес источника + Управление TLE URL источника + Только протокол HTTPS Пожалуйста, проверьте URL Обновить спутники: diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3ffe0d5e..2ea65b8d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,6 +5,8 @@ No Yes + Cancel + Update Satellites Passes @@ -12,8 +14,9 @@ Settings Info - Enter HTTPS source address + Manage TLE sources Source URL + Protocol HTTPS only Please check the entered URL TLE data update: diff --git a/core/src/main/java/com/rtbishop/look4sat/data/PreferencesSource.kt b/core/src/main/java/com/rtbishop/look4sat/data/PreferencesSource.kt index 757ae301..8e3bcbe6 100644 --- a/core/src/main/java/com/rtbishop/look4sat/data/PreferencesSource.kt +++ b/core/src/main/java/com/rtbishop/look4sat/data/PreferencesSource.kt @@ -52,4 +52,10 @@ interface PreferencesSource { fun loadModesSelection(): List fun getRotatorServer(): Pair? + + fun loadTleSources(): List + + fun saveTleSources(sources: List) + + fun loadDefaultSources(): List } diff --git a/core/src/main/java/com/rtbishop/look4sat/data/SatDataRepository.kt b/core/src/main/java/com/rtbishop/look4sat/data/SatDataRepository.kt index cf33d179..49105290 100644 --- a/core/src/main/java/com/rtbishop/look4sat/data/SatDataRepository.kt +++ b/core/src/main/java/com/rtbishop/look4sat/data/SatDataRepository.kt @@ -35,12 +35,6 @@ class SatDataRepository( private val satRemoteSource: SatDataRemoteSource, private val ioDispatcher: CoroutineDispatcher ) { - private val defaultSources = listOf( - "https://celestrak.com/NORAD/elements/active.txt", - "https://amsat.org/tle/current/nasabare.txt", - "https://www.prismnet.com/~mmccants/tles/classfd.zip", - "https://www.prismnet.com/~mmccants/tles/inttles.zip" - ) fun saveSelectedModes(modes: List) { preferencesSource.saveModesSelection(modes) @@ -66,7 +60,7 @@ class SatDataRepository( satLocalSource.updateEntries(importSatEntries(stream)) } - suspend fun updateEntriesFromWeb(sources: List = defaultSources) { + suspend fun updateEntriesFromWeb(sources: List) { coroutineScope { launch(ioDispatcher) { val streams = mutableListOf() diff --git a/fastlane/metadata/android/en-US/changelogs/251.txt b/fastlane/metadata/android/en-US/changelogs/251.txt new file mode 100644 index 00000000..750e0d86 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/251.txt @@ -0,0 +1,7 @@ +Added immediate initial setup +Added pass direction arrow to radar view #52 +Added orientation pointer to radar view +Fixed radar view update bug #51 +Fixed tle update issue #53 +Fixed location update bug #54 +Switched to modular architecture \ No newline at end of file diff --git a/fastlane/metadata/android/en-US/whatsnew/whatsnew-en-US b/fastlane/metadata/android/en-US/whatsnew/whatsnew-en-US index e95c9fbe..750e0d86 100644 --- a/fastlane/metadata/android/en-US/whatsnew/whatsnew-en-US +++ b/fastlane/metadata/android/en-US/whatsnew/whatsnew-en-US @@ -1,6 +1,7 @@ -Added simple custom source TLE update dialog Added immediate initial setup Added pass direction arrow to radar view #52 Added orientation pointer to radar view Fixed radar view update bug #51 +Fixed tle update issue #53 +Fixed location update bug #54 Switched to modular architecture \ No newline at end of file