diff --git a/.idea/dictionaries/shoon.xml b/.idea/dictionaries/shoon.xml new file mode 100644 index 0000000..1b70c45 --- /dev/null +++ b/.idea/dictionaries/shoon.xml @@ -0,0 +1,7 @@ + + + + begining + + + \ 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..a257b66 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,31 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "com.lambda.movie" + minSdkVersion 15 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + vectorDrawables.useSupportLibrary = true + } + 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' + implementation 'com.android.support:design:28.0.0' + implementation 'com.android.support:support-vector-drawable:28.0.0' + 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/lambda/androidsprintchallenge1/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/lambda/androidsprintchallenge1/ExampleInstrumentedTest.java new file mode 100644 index 0000000..8de6b4d --- /dev/null +++ b/app/src/androidTest/java/com/lambda/androidsprintchallenge1/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.lambda.androidsprintchallenge1; + +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.lambda.androidsprintchallenge1", appContext.getPackageName()); + } +} diff --git a/app/src/androidTest/java/com/lambda/movie/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/lambda/movie/ExampleInstrumentedTest.java new file mode 100644 index 0000000..5206993 --- /dev/null +++ b/app/src/androidTest/java/com/lambda/movie/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.lambda.movie; + +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.lambda.movie", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..8d9b6bc --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/lambda/movie/EditingPageActivity.java b/app/src/main/java/com/lambda/movie/EditingPageActivity.java new file mode 100644 index 0000000..c31e32c --- /dev/null +++ b/app/src/main/java/com/lambda/movie/EditingPageActivity.java @@ -0,0 +1,101 @@ +package com.lambda.movie; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.CompoundButton; +import android.widget.EditText; +import android.widget.Switch; +import android.widget.TextView; + + +public class EditingPageActivity extends AppCompatActivity { + static MovieList mlCurrent; + Switch swWatched; + EditText etInputData; + @Override + protected void onCreate(Bundle savedInstanceState) { + setContentView(R.layout.activity_editing_page); + super.onCreate(savedInstanceState); + + + receiveData(); + + swWatched.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + TextView tvd=findViewById(R.id.text_debug_for_switch); + if (isChecked) { + tvd.append("TRUE");// The toggle is enabled + } else { + tvd.append("FALSE"); // The toggle is disabled + } + } + }); + findViewById(R.id.button_save).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // search for drug by brand name + TextView currentTextView =findViewById (R.id.input_data); + sendData(currentTextView); + + } + }); + findViewById(R.id.button_delete).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // search for drug by brand name + TextView currentTextView =findViewById (R.id.button_delete); + sendDatatoDelete(currentTextView); + } + }); + } + + + + private void receiveData(){ + etInputData=findViewById(R.id.input_data); + + swWatched =findViewById(R.id.switch_watched); + mlCurrent=(MovieList) getIntent().getSerializableExtra("DATA"); + swWatched.setChecked(mlCurrent.getWatched()); + + etInputData.setText(mlCurrent.getName()); + + + swWatched.setOnCheckedChangeListener(null); + swWatched.setChecked(mlCurrent.isWatched()); + swWatched.invalidate(); + + } + + private void sendData(TextView tv){ + Context context = getApplicationContext(); + Switch sw=findViewById(R.id.switch_watched); + mlCurrent.setName(tv.getText().toString()); + mlCurrent.setWatched(sw.isChecked()); + + MovieList ml=mlCurrent; + Intent intent = new Intent(context, MainActivity.class); + intent.putExtra("DATA", ml); + + startActivity(intent); + } + + private void sendDatatoDelete(TextView tv){ + Context context = getApplicationContext(); + Switch sw=findViewById(R.id.switch_watched); + + mlCurrent.setName(""); //Trigger to delete + // mlCurrent.setWatched(sw.isChecked()); //not necessary + + MovieList ml=mlCurrent; + + Intent intent = new Intent(context, MainActivity.class); + intent.putExtra("DATA", ml); + + startActivity(intent); + } + +} diff --git a/app/src/main/java/com/lambda/movie/MainActivity.java b/app/src/main/java/com/lambda/movie/MainActivity.java new file mode 100644 index 0000000..028cb30 --- /dev/null +++ b/app/src/main/java/com/lambda/movie/MainActivity.java @@ -0,0 +1,186 @@ +package com.lambda.movie; + +import android.content.Context; +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.text.SpannableString; +import android.text.Spanned; +import android.text.style.StrikethroughSpan; +import android.util.Log; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.TextView; + +import java.util.ArrayList; + + +public class MainActivity extends AppCompatActivity { + static MovieList mlCurrent; + + private static ArrayList alMovieList = new ArrayList(100); + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + + findViewById(R.id.button_edit_data).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + sendData(null); + } + }); + + findViewById(R.id.text_list).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + TextView currentTextView = (TextView)v; + sendData(currentTextView); + } + }); + } + + private void receiveData(){ + MovieList ml=(MovieList) getIntent().getSerializableExtra("DATA"); + if(ml==null)return; + findMovieListAPI fml=new findMovieListAPI(alMovieList); + + if(ml.getName().equals("")){//Delete + alMovieList=fml.deleteMovieList(ml); + + // if(mlCurrent==null) + }else{ + + alMovieList=fml.updateMovieList(ml); + } + } + + + + + + @Override + + protected void onResume () { + + super.onResume(); + + Log.i("ActivityLifecycle", getLocalClassName() + " - onResume"); + + setContentView(R.layout.activity_main); + + + receiveData(); + + if (mlCurrent == null) { + + //these are initial dummy + MovieList ml=new MovieList(1,"test1",true); + + this.alMovieList.add(ml); + MovieList ml1=new MovieList(2,"test2",false); + this.alMovieList.add(ml1); + MovieList ml2=new MovieList(3,"test3",true); + this.alMovieList.add(ml2); + mlCurrent=ml2; + + } + + if (alMovieList != null){ + + showResult(alMovieList); + } + + + + findViewById(R.id.button_edit_data).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + sendEmptyData(); + } + }); + } + + private void sendData(TextView tv){ + Context context = getApplicationContext(); + + findMovieListAPI fml=new findMovieListAPI(alMovieList); + mlCurrent=fml.findMovieListByIndex(indexExtractedFromString(tv.getText().toString())); + + Intent intent = new Intent(context, EditingPageActivity.class); + intent.putExtra("DATA", mlCurrent); + startActivity(intent); + } + + private int indexExtractedFromString(String stringName){ + int start=0; + for(int i=0;i aml) { + + Context context= getApplicationContext(); + String str = ""; + LinearLayout ll = findViewById(R.id.scrolling_view); + + MovieList ml; + for (int i = 0; i < aml.size(); i++) { + + ml = aml.get(i); + if(ml==null){ + str=" /n"; + return; + }else{ + str = ml.toString(); + } + TextView tv = new TextView(context); + + SpannableString spannable = new SpannableString(str); + if(ml.getWatched()==true) { + spannable.setSpan(new StrikethroughSpan(), 0, str.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); + tv.setText(spannable); + }else{ + tv.setText(str); + + } + + tv.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + TextView currentTextView = (TextView)v; + sendData(currentTextView); + } + }); + + ll.addView(tv); + } + } +} + + diff --git a/app/src/main/java/com/lambda/movie/MovieList.java b/app/src/main/java/com/lambda/movie/MovieList.java new file mode 100644 index 0000000..1d33a82 --- /dev/null +++ b/app/src/main/java/com/lambda/movie/MovieList.java @@ -0,0 +1,63 @@ +package com.lambda.movie; + +import java.io.Serializable; + +public class MovieList implements Serializable { + private int index; + private String stringName; + private boolean bWatched; + MovieList(int index, String name, boolean watched){ + this.index=index; + this.stringName=name; + bWatched=watched; + } + public String getName(){ + return stringName; + } + + public void setIndex(int index){ + this.index=index; + } + + public int getIndex(){ + return this.index; + } + public void setName(String name){ + this.stringName=name; + + } + public void setWatched(boolean watched){ + this.bWatched=watched; + } + public boolean getWatched(){ + return bWatched; + } + + public void fromString(String str, boolean watched){ + for(int i=0;i amlToFind; + MovieList ml=null; + findMovieListAPI(ArrayList aml){ + amlToFind=aml; + } + MovieList findMovieListByIndex(int index){ + + for(int i=0;i deleteMovieList(MovieList ml){ + if(ml.getIndex()==-1) return amlToFind; + for(int i=0;i updateMovieList(MovieList ml){ + int index=amlToFind.size(); + if(ml.getIndex()==-1){ //new index assignment + amlToFind.add(ml); + int newIndex=index; + int i; + for(i=0;i + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_dashboard_black_24dp.xml b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml new file mode 100644 index 0000000..46fc8de --- /dev/null +++ b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_home_black_24dp.xml b/app/src/main/res/drawable/ic_home_black_24dp.xml new file mode 100644 index 0000000..f8bb0b5 --- /dev/null +++ b/app/src/main/res/drawable/ic_home_black_24dp.xml @@ -0,0 +1,9 @@ + + + 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/drawable/ic_notifications_black_24dp.xml b/app/src/main/res/drawable/ic_notifications_black_24dp.xml new file mode 100644 index 0000000..78b75c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_notifications_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_editing_page.xml b/app/src/main/res/layout/activity_editing_page.xml new file mode 100644 index 0000000..22532f0 --- /dev/null +++ b/app/src/main/res/layout/activity_editing_page.xml @@ -0,0 +1,49 @@ + + + + + + +