feat: Add native Android driver tracking app and real-time backend/frontend bus tracking system
This commit is contained in:
43
rit-driver-app/app/src/main/AndroidManifest.xml
Normal file
43
rit-driver-app/app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- Location Permissions -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
||||
|
||||
<!-- Foreground Service Permissions -->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
|
||||
|
||||
<!-- Wakelock and Network Permissions -->
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
|
||||
android:usesCleartextTraffic="true">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".TrackingService"
|
||||
android:enabled="true"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="location" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.rit.driver;
|
||||
|
||||
public class Config {
|
||||
// Replace this with your VPS public IP address or production domain name
|
||||
public static final String BACKEND_URL = "http://15.206.182.201:8085";
|
||||
|
||||
// Default driver security PIN
|
||||
public static final String DEFAULT_PIN = "RITDRIVER";
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
package com.rit.driver;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private static final int PERMISSION_REQUEST_CODE = 888;
|
||||
|
||||
private EditText etRouteNumber;
|
||||
private EditText etDriverPin;
|
||||
private Button btnStartSharing;
|
||||
private Button btnStopSharing;
|
||||
private TextView tvStatusHeader;
|
||||
private TextView tvStatusLogs;
|
||||
private LinearLayout statusCard;
|
||||
|
||||
private boolean isServiceRunning = false;
|
||||
|
||||
// Receive tracking updates from Foreground Service
|
||||
private final BroadcastReceiver locationReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent != null) {
|
||||
if (intent.hasExtra(TrackingService.EXTRA_STATUS)) {
|
||||
String status = intent.getStringExtra(TrackingService.EXTRA_STATUS);
|
||||
tvStatusHeader.setText("STATUS: " + (isServiceRunning ? "ACTIVE" : "INACTIVE"));
|
||||
logStatus(status);
|
||||
}
|
||||
|
||||
if (intent.hasExtra(TrackingService.EXTRA_LATITUDE) && intent.hasExtra(TrackingService.EXTRA_LONGITUDE)) {
|
||||
double lat = intent.getDoubleExtra(TrackingService.EXTRA_LATITUDE, 0.0);
|
||||
double lng = intent.getDoubleExtra(TrackingService.EXTRA_LONGITUDE, 0.0);
|
||||
float accuracy = intent.getFloatExtra(TrackingService.EXTRA_ACCURACY, 0.0f);
|
||||
|
||||
String gpsInfo = String.format("GPS Coords: %.6f, %.6f\nAccuracy: ±%.1fm", lat, lng, accuracy);
|
||||
logStatus(gpsInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
// Bind Views
|
||||
etRouteNumber = findViewById(R.id.etRouteNumber);
|
||||
etDriverPin = findViewById(R.id.etDriverPin);
|
||||
etDriverPin.setText(Config.DEFAULT_PIN);
|
||||
btnStartSharing = findViewById(R.id.btnStartSharing);
|
||||
btnStopSharing = findViewById(R.id.btnStopSharing);
|
||||
tvStatusHeader = findViewById(R.id.tvStatusHeader);
|
||||
tvStatusLogs = findViewById(R.id.tvStatusLogs);
|
||||
statusCard = findViewById(R.id.statusCard);
|
||||
|
||||
btnStartSharing.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (checkAndRequestPermissions()) {
|
||||
startTracking();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btnStopSharing.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
stopTracking();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
// Register receiver for service communication
|
||||
IntentFilter filter = new IntentFilter(TrackingService.ACTION_LOCATION_BROADCAST);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
registerReceiver(locationReceiver, filter, Context.RECEIVER_NOT_EXPORTED);
|
||||
} else {
|
||||
registerReceiver(locationReceiver, filter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
// Unregister receiver
|
||||
unregisterReceiver(locationReceiver);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
private void startTracking() {
|
||||
String serverUrl = Config.BACKEND_URL;
|
||||
String routeNumber = etRouteNumber.getText().toString().trim();
|
||||
String driverPin = etDriverPin.getText().toString().trim();
|
||||
if (routeNumber.isEmpty()) {
|
||||
Toast.makeText(this, "Enter bus route number", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (driverPin.isEmpty()) {
|
||||
Toast.makeText(this, "Enter security driver PIN", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
Intent serviceIntent = new Intent(this, TrackingService.class);
|
||||
serviceIntent.putExtra("server_url", serverUrl);
|
||||
serviceIntent.putExtra("route_number", routeNumber);
|
||||
serviceIntent.putExtra("driver_pin", driverPin);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
startForegroundService(serviceIntent);
|
||||
} else {
|
||||
startService(serviceIntent);
|
||||
}
|
||||
|
||||
isServiceRunning = true;
|
||||
btnStartSharing.setVisibility(View.GONE);
|
||||
btnStopSharing.setVisibility(View.VISIBLE);
|
||||
tvStatusHeader.setText("STATUS: ACTIVE");
|
||||
logStatus("Foreground tracking service started.");
|
||||
}
|
||||
|
||||
private void stopTracking() {
|
||||
Intent serviceIntent = new Intent(this, TrackingService.class);
|
||||
stopService(serviceIntent);
|
||||
|
||||
isServiceRunning = false;
|
||||
btnStartSharing.setVisibility(View.VISIBLE);
|
||||
btnStopSharing.setVisibility(View.GONE);
|
||||
tvStatusHeader.setText("STATUS: INACTIVE");
|
||||
logStatus("Tracking stopped by driver.");
|
||||
}
|
||||
|
||||
private void logStatus(String msg) {
|
||||
String currentText = tvStatusLogs.getText().toString();
|
||||
tvStatusLogs.setText(msg + "\n\n" + currentText);
|
||||
}
|
||||
|
||||
private boolean checkAndRequestPermissions() {
|
||||
boolean hasFine = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
||||
boolean hasCoarse = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
||||
|
||||
List<String> listPermissionsNeeded = new ArrayList<>();
|
||||
|
||||
if (!hasFine && !hasCoarse) {
|
||||
listPermissionsNeeded.add(Manifest.permission.ACCESS_FINE_LOCATION);
|
||||
listPermissionsNeeded.add(Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.POST_NOTIFICATIONS);
|
||||
}
|
||||
}
|
||||
|
||||
if (!listPermissionsNeeded.isEmpty()) {
|
||||
ActivityCompat.requestPermissions(
|
||||
this,
|
||||
listPermissionsNeeded.toArray(new String[0]),
|
||||
PERMISSION_REQUEST_CODE
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == PERMISSION_REQUEST_CODE) {
|
||||
boolean hasFine = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
||||
boolean hasCoarse = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
||||
|
||||
if (hasFine || hasCoarse) {
|
||||
startTracking();
|
||||
} else {
|
||||
Toast.makeText(this, "Location permission (Precise or Approximate) is required to track the bus.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.rit.driver;
|
||||
|
||||
import android.util.Log;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class NetworkHelper {
|
||||
|
||||
private static final String TAG = "NetworkHelper";
|
||||
|
||||
public interface Callback {
|
||||
void onSuccess();
|
||||
void onFailure(String error);
|
||||
}
|
||||
|
||||
public static void postLocation(final String serverUrl, final String routeNumber, final double lat, final double lng, final String pin, final Callback callback) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
HttpURLConnection conn = null;
|
||||
try {
|
||||
// Clean URL trailing slash and route mapping
|
||||
String cleanUrl = serverUrl;
|
||||
if (cleanUrl.endsWith("/")) {
|
||||
cleanUrl = cleanUrl.substring(0, cleanUrl.length() - 1);
|
||||
}
|
||||
String targetUrl = cleanUrl + "/api/bus-locations/" + routeNumber;
|
||||
|
||||
URL url = new URL(targetUrl);
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setRequestProperty("Content-Type", "application/json");
|
||||
conn.setDoOutput(true);
|
||||
conn.setConnectTimeout(8000);
|
||||
conn.setReadTimeout(8000);
|
||||
|
||||
// Build JSON string payload
|
||||
String jsonInputString = String.format(
|
||||
"{\"latitude\": %f, \"longitude\": %f, \"pin\": \"%s\"}",
|
||||
lat, lng, pin
|
||||
);
|
||||
|
||||
try (OutputStream os = conn.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
|
||||
int code = conn.getResponseCode();
|
||||
if (code == 200 || code == 201) {
|
||||
Log.d(TAG, "Location uploaded successfully: " + code);
|
||||
if (callback != null) {
|
||||
callback.onSuccess();
|
||||
}
|
||||
} else {
|
||||
String errMsg = "HTTP error code " + code;
|
||||
Log.w(TAG, errMsg);
|
||||
if (callback != null) {
|
||||
callback.onFailure(errMsg);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String errMsg = "Upload failed: " + e.getMessage();
|
||||
Log.e(TAG, errMsg, e);
|
||||
if (callback != null) {
|
||||
callback.onFailure(errMsg);
|
||||
}
|
||||
} finally {
|
||||
if (conn != null) {
|
||||
conn.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.rit.driver;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.PowerManager;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
public class TrackingService extends Service {
|
||||
|
||||
private static final String TAG = "TrackingService";
|
||||
private static final String CHANNEL_ID = "TrackingServiceChannel";
|
||||
private static final int NOTIFICATION_ID = 444;
|
||||
|
||||
private LocationManager locationManager;
|
||||
private PowerManager.WakeLock wakeLock;
|
||||
|
||||
private String serverUrl = "";
|
||||
private String routeNumber = "";
|
||||
private String driverPin = "";
|
||||
|
||||
// Broadcast action for MainActivity to update UI coordinates
|
||||
public static final String ACTION_LOCATION_BROADCAST = "com.rit.driver.LOCATION_BROADCAST";
|
||||
public static final String EXTRA_LATITUDE = "extra_latitude";
|
||||
public static final String EXTRA_LONGITUDE = "extra_longitude";
|
||||
public static final String EXTRA_ACCURACY = "extra_accuracy";
|
||||
public static final String EXTRA_STATUS = "extra_status";
|
||||
|
||||
private final LocationListener locationListener = new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
double lat = location.getLatitude();
|
||||
double lng = location.getLongitude();
|
||||
float accuracy = location.getAccuracy();
|
||||
|
||||
Log.d(TAG, "Location updated: " + lat + ", " + lng + " (Accuracy: " + accuracy + "m)");
|
||||
|
||||
// Broadcast updates locally to MainActivity UI
|
||||
Intent broadcastIntent = new Intent(ACTION_LOCATION_BROADCAST);
|
||||
broadcastIntent.putExtra(EXTRA_LATITUDE, lat);
|
||||
broadcastIntent.putExtra(EXTRA_LONGITUDE, lng);
|
||||
broadcastIntent.putExtra(EXTRA_ACCURACY, accuracy);
|
||||
broadcastIntent.putExtra(EXTRA_STATUS, "Broadcasting Location...");
|
||||
sendBroadcast(broadcastIntent);
|
||||
|
||||
// Upload location to backend
|
||||
NetworkHelper.postLocation(serverUrl, routeNumber, lat, lng, driverPin, new NetworkHelper.Callback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.d(TAG, "Uploaded location successfully");
|
||||
Intent statusIntent = new Intent(ACTION_LOCATION_BROADCAST);
|
||||
statusIntent.putExtra(EXTRA_STATUS, "Upload Success: Location synced.");
|
||||
sendBroadcast(statusIntent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String error) {
|
||||
Log.e(TAG, "Upload failed: " + error);
|
||||
Intent statusIntent = new Intent(ACTION_LOCATION_BROADCAST);
|
||||
statusIntent.putExtra(EXTRA_STATUS, "Upload Failed: " + error);
|
||||
sendBroadcast(statusIntent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
Intent statusIntent = new Intent(ACTION_LOCATION_BROADCAST);
|
||||
statusIntent.putExtra(EXTRA_STATUS, "GPS Provider Disabled. Please turn on Location/GPS.");
|
||||
sendBroadcast(statusIntent);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Log.d(TAG, "onCreate: Service starting");
|
||||
createNotificationChannel();
|
||||
}
|
||||
|
||||
@SuppressLint("InvalidWakeLockTag")
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.d(TAG, "onStartCommand: Service active");
|
||||
|
||||
if (intent != null) {
|
||||
serverUrl = intent.getStringExtra("server_url");
|
||||
routeNumber = intent.getStringExtra("route_number");
|
||||
driverPin = intent.getStringExtra("driver_pin");
|
||||
}
|
||||
|
||||
// 1. Show Foreground Notification
|
||||
Intent notificationIntent = new Intent(this, MainActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(
|
||||
this, 0, notificationIntent,
|
||||
PendingIntent.FLAG_IMMUTABLE
|
||||
);
|
||||
|
||||
Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
|
||||
.setContentTitle("RIT Driver Tracker")
|
||||
.setContentText("Active Journey: Route " + routeNumber + " is currently tracking...")
|
||||
.setSmallIcon(android.R.drawable.ic_menu_compass)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
.build();
|
||||
|
||||
startForeground(NOTIFICATION_ID, notification);
|
||||
|
||||
// 2. Acquire Power CPU WakeLock
|
||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
if (pm != null) {
|
||||
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "TrackingService::WakeLock");
|
||||
wakeLock.acquire();
|
||||
Log.d(TAG, "WakeLock acquired successfully");
|
||||
}
|
||||
|
||||
// 3. Register GPS location listener
|
||||
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
try {
|
||||
if (locationManager != null) {
|
||||
// Request updates every 5 seconds (5000ms) or 2 meters
|
||||
locationManager.requestLocationUpdates(
|
||||
LocationManager.GPS_PROVIDER,
|
||||
5000,
|
||||
2.0f,
|
||||
locationListener
|
||||
);
|
||||
Log.d(TAG, "GPS Listener registered successfully");
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
Log.e(TAG, "SecurityException: Location permissions not granted", e);
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
return START_REDELIVER_INTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
Log.d(TAG, "onDestroy: Stopping service cleanups");
|
||||
|
||||
// 1. Remove GPS Listener
|
||||
if (locationManager != null) {
|
||||
locationManager.removeUpdates(locationListener);
|
||||
}
|
||||
|
||||
// 2. Release CPU WakeLock
|
||||
if (wakeLock != null && wakeLock.isHeld()) {
|
||||
wakeLock.release();
|
||||
Log.d(TAG, "WakeLock released cleanly");
|
||||
}
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void createNotificationChannel() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel serviceChannel = new NotificationChannel(
|
||||
CHANNEL_ID,
|
||||
"RIT Driver Tracker Channel",
|
||||
NotificationManager.IMPORTANCE_DEFAULT
|
||||
);
|
||||
NotificationManager manager = getSystemService(NotificationManager.class);
|
||||
if (manager != null) {
|
||||
manager.createNotificationChannel(serviceChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
rit-driver-app/app/src/main/res/drawable/ic_launcher.xml
Normal file
12
rit-driver-app/app/src/main/res/drawable/ic_launcher.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#1E293B"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#F97316"
|
||||
android:pathData="M54,20 C35.22,20 20,35.22 20,54 C20,72.78 35.22,88 54,88 C72.78,88 88,72.78 88,54 C88,35.22 72.78,20 54,20 Z M54,76 C41.85,76 32,66.15 32,54 C32,41.85 41.85,32 54,32 C66.15,32 76,41.85 76,54 C76,66.15 66.15,76 54,76 Z M54,40 L60,54 L54,68 L48,54 Z" />
|
||||
</vector>
|
||||
148
rit-driver-app/app/src/main/res/layout/activity_main.xml
Normal file
148
rit-driver-app/app/src/main/res/layout/activity_main.xml
Normal file
@@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true"
|
||||
android:background="#1E293B">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp">
|
||||
|
||||
<!-- Title -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="RIT Driver Tracker"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="28sp"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginBottom="8dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Live Background Geolocation Broadcaster"
|
||||
android:textColor="#94A3B8"
|
||||
android:textSize="12sp"
|
||||
android:gravity="center"
|
||||
android:layout_marginBottom="32dp" />
|
||||
|
||||
|
||||
|
||||
<!-- Route Number Input -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="BUS ROUTE NUMBER"
|
||||
android:textColor="#94A3B8"
|
||||
android:textSize="11sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="6dp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etRouteNumber"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp"
|
||||
android:background="@android:drawable/editbox_background"
|
||||
android:hint="R01"
|
||||
android:text="R01"
|
||||
android:inputType="textCapCharacters"
|
||||
android:padding="12dp"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginBottom="20dp" />
|
||||
|
||||
<!-- Driver PIN Input -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="DRIVER SECURITY PIN"
|
||||
android:textColor="#94A3B8"
|
||||
android:textSize="11sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="6dp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etDriverPin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp"
|
||||
android:background="@android:drawable/editbox_background"
|
||||
android:hint="Enter Security PIN"
|
||||
android:text="RITDRIVER"
|
||||
android:inputType="textPassword"
|
||||
android:padding="12dp"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginBottom="32dp" />
|
||||
|
||||
<!-- Start Sharing Button -->
|
||||
<Button
|
||||
android:id="@+id/btnStartSharing"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:backgroundTint="#F97316"
|
||||
android:text="START LOCATION SHARING"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textStyle="bold"
|
||||
android:textSize="15sp"
|
||||
android:layout_marginBottom="16dp" />
|
||||
|
||||
<!-- Stop Sharing Button -->
|
||||
<Button
|
||||
android:id="@+id/btnStopSharing"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:backgroundTint="#EF4444"
|
||||
android:text="STOP LOCATION SHARING"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textStyle="bold"
|
||||
android:textSize="15sp"
|
||||
android:visibility="gone"
|
||||
android:layout_marginBottom="24dp" />
|
||||
|
||||
<!-- Status Card -->
|
||||
<LinearLayout
|
||||
android:id="@+id/statusCard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="#0F172A"
|
||||
android:padding="16dp"
|
||||
android:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvStatusHeader"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="STATUS: INACTIVE"
|
||||
android:textColor="#94A3B8"
|
||||
android:textStyle="bold"
|
||||
android:textSize="12sp"
|
||||
android:layout_marginBottom="8dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvStatusLogs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Toggle location sharing to begin tracking.\nKeep phone screen turned on or off — the app will broadcast fine coordinates in the background."
|
||||
android:textColor="#64748B"
|
||||
android:textSize="12sp"
|
||||
android:lineSpacingExtra="3dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Keep screen notice -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Notice: Once active, you can lock the screen or close the app interface. The native system foreground notification service keeps tracking alive."
|
||||
android:textColor="#64748B"
|
||||
android:textSize="10sp"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginBottom="24dp" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
3
rit-driver-app/app/src/main/res/values/strings.xml
Normal file
3
rit-driver-app/app/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">RIT Driver Tracker</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user