aboutsummaryrefslogtreecommitdiff
path: root/androidApp/src/main/java/mx
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-15 20:08:37 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-15 20:08:37 -0600
commit6aa78c8ddbcdeaace0f4596e7c717dafef036f03 (patch)
tree2bfcaff8312058e4c16cc238ded881f59727983e /androidApp/src/main/java/mx
parentd16483ddb5f9989315db95fe2d70747c04ebc657 (diff)
downloadetbsa-trackermap-mobile-6aa78c8ddbcdeaace0f4596e7c717dafef036f03.tar.gz
etbsa-trackermap-mobile-6aa78c8ddbcdeaace0f4596e7c717dafef036f03.tar.bz2
etbsa-trackermap-mobile-6aa78c8ddbcdeaace0f4596e7c717dafef036f03.zip
Improved loading indicators, improved layout semantics, added translations and changed default view to MAP
Diffstat (limited to 'androidApp/src/main/java/mx')
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsFragment.kt3
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt4
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt4
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt1
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt4
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginFragment.kt15
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/UserInformationActivity.kt2
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsViewModel.kt2
8 files changed, 24 insertions, 11 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsFragment.kt
index fa6a37a..b56a403 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsFragment.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsFragment.kt
@@ -35,6 +35,7 @@ class UnitCommandsFragment: Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
+ binding.reportLoading.root.visibility = View.VISIBLE
setupObservers()
setupEvents()
}
@@ -47,7 +48,7 @@ class UnitCommandsFragment: Fragment() {
private fun setupObservers() {
unitCommandsViewModel.commands.observe(viewLifecycleOwner) { commands ->
Log.d("UnitCommandsFragment", "Device commands - $commands")
- binding.reportLoading.visibility = View.GONE
+ binding.reportLoading.root.visibility = View.GONE
val context = activity!!.applicationContext
val adapter = ArrayAdapter<String>(context, R.layout.simple_list_item_checked)
adapter.addAll(commands.map { it.description })
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt
index 232b6e9..0c3577e 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt
@@ -53,7 +53,7 @@ class UnitInformationFragment : Fragment() {
private fun setupObservers() {
unitInformationViewModel.unit.observe(viewLifecycleOwner) { unitInformation ->
Log.d("UnitInformationFragment", "Unit Information Fetched - $unitInformation")
- binding.reportLoading.visibility = View.GONE
+ binding.reportLoading.root.visibility = View.GONE
unitInformation?.let {
displayInformation(it)
}
@@ -65,7 +65,7 @@ class UnitInformationFragment : Fragment() {
val name = arguments?.getString(UnitDetailsAdapter.DEVICE_NAME_ARG)
unitInformationViewModel.fetchUnit(id ?: 0)
binding.nameDetail.text = name
- binding.reportLoading.visibility = View.VISIBLE
+ binding.reportLoading.root.visibility = View.VISIBLE
}
private fun displayInformation(unit: UnitInformation) {
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt
index 957c6a7..20d2a48 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt
@@ -248,7 +248,7 @@ class UnitReportsFragment : Fragment() {
}
private fun loading() {
- binding.reportLoading.visibility = View.VISIBLE
+ binding.reportLoading.root.visibility = View.VISIBLE
binding.eventsScroll.visibility = View.GONE
binding.reportsMapContainer.visibility = View.GONE
@@ -258,7 +258,7 @@ class UnitReportsFragment : Fragment() {
}
private fun showMap(shouldShowMap: Boolean) {
- binding.reportLoading.visibility = View.GONE
+ binding.reportLoading.root.visibility = View.GONE
binding.eventsScroll.visibility = if (shouldShowMap) View.GONE else View.VISIBLE
binding.reportsMapContainer.visibility = if (shouldShowMap) View.VISIBLE else View.GONE
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt
index 53e726e..344907c 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt
@@ -44,6 +44,7 @@ class DevicesAdapter(
engineStopIcon = engineStopIcon,
gridLayout = gridLayout,
detailsButton = detailsButton,
+ reportsButton = reportsButton,
commandsButton = commandsButton,
unitCard = unitCard,
swipeLayout = swipeLayout
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt
index 3b44477..96d4696 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt
@@ -6,6 +6,8 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.view.ViewTreeObserver
+import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import kotlinx.coroutines.DelicateCoroutinesApi
import mx.trackermap.TrackerMap.android.databinding.DevicesFragmentBinding
@@ -59,6 +61,7 @@ class DevicesFragment(private val unitsViewModel: UnitsViewModel) : UnitFragment
false
)
binding.devicesList.adapter = DevicesAdapter(emptyList(), null)
+ binding.infoLoading.root.visibility = View.VISIBLE
}
@DelicateCoroutinesApi
@@ -66,6 +69,7 @@ class DevicesFragment(private val unitsViewModel: UnitsViewModel) : UnitFragment
Log.d("DevicesFragment", "setupObservers()")
unitsViewModel.units.observe(viewLifecycleOwner) { units ->
Log.d("DevicesFragment", "Success $units")
+ binding.infoLoading.root.visibility = View.GONE
binding.devicesList.swapAdapter(
DevicesAdapter(units, this::itemAction),
false
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginFragment.kt
index 1cac5bd..f48eb93 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginFragment.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginFragment.kt
@@ -13,6 +13,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.preference.PreferenceManager
import com.zhuinden.liveevent.observe
import kotlinx.coroutines.DelicateCoroutinesApi
+import mx.trackermap.TrackerMap.android.R
import mx.trackermap.TrackerMap.android.databinding.LoginBinding
import mx.trackermap.TrackerMap.android.units.UnitsActivity
import mx.trackermap.TrackerMap.controllers.SessionController
@@ -75,17 +76,23 @@ class LoginFragment : Fragment() {
loginViewModel.loginState.observe(viewLifecycleOwner) { result ->
Log.d("LoginFragment", result.toString())
when (result) {
+ SessionController.LoginState.Nothing -> {
+ binding.infoLoading.root.visibility = View.GONE
+ }
SessionController.LoginState.Loading -> {
- Toast.makeText(context, "Loading...", Toast.LENGTH_SHORT).show()
+ binding.infoLoading.root.visibility = View.VISIBLE
}
SessionController.LoginState.EmailMissing -> {
- Toast.makeText(context, "Email is missing", Toast.LENGTH_SHORT).show()
+ binding.infoLoading.root.visibility = View.GONE
+ Toast.makeText(context, getString(R.string.login_username_missing), Toast.LENGTH_SHORT).show()
}
SessionController.LoginState.PasswordMissing -> {
- Toast.makeText(context, "Password is missing", Toast.LENGTH_SHORT).show()
+ binding.infoLoading.root.visibility = View.GONE
+ Toast.makeText(context, getString(R.string.login_password_missing), Toast.LENGTH_SHORT).show()
}
SessionController.LoginState.Failure -> {
- Toast.makeText(context, "Failed login", Toast.LENGTH_SHORT).show()
+ binding.infoLoading.root.visibility = View.GONE
+ Toast.makeText(context, getString(R.string.login_login_failed), Toast.LENGTH_SHORT).show()
}
SessionController.LoginState.Success -> {
broadcastManager.sendBroadcast(Intent(EVENT_LOGIN))
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/UserInformationActivity.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/UserInformationActivity.kt
index 5ae8c75..b0a4482 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/UserInformationActivity.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/UserInformationActivity.kt
@@ -84,7 +84,7 @@ class UserInformationActivity : AppCompatActivity() {
}
private fun setLoading(isLoading: Boolean) {
- binding.infoLoading.visibility = if (isLoading) View.VISIBLE else View.GONE
+ binding.infoLoading.root.visibility = if (isLoading) View.VISIBLE else View.GONE
binding.userInfoCard.visibility = if (isLoading) View.GONE else View.VISIBLE
}
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsViewModel.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsViewModel.kt
index 6a04cf4..08d35a2 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsViewModel.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsViewModel.kt
@@ -27,7 +27,7 @@ class UnitsViewModel(
private val geofenceController: GeofencesController by inject()
private var _searchQuery = savedStateHandle.getLiveData("searchQuery", "")
- private var _unitsDisplayMode = MutableLiveData(UnitsDisplayMode.LIST)
+ private var _unitsDisplayMode = MutableLiveData(UnitsDisplayMode.MAP)
private var _units = MutableLiveData<List<UnitInformation>>()
private var _selectedUnit = MutableLiveData<UnitInformation?>()
private var _mapTileInfo = MutableLiveData<TileInfoNew>()