diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6023338 --- /dev/null +++ b/.gitignore @@ -0,0 +1,199 @@ + +# Created by https://www.gitignore.io/api/android,androidstudio +# Edit at https://www.gitignore.io/?templates=android,androidstudio + +### Android ### +# Built application files +*.apk +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +.idea/caches +# Android Studio 3 in .gitignore file. +.idea/caches/build_file_checksums.ser +.idea/modules.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +### Android Patch ### +gen-external-apklibs +output.json + +### AndroidStudio ### +# Covers files to be ignored for android development using Android Studio. + +# Built application files + +# Files for the ART/Dalvik VM + +# Java class files + +# Generated files + +# Gradle files +.gradle + +# Signing files +.signing/ + +# Local configuration file (sdk path, etc) + +# Proguard folder generated by Eclipse + +# Log Files + +# Android Studio +/*/build/ +/*/local.properties +/*/out +/*/*/build +/*/*/production +*.ipr +*~ +*.swp + +# Android Patch + +# External native build folder generated in Android Studio 2.2 and later + +# NDK +obj/ + +# IntelliJ IDEA +*.iws +/out/ + +# User-specific configurations +.idea/caches/ +.idea/libraries/ +.idea/shelf/ +.idea/.name +.idea/compiler.xml +.idea/copyright/profiles_settings.xml +.idea/encodings.xml +.idea/misc.xml +.idea/scopes/scope_settings.xml +.idea/vcs.xml +.idea/jsLibraryMappings.xml +.idea/datasources.xml +.idea/dataSources.ids +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml + +# OS-specific files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Legacy Eclipse project files +.classpath +.project +.cproject +.settings/ + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.war +*.ear + +# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) +hs_err_pid* + +## Plugin-specific files: + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Mongo Explorer plugin +.idea/mongoSettings.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### AndroidStudio Patch ### + +!/gradle/wrapper/gradle-wrapper.jar + +# End of https://www.gitignore.io/api/android,androidstudio \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..30aa626 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..2996d53 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..37a7509 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/render.experimental.xml b/.idea/render.experimental.xml new file mode 100644 index 0000000..f1e6ad7 --- /dev/null +++ b/.idea/render.experimental.xml @@ -0,0 +1,6 @@ + + + + + \ 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..2551e93 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,28 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "com.example.watchedmovielist" + minSdkVersion 21 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support.constraint:constraint-layout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' +} 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/watchedmovielist/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/watchedmovielist/ExampleInstrumentedTest.java new file mode 100644 index 0000000..6222e60 --- /dev/null +++ b/app/src/androidTest/java/com/example/watchedmovielist/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.watchedmovielist; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.example.watchedmovielist", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..102bb2c --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/watchedmovielist/EditActivity.java b/app/src/main/java/com/example/watchedmovielist/EditActivity.java new file mode 100644 index 0000000..024694b --- /dev/null +++ b/app/src/main/java/com/example/watchedmovielist/EditActivity.java @@ -0,0 +1,64 @@ +package com.example.watchedmovielist; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.content.pm.ActivityInfo; +import android.graphics.Movie; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Switch; + +public class EditActivity extends AppCompatActivity { + + private MovieListing movie; + private EditText editTextView; + private Switch watchedFlag; + private Button saver; + private Button ender; + Context context; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_edit); + Intent i = getIntent(); + movie = (MovieListing)i.getSerializableExtra("KEY"); + editTextView = findViewById(R.id.name_edit_text); + watchedFlag = findViewById(R.id.watched_switch); + saver = findViewById(R.id.save_bttn); + ender = findViewById(R.id.delete_button); + context = this; + + if(movie != null) { + + editTextView.setText(movie.getName()); + watchedFlag.setChecked(movie.isWatched()); + } + + saver.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent viewDetailIntent = new Intent(); + movie = new MovieListing(editTextView.getText().toString(), watchedFlag.isChecked()); + viewDetailIntent.putExtra("KEY", movie); + setResult(Activity.RESULT_OK, viewDetailIntent); + finish(); + } + + }); + ender.setOnClickListener((new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent viewDetailIntent = new Intent(); + setResult(Activity.RESULT_CANCELED, viewDetailIntent); + finish(); + } + })); + + } +} diff --git a/app/src/main/java/com/example/watchedmovielist/MainActivity.java b/app/src/main/java/com/example/watchedmovielist/MainActivity.java new file mode 100644 index 0000000..9f7d258 --- /dev/null +++ b/app/src/main/java/com/example/watchedmovielist/MainActivity.java @@ -0,0 +1,103 @@ +package com.example.watchedmovielist; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.graphics.Movie; +import android.graphics.Paint; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.TextView; + +import java.util.ArrayList; + +public class MainActivity extends AppCompatActivity { + Context context; + MovieRepository movies = new MovieRepository() ; + LinearLayout lineMan; + public Button addBttn; + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if(resultCode == Activity.RESULT_CANCELED) return; + MovieListing movie = (MovieListing)data.getSerializableExtra("KEY"); + + if(movie != null) { + movies.add(movie); + Log.i("Debug", "Added movie: " + movie.getName()); + } + } + + @Override + protected void onResume() { + super.onResume(); + + lineMan.removeAllViews(); + for(MovieListing m:movies.getMovies()) { + TextView t = createMovieView(m); + Log.i("Debug", "Added view for " + m.getName()); + lineMan.addView(t); + } + + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + context = this; + + lineMan = (LinearLayout) findViewById(R.id.line_man); + + addBttn = findViewById(R.id.add_movie); + addBttn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent i = new Intent(context, EditActivity.class); + startActivityForResult(i, 0); + } + }); + + + + /* if(movie != null) { + + editTextView.setText(movie.getName()); + watchedFlag.setChecked(movie.isWatched()); + } + */ + + + + } + + private TextView createMovieView(final MovieListing m){ + TextView view = new TextView(context); + view.setText(m.getName()); + view.setPadding(12,12,12,12); + view.setTextSize(22); + if(m.isWatched()) { + view.setPaintFlags(view.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); + } + + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent detailsActivityIntent = new Intent(context, EditActivity.class); + detailsActivityIntent.putExtra("KEY",m); + movies.remove(m); + startActivityForResult(detailsActivityIntent, 0); + } + }); + return view; + } + + +} diff --git a/app/src/main/java/com/example/watchedmovielist/MovieListing.java b/app/src/main/java/com/example/watchedmovielist/MovieListing.java new file mode 100644 index 0000000..d64e295 --- /dev/null +++ b/app/src/main/java/com/example/watchedmovielist/MovieListing.java @@ -0,0 +1,31 @@ +package com.example.watchedmovielist; + +import java.io.Serializable; + +public class MovieListing implements Serializable { + String name = ""; + boolean watched; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isWatched() { + return watched; + } + + public void setWatched(boolean watched) { + this.watched = watched; + } + + public MovieListing(String name, boolean watched) { + this.name = name; + this.watched = watched; + } + + +} diff --git a/app/src/main/java/com/example/watchedmovielist/MovieRepository.java b/app/src/main/java/com/example/watchedmovielist/MovieRepository.java new file mode 100644 index 0000000..f3dfaf3 --- /dev/null +++ b/app/src/main/java/com/example/watchedmovielist/MovieRepository.java @@ -0,0 +1,22 @@ +package com.example.watchedmovielist; + +import java.util.ArrayList; + +public class MovieRepository { + public MovieRepository() { + } + + ArrayList movies = new ArrayList(); + + public void add(MovieListing movie){ + movies.add(movie); + } + + public void remove(MovieListing movie) { + movies.remove(movie); + } + + public ArrayList getMovies() { + return movies; + } +} 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..1f6bb29 --- /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..0d025f9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_edit.xml b/app/src/main/res/layout/activity_edit.xml new file mode 100644 index 0000000..ac92613 --- /dev/null +++ b/app/src/main/res/layout/activity_edit.xml @@ -0,0 +1,80 @@ + + + +