From ba9dab4e26c62865f40c10a3b679e138c862f98e Mon Sep 17 00:00:00 2001 From: Philipp0002 Date: Mon, 29 Jul 2024 17:12:46 +0200 Subject: [PATCH] Code refactor --- app/src/main/AndroidManifest.xml | 4 ++-- .../xadgps_client/background/NotificationWorker.java | 4 ++-- .../de/raffaelhahn/xadgps_client/{ => model}/Device.java | 9 ++------- .../xadgps_client/{ => model}/NotifyDevice.java | 3 +-- .../xadgps_client/{ => model}/OperatingMode.java | 2 +- .../xadgps_client/services/DeviceListService.java | 4 ++-- .../xadgps_client/services/MovementMonitorService.java | 4 ++-- .../xadgps_client/{ => ui}/DeviceInfoSheet.java | 6 ++++-- .../xadgps_client/{ => ui}/DevicesFragment.java | 7 +++---- .../xadgps_client/{ => ui}/DevicesRecyclerAdapter.java | 5 ++++- .../xadgps_client/{ => ui}/LoginActivity.java | 5 ++++- .../raffaelhahn/xadgps_client/{ => ui}/MainActivity.java | 4 +++- .../xadgps_client/{ => ui}/TrackingFragment.java | 5 ++++- app/src/main/res/layout/activity_login.xml | 2 +- app/src/main/res/layout/activity_main.xml | 2 +- app/src/main/res/layout/fragment_devices.xml | 2 +- app/src/main/res/layout/fragment_tracking.xml | 2 +- 17 files changed, 38 insertions(+), 32 deletions(-) rename app/src/main/java/de/raffaelhahn/xadgps_client/{ => model}/Device.java (88%) rename app/src/main/java/de/raffaelhahn/xadgps_client/{ => model}/NotifyDevice.java (96%) rename app/src/main/java/de/raffaelhahn/xadgps_client/{ => model}/OperatingMode.java (91%) rename app/src/main/java/de/raffaelhahn/xadgps_client/{ => ui}/DeviceInfoSheet.java (97%) rename app/src/main/java/de/raffaelhahn/xadgps_client/{ => ui}/DevicesFragment.java (95%) rename app/src/main/java/de/raffaelhahn/xadgps_client/{ => ui}/DevicesRecyclerAdapter.java (95%) rename app/src/main/java/de/raffaelhahn/xadgps_client/{ => ui}/LoginActivity.java (95%) rename app/src/main/java/de/raffaelhahn/xadgps_client/{ => ui}/MainActivity.java (96%) rename app/src/main/java/de/raffaelhahn/xadgps_client/{ => ui}/TrackingFragment.java (98%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index dbdc2f1..f780034 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -21,10 +21,10 @@ android:name=".XADGPSApplication" tools:targetApi="31"> diff --git a/app/src/main/java/de/raffaelhahn/xadgps_client/background/NotificationWorker.java b/app/src/main/java/de/raffaelhahn/xadgps_client/background/NotificationWorker.java index d91a95a..2be5b1b 100644 --- a/app/src/main/java/de/raffaelhahn/xadgps_client/background/NotificationWorker.java +++ b/app/src/main/java/de/raffaelhahn/xadgps_client/background/NotificationWorker.java @@ -21,8 +21,8 @@ import java.util.Optional; import java.util.stream.Collectors; -import de.raffaelhahn.xadgps_client.NotifyDevice; -import de.raffaelhahn.xadgps_client.OperatingMode; +import de.raffaelhahn.xadgps_client.model.NotifyDevice; +import de.raffaelhahn.xadgps_client.model.OperatingMode; import de.raffaelhahn.xadgps_client.R; import de.raffaelhahn.xadgps_client.Constants; import de.raffaelhahn.xadgps_client.async.GetDeviceListAsync; diff --git a/app/src/main/java/de/raffaelhahn/xadgps_client/Device.java b/app/src/main/java/de/raffaelhahn/xadgps_client/model/Device.java similarity index 88% rename from app/src/main/java/de/raffaelhahn/xadgps_client/Device.java rename to app/src/main/java/de/raffaelhahn/xadgps_client/model/Device.java index 6c37033..23adea1 100644 --- a/app/src/main/java/de/raffaelhahn/xadgps_client/Device.java +++ b/app/src/main/java/de/raffaelhahn/xadgps_client/model/Device.java @@ -1,13 +1,8 @@ -package de.raffaelhahn.xadgps_client; +package de.raffaelhahn.xadgps_client.model; import android.content.Context; -import android.util.Log; -import org.json.JSONException; -import org.json.JSONObject; - -import java.lang.reflect.Field; -import java.util.Iterator; +import de.raffaelhahn.xadgps_client.R; public class Device extends NotifyDevice { public String sn; diff --git a/app/src/main/java/de/raffaelhahn/xadgps_client/NotifyDevice.java b/app/src/main/java/de/raffaelhahn/xadgps_client/model/NotifyDevice.java similarity index 96% rename from app/src/main/java/de/raffaelhahn/xadgps_client/NotifyDevice.java rename to app/src/main/java/de/raffaelhahn/xadgps_client/model/NotifyDevice.java index ac4034d..8214f66 100644 --- a/app/src/main/java/de/raffaelhahn/xadgps_client/NotifyDevice.java +++ b/app/src/main/java/de/raffaelhahn/xadgps_client/model/NotifyDevice.java @@ -1,6 +1,5 @@ -package de.raffaelhahn.xadgps_client; +package de.raffaelhahn.xadgps_client.model; -import android.content.Context; import android.util.Log; import org.json.JSONObject; diff --git a/app/src/main/java/de/raffaelhahn/xadgps_client/OperatingMode.java b/app/src/main/java/de/raffaelhahn/xadgps_client/model/OperatingMode.java similarity index 91% rename from app/src/main/java/de/raffaelhahn/xadgps_client/OperatingMode.java rename to app/src/main/java/de/raffaelhahn/xadgps_client/model/OperatingMode.java index af57ceb..eb2f446 100644 --- a/app/src/main/java/de/raffaelhahn/xadgps_client/OperatingMode.java +++ b/app/src/main/java/de/raffaelhahn/xadgps_client/model/OperatingMode.java @@ -1,4 +1,4 @@ -package de.raffaelhahn.xadgps_client; +package de.raffaelhahn.xadgps_client.model; public enum OperatingMode { diff --git a/app/src/main/java/de/raffaelhahn/xadgps_client/services/DeviceListService.java b/app/src/main/java/de/raffaelhahn/xadgps_client/services/DeviceListService.java index 8f48312..ba66154 100644 --- a/app/src/main/java/de/raffaelhahn/xadgps_client/services/DeviceListService.java +++ b/app/src/main/java/de/raffaelhahn/xadgps_client/services/DeviceListService.java @@ -12,8 +12,8 @@ import java.util.Timer; import java.util.TimerTask; -import de.raffaelhahn.xadgps_client.Device; -import de.raffaelhahn.xadgps_client.OperatingMode; +import de.raffaelhahn.xadgps_client.model.Device; +import de.raffaelhahn.xadgps_client.model.OperatingMode; import de.raffaelhahn.xadgps_client.async.AsyncCallback; import de.raffaelhahn.xadgps_client.Constants; import de.raffaelhahn.xadgps_client.async.GetDeviceListAsync; diff --git a/app/src/main/java/de/raffaelhahn/xadgps_client/services/MovementMonitorService.java b/app/src/main/java/de/raffaelhahn/xadgps_client/services/MovementMonitorService.java index 3a164ca..a2e2c63 100644 --- a/app/src/main/java/de/raffaelhahn/xadgps_client/services/MovementMonitorService.java +++ b/app/src/main/java/de/raffaelhahn/xadgps_client/services/MovementMonitorService.java @@ -3,8 +3,8 @@ import android.app.Activity; import androidx.core.app.ActivityCompat; -import de.raffaelhahn.xadgps_client.Device; -import de.raffaelhahn.xadgps_client.NotifyDevice; +import de.raffaelhahn.xadgps_client.model.Device; +import de.raffaelhahn.xadgps_client.model.NotifyDevice; import de.raffaelhahn.xadgps_client.R; import de.raffaelhahn.xadgps_client.Constants; import de.raffaelhahn.xadgps_client.background.BackgroundWorkService; diff --git a/app/src/main/java/de/raffaelhahn/xadgps_client/DeviceInfoSheet.java b/app/src/main/java/de/raffaelhahn/xadgps_client/ui/DeviceInfoSheet.java similarity index 97% rename from app/src/main/java/de/raffaelhahn/xadgps_client/DeviceInfoSheet.java rename to app/src/main/java/de/raffaelhahn/xadgps_client/ui/DeviceInfoSheet.java index 9aabd36..36eae56 100644 --- a/app/src/main/java/de/raffaelhahn/xadgps_client/DeviceInfoSheet.java +++ b/app/src/main/java/de/raffaelhahn/xadgps_client/ui/DeviceInfoSheet.java @@ -1,7 +1,6 @@ -package de.raffaelhahn.xadgps_client; +package de.raffaelhahn.xadgps_client.ui; import android.os.Bundle; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -18,6 +17,9 @@ import java.util.ArrayList; import java.util.Optional; +import de.raffaelhahn.xadgps_client.R; +import de.raffaelhahn.xadgps_client.Utils; +import de.raffaelhahn.xadgps_client.model.Device; import de.raffaelhahn.xadgps_client.services.DeviceListService; import de.raffaelhahn.xadgps_client.services.MovementMonitorService; diff --git a/app/src/main/java/de/raffaelhahn/xadgps_client/DevicesFragment.java b/app/src/main/java/de/raffaelhahn/xadgps_client/ui/DevicesFragment.java similarity index 95% rename from app/src/main/java/de/raffaelhahn/xadgps_client/DevicesFragment.java rename to app/src/main/java/de/raffaelhahn/xadgps_client/ui/DevicesFragment.java index 0da9f22..3782b2d 100644 --- a/app/src/main/java/de/raffaelhahn/xadgps_client/DevicesFragment.java +++ b/app/src/main/java/de/raffaelhahn/xadgps_client/ui/DevicesFragment.java @@ -1,4 +1,4 @@ -package de.raffaelhahn.xadgps_client; +package de.raffaelhahn.xadgps_client.ui; import android.os.Bundle; @@ -12,11 +12,10 @@ import android.view.View; import android.view.ViewGroup; -import org.osmdroid.util.GeoPoint; -import org.osmdroid.views.overlay.Marker; - import java.util.ArrayList; +import de.raffaelhahn.xadgps_client.R; +import de.raffaelhahn.xadgps_client.model.Device; import de.raffaelhahn.xadgps_client.services.DeviceListService; public class DevicesFragment extends Fragment implements DeviceListService.DeviceListUpdateListener { diff --git a/app/src/main/java/de/raffaelhahn/xadgps_client/DevicesRecyclerAdapter.java b/app/src/main/java/de/raffaelhahn/xadgps_client/ui/DevicesRecyclerAdapter.java similarity index 95% rename from app/src/main/java/de/raffaelhahn/xadgps_client/DevicesRecyclerAdapter.java rename to app/src/main/java/de/raffaelhahn/xadgps_client/ui/DevicesRecyclerAdapter.java index 0d6a819..3da2101 100644 --- a/app/src/main/java/de/raffaelhahn/xadgps_client/DevicesRecyclerAdapter.java +++ b/app/src/main/java/de/raffaelhahn/xadgps_client/ui/DevicesRecyclerAdapter.java @@ -1,4 +1,4 @@ -package de.raffaelhahn.xadgps_client; +package de.raffaelhahn.xadgps_client.ui; import android.view.LayoutInflater; import android.view.View; @@ -9,6 +9,9 @@ import java.util.ArrayList; +import de.raffaelhahn.xadgps_client.R; +import de.raffaelhahn.xadgps_client.model.Device; + public class DevicesRecyclerAdapter extends RecyclerView.Adapter { private ArrayList deviceList = new ArrayList<>(); diff --git a/app/src/main/java/de/raffaelhahn/xadgps_client/LoginActivity.java b/app/src/main/java/de/raffaelhahn/xadgps_client/ui/LoginActivity.java similarity index 95% rename from app/src/main/java/de/raffaelhahn/xadgps_client/LoginActivity.java rename to app/src/main/java/de/raffaelhahn/xadgps_client/ui/LoginActivity.java index edb4a99..f90944a 100644 --- a/app/src/main/java/de/raffaelhahn/xadgps_client/LoginActivity.java +++ b/app/src/main/java/de/raffaelhahn/xadgps_client/ui/LoginActivity.java @@ -1,4 +1,4 @@ -package de.raffaelhahn.xadgps_client; +package de.raffaelhahn.xadgps_client.ui; import androidx.appcompat.app.AppCompatActivity; @@ -14,8 +14,11 @@ import java.util.Locale; +import de.raffaelhahn.xadgps_client.Constants; +import de.raffaelhahn.xadgps_client.R; import de.raffaelhahn.xadgps_client.async.AsyncCallback; import de.raffaelhahn.xadgps_client.async.LoginAsync; +import de.raffaelhahn.xadgps_client.model.OperatingMode; public class LoginActivity extends AppCompatActivity { diff --git a/app/src/main/java/de/raffaelhahn/xadgps_client/MainActivity.java b/app/src/main/java/de/raffaelhahn/xadgps_client/ui/MainActivity.java similarity index 96% rename from app/src/main/java/de/raffaelhahn/xadgps_client/MainActivity.java rename to app/src/main/java/de/raffaelhahn/xadgps_client/ui/MainActivity.java index de543e9..189b4fb 100644 --- a/app/src/main/java/de/raffaelhahn/xadgps_client/MainActivity.java +++ b/app/src/main/java/de/raffaelhahn/xadgps_client/ui/MainActivity.java @@ -1,4 +1,4 @@ -package de.raffaelhahn.xadgps_client; +package de.raffaelhahn.xadgps_client.ui; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; @@ -14,6 +14,8 @@ import org.osmdroid.config.Configuration; +import de.raffaelhahn.xadgps_client.Constants; +import de.raffaelhahn.xadgps_client.R; import de.raffaelhahn.xadgps_client.services.DeviceListService; public class MainActivity extends AppCompatActivity { diff --git a/app/src/main/java/de/raffaelhahn/xadgps_client/TrackingFragment.java b/app/src/main/java/de/raffaelhahn/xadgps_client/ui/TrackingFragment.java similarity index 98% rename from app/src/main/java/de/raffaelhahn/xadgps_client/TrackingFragment.java rename to app/src/main/java/de/raffaelhahn/xadgps_client/ui/TrackingFragment.java index 151e2ca..acb3f74 100644 --- a/app/src/main/java/de/raffaelhahn/xadgps_client/TrackingFragment.java +++ b/app/src/main/java/de/raffaelhahn/xadgps_client/ui/TrackingFragment.java @@ -1,4 +1,4 @@ -package de.raffaelhahn.xadgps_client; +package de.raffaelhahn.xadgps_client.ui; import android.Manifest; import android.content.Context; @@ -31,6 +31,9 @@ import java.util.ArrayList; +import de.raffaelhahn.xadgps_client.Constants; +import de.raffaelhahn.xadgps_client.R; +import de.raffaelhahn.xadgps_client.model.Device; import de.raffaelhahn.xadgps_client.services.DeviceListService; public class TrackingFragment extends Fragment implements DeviceListService.DeviceListUpdateListener { diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index dfbb686..d36ba91 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -6,7 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:padding="32dp" - tools:context=".LoginActivity"> + tools:context=".ui.LoginActivity"> + tools:context=".ui.MainActivity"> + tools:context=".ui.TrackingFragment">