diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b75303 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +*.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 diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..1bec35e --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..7ac24c7 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4865ec5 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,34 @@ +apply plugin: 'com.android.application' + +apply plugin: 'kotlin-android' + +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 29 + defaultConfig { + applicationId "com.example.myapplication" + minSdkVersion 22 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.core:core-ktx:1.0.2' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /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 diff --git a/app/src/androidTest/java/com/example/myapplication/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/example/myapplication/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..7f8f7ff --- /dev/null +++ b/app/src/androidTest/java/com/example/myapplication/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.myapplication + +import androidx.test.InstrumentationRegistry +import androidx.test.runner.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.getTargetContext() + assertEquals("com.example.myapplication", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..c58e528 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/MainActivity.kt b/app/src/main/java/com/example/myapplication/MainActivity.kt new file mode 100644 index 0000000..70e086d --- /dev/null +++ b/app/src/main/java/com/example/myapplication/MainActivity.kt @@ -0,0 +1,90 @@ +package com.example.myapplication + +import android.app.Activity + +import android.content.Intent + +import android.graphics.Paint +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.widget.TextView + + + +import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.activity_main.list_layout + + +class MainActivity : AppCompatActivity() { + + companion object { + + val EXTRA_STRING: String = "data" + + val RESULT_INT: Int = 54321 + + } + + + override fun onCreate(savedInstanceState: Bundle?) { + + super.onCreate(savedInstanceState) + + setContentView(R.layout.activity_main) + + text_view_sample_1.setOnClickListener { + intentGenerator(MovieList(text_view_sample_1.text.toString(), text_view_sample_1.background != null)) + list_layout.removeView(it) + } + + + text_view_sample_2.setOnClickListener { + intentGenerator(MovieList(text_view_sample_2.text.toString(), text_view_sample_2.background != null)) + list_layout.removeView(it) + } + + + + text_view_sample_3.setOnClickListener { + intentGenerator(MovieList(text_view_sample_3.text.toString(), text_view_sample_3.background != null)) + list_layout.removeView(it) + } + + button_add_movie.setOnClickListener { + intentGenerator(MovieList(getString(R.string.no_movie_entry))) + } + } + + private fun intentGenerator(name: MovieList) { + val intent = Intent(this, NextActivity::class.java) + intent.putExtra(EXTRA_STRING, name) + startActivityForResult(intent, RESULT_INT) + } + + + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + if (requestCode == RESULT_INT && resultCode == Activity.RESULT_OK) { + + val name: MovieList = data?.getSerializableExtra(MainActivity.EXTRA_STRING) as MovieList + val textView: TextView = textViewGenerator(name) + list_layout.addView(textView) + } + super.onActivityResult(requestCode, resultCode, data) + } + + + fun textViewGenerator(name: MovieList): TextView { + val textView: TextView = TextView(this) + textView.textSize = 30f + textView.text = name.name + + if (name.watched) textView.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG) + + textView.setOnClickListener { + intentGenerator(name) + list_layout.removeView(it) + } + return textView + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/MovieList.kt b/app/src/main/java/com/example/myapplication/MovieList.kt new file mode 100644 index 0000000..e899ebc --- /dev/null +++ b/app/src/main/java/com/example/myapplication/MovieList.kt @@ -0,0 +1,6 @@ +package com.example.myapplication + +import java.io.Serializable + +//initiating the class (there are no objects yet) +data class MovieList(var name: String? = null, var watched: Boolean = false): Serializable diff --git a/app/src/main/java/com/example/myapplication/NextActivity.kt b/app/src/main/java/com/example/myapplication/NextActivity.kt new file mode 100644 index 0000000..e651642 --- /dev/null +++ b/app/src/main/java/com/example/myapplication/NextActivity.kt @@ -0,0 +1,85 @@ +package com.example.myapplication + +import kotlinx.android.synthetic.main.activity_next.* + +import android.app.Activity + +import android.content.Intent + +import androidx.appcompat.app.AppCompatActivity + +import android.os.Bundle +import com.example.myapplication.MainActivity.Companion.EXTRA_STRING + + +class NextActivity : AppCompatActivity() { + + + + override fun onCreate(savedInstanceState: Bundle?) { + + super.onCreate(savedInstanceState) + + setContentView(R.layout.activity_next) + + + //value the movie in the movie list + val movie :MovieList= intent.getSerializableExtra(MainActivity.EXTRA_STRING) as MovieList + + + //null exception + if (movie.name!=getString(R.string.no_movie_entry)) { + + edit_entry.setText(movie.name) + + checkbox.isChecked=movie.watched + + } + + + + button_save.setOnClickListener { + + val intent = Intent() + + intent.putExtra(MainActivity.EXTRA_STRING, MovieList(edit_entry.text.toString(),checkbox.isChecked)) + + setResult(Activity.RESULT_OK, intent) + + finish() + + } + + + + button_delete.setOnClickListener { + + onBackPressed() + + } + + } + + + + /** + + * Take care of popping the fragment back stack or finishing the activity + + * as appropriate. + + */ + + override fun onBackPressed() { + + val intent = Intent() + + intent.putExtra(MainActivity.EXTRA_STRING, MovieList(getString(R.string.no_movie_entry))) + + setResult(Activity.RESULT_CANCELED, intent) + + finish() + + } + +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..6348baa --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + 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..a0ad202 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..7d52cc1 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + +