From 6aa78c8ddbcdeaace0f4596e7c717dafef036f03 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Sat, 15 Jan 2022 20:08:37 -0600 Subject: Improved loading indicators, improved layout semantics, added translations and changed default view to MAP --- .../details/commands/UnitCommandsFragment.kt | 3 +- .../details/information/UnitInformationFragment.kt | 4 +- .../android/details/reports/UnitReportsFragment.kt | 4 +- .../TrackerMap/android/devices/DevicesAdapter.kt | 1 + .../TrackerMap/android/devices/DevicesFragment.kt | 4 + .../TrackerMap/android/session/LoginFragment.kt | 15 +- .../android/session/UserInformationActivity.kt | 2 +- .../TrackerMap/android/units/UnitsViewModel.kt | 2 +- androidApp/src/main/res/drawable/icon_search.xml | 10 + .../src/main/res/layout/devices_fragment.xml | 16 +- .../src/main/res/layout/loading_indicator.xml | 12 + androidApp/src/main/res/layout/login.xml | 142 +++++---- androidApp/src/main/res/layout/login_activity.xml | 33 +- .../src/main/res/layout/unit_details_commands.xml | 130 ++++---- .../main/res/layout/unit_details_information.xml | 84 ++--- .../src/main/res/layout/unit_details_reports.xml | 15 +- androidApp/src/main/res/layout/unit_item.xml | 30 +- androidApp/src/main/res/layout/units_activity.xml | 28 +- .../main/res/layout/user_information_activity.xml | 342 +++++++++++---------- androidApp/src/main/res/values-es-rMX/strings.xml | 6 +- androidApp/src/main/res/values/dimen.xml | 7 +- androidApp/src/main/res/values/strings.xml | 6 +- 22 files changed, 498 insertions(+), 398 deletions(-) create mode 100644 androidApp/src/main/res/drawable/icon_search.xml create mode 100644 androidApp/src/main/res/layout/loading_indicator.xml (limited to 'androidApp') 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(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>() private var _selectedUnit = MutableLiveData() private var _mapTileInfo = MutableLiveData() diff --git a/androidApp/src/main/res/drawable/icon_search.xml b/androidApp/src/main/res/drawable/icon_search.xml new file mode 100644 index 0000000..07b76d6 --- /dev/null +++ b/androidApp/src/main/res/drawable/icon_search.xml @@ -0,0 +1,10 @@ + + + diff --git a/androidApp/src/main/res/layout/devices_fragment.xml b/androidApp/src/main/res/layout/devices_fragment.xml index fd91db3..1dd1690 100644 --- a/androidApp/src/main/res/layout/devices_fragment.xml +++ b/androidApp/src/main/res/layout/devices_fragment.xml @@ -1,17 +1,19 @@ - + + + layout="@layout/loading_indicator" + android:visibility="gone"/> - \ No newline at end of file + \ No newline at end of file diff --git a/androidApp/src/main/res/layout/loading_indicator.xml b/androidApp/src/main/res/layout/loading_indicator.xml new file mode 100644 index 0000000..83b94d5 --- /dev/null +++ b/androidApp/src/main/res/layout/loading_indicator.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/androidApp/src/main/res/layout/login.xml b/androidApp/src/main/res/layout/login.xml index 2512052..35c9410 100644 --- a/androidApp/src/main/res/layout/login.xml +++ b/androidApp/src/main/res/layout/login.xml @@ -1,74 +1,110 @@ - + android:layout_height="match_parent"> - - + + + + + app:layout_constraintEnd_toEndOf="parent" + android:layout_marginHorizontal="@dimen/card_margin" + android:layout_marginBottom="16dp"> - + android:paddingVertical="@dimen/card_large_padding" + android:paddingHorizontal="@dimen/card_padding"> - + - + - + - + - + + + + + + + + + - \ No newline at end of file + + + \ No newline at end of file diff --git a/androidApp/src/main/res/layout/login_activity.xml b/androidApp/src/main/res/layout/login_activity.xml index be143d9..1c75a7b 100644 --- a/androidApp/src/main/res/layout/login_activity.xml +++ b/androidApp/src/main/res/layout/login_activity.xml @@ -1,30 +1,11 @@ - - - - - - - \ No newline at end of file + android:name="mx.trackermap.TrackerMap.android.session.LoginFragment" + app:layout_constraintTop_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" /> \ No newline at end of file diff --git a/androidApp/src/main/res/layout/unit_details_commands.xml b/androidApp/src/main/res/layout/unit_details_commands.xml index 3616f75..01aefb8 100644 --- a/androidApp/src/main/res/layout/unit_details_commands.xml +++ b/androidApp/src/main/res/layout/unit_details_commands.xml @@ -1,79 +1,81 @@ - - + - + - + - + - + - + - + - + + + + + - \ No newline at end of file + \ No newline at end of file diff --git a/androidApp/src/main/res/layout/unit_details_information.xml b/androidApp/src/main/res/layout/unit_details_information.xml index 422b77e..cc8bbb7 100644 --- a/androidApp/src/main/res/layout/unit_details_information.xml +++ b/androidApp/src/main/res/layout/unit_details_information.xml @@ -1,49 +1,59 @@ - - - - - - - - + + + + + app:cardCornerRadius="@dimen/card_border_radius" + app:cardElevation="@dimen/card_elevation" + app:cardUseCompatPadding="true" + app:contentPadding="@dimen/card_padding"> + + + + - + - + + + + + + + - \ No newline at end of file + \ No newline at end of file diff --git a/androidApp/src/main/res/layout/unit_details_reports.xml b/androidApp/src/main/res/layout/unit_details_reports.xml index 0a8e23d..7210e1f 100644 --- a/androidApp/src/main/res/layout/unit_details_reports.xml +++ b/androidApp/src/main/res/layout/unit_details_reports.xml @@ -162,14 +162,15 @@ - + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintBottom_toTopOf="@id/periodSection" + android:visibility="gone"/> \ No newline at end of file diff --git a/androidApp/src/main/res/layout/unit_item.xml b/androidApp/src/main/res/layout/unit_item.xml index cccdd69..6946d1d 100644 --- a/androidApp/src/main/res/layout/unit_item.xml +++ b/androidApp/src/main/res/layout/unit_item.xml @@ -15,10 +15,12 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="end" - android:padding="@dimen/card_padding" + android:padding="@dimen/padding" + android:paddingStart="0dp" android:gravity="center" android:orientation="horizontal" - android:visibility="visible"> + android:visibility="visible" + tools:ignore="RtlSymmetry"> + + + android:textColor="@color/colorAccent" + android:minWidth="0dp" + style="?android:borderlessButtonStyle"/> @@ -53,9 +69,11 @@ app:cardElevation="0dp" app:cardUseCompatPadding="true" app:contentPadding="@dimen/card_padding" + app:contentPaddingLeft="0dp" app:cardBackgroundColor="@color/darkBackground" android:clickable="true" - android:focusable="true"> + android:focusable="true" + tools:visibility="gone"> + app:layout_constraintTop_toTopOf="parent" + tools:ignore="ContentDescription" /> + app:layout_constraintStart_toEndOf="@id/displayModeToggle" + app:layout_constraintTop_toTopOf="@id/userButton"> + app:layout_constraintTop_toTopOf="parent"/> \ No newline at end of file diff --git a/androidApp/src/main/res/layout/user_information_activity.xml b/androidApp/src/main/res/layout/user_information_activity.xml index 0b4924a..c409e98 100644 --- a/androidApp/src/main/res/layout/user_information_activity.xml +++ b/androidApp/src/main/res/layout/user_information_activity.xml @@ -6,17 +6,6 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - + android:layout_height="match_parent"> - + android:orientation="vertical"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + app:contentPadding="@dimen/card_padding" + app:cardCornerRadius="@dimen/card_border_radius" + app:cardElevation="@dimen/card_elevation"> + + + + + + + + + + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/androidApp/src/main/res/values-es-rMX/strings.xml b/androidApp/src/main/res/values-es-rMX/strings.xml index 7ebf7d2..bd3a281 100644 --- a/androidApp/src/main/res/values-es-rMX/strings.xml +++ b/androidApp/src/main/res/values-es-rMX/strings.xml @@ -9,6 +9,10 @@ Contraseña Iniciar sesión + Falta el nombre de usuario + Falta la contraseña + Falló el inicio de sesión + Cambiar a lista de dispositivos Cambiar a mapa @@ -59,7 +63,7 @@ Detalles Reportes Comandos - Escribe para buscar + Buscar Contacto diff --git a/androidApp/src/main/res/values/dimen.xml b/androidApp/src/main/res/values/dimen.xml index 906c4af..271a12b 100644 --- a/androidApp/src/main/res/values/dimen.xml +++ b/androidApp/src/main/res/values/dimen.xml @@ -3,16 +3,19 @@ 8dp 16dp + + 160dp + 20dp 8dp 32dp 16dp 16dp - 5dp + 10dp - 12sp + 11sp 8dp diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml index 5f9714e..07419f3 100644 --- a/androidApp/src/main/res/values/strings.xml +++ b/androidApp/src/main/res/values/strings.xml @@ -32,6 +32,10 @@ Password Login + Username is missing + Password is missing + Login failed + Switch to device list Switch to map @@ -82,7 +86,7 @@ Details Reports Commands - Type to search + Search Contact -- cgit v1.2.3