diff --git a/ListyCity/.gradle/8.13/checksums/checksums.lock b/ListyCity/.gradle/8.13/checksums/checksums.lock
index bbc83c574..8407f1832 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..da277ab1f
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..aa2aff56f
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..cf1248032 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..c56b24e23 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..73bcfabe6 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..aceaf9acc 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..2fbb14a3f 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..2086556b0 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..e9c9f55eb 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..d67e730aa 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
+#Thu Feb 26 10:57:48 PKT 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..4fc8ca7c5 100644
Binary files a/ListyCity/.gradle/file-system.probe and b/ListyCity/.gradle/file-system.probe differ
diff --git a/ListyCity/.idea/ListyCity.iml b/ListyCity/.idea/ListyCity.iml
new file mode 100644
index 000000000..d6ebd4805
--- /dev/null
+++ b/ListyCity/.idea/ListyCity.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ListyCity/.idea/caches/deviceStreaming.xml b/ListyCity/.idea/caches/deviceStreaming.xml
index 2697e350f..28297259f 100644
--- a/ListyCity/.idea/caches/deviceStreaming.xml
+++ b/ListyCity/.idea/caches/deviceStreaming.xml
@@ -51,18 +51,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
@@ -100,6 +88,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -112,6 +148,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -136,6 +196,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -148,6 +232,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -160,6 +292,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -220,6 +412,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -227,7 +431,7 @@
-
+
@@ -256,6 +460,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -292,6 +508,11 @@
+
@@ -305,18 +526,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -366,6 +628,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -379,6 +688,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -475,6 +820,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -573,6 +930,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -621,6 +990,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -705,6 +1086,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -717,6 +1110,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -725,9 +1154,21 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -741,6 +1182,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -791,6 +1244,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -802,6 +1315,11 @@
+
+
+
+
+
@@ -827,6 +1345,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -864,6 +1394,11 @@
+
+
+
+
+
@@ -877,6 +1412,11 @@
+
+
+
+
+
@@ -890,6 +1430,11 @@
+
+
+
+
+
@@ -903,6 +1448,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/app/build.gradle.kts b/ListyCity/app/build.gradle.kts
index 32a970b76..5cafcf8d3 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.google.gms.google-services")
}
@@ -38,6 +39,8 @@ dependencies {
implementation(libs.material)
implementation(libs.activity)
implementation(libs.constraintlayout)
+ implementation(platform("com.google.firebase:firebase-bom:34.3.0"))
+ implementation("com.google.firebase: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..1fb2a7911
--- /dev/null
+++ b/ListyCity/app/google-services.json
@@ -0,0 +1,29 @@
+{
+ "project_info": {
+ "project_number": "820681107984",
+ "project_id": "test-lab-05-b0acc",
+ "storage_bucket": "test-lab-05-b0acc.firebasestorage.app"
+ },
+ "client": [
+ {
+ "client_info": {
+ "mobilesdk_app_id": "1:820681107984:android:26f9b5b4b874959f097895",
+ "android_client_info": {
+ "package_name": "com.example.lab5_starter"
+ }
+ },
+ "oauth_client": [],
+ "api_key": [
+ {
+ "current_key": "AIzaSyAZAwySbE1ivY3pMkSIF_Y0_p89yKhvXzo"
+ }
+ ],
+ "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/CityDialogFragment.java b/ListyCity/app/src/main/java/com/example/lab5_starter/CityDialogFragment.java
index 49b92df50..39e8599c7 100644
--- a/ListyCity/app/src/main/java/com/example/lab5_starter/CityDialogFragment.java
+++ b/ListyCity/app/src/main/java/com/example/lab5_starter/CityDialogFragment.java
@@ -17,6 +17,7 @@ public class CityDialogFragment extends DialogFragment {
interface CityDialogListener {
void updateCity(City city, String title, String year);
void addCity(City city);
+ void deleteCity(City city);
}
private CityDialogListener listener;
@@ -49,7 +50,8 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
String tag = getTag();
Bundle bundle = getArguments();
- City city;
+// City city;
+ final City city;
if (Objects.equals(tag, "City Details") && bundle != null){
city = (City) bundle.getSerializable("City");
@@ -61,7 +63,7 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
city = null;}
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
- return builder
+ builder
.setView(view)
.setTitle("City Details")
.setNegativeButton("Cancel", null)
@@ -73,7 +75,15 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
} else {
listener.addCity(new City(title, year));
}
- })
- .create();
+ });
+// .create();
+
+ if (Objects.equals(tag, "City Details") && city != null) {
+ builder.setNeutralButton("Delete", (dialog, which) -> {
+ listener.deleteCity(city);
+ });
+ }
+
+ return builder.create();
}
}
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..3f44e04ed 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,6 +1,7 @@
package com.example.lab5_starter;
import android.os.Bundle;
+import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
@@ -11,6 +12,11 @@
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
+import com.google.firebase.firestore.CollectionReference;
+import com.google.firebase.firestore.DocumentReference;
+import com.google.firebase.firestore.FirebaseFirestore;
+import com.google.firebase.firestore.QueryDocumentSnapshot;
+
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity implements CityDialogFragment.CityDialogListener {
@@ -20,6 +26,8 @@ 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) {
@@ -32,6 +40,9 @@ protected void onCreate(Bundle savedInstanceState) {
return insets;
});
+ db = FirebaseFirestore.getInstance();
+ citiesRef = db.collection("cities");
+
// Set views
addCityButton = findViewById(R.id.buttonAddCity);
cityListView = findViewById(R.id.listviewCities);
@@ -41,7 +52,24 @@ protected void onCreate(Bundle savedInstanceState) {
cityArrayAdapter = new CityArrayAdapter(this, cityArrayList);
cityListView.setAdapter(cityArrayAdapter);
- addDummyData();
+// addDummyData();
+
+ 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 cityName = snapshot.getString("name");
+ String provinceName = snapshot.getString("province");
+
+ cityArrayList.add(new City(cityName, provinceName));
+ }
+ cityArrayAdapter.notifyDataSetChanged();
+ }
+ });
// set listeners
addCityButton.setOnClickListener(view -> {
@@ -71,13 +99,27 @@ 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);
+ @Override
+ public void deleteCity(City city) {
+ cityArrayList.remove(city);
cityArrayAdapter.notifyDataSetChanged();
+
+ citiesRef.document(city.getName())
+ .delete()
+ .addOnSuccessListener(aVoid -> Log.d("Firestore", "Document successfully deleted!"))
+ .addOnFailureListener(e -> Log.w("Firestore", "Error deleting document", e));
}
+
+// public void addDummyData(){
+// City m1 = new City("Edmonton", "AB");
+// City m2 = new City("Vancouver", "BC");
+// cityArrayList.add(m1);
+// cityArrayList.add(m2);
+// cityArrayAdapter.notifyDataSetChanged();
+// }
}
\ No newline at end of file
diff --git a/ListyCity/build.gradle.kts b/ListyCity/build.gradle.kts
index 2034cf75c..5cb53ad35 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.3" 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..b52f02847 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/local.properties b/ListyCity/local.properties
index 7501004a9..29f2c7687 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
+#Thu Feb 26 11:05:37 PKT 2026
+sdk.dir=C\:\\Users\\HP\\AppData\\Local\\Android\\Sdk