diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/.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/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b589d56 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..dcfe450 --- /dev/null +++ b/.idea/deploymentTargetSelector.xml @@ -0,0 +1,18 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..0897082 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..fdf8d99 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0ad17cb --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/other.xml b/.idea/other.xml new file mode 100644 index 0000000..49481ad --- /dev/null +++ b/.idea/other.xml @@ -0,0 +1,329 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..0a4803d --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,58 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.jetbrains.kotlin.android) + id("com.google.gms.google-services") +} + +android { + namespace = "com.bignerdranch.android.listr" + compileSdk = 34 + + defaultConfig { + applicationId = "com.bignerdranch.android.listr" + minSdk = 24 + targetSdk = 34 + 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_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } + buildFeatures { + viewBinding = true + } + +} + +dependencies { + + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.material) + implementation(libs.androidx.activity) + implementation(libs.androidx.constraintlayout) + implementation(libs.androidx.navigation.ui.ktx) + implementation(libs.androidx.fragment.ktx) + implementation(libs.androidx.navigation.fragment.ktx) + implementation(libs.firebase.bom) + implementation(libs.firebase.firestore) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) +} \ No newline at end of file diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 0000000..3ed7150 --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "921019127720", + "project_id": "listr-app-fall-2024", + "storage_bucket": "listr-app-fall-2024.firebasestorage.app" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:921019127720:android:b5177a46ed71d83a6def9d", + "android_client_info": { + "package_name": "com.bignerdranch.android.listr" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyCbE9LjIiPqW2hsLI8-_iZo_gVKuQ96LPE" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/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/app/src/androidTest/java/com/bignerdranch/android/listr/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/bignerdranch/android/listr/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..badc5fc --- /dev/null +++ b/app/src/androidTest/java/com/bignerdranch/android/listr/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.bignerdranch.android.listr + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.bignerdranch.android.listr", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..9c2db9e --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/bignerdranch/android/listr/MainActivity.kt b/app/src/main/java/com/bignerdranch/android/listr/MainActivity.kt new file mode 100644 index 0000000..fc2f263 --- /dev/null +++ b/app/src/main/java/com/bignerdranch/android/listr/MainActivity.kt @@ -0,0 +1,37 @@ +package com.bignerdranch.android.listr + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import androidx.navigation.NavController +import androidx.navigation.fragment.NavHostFragment +import androidx.navigation.ui.AppBarConfiguration +import androidx.navigation.ui.navigateUp +import androidx.navigation.ui.setupActionBarWithNavController +import androidx.navigation.ui.setupWithNavController +import com.bignerdranch.android.listr.databinding.ActivityMainBinding + +class MainActivity : AppCompatActivity() { + private lateinit var binding: ActivityMainBinding + private lateinit var navController: NavController + private lateinit var appBarConfiguration: AppBarConfiguration + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityMainBinding.inflate(layoutInflater) + setContentView(binding.root) + + // Set the toolbar as the ActionBar + setSupportActionBar(binding.toolbar) + + val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment + navController = navHostFragment.navController + binding.navView.setupWithNavController(navController) + + appBarConfiguration = AppBarConfiguration(navController.graph, binding.drawerLayout) + setupActionBarWithNavController(navController, appBarConfiguration) + } + + override fun onSupportNavigateUp(): Boolean { + return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp() + } +} diff --git a/app/src/main/java/com/bignerdranch/android/listr/naughty/NaughtyFragment.kt b/app/src/main/java/com/bignerdranch/android/listr/naughty/NaughtyFragment.kt new file mode 100644 index 0000000..1bcd482 --- /dev/null +++ b/app/src/main/java/com/bignerdranch/android/listr/naughty/NaughtyFragment.kt @@ -0,0 +1,60 @@ +package com.bignerdranch.android.listr.naughty + +import android.os.Bundle +import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.bignerdranch.android.listr.databinding.FragmentNaughtyBinding +import com.google.firebase.firestore.ktx.firestore +import com.google.firebase.ktx.Firebase + +private const val TAG = "NaughtyFragment" + +class NaughtyFragment: Fragment() { + private var _binding: FragmentNaughtyBinding? = null + private val binding + get() = checkNotNull(_binding) { + "binding cannot be created. Is view created?" + } + + private val db = Firebase.firestore + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + _binding = FragmentNaughtyBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + binding.addNaughtyMessage.setOnClickListener() { + addMsg() + } + } + + private fun addMsg() { + val msg = hashMapOf( + "message" to "${binding.naughtyMessage.text}" + ) + + db.collection("naughty") + .add(msg) + .addOnSuccessListener { documentReference -> + Log.d(TAG,"DocumentSnapshot added with ID ${documentReference.id}") + } + .addOnFailureListener{ e -> + Log.w(TAG,"Error adding document", e) + } + } + + override fun onDestroy() { + super.onDestroy() + _binding = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bignerdranch/android/listr/nice/NiceFragment.kt b/app/src/main/java/com/bignerdranch/android/listr/nice/NiceFragment.kt new file mode 100644 index 0000000..25006ea --- /dev/null +++ b/app/src/main/java/com/bignerdranch/android/listr/nice/NiceFragment.kt @@ -0,0 +1,60 @@ +package com.bignerdranch.android.listr.nice + +import android.os.Bundle +import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.bignerdranch.android.listr.databinding.FragementNiceBinding +import com.google.firebase.firestore.ktx.firestore +import com.google.firebase.ktx.Firebase + +private const val TAG = "NiceFragment" + +class NiceFragment: Fragment() { + private var _binding: FragementNiceBinding? = null + private val binding + get() = checkNotNull(_binding) { + "binding cannot be created. Is view created?" + } + + private val db = Firebase.firestore + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + _binding = FragementNiceBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + binding.addNiceMessage.setOnClickListener() { + addMsg() + } + } + + private fun addMsg() { + val msg = hashMapOf( + "message" to "${binding.niceMessage.text}" + ) + + db.collection("nice") + .add(msg) + .addOnSuccessListener { documentReference -> + Log.d(TAG,"DocumentSnapshot added with ID ${documentReference.id}") + } + .addOnFailureListener{ e -> + Log.w(TAG,"Error adding document", e) + } + } + + override fun onDestroy() { + super.onDestroy() + _binding = null + } +} diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/naughty_icon.png b/app/src/main/res/drawable/naughty_icon.png new file mode 100644 index 0000000..be6b66b Binary files /dev/null and b/app/src/main/res/drawable/naughty_icon.png differ diff --git a/app/src/main/res/drawable/nice_icon.png b/app/src/main/res/drawable/nice_icon.png new file mode 100644 index 0000000..00c892f Binary files /dev/null and b/app/src/main/res/drawable/nice_icon.png differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..d72d6a0 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragement_nice.xml b/app/src/main/res/layout/fragement_nice.xml new file mode 100644 index 0000000..65c21d7 --- /dev/null +++ b/app/src/main/res/layout/fragement_nice.xml @@ -0,0 +1,30 @@ + + + + + +