diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-24 15:12:11 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-24 15:12:11 -0600 |
commit | ac5eeffba586954042c9efcf196c2efcfe854c4a (patch) | |
tree | 20378bce6484d4c68203556d9f4e76d18fc566f3 /androidApp | |
parent | 0381ae0b930ceb7b43ef1e66950c9bd6f9dfcc56 (diff) | |
parent | 7f1388bc554a3ee68a1865d2a219395805a79575 (diff) | |
download | etbsa-trackermap-mobile-ac5eeffba586954042c9efcf196c2efcfe854c4a.tar.gz etbsa-trackermap-mobile-ac5eeffba586954042c9efcf196c2efcfe854c4a.tar.bz2 etbsa-trackermap-mobile-ac5eeffba586954042c9efcf196c2efcfe854c4a.zip |
Merged main from upstream (unbranded)
Diffstat (limited to 'androidApp')
32 files changed, 505 insertions, 17 deletions
diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index f6de76e..4d21e69 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -45,8 +45,8 @@ val googleImplementation by configurations dependencies { implementation(project(":shared")) implementation("com.google.android.material:material:1.5.0") - implementation("androidx.appcompat:appcompat:1.4.0") - implementation("androidx.constraintlayout:constraintlayout:2.1.2") + implementation("androidx.appcompat:appcompat:1.4.1") + implementation("androidx.constraintlayout:constraintlayout:2.1.3") implementation("com.squareup.okhttp3:okhttp:4.9.1") implementation("com.github.Zhuinden:live-event:1.2.0") implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0") diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/TrackerApp.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/TrackerApp.kt index 1811733..1d181dd 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/TrackerApp.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/TrackerApp.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android import android.app.Application @@ -29,7 +46,7 @@ open class TrackerApp : Application() { super.onCreate() val appModule = module { - single { "https://etbsa.net/api" } + single { getString(R.string.default_server_url) } factory { SessionApi(get()) } factory { UsersApi(get()) } factory { DevicesApi(get()) } diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt index 9633332..5272f06 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/DetailsActivity.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.details import android.Manifest diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/UnitDetailsAdapter.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/UnitDetailsAdapter.kt index cc2a7c2..e913cb5 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/UnitDetailsAdapter.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/UnitDetailsAdapter.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.details import android.os.Bundle 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 9d12608..ecd1a53 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 @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.details.commands import android.os.Bundle diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsViewModel.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsViewModel.kt index 06c0439..3bb7f11 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsViewModel.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsViewModel.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.details.commands import android.util.Log 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 7966c5b..e731587 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 @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.details.information import android.content.Intent diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationViewModel.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationViewModel.kt index 721fa68..43d8821 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationViewModel.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationViewModel.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.details.information import android.util.Log 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 08d7076..22c75f4 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 @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.details.reports import android.app.Activity diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsViewModel.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsViewModel.kt index 0bdf61b..41a6b6d 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsViewModel.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsViewModel.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.details.reports import androidx.lifecycle.* 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 b1854a9..4cfd6b5 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 @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.devices import android.view.LayoutInflater 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 b905beb..ad93429 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 @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.devices import android.content.Intent diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt index c483d52..a76ebde 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.map import android.graphics.Bitmap @@ -97,6 +114,7 @@ open class MapFragment : GlobeMapFragment() { hasStarted = true setupCallbacks.forEach { it() } + setupCallbacks.clear() } override fun onStop() { diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapWrapperFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapWrapperFragment.kt index c8ef688..c9eab70 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapWrapperFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapWrapperFragment.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.map import android.os.Bundle diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/UnitMapFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/UnitMapFragment.kt index 9718262..e7e5ce0 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/UnitMapFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/UnitMapFragment.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.map import android.content.Intent diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginActivity.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginActivity.kt index 3fbab80..23e781b 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginActivity.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginActivity.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.session import android.os.Bundle 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 f1b23a6..c855f44 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 @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.session import android.content.* @@ -7,7 +24,6 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Toast -import androidx.core.widget.doAfterTextChanged import androidx.fragment.app.Fragment import androidx.localbroadcastmanager.content.LocalBroadcastManager import androidx.preference.PreferenceManager @@ -43,6 +59,14 @@ class LoginFragment : Fragment() { setupEvents() setupObservers() broadcastManager = LocalBroadcastManager.getInstance(activity!!) + binding.urlEditText.setText( + PreferenceManager + .getDefaultSharedPreferences(activity) + .getString( + PREFERENCE_SERVER_URL, + getString(R.string.default_server_url) + ) ?: getString(R.string.default_server_url) + ) loginViewModel.restoreSession() } @@ -67,6 +91,7 @@ class LoginFragment : Fragment() { loginViewModel.login( binding.usernameEditText.text.toString(), binding.passwordEditText.text.toString(), + binding.urlEditText.text.toString(), PreferenceManager .getDefaultSharedPreferences(activity) .getString(PREFERENCE_TOKEN, null) @@ -84,6 +109,10 @@ class LoginFragment : Fragment() { SessionController.LoginState.Loading -> { binding.infoLoading.root.visibility = View.VISIBLE } + SessionController.LoginState.UrlMissing -> { + binding.infoLoading.root.visibility = View.GONE + Toast.makeText(context, getString(R.string.login_url_missing), Toast.LENGTH_SHORT).show() + } SessionController.LoginState.EmailMissing -> { binding.infoLoading.root.visibility = View.GONE Toast.makeText(context, getString(R.string.login_username_missing), Toast.LENGTH_SHORT).show() @@ -97,6 +126,12 @@ class LoginFragment : Fragment() { Toast.makeText(context, getString(R.string.login_login_failed), Toast.LENGTH_SHORT).show() } SessionController.LoginState.Success -> { + PreferenceManager + .getDefaultSharedPreferences(activity) + .edit() + .putString(PREFERENCE_SERVER_URL, binding.urlEditText.text.toString()) + .apply() + broadcastManager.sendBroadcast(Intent(EVENT_LOGIN)) val activity = requireActivity() val intent = Intent(activity.applicationContext, UnitsActivity::class.java) @@ -126,6 +161,7 @@ class LoginFragment : Fragment() { const val EVENT_TOKEN = "eventToken" const val KEY_TOKEN = "keyToken" + const val PREFERENCE_SERVER_URL = "server_url" const val PREFERENCE_TOKEN = "token" } }
\ No newline at end of file diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginViewModel.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginViewModel.kt index 88b56cf..bcee2ec 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginViewModel.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/LoginViewModel.kt @@ -1,7 +1,22 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.session -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.zhuinden.eventemitter.EventEmitter @@ -40,7 +55,7 @@ class LoginViewModel : ViewModel(), KoinComponent { sessionController.restoreSession() } - fun login(email: String, password: String, token: String?) { - sessionController.login(SessionBody(email, password, token)) + fun login(email: String, password: String, url: String, token: String?) { + sessionController.login(SessionBody(url, email, password, token)) } }
\ No newline at end of file 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 5fad118..e78e2b0 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 @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.session import android.content.Intent @@ -65,6 +82,11 @@ class UserInformationActivity : AppCompatActivity() { emailInfo.text = user.email ?: "" idInfo.text = "${user.id ?: "--"}" adminInfo.text = "${user.administrator}" + serverInfo.text = "${ + PreferenceManager + .getDefaultSharedPreferences(this@UserInformationActivity) + .getString(LoginFragment.PREFERENCE_SERVER_URL, getString(R.string.default_server_url)) + }" user.deviceLimit?.let { deviceLimitInfo.text = "${user.deviceLimit ?: "--"}" if (it > 0) { diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/UserInformationViewModel.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/UserInformationViewModel.kt index 9bb5ac7..0d3784c 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/UserInformationViewModel.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/UserInformationViewModel.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.session import android.util.Log diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/MarkerTransformations.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/MarkerTransformations.kt index f684a10..242cccf 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/MarkerTransformations.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/MarkerTransformations.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.shared import android.util.Log diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/UnitRenderData.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/UnitRenderData.kt index e8a4bd6..123e1ab 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/UnitRenderData.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/UnitRenderData.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.shared import android.content.Context diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/Utils.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/Utils.kt index abfe1bb..ac9673f 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/Utils.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/Utils.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.shared import android.app.NotificationManager diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitFragment.kt index e514094..05a14c9 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitFragment.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.units import androidx.fragment.app.Fragment diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt index 58147e4..4371eed 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.units import android.content.Context @@ -8,10 +25,8 @@ import android.view.View import android.view.inputmethod.InputMethodManager import android.widget.Toast import androidx.appcompat.app.AppCompatActivity -import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.TooltipCompat import androidx.core.widget.doAfterTextChanged -import androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_FADE import androidx.fragment.app.commit import kotlinx.coroutines.DelicateCoroutinesApi import mx.trackermap.TrackerMap.android.R 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 cb30725..d7b6db1 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 @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.android.units import android.util.Log diff --git a/androidApp/src/main/res/layout/devices_fragment.xml b/androidApp/src/main/res/layout/devices_fragment.xml index 1dd1690..6e4db3f 100644 --- a/androidApp/src/main/res/layout/devices_fragment.xml +++ b/androidApp/src/main/res/layout/devices_fragment.xml @@ -2,7 +2,8 @@ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="@color/background"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/devicesList" diff --git a/androidApp/src/main/res/layout/login.xml b/androidApp/src/main/res/layout/login.xml index 7c79e5c..78c3e46 100644 --- a/androidApp/src/main/res/layout/login.xml +++ b/androidApp/src/main/res/layout/login.xml @@ -70,8 +70,8 @@ app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/usernameInputLayout" - app:layout_constraintBottom_toTopOf="@id/signinButton" - android:layout_marginTop="24dp"> + app:layout_constraintBottom_toTopOf="@id/urlInputLayout" + android:layout_marginTop="@dimen/fields_spacing"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/passwordEditText" @@ -81,17 +81,38 @@ </com.google.android.material.textfield.TextInputLayout> + <com.google.android.material.textfield.TextInputLayout + android:id="@+id/urlInputLayout" + style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/login_url" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.5" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/passwordInputLayout" + app:layout_constraintBottom_toTopOf="@id/signinButton" + android:layout_marginTop="@dimen/fields_spacing"> + + <com.google.android.material.textfield.TextInputEditText + android:id="@+id/urlEditText" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:inputType="textUri"/> + + </com.google.android.material.textfield.TextInputLayout> + <com.google.android.material.button.MaterialButton android:id="@+id/signinButton" android:layout_width="0dp" android:layout_height="wrap_content" app:layout_constraintWidth_percent="0.5" - app:layout_constraintTop_toBottomOf="@id/passwordInputLayout" + app:layout_constraintTop_toBottomOf="@id/urlInputLayout" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintHorizontal_bias="0.5" - android:layout_marginTop="24dp" + android:layout_marginTop="@dimen/fields_large_spacing" android:text="@string/login_login"/> </androidx.constraintlayout.widget.ConstraintLayout> diff --git a/androidApp/src/main/res/layout/units_activity.xml b/androidApp/src/main/res/layout/units_activity.xml index 5abb95b..60a77db 100644 --- a/androidApp/src/main/res/layout/units_activity.xml +++ b/androidApp/src/main/res/layout/units_activity.xml @@ -5,7 +5,8 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawerLayout" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:animateLayoutChanges="true"> <androidx.fragment.app.FragmentContainerView android:id="@+id/displayContainer" @@ -74,7 +75,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/fab_margin" - android:layout_marginEnd="@dimen/fab_margin" + android:layout_marginEnd="@dimen/search_horizontal_margin" android:backgroundTint="@android:color/white" android:contentDescription="@string/switch_layer" android:src="@drawable/icon_layers" diff --git a/androidApp/src/main/res/layout/user_information_activity.xml b/androidApp/src/main/res/layout/user_information_activity.xml index 2f0486c..3ed9048 100644 --- a/androidApp/src/main/res/layout/user_information_activity.xml +++ b/androidApp/src/main/res/layout/user_information_activity.xml @@ -131,6 +131,20 @@ android:layout_marginBottom="@dimen/fields_spacing" tools:text="Admin" /> + <TextView + android:id="@+id/serverInfoLabel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/login_url" + android:textAppearance="@style/TextAppearance.AppCompat.Body2"/> + + <TextView + android:id="@+id/serverInfo" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="@dimen/fields_spacing" + tools:text="@string/default_server_url" /> + <com.google.android.material.button.MaterialButton android:id="@+id/signoutButton" android:layout_width="match_parent" diff --git a/androidApp/src/main/res/values-es-rMX/strings.xml b/androidApp/src/main/res/values-es-rMX/strings.xml index 28aee79..eeb7149 100644 --- a/androidApp/src/main/res/values-es-rMX/strings.xml +++ b/androidApp/src/main/res/values-es-rMX/strings.xml @@ -10,10 +10,12 @@ <!-- LoginActivity --> <string name="login_username">Nombre de usuario</string> <string name="login_password">Contraseña</string> + <string name="login_url">URL del servidor</string> <string name="login_login">Iniciar sesión</string> <string name="login_username_missing">Falta el nombre de usuario</string> <string name="login_password_missing">Falta la contraseña</string> + <string name="login_url_missing">Falta la URL del servidor</string> <string name="login_login_failed">Falló el inicio de sesión</string> <!-- UnitsActivity --> diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml index 4f5a213..865368e 100644 --- a/androidApp/src/main/res/values/strings.xml +++ b/androidApp/src/main/res/values/strings.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name" translatable="false">ETBSA</string> + <string name="default_server_url" translatable="false">https://etbsa.net/api</string> <!-- Non translatable --> <string name="app_website_url" translatable="false">https://etbsa.com.mx/</string> @@ -23,10 +24,12 @@ <!-- LoginActivity --> <string name="login_username">Username</string> <string name="login_password">Password</string> + <string name="login_url">Server URL</string> <string name="login_login">Login</string> <string name="login_username_missing">Username is missing</string> <string name="login_password_missing">Password is missing</string> + <string name="login_url_missing">Server URL is missing</string> <string name="login_login_failed">Login failed</string> <!-- UnitsActivity --> |