-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing the main activity (+5 squashed commits)
Squashed commits: [55b7173] adding the view class [e83b8b4] removing menu and adding id for layout parent [1355f4f] no message [e209ad6] Changed description [7395189] initial lab2 commit
- Loading branch information
Showing
31 changed files
with
475 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="se.kth.csc.iprog.dinnerplanner.android" | ||
android:versionCode="1" | ||
android:versionName="1.0" > | ||
|
||
<uses-sdk | ||
android:minSdkVersion="8" | ||
android:targetSdkVersion="18" /> | ||
|
||
<application | ||
android:name="se.kth.csc.iprog.dinnerplanner.android.DinnerPlannerApplication" | ||
android:allowBackup="true" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
<activity | ||
android:name="se.kth.csc.iprog.dinnerplanner.android.MainActivity" | ||
android:label="@string/app_name" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
iprog-dinnerplanner-android | ||
=========================== | ||
Interaction Programing - Lab assignment - Android | ||
================================================= | ||
|
||
This project contains the startup code for Android version of the Interaction Programing course lab assignment. For more details on how to complete the assignment follow the instructions on the [course website](https://www.kth.se/social/course/DH2641). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# To enable ProGuard in your project, edit project.properties | ||
# to define the proguard.config property as described in that file. | ||
# | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in ${sdk.dir}/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the ProGuard | ||
# include property in project.properties. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# 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 *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This file is automatically generated by Android Tools. | ||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||
# | ||
# This file must be checked in Version Control Systems. | ||
# | ||
# To customize properties used by the Ant build system edit | ||
# "ant.properties", and override values to adapt the script to your | ||
# project structure. | ||
# | ||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): | ||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt | ||
|
||
# Project target. | ||
target=android-19 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<RelativeLayout 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: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=".MainActivity" | ||
android:id="@+id/main_view"> | ||
|
||
<TextView | ||
android:id="@+id/example_text" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/hello_world" /> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<resources> | ||
|
||
<!-- | ||
Customize dimensions originally defined in res/values/dimens.xml (such as | ||
screen margins) for sw600dp devices (e.g. 7" tablets) here. | ||
--> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<resources> | ||
|
||
<!-- | ||
Customize dimensions originally defined in res/values/dimens.xml (such as | ||
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. | ||
--> | ||
<dimen name="activity_horizontal_margin">128dp</dimen> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<resources> | ||
|
||
<!-- | ||
Base application theme for API 11+. This theme completely replaces | ||
AppBaseTheme from res/values/styles.xml on API 11+ devices. | ||
--> | ||
<style name="AppBaseTheme" parent="android:Theme.Holo.Light"> | ||
<!-- API 11 theme customizations can go here. --> | ||
</style> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<resources> | ||
|
||
<!-- | ||
Base application theme for API 14+. This theme completely replaces | ||
AppBaseTheme from BOTH res/values/styles.xml and | ||
res/values-v11/styles.xml on API 14+ devices. | ||
--> | ||
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar"> | ||
<!-- API 14 theme customizations can go here. --> | ||
</style> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<resources> | ||
|
||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<string name="app_name">DinnerPlanner</string> | ||
<string name="action_settings">Settings</string> | ||
<string name="hello_world">Hello world!</string> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<resources> | ||
|
||
<!-- | ||
Base application theme, dependent on API level. This theme is replaced | ||
by AppBaseTheme from res/values-vXX/styles.xml on newer devices. | ||
--> | ||
<style name="AppBaseTheme" parent="android:Theme.Light"> | ||
<!-- | ||
Theme customizations available in newer API levels can go in | ||
res/values-vXX/styles.xml, while customizations related to | ||
backward-compatibility can go here. | ||
--> | ||
</style> | ||
|
||
<!-- Application theme. --> | ||
<style name="AppTheme" parent="AppBaseTheme"> | ||
<!-- All customizations that are NOT specific to a particular API-level can go here. --> | ||
</style> | ||
|
||
</resources> |
19 changes: 19 additions & 0 deletions
19
src/se/kth/csc/iprog/dinnerplanner/android/DinnerPlannerApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package se.kth.csc.iprog.dinnerplanner.android; | ||
|
||
import se.kth.csc.iprog.dinnerplanner.model.DinnerModel; | ||
import android.app.Application; | ||
|
||
public class DinnerPlannerApplication extends Application { | ||
|
||
private DinnerModel model = new DinnerModel(); | ||
|
||
public DinnerModel getModel() { | ||
return model; | ||
} | ||
|
||
public void setModel(DinnerModel model) { | ||
this.model = model; | ||
} | ||
|
||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/se/kth/csc/iprog/dinnerplanner/android/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package se.kth.csc.iprog.dinnerplanner.android; | ||
|
||
import se.kth.csc.iprog.dinnerplanner.android.view.MainView; | ||
import se.kth.csc.iprog.dinnerplanner.model.DinnerModel; | ||
import android.os.Bundle; | ||
import android.app.Activity; | ||
|
||
public class MainActivity extends Activity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
// Default call to load previous state | ||
super.onCreate(savedInstanceState); | ||
|
||
// Set the view for the main activity screen | ||
// it must come before any call to findViewById method | ||
setContentView(R.layout.activity_main); | ||
|
||
// Get the model | ||
DinnerModel model = ((DinnerPlannerApplication) this.getApplication()).getModel(); | ||
|
||
// Creating the view class | ||
MainView mainView = new MainView(findViewById(R.id.main_view), model); | ||
|
||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/se/kth/csc/iprog/dinnerplanner/android/view/MainView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package se.kth.csc.iprog.dinnerplanner.android.view; | ||
|
||
import se.kth.csc.iprog.dinnerplanner.android.R; | ||
import se.kth.csc.iprog.dinnerplanner.model.DinnerModel; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
public class MainView { | ||
|
||
View view; | ||
|
||
public MainView(View view, DinnerModel model) { | ||
|
||
// store in the class the reference to the Android View | ||
this.view = view; | ||
|
||
TextView example = (TextView) view.findViewById(R.id.example_text); | ||
example.setText("Hello world"); | ||
|
||
// Setup the rest of the view layout | ||
} | ||
|
||
} |
100 changes: 100 additions & 0 deletions
100
src/se/kth/csc/iprog/dinnerplanner/model/DinnerModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package se.kth.csc.iprog.dinnerplanner.model; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class DinnerModel { | ||
|
||
|
||
Set<Dish> dishes = new HashSet<Dish>(); | ||
|
||
/** | ||
* TODO: For Lab2 you need to implement the IDinnerModel interface. | ||
* When you do this you will have all the needed fields and methods | ||
* for the dinner planner (number of guests, selected dishes, etc.). | ||
*/ | ||
|
||
|
||
/** | ||
* The constructor of the overall model. Set the default values here | ||
*/ | ||
public DinnerModel(){ | ||
|
||
//Adding some example data, you can add more | ||
Dish dish1 = new Dish("French toast",Dish.STARTER,"toast.jpg","In a large mixing bowl, beat the eggs. Add the milk, brown sugar and nutmeg; stir well to combine. Soak bread slices in the egg mixture until saturated. Heat a lightly oiled griddle or frying pan over medium high heat. Brown slices on both sides, sprinkle with cinnamon and serve hot."); | ||
Ingredient dish1ing1 = new Ingredient("eggs",0.5,"",1); | ||
Ingredient dish1ing2 = new Ingredient("milk",30,"ml",6); | ||
Ingredient dish1ing3 = new Ingredient("brown sugar",7,"g",1); | ||
Ingredient dish1ing4 = new Ingredient("ground nutmeg",0.5,"g",12); | ||
Ingredient dish1ing5 = new Ingredient("white bread",2,"slices",2); | ||
dish1.addIngredient(dish1ing1); | ||
dish1.addIngredient(dish1ing2); | ||
dish1.addIngredient(dish1ing3); | ||
dish1.addIngredient(dish1ing4); | ||
dish1.addIngredient(dish1ing5); | ||
dishes.add(dish1); | ||
|
||
Dish dish2 = new Dish("Meat balls",Dish.MAIN,"meatballs.jpg","Preheat an oven to 400 degrees F (200 degrees C). Place the beef into a mixing bowl, and season with salt, onion, garlic salt, Italian seasoning, oregano, red pepper flakes, hot pepper sauce, and Worcestershire sauce; mix well. Add the milk, Parmesan cheese, and bread crumbs. Mix until evenly blended, then form into 1 1/2-inch meatballs, and place onto a baking sheet. Bake in the preheated oven until no longer pink in the center, 20 to 25 minutes."); | ||
Ingredient dish2ing1 = new Ingredient("extra lean ground beef",115,"g",20); | ||
Ingredient dish2ing2 = new Ingredient("sea salt",0.7,"g",3); | ||
Ingredient dish2ing3 = new Ingredient("small onion, diced",0.25,"",2); | ||
Ingredient dish2ing4 = new Ingredient("garlic salt",0.6,"g",3); | ||
Ingredient dish2ing5 = new Ingredient("Italian seasoning",0.3,"g",3); | ||
Ingredient dish2ing6 = new Ingredient("dried oregano",0.3,"g",3); | ||
Ingredient dish2ing7 = new Ingredient("crushed red pepper flakes",0.6,"g",3); | ||
Ingredient dish2ing8 = new Ingredient("Worcestershire sauce",16,"ml",7); | ||
Ingredient dish2ing9 = new Ingredient("milk",20,"ml",4); | ||
Ingredient dish2ing10 = new Ingredient("grated Parmesan cheese",5,"g",8); | ||
Ingredient dish2ing11 = new Ingredient("seasoned bread crumbs",115,"g",4); | ||
dish2.addIngredient(dish2ing1); | ||
dish2.addIngredient(dish2ing2); | ||
dish2.addIngredient(dish2ing3); | ||
dish2.addIngredient(dish2ing4); | ||
dish2.addIngredient(dish2ing5); | ||
dish2.addIngredient(dish2ing6); | ||
dish2.addIngredient(dish2ing7); | ||
dish2.addIngredient(dish2ing8); | ||
dish2.addIngredient(dish2ing9); | ||
dish2.addIngredient(dish2ing10); | ||
dish2.addIngredient(dish2ing11); | ||
dishes.add(dish2); | ||
|
||
} | ||
|
||
/** | ||
* Returns the set of dishes of specific type. (1 = starter, 2 = main, 3 = desert). | ||
*/ | ||
public Set<Dish> getDishes(){ | ||
return dishes; | ||
} | ||
|
||
/** | ||
* Returns the set of dishes of specific type. (1 = starter, 2 = main, 3 = desert). | ||
*/ | ||
public Set<Dish> getDishesOfType(int type){ | ||
Set<Dish> result = new HashSet<Dish>(); | ||
for(Dish d : dishes){ | ||
if(d.getType() == type){ | ||
result.add(d); | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
/** | ||
* Returns the set of dishes of specific type, that contain filter in their name | ||
* or name of any ingredient. | ||
*/ | ||
public Set<Dish> filterDishesOfType(int type, String filter){ | ||
Set<Dish> result = new HashSet<Dish>(); | ||
for(Dish d : dishes){ | ||
if(d.getType() == type && d.contains(filter)){ | ||
result.add(d); | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
|
||
|
||
} |
Oops, something went wrong.