diff --git a/code/.gitignore b/code/.gitignore new file mode 100644 index 00000000..aa724b77 --- /dev/null +++ b/code/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/code/.idea/.name b/code/.idea/.name new file mode 100644 index 00000000..cb67bab4 --- /dev/null +++ b/code/.idea/.name @@ -0,0 +1 @@ +ListyCity \ No newline at end of file diff --git a/code/.idea/AndroidProjectSystem.xml b/code/.idea/AndroidProjectSystem.xml new file mode 100644 index 00000000..4a53bee8 --- /dev/null +++ b/code/.idea/AndroidProjectSystem.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/code/.idea/compiler.xml b/code/.idea/compiler.xml new file mode 100644 index 00000000..b86273d9 --- /dev/null +++ b/code/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/code/.idea/deploymentTargetSelector.xml b/code/.idea/deploymentTargetSelector.xml new file mode 100644 index 00000000..b268ef36 --- /dev/null +++ b/code/.idea/deploymentTargetSelector.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/code/.idea/gradle.xml b/code/.idea/gradle.xml new file mode 100644 index 00000000..97f0a8e1 --- /dev/null +++ b/code/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/code/.idea/migrations.xml b/code/.idea/migrations.xml new file mode 100644 index 00000000..f8051a6f --- /dev/null +++ b/code/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/code/.idea/misc.xml b/code/.idea/misc.xml new file mode 100644 index 00000000..74dd639e --- /dev/null +++ b/code/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/code/.idea/runConfigurations.xml b/code/.idea/runConfigurations.xml new file mode 100644 index 00000000..16660f1d --- /dev/null +++ b/code/.idea/runConfigurations.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/code/.idea/vcs.xml b/code/.idea/vcs.xml new file mode 100644 index 00000000..6c0b8635 --- /dev/null +++ b/code/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/code/app/.gitignore b/code/app/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/code/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/code/app/build.gradle.kts b/code/app/build.gradle.kts new file mode 100644 index 00000000..4acd1dfc --- /dev/null +++ b/code/app/build.gradle.kts @@ -0,0 +1,44 @@ +plugins { + alias(libs.plugins.android.application) +} + +android { + namespace = "com.example.listycity" + compileSdk { + version = release(36) + } + + defaultConfig { + applicationId = "com.example.listycity" + minSdk = 24 + targetSdk = 36 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } +} + +dependencies { + implementation(libs.appcompat) + implementation(libs.material) + implementation(libs.activity) + implementation(libs.constraintlayout) + testImplementation(libs.junit) + androidTestImplementation(libs.ext.junit) + androidTestImplementation(libs.espresso.core) +} \ No newline at end of file diff --git a/code/app/proguard-rules.pro b/code/app/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/code/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/code/app/src/androidTest/java/com/example/listycity/ExampleInstrumentedTest.java b/code/app/src/androidTest/java/com/example/listycity/ExampleInstrumentedTest.java new file mode 100644 index 00000000..7b7c2106 --- /dev/null +++ b/code/app/src/androidTest/java/com/example/listycity/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.listycity; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.example.listycity", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/code/app/src/main/AndroidManifest.xml b/code/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..7c439aa7 --- /dev/null +++ b/code/app/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/app/src/main/java/com/example/listycity/MainActivity.java b/code/app/src/main/java/com/example/listycity/MainActivity.java new file mode 100644 index 00000000..84eb86e7 --- /dev/null +++ b/code/app/src/main/java/com/example/listycity/MainActivity.java @@ -0,0 +1,94 @@ +package com.example.listycity; + +import android.os.Bundle; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ListView; + +import androidx.activity.EdgeToEdge; +import androidx.appcompat.app.AppCompatActivity; + +import java.util.ArrayList; +import java.util.Arrays; +import androidx.appcompat.widget.Toolbar; + +public class MainActivity extends AppCompatActivity { + + ListView cityList; + ArrayAdapter cityAdapter; + ArrayList datalist; + + Button addCityButton, deleteCityButton, confirmAddButton; + EditText cityInput; + + boolean deleteMode = false; // STATE FLAG + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + EdgeToEdge.enable(this); + setContentView(R.layout.activity_main); + Toolbar toolbar = findViewById(R.id.top_bar); + setSupportActionBar(toolbar); + + + cityList = findViewById(R.id.city_list); + addCityButton = findViewById(R.id.add_city_button); + deleteCityButton = findViewById(R.id.delete_city_button); + confirmAddButton = findViewById(R.id.confirm_add_button); + cityInput = findViewById(R.id.city_input); + + String[] cities = { + "Edmonton", "Vancouver", "Moscow", "Sydney", + "Berlin", "Vienna", "Tokyo", "Beijing", + "Osaka", "New Delhi" + }; + + datalist = new ArrayList<>(Arrays.asList(cities)); + + cityAdapter = new ArrayAdapter<>( + this, + R.layout.content, + datalist + ); + + cityList.setAdapter(cityAdapter); + + // ADD CITY BUTTON + addCityButton.setOnClickListener(v -> { + deleteMode = false; + cityInput.setVisibility(View.VISIBLE); + confirmAddButton.setVisibility(View.VISIBLE); + }); + + // CONFIRM ADD + confirmAddButton.setOnClickListener(v -> { + String city = cityInput.getText().toString().trim(); + + if (!city.isEmpty()) { + datalist.add(city); + cityAdapter.notifyDataSetChanged(); + cityInput.setText(""); + } + + cityInput.setVisibility(View.GONE); + confirmAddButton.setVisibility(View.GONE); + }); + + // DELETE MODE BUTTON + deleteCityButton.setOnClickListener(v -> { + deleteMode = true; + }); + + // LIST ITEM CLICK + cityList.setOnItemClickListener((parent, view, position, id) -> { + if (deleteMode) { + datalist.remove(position); + cityAdapter.notifyDataSetChanged(); + deleteMode = false; // exit delete mode after one delete + } + }); + } +} \ No newline at end of file diff --git a/code/app/src/main/res/drawable/ic_launcher_background.xml b/code/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..07d5da9c --- /dev/null +++ b/code/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/app/src/main/res/drawable/ic_launcher_foreground.xml b/code/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 00000000..2b068d11 --- /dev/null +++ b/code/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/code/app/src/main/res/layout/activity_main.xml b/code/app/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..bd88a7bd --- /dev/null +++ b/code/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,68 @@ + + + + + + + +