diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 000000000..26d33521a
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/caches/deviceStreaming.xml b/.idea/caches/deviceStreaming.xml
new file mode 100644
index 000000000..2cfab2209
--- /dev/null
+++ b/.idea/caches/deviceStreaming.xml
@@ -0,0 +1,1358 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/deviceManager.xml b/.idea/deviceManager.xml
new file mode 100644
index 000000000..91f95584d
--- /dev/null
+++ b/.idea/deviceManager.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/lab-05.iml b/.idea/lab-05.iml
new file mode 100644
index 000000000..d6ebd4805
--- /dev/null
+++ b/.idea/lab-05.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/markdown.xml b/.idea/markdown.xml
new file mode 100644
index 000000000..c61ea3346
--- /dev/null
+++ b/.idea/markdown.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 000000000..63c7c6e9b
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 000000000..bf2dd997c
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 000000000..35eb1ddfb
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ListyCity/.gradle/8.13/checksums/checksums.lock b/ListyCity/.gradle/8.13/checksums/checksums.lock
index bbc83c574..96744d79b 100644
Binary files a/ListyCity/.gradle/8.13/checksums/checksums.lock and b/ListyCity/.gradle/8.13/checksums/checksums.lock differ
diff --git a/ListyCity/.gradle/8.13/checksums/md5-checksums.bin b/ListyCity/.gradle/8.13/checksums/md5-checksums.bin
new file mode 100644
index 000000000..e729076e9
Binary files /dev/null and b/ListyCity/.gradle/8.13/checksums/md5-checksums.bin differ
diff --git a/ListyCity/.gradle/8.13/checksums/sha1-checksums.bin b/ListyCity/.gradle/8.13/checksums/sha1-checksums.bin
new file mode 100644
index 000000000..e04846b9e
Binary files /dev/null and b/ListyCity/.gradle/8.13/checksums/sha1-checksums.bin differ
diff --git a/ListyCity/.gradle/8.13/executionHistory/executionHistory.bin b/ListyCity/.gradle/8.13/executionHistory/executionHistory.bin
index cb315949f..29ca5655a 100644
Binary files a/ListyCity/.gradle/8.13/executionHistory/executionHistory.bin and b/ListyCity/.gradle/8.13/executionHistory/executionHistory.bin differ
diff --git a/ListyCity/.gradle/8.13/executionHistory/executionHistory.lock b/ListyCity/.gradle/8.13/executionHistory/executionHistory.lock
index 3c4131d81..3885f1a7d 100644
Binary files a/ListyCity/.gradle/8.13/executionHistory/executionHistory.lock and b/ListyCity/.gradle/8.13/executionHistory/executionHistory.lock differ
diff --git a/ListyCity/.gradle/8.13/fileHashes/fileHashes.bin b/ListyCity/.gradle/8.13/fileHashes/fileHashes.bin
index c8f8243a6..0ac13600e 100644
Binary files a/ListyCity/.gradle/8.13/fileHashes/fileHashes.bin and b/ListyCity/.gradle/8.13/fileHashes/fileHashes.bin differ
diff --git a/ListyCity/.gradle/8.13/fileHashes/fileHashes.lock b/ListyCity/.gradle/8.13/fileHashes/fileHashes.lock
index 08f6ffb74..828173a1e 100644
Binary files a/ListyCity/.gradle/8.13/fileHashes/fileHashes.lock and b/ListyCity/.gradle/8.13/fileHashes/fileHashes.lock differ
diff --git a/ListyCity/.gradle/8.13/fileHashes/resourceHashesCache.bin b/ListyCity/.gradle/8.13/fileHashes/resourceHashesCache.bin
index 90bff000e..dc65c769c 100644
Binary files a/ListyCity/.gradle/8.13/fileHashes/resourceHashesCache.bin and b/ListyCity/.gradle/8.13/fileHashes/resourceHashesCache.bin differ
diff --git a/ListyCity/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/ListyCity/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index 10671ef5b..78aeb9175 100644
Binary files a/ListyCity/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/ListyCity/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/ListyCity/.gradle/buildOutputCleanup/outputFiles.bin b/ListyCity/.gradle/buildOutputCleanup/outputFiles.bin
index 08cae2c93..c95522c36 100644
Binary files a/ListyCity/.gradle/buildOutputCleanup/outputFiles.bin and b/ListyCity/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/ListyCity/.gradle/config.properties b/ListyCity/.gradle/config.properties
index bb27d6477..62e94d674 100644
--- a/ListyCity/.gradle/config.properties
+++ b/ListyCity/.gradle/config.properties
@@ -1,2 +1,2 @@
-#Tue Oct 07 08:20:18 MDT 2025
-java.home=/Applications/Android Studio.app/Contents/jbr/Contents/Home
+#Fri Feb 06 08:03:04 MST 2026
+java.home=C\:\\Program Files\\Android\\Android Studio\\jbr
diff --git a/ListyCity/.gradle/file-system.probe b/ListyCity/.gradle/file-system.probe
index e5f5fc419..e6c765c6c 100644
Binary files a/ListyCity/.gradle/file-system.probe and b/ListyCity/.gradle/file-system.probe differ
diff --git a/ListyCity/.idea/caches/deviceStreaming.xml b/ListyCity/.idea/caches/deviceStreaming.xml
index 2697e350f..2cfab2209 100644
--- a/ListyCity/.idea/caches/deviceStreaming.xml
+++ b/ListyCity/.idea/caches/deviceStreaming.xml
@@ -51,18 +51,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
@@ -100,6 +88,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -136,6 +160,30 @@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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -802,6 +1207,11 @@
+
+
+
+
+
@@ -827,6 +1237,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -864,6 +1286,11 @@
+
+
+
+
+
@@ -877,6 +1304,11 @@
+
+
+
+
+
@@ -890,6 +1322,11 @@
+
+
+
+
+
@@ -903,6 +1340,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ListyCity/.idea/gradle.xml b/ListyCity/.idea/gradle.xml
index 97f0a8e14..639c779c3 100644
--- a/ListyCity/.idea/gradle.xml
+++ b/ListyCity/.idea/gradle.xml
@@ -1,5 +1,6 @@
+
diff --git a/ListyCity/.idea/misc.xml b/ListyCity/.idea/misc.xml
index 74dd639e4..b2c751a35 100644
--- a/ListyCity/.idea/misc.xml
+++ b/ListyCity/.idea/misc.xml
@@ -1,4 +1,3 @@
-
diff --git a/ListyCity/.idea/studiobot.xml b/ListyCity/.idea/studiobot.xml
new file mode 100644
index 000000000..539e3b805
--- /dev/null
+++ b/ListyCity/.idea/studiobot.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ListyCity/app/build.gradle.kts b/ListyCity/app/build.gradle.kts
index 32a970b76..0614ef79c 100644
--- a/ListyCity/app/build.gradle.kts
+++ b/ListyCity/app/build.gradle.kts
@@ -1,5 +1,6 @@
plugins {
- alias(libs.plugins.android.application)
+ id("com.android.application")
+ id("com.google.gms.google-services")
}
@@ -33,11 +34,14 @@ android {
}
dependencies {
+ implementation(platform("com.google.firebase:firebase-bom:34.9.0"))
+ implementation("com.google.firebase:firebase-analytics")
implementation(libs.appcompat)
implementation(libs.material)
implementation(libs.activity)
implementation(libs.constraintlayout)
+ implementation(libs.firebase.firestore)
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
diff --git a/ListyCity/app/google-services.json b/ListyCity/app/google-services.json
new file mode 100644
index 000000000..ffcf19bfe
--- /dev/null
+++ b/ListyCity/app/google-services.json
@@ -0,0 +1,29 @@
+{
+ "project_info": {
+ "project_number": "850871245665",
+ "project_id": "listcity-73139",
+ "storage_bucket": "listcity-73139.firebasestorage.app"
+ },
+ "client": [
+ {
+ "client_info": {
+ "mobilesdk_app_id": "1:850871245665:android:657c49385d9fec2cd2c320",
+ "android_client_info": {
+ "package_name": "com.example.lab5_starter"
+ }
+ },
+ "oauth_client": [],
+ "api_key": [
+ {
+ "current_key": "AIzaSyCjz9uLZjH5fPkc-_WUeQjkt1k066ZQexM"
+ }
+ ],
+ "services": {
+ "appinvite_service": {
+ "other_platform_oauth_client": []
+ }
+ }
+ }
+ ],
+ "configuration_version": "1"
+}
\ No newline at end of file
diff --git a/ListyCity/app/src/main/java/com/example/lab5_starter/MainActivity.java b/ListyCity/app/src/main/java/com/example/lab5_starter/MainActivity.java
index c5560b544..ac1515770 100644
--- a/ListyCity/app/src/main/java/com/example/lab5_starter/MainActivity.java
+++ b/ListyCity/app/src/main/java/com/example/lab5_starter/MainActivity.java
@@ -1,17 +1,37 @@
package com.example.lab5_starter;
+import android.app.AlertDialog;
+import android.content.Context;
import android.os.Bundle;
+import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
+import android.widget.Toast;
import androidx.activity.EdgeToEdge;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
+
+import com.google.android.gms.tasks.OnFailureListener;
+import com.google.android.gms.tasks.OnSuccessListener;
+import com.google.firebase.Firebase;
+import com.google.firebase.firestore.CollectionReference;
+import com.google.firebase.firestore.DocumentReference;
+import com.google.firebase.firestore.DocumentSnapshot;
+import com.google.firebase.firestore.EventListener;
+import com.google.firebase.firestore.FirebaseFirestore;
+import com.google.firebase.firestore.FirebaseFirestoreException;
+import com.google.firebase.firestore.QueryDocumentSnapshot;
+import com.google.firebase.firestore.QuerySnapshot;
+
import java.util.ArrayList;
+import java.util.HashMap;
public class MainActivity extends AppCompatActivity implements CityDialogFragment.CityDialogListener {
@@ -21,6 +41,9 @@ public class MainActivity extends AppCompatActivity implements CityDialogFragmen
private ArrayList cityArrayList;
private ArrayAdapter cityArrayAdapter;
+ private FirebaseFirestore db;
+ private CollectionReference citiesRef;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -41,7 +64,32 @@ protected void onCreate(Bundle savedInstanceState) {
cityArrayAdapter = new CityArrayAdapter(this, cityArrayList);
cityListView.setAdapter(cityArrayAdapter);
- addDummyData();
+ db = FirebaseFirestore.getInstance();
+ citiesRef = db.collection("cities");
+
+ citiesRef.addSnapshotListener((value, error) -> {
+ if (error != null) {
+ Log.e("Firestore", error.toString());
+ return;
+ }
+
+ if (value != null && !value.isEmpty()) {
+ cityArrayList.clear();
+
+ for (QueryDocumentSnapshot snapshot : value) {
+ String name = snapshot.getString("name");
+ String province = snapshot.getString("province");
+
+ cityArrayList.add(new City(name, province));
+ }
+
+ cityArrayAdapter.notifyDataSetChanged();
+ }
+ });
+
+
+
+
// set listeners
addCityButton.setOnClickListener(view -> {
@@ -55,29 +103,53 @@ protected void onCreate(Bundle savedInstanceState) {
cityDialogFragment.show(getSupportFragmentManager(),"City Details");
});
+ cityListView.setOnItemLongClickListener((parent, view, position, id) -> {
+ City city = cityArrayList.get(position);
+ new AlertDialog.Builder(MainActivity.this)
+ .setTitle("Delete City")
+ .setMessage("Are you sure you want to delete this city?")
+ .setPositiveButton("Yes", (dialog, which) -> {
+ deleteCity(city);
+ })
+ .setNegativeButton("No", (dialog, which) -> {
+ dialog.dismiss();
+ })
+ .show();
+
+ return true;
+ });
+
}
@Override
public void updateCity(City city, String title, String year) {
- city.setName(title);
- city.setProvince(year);
- cityArrayAdapter.notifyDataSetChanged();
+ deleteCity(city);
+ addCity(new City (title, year));
- // Updating the database using delete + addition
}
@Override
- public void addCity(City city){
+ public void addCity(City city) {
cityArrayList.add(city);
cityArrayAdapter.notifyDataSetChanged();
+ DocumentReference docRef = citiesRef.document(city.getName());
+ docRef.set(city);
}
-
- public void addDummyData(){
- City m1 = new City("Edmonton", "AB");
- City m2 = new City("Vancouver", "BC");
- cityArrayList.add(m1);
- cityArrayList.add(m2);
- cityArrayAdapter.notifyDataSetChanged();
+ public void deleteCity(City city) {
+
+ DocumentReference docRef = citiesRef.document(city.getName());
+
+ docRef.delete()
+ .addOnSuccessListener(aVoid -> {
+ cityArrayList.remove(city);
+ cityArrayAdapter.notifyDataSetChanged();
+ Toast.makeText(this, "✓ Deleted " + city.getName(), Toast.LENGTH_SHORT).show();
+ })
+ .addOnFailureListener(e ->
+ Toast.makeText(this, "✗ Failed: " + e.getMessage(), Toast.LENGTH_SHORT).show()
+ );
}
+
+
}
\ No newline at end of file
diff --git a/ListyCity/build.gradle.kts b/ListyCity/build.gradle.kts
index 2034cf75c..6a1d73ade 100644
--- a/ListyCity/build.gradle.kts
+++ b/ListyCity/build.gradle.kts
@@ -1,5 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
+ id("com.google.gms.google-services") version "4.4.4" apply false
}
\ No newline at end of file
diff --git a/ListyCity/build/reports/problems/problems-report.html b/ListyCity/build/reports/problems/problems-report.html
index fbc8850fd..04305394d 100644
--- a/ListyCity/build/reports/problems/problems-report.html
+++ b/ListyCity/build/reports/problems/problems-report.html
@@ -650,7 +650,7 @@
diff --git a/ListyCity/gradle/libs.versions.toml b/ListyCity/gradle/libs.versions.toml
index da27b4074..9d0d5cc32 100644
--- a/ListyCity/gradle/libs.versions.toml
+++ b/ListyCity/gradle/libs.versions.toml
@@ -7,6 +7,7 @@ appcompat = "1.7.0"
material = "1.12.0"
activity = "1.10.0"
constraintlayout = "2.2.0"
+firebaseFirestore = "26.1.0"
[libraries]
junit = { group = "junit", name = "junit", version.ref = "junit" }
@@ -16,6 +17,7 @@ appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "a
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
+firebase-firestore = { group = "com.google.firebase", name = "firebase-firestore", version.ref = "firebaseFirestore" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
diff --git a/ListyCity/local.properties b/ListyCity/local.properties
index 7501004a9..132064fb1 100644
--- a/ListyCity/local.properties
+++ b/ListyCity/local.properties
@@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
-#Tue Oct 07 02:55:15 MDT 2025
-sdk.dir=/Users/re/Library/Android/sdk
+#Fri Feb 06 08:03:17 MST 2026
+sdk.dir=C\:\\Users\\sam\\AppData\\Local\\Android\\Sdk
diff --git a/README.md b/README.md
index 7f11ea160..12dfeead3 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,10 @@
## Student Details
-- **Full Name:** ``
-- **CCID:** ``
+- **Full Name:** `Sam Liu`
+- **CCID:** `Sam12`
+
+## New Function: press and hold to delete city
## References and Resources