mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-03 19:27:24 +00:00
Further refactoring and strings cleanup. Changed the look of a transmission recycler item.
This commit is contained in:
1 parent
96939794b5
commit
eee5c725fd
16 files changed
+204
-170
No files matched your search
@@ -117,7 +117,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
apply()
|
||||
}
|
||||
_gsp.postValue(GroundStationPosition(lat, lon, alt))
|
||||
_debugMessage.postValue(app.getString(R.string.updateLocSuccess))
|
||||
_debugMessage.postValue(app.getString(R.string.update_loc_success))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,9 +142,9 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
}
|
||||
tleMainList = tleList
|
||||
tleSelection = mutableListOf()
|
||||
_debugMessage.postValue(app.getString(R.string.updateTleSuccess))
|
||||
_debugMessage.postValue(app.getString(R.string.update_tle_success))
|
||||
} catch (exception: IOException) {
|
||||
_debugMessage.postValue(app.getString(R.string.updateTleFailure))
|
||||
_debugMessage.postValue(app.getString(R.string.update_failure))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,9 +153,9 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
repository.updateTransmittersDatabase()
|
||||
_debugMessage.postValue(app.getString(R.string.updateTransSuccess))
|
||||
_debugMessage.postValue(app.getString(R.string.update_trans_success))
|
||||
} catch (exception: IOException) {
|
||||
_debugMessage.postValue(app.getString(R.string.updateTransFailure))
|
||||
_debugMessage.postValue(app.getString(R.string.update_failure))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,18 +190,12 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
val predictor = PassPredictor(tle, gsp.value)
|
||||
val passes = predictor.getPasses(dateNow, hoursAhead, true)
|
||||
passes.forEach {
|
||||
passList.add(
|
||||
SatPass(
|
||||
tle,
|
||||
predictor,
|
||||
it
|
||||
)
|
||||
)
|
||||
passList.add(SatPass(tle, predictor, it))
|
||||
}
|
||||
} catch (exception: IllegalArgumentException) {
|
||||
_debugMessage.postValue(app.getString(R.string.error_sat_tle))
|
||||
_debugMessage.postValue(app.getString(R.string.err_parse_tle))
|
||||
} catch (exception: SatNotFoundException) {
|
||||
_debugMessage.postValue(app.getString(R.string.error_sat_wont_pass))
|
||||
_debugMessage.postValue(app.getString(R.string.err_sat_wont_pass))
|
||||
}
|
||||
}
|
||||
passList.removeAll { it.pass.startTime.after(dateFuture) }
|
||||
@@ -224,7 +218,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
val tleList = ObjectInputStream(tleStream).readObject()
|
||||
tleList as List<TLE>
|
||||
} catch (exception: FileNotFoundException) {
|
||||
_debugMessage.postValue(app.getString(R.string.no_tle_found))
|
||||
_debugMessage.postValue(app.getString(R.string.err_no_tle_file))
|
||||
emptyList()
|
||||
} catch (exception: IOException) {
|
||||
_debugMessage.postValue(exception.toString())
|
||||
@@ -235,7 +229,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
val selectionList = ObjectInputStream(selectionStream).readObject()
|
||||
selectionList as MutableList<Int>
|
||||
} catch (exception: FileNotFoundException) {
|
||||
_debugMessage.postValue(app.getString(R.string.no_selection_found))
|
||||
_debugMessage.postValue(app.getString(R.string.err_no_selection_file))
|
||||
mutableListOf()
|
||||
} catch (exception: IOException) {
|
||||
_debugMessage.postValue(exception.toString())
|
||||
|
||||
@@ -124,15 +124,19 @@ class MainActivity : AppCompatActivity() {
|
||||
viewModel.debugMessage.observe(this, Observer { message ->
|
||||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
|
||||
when (message) {
|
||||
getString(R.string.updateLocSuccess) -> drawerBtnLoc.enable()
|
||||
getString(R.string.updateTleSuccess), getString(R.string.updateTleFailure) -> drawerBtnTle.enable()
|
||||
getString(R.string.updateTransSuccess), getString(R.string.updateTransFailure) -> drawerBtnTrans.enable()
|
||||
getString(R.string.update_loc_success) -> drawerBtnLoc.enable()
|
||||
getString(R.string.update_tle_success) -> drawerBtnTle.enable()
|
||||
getString(R.string.update_trans_success) -> drawerBtnTrans.enable()
|
||||
getString(R.string.update_failure) -> {
|
||||
drawerBtnTle.enable()
|
||||
drawerBtnTrans.enable()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.gsp.observe(this, Observer { gsp ->
|
||||
drawerLat.text = String.format(getString(R.string.pattern_loc), gsp.latitude)
|
||||
drawerLon.text = String.format(getString(R.string.pattern_loc), gsp.longitude)
|
||||
drawerLat.text = String.format(getString(R.string.pat_location), gsp.latitude)
|
||||
drawerLon.text = String.format(getString(R.string.pat_location), gsp.longitude)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -159,7 +163,8 @@ class MainActivity : AppCompatActivity() {
|
||||
private fun requestLocationUpdate() {
|
||||
if (ContextCompat.checkSelfPermission(this, permLocation) != permGranted) {
|
||||
if (ActivityCompat.shouldShowRequestPermissionRationale(this, permLocation)) {
|
||||
Toast.makeText(this, getString(R.string.no_permissions), Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(this, getString(R.string.err_no_permissions), Toast.LENGTH_LONG)
|
||||
.show()
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(this, arrayOf(permLocation), permLocationCode)
|
||||
}
|
||||
@@ -182,14 +187,14 @@ class MainActivity : AppCompatActivity() {
|
||||
val navController = findNavController(R.id.nav_host)
|
||||
return navController.navigateUp(appBarConfig) || super.onSupportNavigateUp()
|
||||
}
|
||||
}
|
||||
|
||||
fun ImageButton.enable() {
|
||||
this.isEnabled = true
|
||||
this.alpha = 1.0f
|
||||
}
|
||||
private fun ImageButton.enable() {
|
||||
this.isEnabled = true
|
||||
this.alpha = 1.0f
|
||||
}
|
||||
|
||||
fun ImageButton.disable() {
|
||||
this.isEnabled = false
|
||||
this.alpha = 0.25f
|
||||
private fun ImageButton.disable() {
|
||||
this.isEnabled = false
|
||||
this.alpha = 0.25f
|
||||
}
|
||||
}
|
||||
@@ -205,9 +205,9 @@ class MapViewFragment : Fragment() {
|
||||
|
||||
if (lon > 180f) lon -= 360f
|
||||
|
||||
mapLat.text = String.format(context.getString(R.string.pattern_value_lat), lat)
|
||||
mapLon.text = String.format(context.getString(R.string.pattern_value_lon), lon)
|
||||
mapRng.text = String.format(context.getString(R.string.pattern_value_rng), rng)
|
||||
mapLat.text = String.format(context.getString(R.string.pat_latitude), lat)
|
||||
mapLon.text = String.format(context.getString(R.string.pat_longitude), lon)
|
||||
mapRng.text = String.format(context.getString(R.string.pat_range), rng)
|
||||
}
|
||||
|
||||
private fun drawGroundTrack(
|
||||
|
||||
@@ -83,8 +83,8 @@ class PassListFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun findViews(view: View) {
|
||||
aosTimerText = (mainActivity).findViewById(R.id.toolbar_timer)
|
||||
btnPassPrefs = (mainActivity).findViewById(R.id.toolbar_filter)
|
||||
aosTimerText = mainActivity.findViewById(R.id.toolbar_timer)
|
||||
btnPassPrefs = mainActivity.findViewById(R.id.toolbar_filter)
|
||||
swipeLayout = view.findViewById(R.id.pass_list_refresh)
|
||||
satPassRecycler = view.findViewById(R.id.pass_list_recycler)
|
||||
passListFab = view.findViewById(R.id.pass_list_fab)
|
||||
@@ -161,7 +161,7 @@ class PassListFragment : Fragment() {
|
||||
}
|
||||
} else Toast.makeText(
|
||||
mainActivity,
|
||||
getString(R.string.error_enter_value),
|
||||
getString(R.string.err_enter_value),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
|
||||
@@ -176,7 +176,7 @@ class PassListFragment : Fragment() {
|
||||
|
||||
private fun showSelectSatDialog(tleMainList: List<TLE>, selectionList: MutableList<Int>) {
|
||||
if (tleMainList.isEmpty()) {
|
||||
Toast.makeText(mainActivity, getString(R.string.error_update_tle), Toast.LENGTH_SHORT)
|
||||
Toast.makeText(mainActivity, getString(R.string.err_update_tle), Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
} else {
|
||||
val tleNameArray = arrayOfNulls<String>(tleMainList.size).apply {
|
||||
@@ -235,7 +235,7 @@ class PassListFragment : Fragment() {
|
||||
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
aosTimerText.text = String.format(
|
||||
mainActivity.getString(R.string.pattern_timer_aos),
|
||||
mainActivity.getString(R.string.pat_timer_aos),
|
||||
TimeUnit.MILLISECONDS.toHours(millisUntilFinished) % 60,
|
||||
TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished) % 60,
|
||||
TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) % 60
|
||||
@@ -255,7 +255,7 @@ class PassListFragment : Fragment() {
|
||||
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
aosTimerText.text = String.format(
|
||||
mainActivity.getString(R.string.pattern_timer_los),
|
||||
mainActivity.getString(R.string.pat_timer_los),
|
||||
TimeUnit.MILLISECONDS.toHours(millisUntilFinished) % 60,
|
||||
TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished) % 60,
|
||||
TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) % 60
|
||||
@@ -271,6 +271,6 @@ class PassListFragment : Fragment() {
|
||||
isTimerSet = false
|
||||
}
|
||||
if (resetToNull) aosTimerText.text =
|
||||
String.format(getString(R.string.pattern_timer_aos), 0, 0, 0)
|
||||
String.format(getString(R.string.pat_timer_aos), 0, 0, 0)
|
||||
}
|
||||
}
|
||||
@@ -169,18 +169,14 @@ class PolarViewFragment : Fragment() {
|
||||
|
||||
private fun setPassText() {
|
||||
satPos = satPass.predictor.getSatPos(Date())
|
||||
polarAzimuth.text = String.format(
|
||||
context.getString(R.string.pattern_value_az),
|
||||
rad2Deg(satPos.azimuth)
|
||||
)
|
||||
polarElevation.text = String.format(
|
||||
context.getString(R.string.pattern_value_el),
|
||||
rad2Deg(satPos.elevation)
|
||||
)
|
||||
polarAzimuth.text =
|
||||
String.format(context.getString(R.string.pat_azimuth), rad2Deg(satPos.azimuth))
|
||||
polarElevation.text =
|
||||
String.format(context.getString(R.string.pat_elevation), rad2Deg(satPos.elevation))
|
||||
polarRange.text =
|
||||
String.format(context.getString(R.string.pattern_value_rng), satPos.range)
|
||||
String.format(context.getString(R.string.pat_range), satPos.range)
|
||||
polarAltitude.text =
|
||||
String.format(context.getString(R.string.pattern_value_alt), satPos.altitude)
|
||||
String.format(context.getString(R.string.pat_altitude), satPos.altitude)
|
||||
}
|
||||
|
||||
private fun drawRadarView(cvs: Canvas) {
|
||||
|
||||
@@ -93,26 +93,26 @@ class SatPassAdapter : RecyclerView.Adapter<SatPassAdapter.SatPassHolder>() {
|
||||
|
||||
fun bind(satPass: SatPass) {
|
||||
val aos = SimpleDateFormat(
|
||||
context.getString(R.string.pattern_time),
|
||||
context.getString(R.string.pat_time),
|
||||
Locale.getDefault()
|
||||
).format(satPass.pass.startTime)
|
||||
val los = SimpleDateFormat(
|
||||
context.getString(R.string.pattern_time),
|
||||
context.getString(R.string.pat_time),
|
||||
Locale.getDefault()
|
||||
).format(satPass.pass.endTime)
|
||||
|
||||
satName.text = satPass.tle.name
|
||||
satId.text =
|
||||
String.format(context.getString(R.string.pattern_pass_satId), satPass.tle.catnum)
|
||||
String.format(context.getString(R.string.pass_satId), satPass.tle.catnum)
|
||||
maxEl.text =
|
||||
String.format(context.getString(R.string.pattern_pass_maxEl), satPass.pass.maxEl)
|
||||
String.format(context.getString(R.string.pass_maxEl), satPass.pass.maxEl)
|
||||
azimuth.text = String.format(
|
||||
context.getString(R.string.pattern_pass_azimuth),
|
||||
context.getString(R.string.pass_azimuth),
|
||||
satPass.pass.aosAzimuth,
|
||||
satPass.pass.losAzimuth
|
||||
)
|
||||
aosTime.text = String.format(context.getString(R.string.pattern_pass_aos), aos)
|
||||
losTime.text = String.format(context.getString(R.string.pattern_pass_los), los)
|
||||
aosTime.text = String.format(context.getString(R.string.pass_aos), aos)
|
||||
losTime.text = String.format(context.getString(R.string.pass_los), los)
|
||||
progressBar.progress = satPass.progress
|
||||
|
||||
itemView.setOnClickListener {
|
||||
|
||||
@@ -66,12 +66,12 @@ class TransmitterAdapter : RecyclerView.Adapter<TransmitterAdapter.TransmitterHo
|
||||
|
||||
if (transmitter.downlinkLow != null && transmitter.downlinkHigh == null) {
|
||||
downlink.text = String.format(
|
||||
context.getString(R.string.pattern_trans_down_low),
|
||||
context.getString(R.string.trans_down_low),
|
||||
transmitter.downlinkLow / freqDivider
|
||||
)
|
||||
} else if (transmitter.downlinkLow != null && transmitter.downlinkHigh != null) {
|
||||
downlink.text = String.format(
|
||||
context.getString(R.string.pattern_trans_down_lowHigh),
|
||||
context.getString(R.string.trans_down_lowHigh),
|
||||
transmitter.downlinkLow / freqDivider,
|
||||
transmitter.downlinkHigh / freqDivider
|
||||
)
|
||||
@@ -81,12 +81,12 @@ class TransmitterAdapter : RecyclerView.Adapter<TransmitterAdapter.TransmitterHo
|
||||
|
||||
if (transmitter.uplinkLow != null && transmitter.uplinkHigh == null) {
|
||||
uplink.text = String.format(
|
||||
context.getString(R.string.pattern_trans_up_low),
|
||||
context.getString(R.string.trans_up_low),
|
||||
transmitter.uplinkLow / freqDivider
|
||||
)
|
||||
} else if (transmitter.uplinkLow != null && transmitter.uplinkHigh != null) {
|
||||
uplink.text = String.format(
|
||||
context.getString(R.string.pattern_trans_up_lowHigh),
|
||||
context.getString(R.string.trans_up_lowHigh),
|
||||
transmitter.uplinkLow / freqDivider,
|
||||
transmitter.uplinkHigh / freqDivider
|
||||
)
|
||||
@@ -96,18 +96,18 @@ class TransmitterAdapter : RecyclerView.Adapter<TransmitterAdapter.TransmitterHo
|
||||
|
||||
if (transmitter.mode != null) {
|
||||
mode.text =
|
||||
String.format(context.getString(R.string.pattern_trans_mode), transmitter.mode)
|
||||
String.format(context.getString(R.string.trans_mode), transmitter.mode)
|
||||
} else {
|
||||
mode.text = context.getString(R.string.no_mode)
|
||||
}
|
||||
if (transmitter.isInverted) {
|
||||
inverted.text = String.format(
|
||||
context.getString(R.string.pattern_trans_invert),
|
||||
context.getString(R.string.trans_inverted),
|
||||
context.getString(R.string.btn_yes)
|
||||
)
|
||||
} else {
|
||||
inverted.text = String.format(
|
||||
context.getString(R.string.pattern_trans_invert),
|
||||
context.getString(R.string.trans_inverted),
|
||||
context.getString(R.string.btn_no)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user