diff --git a/labs/Lab7_Firebase/.gitignore b/labs/Lab7_Firebase/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..603b14077394cd2294ac6922fe619669630ef3ab --- /dev/null +++ b/labs/Lab7_Firebase/.gitignore @@ -0,0 +1,14 @@ +*.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 diff --git a/labs/Lab7_Firebase/.idea/.name b/labs/Lab7_Firebase/.idea/.name new file mode 100644 index 0000000000000000000000000000000000000000..a25cba57d101f6d204742eaf6f64fb1dc5283669 --- /dev/null +++ b/labs/Lab7_Firebase/.idea/.name @@ -0,0 +1 @@ +Lab7-Firebase \ No newline at end of file diff --git a/labs/Lab7_Firebase/.idea/codeStyles/Project.xml b/labs/Lab7_Firebase/.idea/codeStyles/Project.xml new file mode 100644 index 0000000000000000000000000000000000000000..3cc336b9349299395940823dfc3e3725bc394c07 --- /dev/null +++ b/labs/Lab7_Firebase/.idea/codeStyles/Project.xml @@ -0,0 +1,138 @@ +<component name="ProjectCodeStyleConfiguration"> + <code_scheme name="Project" version="173"> + <JetCodeStyleSettings> + <option name="PACKAGES_TO_USE_STAR_IMPORTS"> + <value> + <package name="java.util" alias="false" withSubpackages="false" /> + <package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" /> + <package name="io.ktor" alias="false" withSubpackages="true" /> + </value> + </option> + <option name="PACKAGES_IMPORT_LAYOUT"> + <value> + <package name="" alias="false" withSubpackages="true" /> + <package name="java" alias="false" withSubpackages="true" /> + <package name="javax" alias="false" withSubpackages="true" /> + <package name="kotlin" alias="false" withSubpackages="true" /> + <package name="" alias="true" withSubpackages="true" /> + </value> + </option> + <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" /> + </JetCodeStyleSettings> + <codeStyleSettings language="XML"> + <indentOptions> + <option name="CONTINUATION_INDENT_SIZE" value="4" /> + </indentOptions> + <arrangement> + <rules> + <section> + <rule> + <match> + <AND> + <NAME>xmlns:android</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>^$</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>xmlns:.*</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>^$</XML_NAMESPACE> + </AND> + </match> + <order>BY_NAME</order> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*:id</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*:name</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>name</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>^$</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>style</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>^$</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>^$</XML_NAMESPACE> + </AND> + </match> + <order>BY_NAME</order> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> + </AND> + </match> + <order>ANDROID_ATTRIBUTE_ORDER</order> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>.*</XML_NAMESPACE> + </AND> + </match> + <order>BY_NAME</order> + </rule> + </section> + </rules> + </arrangement> + </codeStyleSettings> + <codeStyleSettings language="kotlin"> + <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" /> + </codeStyleSettings> + </code_scheme> +</component> \ No newline at end of file diff --git a/labs/Lab7_Firebase/.idea/codeStyles/codeStyleConfig.xml b/labs/Lab7_Firebase/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000000000000000000000000000000000000..79ee123c2b23e069e35ed634d687e17f731cc702 --- /dev/null +++ b/labs/Lab7_Firebase/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ +<component name="ProjectCodeStyleConfiguration"> + <state> + <option name="USE_PER_PROJECT_SETTINGS" value="true" /> + </state> +</component> \ No newline at end of file diff --git a/labs/Lab7_Firebase/.idea/gradle.xml b/labs/Lab7_Firebase/.idea/gradle.xml new file mode 100644 index 0000000000000000000000000000000000000000..5cd135a064522bbb757161b1eee5a7d65de1989e --- /dev/null +++ b/labs/Lab7_Firebase/.idea/gradle.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="GradleMigrationSettings" migrationVersion="1" /> + <component name="GradleSettings"> + <option name="linkedExternalProjectsSettings"> + <GradleProjectSettings> + <option name="testRunner" value="PLATFORM" /> + <option name="distributionType" value="DEFAULT_WRAPPED" /> + <option name="externalProjectPath" value="$PROJECT_DIR$" /> + <option name="modules"> + <set> + <option value="$PROJECT_DIR$" /> + <option value="$PROJECT_DIR$/app" /> + </set> + </option> + <option name="resolveModulePerSourceSet" value="false" /> + </GradleProjectSettings> + </option> + </component> +</project> \ No newline at end of file diff --git a/labs/Lab7_Firebase/.idea/jarRepositories.xml b/labs/Lab7_Firebase/.idea/jarRepositories.xml new file mode 100644 index 0000000000000000000000000000000000000000..e34606ccde7a9d4b04ae93b6d8a8a158820381de --- /dev/null +++ b/labs/Lab7_Firebase/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="RemoteRepositoriesConfiguration"> + <remote-repository> + <option name="id" value="central" /> + <option name="name" value="Maven Central repository" /> + <option name="url" value="https://repo1.maven.org/maven2" /> + </remote-repository> + <remote-repository> + <option name="id" value="jboss.community" /> + <option name="name" value="JBoss Community repository" /> + <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> + </remote-repository> + <remote-repository> + <option name="id" value="BintrayJCenter" /> + <option name="name" value="BintrayJCenter" /> + <option name="url" value="https://jcenter.bintray.com/" /> + </remote-repository> + <remote-repository> + <option name="id" value="Google" /> + <option name="name" value="Google" /> + <option name="url" value="https://dl.google.com/dl/android/maven2/" /> + </remote-repository> + <remote-repository> + <option name="id" value="MavenRepo" /> + <option name="name" value="MavenRepo" /> + <option name="url" value="https://repo.maven.apache.org/maven2/" /> + </remote-repository> + </component> +</project> \ No newline at end of file diff --git a/labs/Lab7_Firebase/.idea/misc.xml b/labs/Lab7_Firebase/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..37a750962da6f2b31810e85c8acae1081de7f58c --- /dev/null +++ b/labs/Lab7_Firebase/.idea/misc.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/build/classes" /> + </component> + <component name="ProjectType"> + <option name="id" value="Android" /> + </component> +</project> \ No newline at end of file diff --git a/labs/Lab7_Firebase/.idea/runConfigurations.xml b/labs/Lab7_Firebase/.idea/runConfigurations.xml new file mode 100644 index 0000000000000000000000000000000000000000..7f68460d8b38ac04e3a3224d7c79ef719b1991a9 --- /dev/null +++ b/labs/Lab7_Firebase/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="RunConfigurationProducerService"> + <option name="ignoredProducers"> + <set> + <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" /> + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" /> + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" /> + </set> + </option> + </component> +</project> \ No newline at end of file diff --git a/labs/Lab7_Firebase/.idea/vcs.xml b/labs/Lab7_Firebase/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..6c0b8635858dc7ad44b93df54b762707ce49eefc --- /dev/null +++ b/labs/Lab7_Firebase/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$/.." vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/labs/Lab7_Firebase/Lab7_Firebase.pdf b/labs/Lab7_Firebase/Lab7_Firebase.pdf new file mode 100644 index 0000000000000000000000000000000000000000..9edd03fb7fa2ef67c0a9f01a22af0357e8212b1c Binary files /dev/null and b/labs/Lab7_Firebase/Lab7_Firebase.pdf differ diff --git a/labs/Lab7_Firebase/Lab7_walkthrough.mp4 b/labs/Lab7_Firebase/Lab7_walkthrough.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..6a06480aa0ea7b6b54323c24feedb421cd5144c0 Binary files /dev/null and b/labs/Lab7_Firebase/Lab7_walkthrough.mp4 differ diff --git a/labs/Lab7_Firebase/app/.gitignore b/labs/Lab7_Firebase/app/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..796b96d1c402326528b4ba3c12ee9d92d0e212e9 --- /dev/null +++ b/labs/Lab7_Firebase/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/labs/Lab7_Firebase/app/build.gradle b/labs/Lab7_Firebase/app/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..09213f7d6e182e858f7d6e1b99c1baee5a2a8ce6 --- /dev/null +++ b/labs/Lab7_Firebase/app/build.gradle @@ -0,0 +1,38 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'com.google.gms.google-services' + +android { + compileSdkVersion 30 + defaultConfig { + applicationId "com.example.lab7_firebase" + minSdkVersion 26 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.2' + implementation 'com.google.firebase:firebase-auth:19.4.0' + implementation 'com.google.firebase:firebase-database:19.5.0' + testImplementation 'junit:junit:4.13' + androidTestImplementation 'androidx.test:runner:1.3.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + implementation "androidx.core:core-ktx:1.3.2" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} +repositories { + mavenCentral() +} diff --git a/labs/Lab7_Firebase/app/google-services.json b/labs/Lab7_Firebase/app/google-services.json new file mode 100644 index 0000000000000000000000000000000000000000..217f261046447225239e7e37b357b9a63f3249fd --- /dev/null +++ b/labs/Lab7_Firebase/app/google-services.json @@ -0,0 +1,77 @@ +{ + "project_info": { + "project_number": "29102789333", + "firebase_url": "https://myhomelibrary-838ac.firebaseio.com", + "project_id": "myhomelibrary-838ac", + "storage_bucket": "myhomelibrary-838ac.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:29102789333:android:b8df690b5bb5063d94085c", + "android_client_info": { + "package_name": "com.example.lab7_firebase" + } + }, + "oauth_client": [ + { + "client_id": "29102789333-b0jc7do4lghpm5oo3panm8rgcqrco9at.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCYVtTDVxur-80vXj37SRHPAvhQeSX8L6U" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "29102789333-b0jc7do4lghpm5oo3panm8rgcqrco9at.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:29102789333:android:7f079efdba385b39", + "android_client_info": { + "package_name": "com.example.tesla.myhomelibrary" + } + }, + "oauth_client": [ + { + "client_id": "29102789333-lifqn2quqbnlo19aieom1gmfteqij6ds.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "com.example.tesla.myhomelibrary", + "certificate_hash": "072259d7f3e54982791790117fdd745fd884baf0" + } + }, + { + "client_id": "29102789333-b0jc7do4lghpm5oo3panm8rgcqrco9at.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCYVtTDVxur-80vXj37SRHPAvhQeSX8L6U" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "29102789333-b0jc7do4lghpm5oo3panm8rgcqrco9at.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/proguard-rules.pro b/labs/Lab7_Firebase/app/proguard-rules.pro new file mode 100644 index 0000000000000000000000000000000000000000..f1b424510da51fd82143bc74a0a801ae5a1e2fcd --- /dev/null +++ b/labs/Lab7_Firebase/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 diff --git a/labs/Lab7_Firebase/app/src/androidTest/java/com/example/lab7_firebase/TestValidation.kt b/labs/Lab7_Firebase/app/src/androidTest/java/com/example/lab7_firebase/TestValidation.kt new file mode 100644 index 0000000000000000000000000000000000000000..f70d1f958860ee914f310423e55c2fc9b80c4ba3 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/androidTest/java/com/example/lab7_firebase/TestValidation.kt @@ -0,0 +1,7 @@ +package com.example.lab7_firebase + +class TestValidation { + // TODO: Test passwords + // Add two tests for a valid password + // Add two tests for an invalid password +} \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/AndroidManifest.xml b/labs/Lab7_Firebase/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000000000000000000000000000000000..e898fc5c22cdd2c1a8e7881bff2ba2cacbeb6c6d --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/AndroidManifest.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + package="com.example.lab7_firebase"> + + <uses-permission android:name="android.permission.INTERNET" /> + + <application + android:allowBackup="true" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:roundIcon="@mipmap/ic_launcher_round" + android:supportsRtl="true" + android:theme="@style/AppTheme" + tools:ignore="AllowBackup"> + <activity android:name="com.example.lab7_firebase.MainActivity"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <activity android:name="com.example.lab7_firebase.LoginActivity" /> + <activity android:name="com.example.lab7_firebase.RegistrationActivity" /> + <activity android:name="com.example.lab7_firebase.DashboardActivity" /> + <activity android:name="com.example.lab7_firebase.AuthorActivity" /> + </application> + +</manifest> \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/Author.kt b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/Author.kt new file mode 100644 index 0000000000000000000000000000000000000000..0efed7789a9ca8d8ca9a058b775e9629203b2290 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/Author.kt @@ -0,0 +1,3 @@ +package com.example.lab7_firebase + +data class Author (val authorId: String ="", val authorName: String = "", val authorCountry: String = "") \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/AuthorActivity.kt b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/AuthorActivity.kt new file mode 100644 index 0000000000000000000000000000000000000000..5278e08ffd72a6208e516028e151a9f82b1b9daf --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/AuthorActivity.kt @@ -0,0 +1,115 @@ +package com.example.lab7_firebase + +import android.os.Bundle +import android.text.TextUtils +import android.util.Log +import android.view.View +import android.widget.* +import androidx.appcompat.app.AppCompatActivity +import com.google.firebase.database.* +import java.lang.Exception +import java.util.* + +class AuthorActivity : AppCompatActivity() { + private lateinit var buttonAddTitle: Button + private lateinit var editTextTitleName: EditText + private lateinit var seekBarRating: SeekBar + internal lateinit var textViewRating: TextView + private lateinit var textViewAuthor: TextView + internal lateinit var listViewTitles: ListView + + private lateinit var databaseTitles: DatabaseReference + + internal lateinit var titles: MutableList<Title> + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_author) + + val intent = intent + + /* + * this line is important + * this time we are not getting the reference of a direct node + * but inside the node track we are creating a new child with the author id + * and inside that node we will store all the titles with unique ids + * */ + databaseTitles = FirebaseDatabase.getInstance().getReference("titles").child(intent.getStringExtra( + AUTHOR_ID + )!!) + + buttonAddTitle = findViewById<View>(R.id.buttonAddTitle) as Button + editTextTitleName = findViewById<View>(R.id.editTextName) as EditText + seekBarRating = findViewById<View>(R.id.seekBarRating) as SeekBar + textViewRating = findViewById<View>(R.id.textViewRating) as TextView + textViewAuthor = findViewById<View>(R.id.textViewAuthor) as TextView + listViewTitles = findViewById<View>(R.id.listViewTitles) as ListView + + titles = ArrayList() + + textViewAuthor.text = intent.getStringExtra(AUTHOR_NAME) + + seekBarRating.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { + override fun onProgressChanged(seekBar: SeekBar, i: Int, b: Boolean) { + textViewRating.text = i.toString() + } + + override fun onStartTrackingTouch(seekBar: SeekBar) { + // do nothing + } + + override fun onStopTrackingTouch(seekBar: SeekBar) { + // do nothing + } + }) + + buttonAddTitle.setOnClickListener { saveTitle() } + } + + override fun onStart() { + super.onStart() + + databaseTitles.addValueEventListener(object : ValueEventListener { + override fun onDataChange(dataSnapshot: DataSnapshot) { + titles.clear() + + var title: Title? = null + for (postSnapshot in dataSnapshot.children) { + try { + title = postSnapshot.getValue(Title::class.java) + } catch (e: Exception) { + Log.e(TAG, e.toString()) + } finally { + titles.add(title!!) + } + } + val titleListAdapter = TitleList(this@AuthorActivity, titles) + listViewTitles.adapter = titleListAdapter + } + + override fun onCancelled(databaseError: DatabaseError) { + // do nothing + } + }) + } + + private fun saveTitle() { + val titleName = editTextTitleName.text.toString().trim { it <= ' ' } + val rating = seekBarRating.progress + if (!TextUtils.isEmpty(titleName)) { + val id = (databaseTitles.push()).key.toString() + val title = Title(id, titleName, rating) + databaseTitles.child(id).setValue(title) + Toast.makeText(this, "Title saved", Toast.LENGTH_LONG).show() + editTextTitleName.setText("") + } else { + Toast.makeText(this, "Please enter title name", Toast.LENGTH_LONG).show() + } + } + + companion object { + const val TAG = "Lab-Firebase" + const val AUTHOR_NAME = "com.example.tesla.myhomelibrary.authorname" + const val AUTHOR_ID = "com.example.tesla.myhomelibrary.authorid" + } +} diff --git a/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/AuthorList.kt b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/AuthorList.kt new file mode 100644 index 0000000000000000000000000000000000000000..64084c4e13f03a6c1baa75503dbcc012041fdcb6 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/AuthorList.kt @@ -0,0 +1,28 @@ +package com.example.lab7_firebase + +import android.annotation.SuppressLint +import android.app.Activity +import android.view.View +import android.view.ViewGroup +import android.widget.ArrayAdapter +import android.widget.TextView + + +class AuthorList(private val context: Activity, private var authors: List<Author>) : ArrayAdapter<Author>(context, + R.layout.layout_author_list, authors) { + + @SuppressLint("InflateParams", "ViewHolder") + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val inflater = context.layoutInflater + val listViewItem = inflater.inflate(R.layout.layout_author_list, null, true) + + val textViewName = listViewItem.findViewById<View>(R.id.textViewName) as TextView + val textViewCountry = listViewItem.findViewById<View>(R.id.textViewCountry) as TextView + + val author = authors[position] + textViewName.text = author.authorName + textViewCountry.text = author.authorCountry + + return listViewItem + } +} \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/DashboardActivity.kt b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/DashboardActivity.kt new file mode 100644 index 0000000000000000000000000000000000000000..a9609701e93462c398a9304b94077b035a5cf9c3 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/DashboardActivity.kt @@ -0,0 +1,145 @@ +package com.example.lab7_firebase + +import android.content.Intent +import android.os.Bundle +import android.util.Log +import android.view.View +import android.widget.* +import androidx.appcompat.app.AlertDialog +import androidx.appcompat.app.AppCompatActivity +import com.google.firebase.database.* +import java.lang.Exception +import java.util.* + +class DashboardActivity : AppCompatActivity() { + + private lateinit var editTextName: EditText + private lateinit var spinnerCountry: Spinner + private lateinit var buttonAddAuthor: Button + internal lateinit var listViewAuthors: ListView + + internal lateinit var authors: MutableList<Author> + + private lateinit var databaseAuthors: DatabaseReference + + private lateinit var uid: String + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_dashboard) + + //getting the reference of artists node + databaseAuthors = FirebaseDatabase.getInstance().getReference("authors") + + editTextName = findViewById<View>(R.id.editTextName) as EditText + spinnerCountry = findViewById<View>(R.id.spinnerCountry) as Spinner + listViewAuthors = findViewById<View>(R.id.listViewAuthors) as ListView + buttonAddAuthor = findViewById<View>(R.id.buttonAddAuthor) as Button + + authors = ArrayList() + uid = intent.getStringExtra(USER_ID)!! + + buttonAddAuthor.setOnClickListener { + addAuthor() + } + + //attaching listener to ListView + listViewAuthors.onItemClickListener = AdapterView.OnItemClickListener { adapterView, view, i, l -> + //getting the selected artist + val author = authors[i] + + //creating an intent + val intent = Intent(applicationContext, AuthorActivity::class.java) + + intent.putExtra(AUTHOR_ID, author.authorId) + intent.putExtra(AUTHOR_NAME, author.authorName) + intent.putExtra(USER_ID, USER_ID) + startActivity(intent) + } + + listViewAuthors.onItemLongClickListener = AdapterView.OnItemLongClickListener { adapterView, view, i, l -> + val author = authors[i] + showUpdateDeleteDialog(author.authorId, author.authorName) + true + } + } + + private fun showUpdateDeleteDialog(authorId: String, authorName: String) { + + val dialogBuilder = AlertDialog.Builder(this) + val inflater = layoutInflater + val dialogView = inflater.inflate(R.layout.update_dialog, null) + dialogBuilder.setView(dialogView) + + val editTextName = dialogView.findViewById<View>(R.id.editTextName) as EditText + val spinnerCountry = dialogView.findViewById<View>(R.id.spinnerCountry) as Spinner + val buttonUpdate = dialogView.findViewById<View>(R.id.buttonUpdateAuthor) as Button + val buttonDelete = dialogView.findViewById<View>(R.id.buttonDeleteAuthor) as Button + + dialogBuilder.setTitle(authorName) + val b = dialogBuilder.create() + b.show() + + // TODO: Set update listener + buttonUpdate.setOnClickListener { + + } + + // TODO: Set delete listener + buttonDelete.setOnClickListener { + + } + } + + // TODO: Add an author + private fun addAuthor() { + + } + + // TODO: Update an author + private fun updateAuthor(id: String, uid: String, name: String, country: String): Boolean { + + return true + } + + // TODO: Delete an author + private fun deleteAuthor(id: String): Boolean { + + return true + } + + override fun onStart() { + super.onStart() + + databaseAuthors.addValueEventListener(object : ValueEventListener { + override fun onDataChange(dataSnapshot: DataSnapshot) { + authors.clear() + + var author: Author? = null + for (postSnapshot in dataSnapshot.child(uid).children) { + try { + author = postSnapshot.getValue(Author::class.java) + } catch (e: Exception) { + Log.e(TAG, e.toString()) + } finally { + authors.add(author!!) + } + } + + val authorAdapter = AuthorList(this@DashboardActivity, authors) + listViewAuthors.adapter = authorAdapter + } + + override fun onCancelled(databaseError: DatabaseError) { + + } + }) + } + + companion object { + const val TAG = "Lab-Firebase" + const val AUTHOR_NAME = "com.example.tesla.myhomelibrary.authorname" + const val AUTHOR_ID = "com.example.tesla.myhomelibrary.authorid" + const val USER_ID = "com.example.tesla.myhomelibrary.userid" + } +} \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/LoginActivity.kt b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/LoginActivity.kt new file mode 100644 index 0000000000000000000000000000000000000000..03980c3c1d4ce63c9b63569527a787953a0c9256 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/LoginActivity.kt @@ -0,0 +1,48 @@ +package com.example.lab7_firebase + +import android.os.Bundle +import android.widget.Button +import android.widget.EditText +import android.widget.ProgressBar +import androidx.appcompat.app.AppCompatActivity +import com.google.firebase.auth.FirebaseAuth +import com.google.firebase.database.DatabaseReference +import com.google.firebase.database.FirebaseDatabase + +class LoginActivity : AppCompatActivity() { + private var mDatabaseReference: DatabaseReference? = null + private var mDatabase: FirebaseDatabase? = null + private var userEmail: EditText? = null + private var userPassword: EditText? = null + private var loginBtn: Button? = null + private var progressBar: ProgressBar? = null + + private var mAuth: FirebaseAuth? = null + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_login) + + mDatabase = FirebaseDatabase.getInstance() + mDatabaseReference = mDatabase!!.reference.child("Users") + mAuth = FirebaseAuth.getInstance() + + userEmail = findViewById(R.id.email) + userPassword = findViewById(R.id.password) + loginBtn = findViewById(R.id.login) + progressBar = findViewById(R.id.progressBar) + + loginBtn!!.setOnClickListener { loginUserAccount() } + } + + // TODO: Allow the user to log into their account + // If the email and password are not empty, try to log in + // If the login is successful, store info into intent and launch DashboardActivity + private fun loginUserAccount() { + + } + + companion object { + const val USER_EMAIL = "com.example.tesla.myhomelibrary.useremail" + const val USER_ID = "com.example.tesla.myhomelibrary.userid" + } +} \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/MainActivity.kt b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/MainActivity.kt new file mode 100644 index 0000000000000000000000000000000000000000..c713fdf32005162baefaa6b3afa8f0df02ee6ad2 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/MainActivity.kt @@ -0,0 +1,32 @@ +package com.example.lab7_firebase + +import android.content.Intent +import android.os.Bundle +import android.widget.Button +import androidx.appcompat.app.AppCompatActivity + +class MainActivity : AppCompatActivity() { + + private var registerBtn: Button? = null + private var loginBtn: Button? = null + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + initializeViews() + + registerBtn!!.setOnClickListener { + val intent = Intent(this@MainActivity, RegistrationActivity::class.java) + startActivity(intent) + } + loginBtn!!.setOnClickListener { + val intent = Intent(this@MainActivity, LoginActivity::class.java) + startActivity(intent) + } + } + + private fun initializeViews() { + registerBtn = findViewById(R.id.register) + loginBtn = findViewById(R.id.login) + } +} diff --git a/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/RegistrationActivity.kt b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/RegistrationActivity.kt new file mode 100644 index 0000000000000000000000000000000000000000..c9b11fd4ebec1e082d434c259f8077c58906ef5d --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/RegistrationActivity.kt @@ -0,0 +1,65 @@ +package com.example.lab7_firebase + +import android.content.Intent +import android.os.Bundle +import android.view.View +import android.widget.Button +import android.widget.EditText +import android.widget.ProgressBar +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity +import com.google.firebase.auth.FirebaseAuth + +class RegistrationActivity : AppCompatActivity() { + + private var emailTV: EditText? = null + private var passwordTV: EditText? = null + private var regBtn: Button? = null + private var progressBar: ProgressBar? = null + private var validator = Validators() + + private var mAuth: FirebaseAuth? = null + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_registration) + + mAuth = FirebaseAuth.getInstance() + + emailTV = findViewById(R.id.email) + passwordTV = findViewById(R.id.password) + regBtn = findViewById(R.id.register) + progressBar = findViewById(R.id.progressBar) + + regBtn!!.setOnClickListener { registerNewUser() } + } + + private fun registerNewUser() { + progressBar!!.visibility = View.VISIBLE + + val email: String = emailTV!!.text.toString() + val password: String = passwordTV!!.text.toString() + + if (!validator.validEmail(email)) { + Toast.makeText(applicationContext, "Please enter a valid email...", Toast.LENGTH_LONG).show() + return + } + if (!validator.validPassword(password)) { + Toast.makeText(applicationContext, "Please enter a valid password!", Toast.LENGTH_LONG).show() + return + } + + mAuth!!.createUserWithEmailAndPassword(email, password) + .addOnCompleteListener { task -> + if (task.isSuccessful) { + Toast.makeText(applicationContext, "Registration successful!", Toast.LENGTH_LONG).show() + progressBar!!.visibility = View.GONE + + val intent = Intent(this@RegistrationActivity, LoginActivity::class.java) + startActivity(intent) + } else { + Toast.makeText(applicationContext, "Registration failed! Please try again later", Toast.LENGTH_LONG).show() + progressBar!!.visibility = View.GONE + } + } + } +} diff --git a/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/Title.kt b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/Title.kt new file mode 100644 index 0000000000000000000000000000000000000000..4cdb09ff3c32bac6c01e650574ed33ce8827907c --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/Title.kt @@ -0,0 +1,3 @@ +package com.example.lab7_firebase + +data class Title (val id: String = "", val titleName: String = "", val rating: Int = 0) diff --git a/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/TitleList.kt b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/TitleList.kt new file mode 100644 index 0000000000000000000000000000000000000000..6d8d2620468ab4e8df97df636811a3daced5dcd4 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/TitleList.kt @@ -0,0 +1,27 @@ +package com.example.lab7_firebase + +import android.annotation.SuppressLint +import android.app.Activity +import android.view.View +import android.view.ViewGroup +import android.widget.ArrayAdapter +import android.widget.TextView + +class TitleList(private val context: Activity, private var titles: List<Title>) : ArrayAdapter<Title>(context, + R.layout.layout_author_list, titles) { + + @SuppressLint("InflateParams", "ViewHolder") + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val inflater = context.layoutInflater + val listViewItem = inflater.inflate(R.layout.layout_author_list, null, true) + + val textViewName = listViewItem.findViewById<View>(R.id.textViewName) as TextView + val textViewRating = listViewItem.findViewById<View>(R.id.textViewCountry) as TextView + + val title = titles[position] + textViewName.text = title.titleName + textViewRating.text = title.rating.toString() + + return listViewItem + } +} diff --git a/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/Validators.kt b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/Validators.kt new file mode 100644 index 0000000000000000000000000000000000000000..f8272e040ef490a9577903baa1dd6923cb7df6b0 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/java/com/example/lab7_firebase/Validators.kt @@ -0,0 +1,26 @@ +package com.example.lab7_firebase + +class Validators { + fun validEmail(email: String?) : Boolean { + if (email.isNullOrEmpty()) { + return false + } + + // General Email Regex (RFC 5322 Official Standard) + val emailRegex = Regex("(?:[a-z0-9!#\$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#\$%&'" + + "*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x" + + "5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z" + + "0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4" + + "][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z" + + "0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|" + + "\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)])") + return emailRegex.matches(email) + } + + // TODO: Validate password + // Passwords should be at least 4 characters with 1 letter and 1 number + fun validPassword(password: String?) : Boolean { + + return true + } +} \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/res/drawable/ic_launcher_background.xml b/labs/Lab7_Firebase/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000000000000000000000000000000000000..d5fccc538c179838bfdce779c26eebb4fa0b5ce9 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ +<?xml version="1.0" encoding="utf-8"?> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="108dp" + android:height="108dp" + android:viewportHeight="108" + android:viewportWidth="108"> + <path + android:fillColor="#26A69A" + android:pathData="M0,0h108v108h-108z" /> + <path + android:fillColor="#00000000" + android:pathData="M9,0L9,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M19,0L19,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M29,0L29,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M39,0L39,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M49,0L49,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M59,0L59,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M69,0L69,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M79,0L79,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M89,0L89,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M99,0L99,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,9L108,9" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,19L108,19" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,29L108,29" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,39L108,39" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,49L108,49" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,59L108,59" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,69L108,69" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,79L108,79" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,89L108,89" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,99L108,99" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M19,29L89,29" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M19,39L89,39" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M19,49L89,49" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M19,59L89,59" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M19,69L89,69" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M19,79L89,79" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M29,19L29,89" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M39,19L39,89" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M49,19L49,89" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M59,19L59,89" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M69,19L69,89" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M79,19L79,89" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> +</vector> diff --git a/labs/Lab7_Firebase/app/src/main/res/drawable/ic_launcher_foreground.xml b/labs/Lab7_Firebase/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000000000000000000000000000000000000..c7bd21dbd86990cde81fea8abd3bf904b4546749 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:aapt="http://schemas.android.com/aapt" + android:width="108dp" + android:height="108dp" + android:viewportHeight="108" + android:viewportWidth="108"> + <path + android:fillType="evenOdd" + android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z" + android:strokeColor="#00000000" + android:strokeWidth="1"> + <aapt:attr name="android:fillColor"> + <gradient + android:endX="78.5885" + android:endY="90.9159" + android:startX="48.7653" + android:startY="61.0927" + android:type="linear"> + <item + android:color="#44000000" + android:offset="0.0" /> + <item + android:color="#00000000" + android:offset="1.0" /> + </gradient> + </aapt:attr> + </path> + <path + android:fillColor="#FFFFFF" + android:fillType="nonZero" + android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z" + android:strokeColor="#00000000" + android:strokeWidth="1" /> +</vector> diff --git a/labs/Lab7_Firebase/app/src/main/res/layout/activity_author.xml b/labs/Lab7_Firebase/app/src/main/res/layout/activity_author.xml new file mode 100644 index 0000000000000000000000000000000000000000..2a6ab3187fc8ab8f773958090f0ce31835e33f47 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/layout/activity_author.xml @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/activity_artist" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingBottom="@dimen/activity_vertical_margin" + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin" + tools:context="com.example.lab7_firebase.AuthorActivity"> + + <TextView + android:id="@+id/textViewAuthor" + android:padding="@dimen/activity_horizontal_margin" + android:textAlignment="center" + android:textAppearance="@style/Base.TextAppearance.AppCompat.Large" + android:textStyle="bold" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + <EditText + android:layout_below="@id/textViewAuthor" + android:id="@+id/editTextName" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:inputType="text" + android:hint="@string/enter_title_name" + android:importantForAutofill="no" /> + + <LinearLayout + android:orientation="horizontal" + android:id="@+id/linearLayout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/editTextName"> + + <SeekBar + android:layout_weight="1" + android:id="@+id/seekBarRating" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:max="5" /> + + <TextView + android:text="@string/one" + android:id="@+id/textViewRating" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + </LinearLayout> + + + <Button + android:id="@+id/buttonAddTitle" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/linearLayout" + android:text="@string/add_titles" /> + + <TextView + android:id="@+id/textView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/buttonAddTitle" + android:padding="@dimen/activity_horizontal_margin" + android:text="@string/titles" + android:textAlignment="center" + android:textAppearance="@style/Base.TextAppearance.AppCompat.Large" /> + + <ListView + android:id="@+id/listViewTitles" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@+id/textView" /> + +</RelativeLayout> \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/res/layout/activity_dashboard.xml b/labs/Lab7_Firebase/app/src/main/res/layout/activity_dashboard.xml new file mode 100644 index 0000000000000000000000000000000000000000..67817f183b99e31425499ada212e2cd05651cde1 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/layout/activity_dashboard.xml @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/activity_main" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingBottom="@dimen/activity_vertical_margin" + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin" + tools:context="com.example.lab7_firebase.DashboardActivity"> + + + <EditText + android:id="@+id/editTextName" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/enter_author_name" + android:inputType="text" + android:importantForAutofill="no" /> + + <Spinner + android:id="@+id/spinnerCountry" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/editTextName" + android:entries="@array/countries" /> + + <Button + android:id="@+id/buttonAddAuthor" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/spinnerCountry" + android:text="@string/add" /> + + <TextView + android:id="@+id/textView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/buttonAddAuthor" + android:padding="@dimen/activity_horizontal_margin" + android:text="@string/authors" + android:textAlignment="center" + android:textAppearance="@style/Base.TextAppearance.AppCompat.Large" /> + + <TextView + android:id="@+id/textView1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/textView" + android:text="@string/tap_to_view" + android:textAlignment="center" /> + + <ListView + android:id="@+id/listViewAuthors" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@+id/textView1" /> + +</RelativeLayout> \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/res/layout/activity_login.xml b/labs/Lab7_Firebase/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000000000000000000000000000000000000..4155f515a966e0d21d870c596e8915a422dab34e --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center_vertical" + android:orientation="vertical" + android:padding="16dp" + tools:context="com.example.lab7_firebase.LoginActivity"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/account_login"/> + <EditText + android:id="@+id/email" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/email" + android:inputType="textEmailAddress" + android:importantForAutofill="no" /> + + <EditText + android:id="@+id/password" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/password" + android:inputType="textPassword" + android:importantForAutofill="no" /> + + <Button + android:id="@+id/login" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/login" /> + + <ProgressBar + android:id="@+id/progressBar" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:visibility="gone" /> +</LinearLayout> \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/res/layout/activity_main.xml b/labs/Lab7_Firebase/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000000000000000000000000000000000000..78b56f22dd6f163f39a72d93c8ae053872fcf1e5 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + tools:context="com.example.lab7_firebase.MainActivity"> + + <Button + android:id="@+id/register" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/register"/> + <Button + android:id="@+id/login" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/login"/> + +</LinearLayout> \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/res/layout/activity_registration.xml b/labs/Lab7_Firebase/app/src/main/res/layout/activity_registration.xml new file mode 100644 index 0000000000000000000000000000000000000000..d4fe4d7f4aebbff0432e1776b03a3b1c4b1dbc7b --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/layout/activity_registration.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center_vertical" + android:orientation="vertical" + android:padding="16dp" + tools:context="com.example.lab7_firebase.RegistrationActivity"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/register_new_account" /> + + <EditText + android:id="@+id/email" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/email" + android:inputType="textEmailAddress" + android:importantForAutofill="no" /> + + <EditText + android:id="@+id/password" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/password" + android:inputType="textPassword" + android:importantForAutofill="no" /> + + <Button + android:id="@+id/register" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/register" /> + + <ProgressBar + android:id="@+id/progressBar" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:visibility="gone" /> + +</LinearLayout> \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/res/layout/layout_author_list.xml b/labs/Lab7_Firebase/app/src/main/res/layout/layout_author_list.xml new file mode 100644 index 0000000000000000000000000000000000000000..c616f86e65c2761b4678b2d4791b0a544b65d5f0 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/layout/layout_author_list.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" android:layout_width="match_parent" + android:layout_height="match_parent"> + + <TextView + android:text="@string/test_author" + android:textAppearance="@style/Base.TextAppearance.AppCompat.Large" + android:id="@+id/textViewName" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + <TextView + android:text="@string/test_country" + android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium" + android:id="@+id/textViewCountry" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + +</LinearLayout> + diff --git a/labs/Lab7_Firebase/app/src/main/res/layout/update_dialog.xml b/labs/Lab7_Firebase/app/src/main/res/layout/update_dialog.xml new file mode 100644 index 0000000000000000000000000000000000000000..d45de775933cbac16e3c6ceea74aaa9633590bf1 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/layout/update_dialog.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:padding="@dimen/activity_horizontal_margin"> + + <EditText + android:id="@+id/editTextName" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/enter_name" + android:inputType="text" + android:importantForAutofill="no" /> + + <Spinner + android:id="@+id/spinnerCountry" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:entries="@array/countries" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + style="?android:attr/buttonBarStyle" + android:orientation="horizontal"> + + <Button + android:id="@+id/buttonUpdateAuthor" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + style="?android:attr/buttonBarButtonStyle" + android:text="@string/update" /> + + <Button + android:id="@+id/buttonDeleteAuthor" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + style="?android:attr/buttonBarButtonStyle" + android:text="@string/delete" /> + + </LinearLayout> +</LinearLayout> \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/res/mipmap-anydpi/ic_launcher.xml b/labs/Lab7_Firebase/app/src/main/res/mipmap-anydpi/ic_launcher.xml new file mode 100644 index 0000000000000000000000000000000000000000..eca70cfe52eac1ba66ba280a68ca7be8fcf88a16 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/mipmap-anydpi/ic_launcher.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@drawable/ic_launcher_background" /> + <foreground android:drawable="@drawable/ic_launcher_foreground" /> +</adaptive-icon> \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/labs/Lab7_Firebase/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml new file mode 100644 index 0000000000000000000000000000000000000000..eca70cfe52eac1ba66ba280a68ca7be8fcf88a16 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@drawable/ic_launcher_background" /> + <foreground android:drawable="@drawable/ic_launcher_foreground" /> +</adaptive-icon> \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/res/mipmap-hdpi/ic_launcher.png b/labs/Lab7_Firebase/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..a2f5908281d070150700378b64a84c7db1f97aa1 Binary files /dev/null and b/labs/Lab7_Firebase/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/labs/Lab7_Firebase/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/labs/Lab7_Firebase/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000000000000000000000000000000000000..1b523998081149a985cef0cdf89045b9ed29964a Binary files /dev/null and b/labs/Lab7_Firebase/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/labs/Lab7_Firebase/app/src/main/res/mipmap-mdpi/ic_launcher.png b/labs/Lab7_Firebase/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..ff10afd6e182edb2b1a63c8f984e9070d9f950ba Binary files /dev/null and b/labs/Lab7_Firebase/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/labs/Lab7_Firebase/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/labs/Lab7_Firebase/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000000000000000000000000000000000000..115a4c768a20c9e13185c17043f4c4d12dd4632a Binary files /dev/null and b/labs/Lab7_Firebase/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/labs/Lab7_Firebase/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/labs/Lab7_Firebase/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..dcd3cd8083358269d6ed7894726283bb9bcbbfea Binary files /dev/null and b/labs/Lab7_Firebase/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/labs/Lab7_Firebase/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/labs/Lab7_Firebase/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000000000000000000000000000000000000..459ca609d3ae0d3943ab44cdc27feef9256dc6d7 Binary files /dev/null and b/labs/Lab7_Firebase/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/labs/Lab7_Firebase/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/labs/Lab7_Firebase/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..8ca12fe024be86e868d14e91120a6902f8e88ac6 Binary files /dev/null and b/labs/Lab7_Firebase/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/labs/Lab7_Firebase/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/labs/Lab7_Firebase/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000000000000000000000000000000000..8e19b410a1b15ff180f3dacac19395fe3046cdec Binary files /dev/null and b/labs/Lab7_Firebase/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/labs/Lab7_Firebase/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/labs/Lab7_Firebase/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..b824ebdd48db917eea2e67a82260a100371f8a24 Binary files /dev/null and b/labs/Lab7_Firebase/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/labs/Lab7_Firebase/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/labs/Lab7_Firebase/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000000000000000000000000000000000..4c19a13c239cb67b8a2134ddd5f325db1d2d5bee Binary files /dev/null and b/labs/Lab7_Firebase/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/labs/Lab7_Firebase/app/src/main/res/values/colors.xml b/labs/Lab7_Firebase/app/src/main/res/values/colors.xml new file mode 100644 index 0000000000000000000000000000000000000000..3ab3e9cbce07f7cdc941fc8ba424c05e83ed80f0 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="colorPrimary">#3F51B5</color> + <color name="colorPrimaryDark">#303F9F</color> + <color name="colorAccent">#FF4081</color> +</resources> diff --git a/labs/Lab7_Firebase/app/src/main/res/values/dimens.xml b/labs/Lab7_Firebase/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000000000000000000000000000000000000..48963b20617f19bb0acd4f8d64652afde649ae52 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/values/dimens.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <!-- Default screen margins, per the Android Design guidelines. --> + <dimen name="activity_horizontal_margin">16dp</dimen> + <dimen name="activity_vertical_margin">16dp</dimen> +</resources> \ No newline at end of file diff --git a/labs/Lab7_Firebase/app/src/main/res/values/strings.xml b/labs/Lab7_Firebase/app/src/main/res/values/strings.xml new file mode 100644 index 0000000000000000000000000000000000000000..8b2d3699bb3ed615da15aaf4bfd3cfcbd8e32331 --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/values/strings.xml @@ -0,0 +1,31 @@ +<resources> + <string name="app_name">MyHomeLibrary</string> + <array name="countries"> + <item name="america">America</item> + <item name="france">France</item> + <item name="spain">Spain</item> + <item name="columbia">Columbia</item> + <item name="russia">Russia</item> + </array> + + <string name="enter_name">Enter name</string> + <string name="enter_title_name">Enter title name</string> + <string name="enter_author_name">Enter author\'s name</string> + <string name="add_titles">Add Titles</string> + <string name="register_new_account">Register new account</string> + <string name="tap_to_view">Tap on an Author to add and view titles</string> + <string name="one">1</string> + <string name="add">Add</string> + <string name="authors">Authors</string> + <string name="account_login">Account Login</string> + <string name="delete">Delete</string> + <string name="email">Email</string> + <string name="login">Login</string> + <string name="password">Password</string> + <string name="register">Register</string> + <string name="titles">Titles</string> + <string name="update">Update</string> + + <string name="test_author">Ivo Andric</string> + <string name="test_country">Kingdom of Yugoslavia</string> +</resources> diff --git a/labs/Lab7_Firebase/app/src/main/res/values/styles.xml b/labs/Lab7_Firebase/app/src/main/res/values/styles.xml new file mode 100644 index 0000000000000000000000000000000000000000..5885930df6d10edf3d6df40d6556297d11f953da --- /dev/null +++ b/labs/Lab7_Firebase/app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ +<resources> + + <!-- Base application theme. --> + <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> + <!-- Customize your theme here. --> + <item name="colorPrimary">@color/colorPrimary</item> + <item name="colorPrimaryDark">@color/colorPrimaryDark</item> + <item name="colorAccent">@color/colorAccent</item> + </style> + +</resources> diff --git a/labs/Lab7_Firebase/build.gradle b/labs/Lab7_Firebase/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..58fcefa6bafae802c9889fb1a88599542a5e1796 --- /dev/null +++ b/labs/Lab7_Firebase/build.gradle @@ -0,0 +1,29 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.4.10' + + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:4.0.2' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + classpath 'com.google.gms:google-services:4.3.4' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/labs/Lab7_Firebase/gradle.properties b/labs/Lab7_Firebase/gradle.properties new file mode 100644 index 0000000000000000000000000000000000000000..23339e0df69d1fe76df74d7cc6c861fced84e98c --- /dev/null +++ b/labs/Lab7_Firebase/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official diff --git a/labs/Lab7_Firebase/gradle/wrapper/gradle-wrapper.jar b/labs/Lab7_Firebase/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..f6b961fd5a86aa5fbfe90f707c3138408be7c718 Binary files /dev/null and b/labs/Lab7_Firebase/gradle/wrapper/gradle-wrapper.jar differ diff --git a/labs/Lab7_Firebase/gradle/wrapper/gradle-wrapper.properties b/labs/Lab7_Firebase/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000000000000000000000000000000000..549e5d0b0b1a179d2316bfd9ebd587a25a4a0f8d --- /dev/null +++ b/labs/Lab7_Firebase/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Oct 09 03:04:08 BOT 2019 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/labs/Lab7_Firebase/gradlew b/labs/Lab7_Firebase/gradlew new file mode 100644 index 0000000000000000000000000000000000000000..cccdd3d517fc5249beaefa600691cf150f2fa3e6 --- /dev/null +++ b/labs/Lab7_Firebase/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/labs/Lab7_Firebase/gradlew.bat b/labs/Lab7_Firebase/gradlew.bat new file mode 100644 index 0000000000000000000000000000000000000000..f9553162f122c71b34635112e717c3e733b5b212 --- /dev/null +++ b/labs/Lab7_Firebase/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/labs/Lab7_Firebase/settings.gradle b/labs/Lab7_Firebase/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..dc5064cd0c419e8806674dfd741f7263d7a9c596 --- /dev/null +++ b/labs/Lab7_Firebase/settings.gradle @@ -0,0 +1,2 @@ +include ':app' +rootProject.name='Lab7-Firebase'