Permalink
Browse files

Merge branch 'master' of github.com:joey-mbk/MobileCityGuide

  • Loading branch information...
joey-mbk committed May 11, 2012
2 parents 06bd6e1 + 43711ca commit 67529c1aecf273447124e65c055643d722d1234f
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
BIN +46.8 KB res/drawable/gp1.jpg
Binary file not shown.
View
BIN +19.8 KB res/drawable/gp2.jpg
Binary file not shown.
View
BIN +16.4 KB res/drawable/gp3.jpg
Binary file not shown.
View
BIN +5.29 KB res/drawable/lac1.jpg
Binary file not shown.
View
BIN +12.4 KB res/drawable/lac2.jpg
Binary file not shown.
View
BIN +15.3 KB res/drawable/lac3.jpg
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
BIN +48.1 KB res/drawable/univ1.jpg
Binary file not shown.
View
BIN +78.7 KB res/drawable/univ2.jpg
Diff not rendered.
View
BIN +17.6 KB res/drawable/univ3.jpg
Diff not rendered.
View
Diff not rendered.
View
@@ -33,7 +33,7 @@
<ListView
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_marginTop="10dp"
android:layout_weight="0.47"
View
@@ -57,6 +57,10 @@
<string name="itinerary_delete">Delete an itinerary</string>
<string name="itinerary_deleteButton">Delete itinerary</string>
<string name="select_poiToDelete_text">Select a poi to delete it</string>
<string name="no_theme">You must select a theme</string>
<string name="no_ItineraryName">You must select a theme</string>
<string name="create_itinerary_error_alreadyused_text">Sorry, this itinerary name is already used. Please, choose another one.</string>
<string name="create_itinerary_error_itineraryNameformat_text">Sorry, itinerary name must contain only alphanumerical characters and no space.</string>
<string name="about_text">\
All rights reserved.
For educational use only.
@@ -18,16 +18,21 @@
import com.mobilecityguide.MobileCityGuideActivity;
import com.mobilecityguide.R;
import com.mobilecityguide.activity.CreateProfile.DialogButtonClickHandler;
import com.mobilecityguide.controllers.CategoryController;
import com.mobilecityguide.controllers.ItineraryController;
import com.mobilecityguide.controllers.UserController;
import com.mobilecityguide.models.Category;
import com.mobilecityguide.models.Itinerary;
public class CreateItinerary extends Activity implements OnClickListener {
protected CharSequence[] options_t;
protected int selections_t;
/* Error dialog */
AlertDialog.Builder error;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -88,32 +93,61 @@ private void setListeners() {
public void onClick(View v) {
Intent intent;
switch (v.getId()) {
case R.id.theme:
AlertDialog.Builder theme = new AlertDialog.Builder(this);
theme.setTitle(R.string.createitinerary_theme_text);
theme.setSingleChoiceItems(options_t, selections_t, new DialogSingleSelectionClickHandler());
theme.setPositiveButton("OK", new DialogButtonClickHandler());
theme.show();
break;
case R.id.add_pois:
case R.id.theme:
AlertDialog.Builder theme = new AlertDialog.Builder(this);
theme.setTitle(R.string.createitinerary_theme_text);
theme.setSingleChoiceItems(options_t, selections_t, new DialogSingleSelectionClickHandler());
theme.setPositiveButton("OK", new DialogButtonClickHandler("theme"));
theme.show();
break;
case R.id.add_pois:
String name =((EditText)findViewById(R.id.itineraryname)).getText().toString();
String selectedTheme = ((Button) findViewById(R.id.theme)).getText().toString();
if(selectedTheme.equals("Theme of the itinerary")){
error = new AlertDialog.Builder(this);
error.setTitle(R.string.create_profile_error_title);
error.setMessage(R.string.no_theme);
error.setPositiveButton("OK", new DialogButtonClickHandler("error"));
error.show();
}
else if(name == null || name.equals("") || !name.matches("[a-zA-Z0-9]+")){
error = new AlertDialog.Builder(this);
error.setTitle(R.string.create_profile_error_title);
error.setMessage(R.string.create_itinerary_error_itineraryNameformat_text);
error.setPositiveButton("OK", new DialogButtonClickHandler("error"));
error.show();
}
else if(ItineraryController.isItineraryNameAlreadyUsed(name)){
error = new AlertDialog.Builder(this);
error.setTitle(R.string.create_profile_error_title);
error.setMessage(R.string.create_itinerary_error_alreadyused_text);
error.setPositiveButton("OK", new DialogButtonClickHandler("error"));
error.show();
}
else
{
System.out.println("Itinerary create");
/* we create the itinerary object */
Itinerary itinerary = new Itinerary();
itinerary.setId(ItineraryController.itineraryMapper.getLastItineraryID()+1);
itinerary.addTitle(UserController.activeUser.getLanguage()[0], ((EditText)findViewById(R.id.itineraryname)).getText().toString());
itinerary.addTitle(UserController.activeUser.getLanguage()[0], ((EditText)findViewById(R.id.itineraryname)).getText().toString());
itinerary.setTheme(CategoryController.getCategory( ((Button) findViewById(R.id.theme)).getText().toString() ));
/* add it to the database */
try {
ItineraryController.addItinerary(itinerary);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error while creating a new itinerary.");
}
intent = new Intent(this, ItinerariesList.class);
startActivity(intent);
Toast.makeText(this, R.string.createitinerary_added_text, Toast.LENGTH_SHORT).show();
break;
}
break;
}
}
@@ -124,12 +158,21 @@ public void onClick(DialogInterface dialog, int which) {
}
public class DialogButtonClickHandler implements DialogInterface.OnClickListener {
private String window;
public DialogButtonClickHandler(String window) {
this.window = window;
}
public void onClick(DialogInterface dialog, int clicked) {
switch(clicked) {
case DialogInterface.BUTTON_POSITIVE:
case DialogInterface.BUTTON_POSITIVE:
if (window.equals("theme")) {
Button button = (Button) findViewById(R.id.theme);
button.setText(options_t[selections_t]);
}
break;
}
}
}
@@ -1,5 +1,7 @@
package com.mobilecityguide.activity;
import java.util.HashMap;
import com.mobilecityguide.MobileCityGuideActivity;
import com.mobilecityguide.R;
import com.mobilecityguide.controllers.POIController;
@@ -8,14 +10,18 @@
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -25,6 +31,8 @@
private boolean freewalk;
private int step;
ImageView image;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -78,6 +86,66 @@ else if (this.freewalk) {
setContentView(R.layout.poi_details);
((TextView) findViewById(R.id.description)).setText(desc);
((TextView) findViewById(R.id.address)).setText(poi.getAddress());
image = (ImageView) findViewById(R.id.imageView);
String path = ((poi.getImages("day")).split("\\."))[0];
if(path.equals("barb93"))
image.setImageResource(R.drawable.barb93);
else if(path.equals("barbe1"))
image.setImageResource(R.drawable.barbe1);
else if(path.equals("barbe2"))
image.setImageResource(R.drawable.barbe2);
else if(path.equals("barbe3"))
image.setImageResource(R.drawable.barbe3);
else if(path.equals("cinescope1"))
image.setImageResource(R.drawable.cinescope1);
else if(path.equals("cinescope2"))
image.setImageResource(R.drawable.cinescope2);
else if(path.equals("cinescope3"))
image.setImageResource(R.drawable.cinescope3);
else if(path.equals("creperie_bretone"))
image.setImageResource(R.drawable.creperie_bretone);
else if(path.equals("creperie_bretone2"))
image.setImageResource(R.drawable.creperie_bretone2);
else if(path.equals("esplanade"))
image.setImageResource(R.drawable.esplanade);
else if(path.equals("esplanade2"))
image.setImageResource(R.drawable.esplanade2);
else if(path.equals("gp1"))
image.setImageResource(R.drawable.gp1);
else if(path.equals("gp2"))
image.setImageResource(R.drawable.gp2);
else if(path.equals("gp3"))
image.setImageResource(R.drawable.gp3);
else if(path.equals("lac1"))
image.setImageResource(R.drawable.lac1);
else if(path.equals("lac2"))
image.setImageResource(R.drawable.lac2);
else if(path.equals("lac3"))
image.setImageResource(R.drawable.lac3);
else if(path.equals("sciences1"))
image.setImageResource(R.drawable.sciences1);
else if(path.equals("sciences2"))
image.setImageResource(R.drawable.sciences2);
else if(path.equals("sciences3"))
image.setImageResource(R.drawable.sciences3);
else if(path.equals("univ1"))
image.setImageResource(R.drawable.univ1);
else if(path.equals("univ2"))
image.setImageResource(R.drawable.univ2);
else if(path.equals("univ3"))
image.setImageResource(R.drawable.univ3);
else if(path.equals("wallons1"))
image.setImageResource(R.drawable.wallons1);
else if(path.equals("museeherge31"))
image.setImageResource(R.drawable.museeherge31);
else if(path.equals("museeherge5"))
image.setImageResource(R.drawable.museeherge5);
else if(path.equals("museelln1"))
image.setImageResource(R.drawable.museelln1);
else if(path.equals("museelln2"))
image.setImageResource(R.drawable.museelln2);
/* if we're coming from an itinerary, show a 'Next' button */
if (this.inItinerary) {
@@ -118,4 +118,18 @@ public static void addItinerary(Itinerary itinerary) throws Exception{
public static Itinerary getLastAddedItinerary() throws Exception{
return getItinerary(itineraryMapper.getLastItineraryID());
}
public static boolean isItineraryNameAlreadyUsed(String name){
boolean bool = true;
try {
bool = getCityItinerariesTitles().contains(name);
if(!bool){
bool = UserController.getActiveUserItinerariesNames().contains(name);
}
} catch (Exception e) {
e.printStackTrace();
}
return bool;
}
}

0 comments on commit 67529c1

Please sign in to comment.