From: Petru Trimbitas Date: Mon, 10 Jun 2013 10:00:59 +0000 (+0300) Subject: Adds new event_view layout wich looks better. Still needs improvments X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=99658f577dd666fd3b558d5346a5aadb0d9d3a06;p=unical.git Adds new event_view layout wich looks better. Still needs improvments --- diff --git a/res/layout/event_view.xml b/res/layout/event_view.xml index 72b2078..42b2992 100644 --- a/res/layout/event_view.xml +++ b/res/layout/event_view.xml @@ -1,52 +1,79 @@ - - - - - + android:src="@android:drawable/title_bar_tall" /> + android:layout_height="wrap_content"> - + android:layout_weight="1" + android:orientation="vertical" > - + + + + + + + + android:layout_weight="1" + android:orientation="vertical" > + + + + + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index ed1faa2..0915330 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -17,6 +17,13 @@ No Delete this event ? New Event + Sunday + Monday + Tuesday + Wednesday + Thursday + Friday + Saturday Daily diff --git a/src/ro/ieval/unical/CalendarUtils.java b/src/ro/ieval/unical/CalendarUtils.java new file mode 100644 index 0000000..40489a9 --- /dev/null +++ b/src/ro/ieval/unical/CalendarUtils.java @@ -0,0 +1,19 @@ +package ro.ieval.unical; + +import java.util.GregorianCalendar; + +import android.content.Context; +import android.content.res.Resources; + +public class CalendarUtils { + public static String DayToString(Context context, GregorianCalendar gc) { + int dc=gc.get(GregorianCalendar.DAY_OF_WEEK); + if(dc==GregorianCalendar.SUNDAY) return context.getString(R.string.sunday); + else if(dc==GregorianCalendar.MONDAY) return context.getString(R.string.monday); + else if(dc==GregorianCalendar.TUESDAY) return context.getString(R.string.tuesday); + else if(dc==GregorianCalendar.WEDNESDAY) return context.getString(R.string.wednesday); + else if(dc==GregorianCalendar.THURSDAY) return context.getString(R.string.thursday); + else if(dc==GregorianCalendar.FRIDAY) return context.getString(R.string.friday); + else return context.getString(R.string.saturday); + } +} diff --git a/src/ro/ieval/unical/DisplayEventActivity.java b/src/ro/ieval/unical/DisplayEventActivity.java index 47f82a6..8055ec1 100644 --- a/src/ro/ieval/unical/DisplayEventActivity.java +++ b/src/ro/ieval/unical/DisplayEventActivity.java @@ -1,6 +1,8 @@ package ro.ieval.unical; +import java.text.SimpleDateFormat; import java.util.Date; +import java.util.GregorianCalendar; import android.app.Activity; import android.content.Context; @@ -25,16 +27,30 @@ public class DisplayEventActivity extends Activity { super.onCreate(savedInstanceState); final Event e=getIntent().getParcelableExtra(EXTRA_EVENT); setContentView(R.layout.event_view); + setTitle(e.title); - final TextView eventTitle= (TextView) findViewById(R.id.eventTitle); - final TextView date=(TextView) findViewById(R.id.date); - final TextView description=(TextView) findViewById(R.id.description); - final TextView location= (TextView) findViewById(R.id.location); - - eventTitle.setText(e.title); - date.setText(new Date(e.dtstart).toString()); - description.setText(e.description); - location.setText(e.eventLocation); + final TextView startday= (TextView) findViewById(R.id.startday); + final TextView endday= (TextView) findViewById(R.id.endday); + final TextView startdate= (TextView) findViewById(R.id.startdate); + final TextView enddate= (TextView) findViewById(R.id.enddate); + final TextView starttime= (TextView) findViewById(R.id.starttime); + final TextView endtime= (TextView) findViewById(R.id.endtime); + + GregorianCalendar cstart = new GregorianCalendar(); + cstart.setTime(new Date(e.dtstart)); + GregorianCalendar cend = new GregorianCalendar(); + cend.setTime(new Date(e.dtend)); + SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); + SimpleDateFormat stf = new SimpleDateFormat("kk:mm:ss"); + + startday.setText(CalendarUtils.DayToString(this,cstart)); + if(CalendarUtils.DayToString(this,cstart)!=CalendarUtils.DayToString(this, cend)) + endday.setText(CalendarUtils.DayToString(this, cend)); + startdate.setText(sdf.format(cstart.getTime())); + if(sdf.format(cstart.getTime())!=sdf.format(cend.getTime())) + enddate.setText(sdf.format(cend.getTime())); + starttime.setText(stf.format(cstart.getTime())); + endtime.setText(stf.format(cend.getTime())); } @Override diff --git a/src/ro/ieval/unical/Event.java b/src/ro/ieval/unical/Event.java index 97ce822..a069a9f 100644 --- a/src/ro/ieval/unical/Event.java +++ b/src/ro/ieval/unical/Event.java @@ -98,7 +98,7 @@ final class Event implements Parcelable{ final ContentResolver cr=context.getContentResolver(); cr.delete(Uri.withAppendedPath(Events.CONTENT_URI, Long.toString(_id)), null, null); } - + @Override public int describeContents() { return 0;