--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <EditText
+ android:inputType="text"
+ android:id="@+id/eventtitle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:hint="@string/eventname"
+ android:ems="10" >
+
+ <requestFocus />
+ </EditText>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/start_label"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ style="@android:style/Widget.DeviceDefault.EditText"
+ android:id="@+id/time_start"
+ android:freezesText="true"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="showDateTimePickerDialog"
+ android:text="@string/pick_time"
+ android:layout_weight="1"
+ android:ems="10"
+ android:focusable="false"
+ />
+ <TextView
+ style="@android:style/Widget.DeviceDefault.EditText"
+ android:id="@+id/date_start"
+ android:freezesText="true"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="showDateTimePickerDialog"
+ android:text="@string/pick_date"
+ android:layout_weight="1"
+ android:ems="10"
+ android:focusable="false"
+ />
+
+ </LinearLayout>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/end_label"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ style="@android:style/Widget.DeviceDefault.EditText"
+ android:id="@+id/time_end"
+ android:freezesText="true"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="showDateTimePickerDialog"
+ android:text="@string/pick_time"
+ android:layout_weight="1"
+ android:ems="10"
+ android:focusable="false"
+ />
+ <TextView
+ style="@android:style/Widget.DeviceDefault.EditText"
+ android:id="@+id/date_end"
+ android:freezesText="true"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="showDateTimePickerDialog"
+ android:text="@string/pick_date"
+ android:layout_weight="1"
+ android:ems="10"
+ android:focusable="false"
+ />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
+ <EditText
+ android:id="@+id/description"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/description"
+ android:inputType="textMultiLine" >
+
+ <requestFocus />
+ </EditText>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/repeat"
+ android:layout_weight="1"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <Switch
+ android:id="@+id/repeat_switch"
+ android:layout_weight="1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:id="@+id/repeat_layout"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/repeat_every"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <EditText
+ android:id="@+id/repeat_time"
+ android:inputType="number"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <Spinner
+ android:id="@+id/repeat_spinner"
+ android:entries="@array/repeat_array_p"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/repeat_count_layout"
+ android:layout_gravity="left"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" >
+
+ <Spinner
+ android:id="@+id/repeat_type"
+ android:entries="@array/repeat_type_array"
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" />
+ <EditText
+ android:id="@+id/repeat_count"
+ android:inputType="number"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:visibility="gone" />
+ <TextView
+ style="@android:style/Widget.DeviceDefault.EditText"
+ android:id="@+id/repeat_until"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="showDateTimePickerDialog"
+ android:ems="8"
+ android:visibility="gone" />
+ </LinearLayout>
+ <EditText
+ android:id="@+id/description"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/description"
+ android:inputType="textMultiLine" >
+
+ <requestFocus />
+ </EditText>
+ </LinearLayout>
+</LinearLayout>
+ </ScrollView>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <EditText
- android:inputType="text"
- android:id="@+id/eventtitle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="@string/eventname"
- android:ems="10" >
-
- <requestFocus />
- </EditText>
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/start_label"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <TextView
- style="@android:style/Widget.DeviceDefault.EditText"
- android:id="@+id/time_start"
- android:freezesText="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="showDateTimePickerDialog"
- android:text="@string/pick_time"
- android:layout_weight="1"
- android:ems="10"
- android:focusable="false"
- />
- <TextView
- style="@android:style/Widget.DeviceDefault.EditText"
- android:id="@+id/date_start"
- android:freezesText="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="showDateTimePickerDialog"
- android:text="@string/pick_date"
- android:layout_weight="1"
- android:ems="10"
- android:focusable="false"
- />
-
- </LinearLayout>
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/end_label"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <TextView
- style="@android:style/Widget.DeviceDefault.EditText"
- android:id="@+id/time_end"
- android:freezesText="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="showDateTimePickerDialog"
- android:text="@string/pick_time"
- android:layout_weight="1"
- android:ems="10"
- android:focusable="false"
- />
- <TextView
- style="@android:style/Widget.DeviceDefault.EditText"
- android:id="@+id/date_end"
- android:freezesText="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="showDateTimePickerDialog"
- android:text="@string/pick_date"
- android:layout_weight="1"
- android:ems="10"
- android:focusable="false"
- />
-
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/repeat"
- android:layout_weight="1"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <Switch
- android:id="@+id/repeat_switch"
- android:layout_weight="1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/repeat_layout"
- android:orientation="vertical" >
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="left" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/repeat_every"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <EditText
- android:id="@+id/repeat_time"
- android:inputType="number"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <Spinner
- android:id="@+id/repeat_spinner"
- android:entries="@array/repeat_array_p"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- />
-
- </LinearLayout>
-
- <LinearLayout
- android:id="@+id/repeat_count_layout"
- android:layout_gravity="left"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
-
- <Spinner
- android:id="@+id/repeat_type"
- android:entries="@array/repeat_type_array"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="1" />
- <EditText
- android:id="@+id/repeat_count"
- android:inputType="number"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:visibility="gone" />
- <TextView
- style="@android:style/Widget.DeviceDefault.EditText"
- android:id="@+id/repeat_until"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="showDateTimePickerDialog"
- android:ems="8"
- android:visibility="gone" />
- </LinearLayout>
- </LinearLayout>
-</LinearLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <EditText
- android:id="@+id/description"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:hint="@string/description"
- android:inputType="textMultiLine" >
-
- <requestFocus />
- </EditText>
-
-</LinearLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
-
-</LinearLayout>
package ro.ieval.unical;
+import java.text.SimpleDateFormat;
import java.util.Calendar;
+import java.util.Date;
import java.util.GregorianCalendar;
import android.app.ActionBar;
import android.view.View;
import android.widget.*;
-//TODO if i want to add a new event after i edit one the fields are being filled with the last event data
-
public final class AddEventActivity extends Activity implements OnDateSetListener, OnTimeSetListener{
+
+ private class OnCheckedChangeListener implements android.widget.CompoundButton.OnCheckedChangeListener{
+ private final LinearLayout layout;
+ public OnCheckedChangeListener(final LinearLayout layout){
+ this.layout=layout;
+ }
+
+ private class OnItemSelectedListener implements android.widget.AdapterView.OnItemSelectedListener{
+ private final View repeatCount;
+ private final View repeatUntil;
+
+ public OnItemSelectedListener(final View repeatCount, final View repeatUntil) {
+ this.repeatCount=repeatCount;
+ this.repeatUntil=repeatUntil;
+ }
+
+ @Override
+ public void onItemSelected(final AdapterView<?> whatever, final View ignored, final int pos, final long id) {
+ switch(pos){
+ case 0:
+ repeatCount.setVisibility(View.GONE);
+ repeatUntil.setVisibility(View.GONE);
+ break;
+ case 1:
+ repeatCount.setVisibility(View.GONE);
+ repeatUntil.setVisibility(View.VISIBLE);
+ break;
+ case 2:
+ repeatCount.setVisibility(View.VISIBLE);
+ repeatUntil.setVisibility(View.GONE);
+ break;
+ default:
+ }
+ }
+
+ @Override public void onNothingSelected(final AdapterView<?> arg0) { /* do nothing */ }
+ }
+
+ @Override
+ public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
+ if(isChecked) {
+ Utils.setEnabledRecursively(layout, true);
+ final Spinner repeatType = (Spinner) findViewById(R.id.repeat_type);
+ repeatType.setOnItemSelectedListener(new OnItemSelectedListener(findViewById(R.id.repeat_count),findViewById(R.id.repeat_until)));
+ }else {
+ Utils.setEnabledRecursively(layout, false);
+ }
+ }
+ }
+
private TextView dateTimeTextView;
public static final String EXTRA_EVENT = "event";
+ private Event event;
public static void editEvent(final Context c, final Event e) {
final Intent i = new Intent(c,AddEventActivity.class);
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.add_event_title);
- final Event event = getIntent().hasExtra(EXTRA_EVENT) ? (Event) getIntent().getParcelableExtra(EXTRA_EVENT) : new Event();
+ event = getIntent().hasExtra(EXTRA_EVENT) ? (Event) getIntent().getParcelableExtra(EXTRA_EVENT) : new Event();
final ActionBar actionBar = getActionBar();
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
- final ActionBar.Tab t1 = actionBar.newTab().setText(this.getString(R.string.addevtab1));
- final ActionBar.Tab t2 = actionBar.newTab().setText(this.getString(R.string.addevtab2));
- final ActionBar.Tab t3 = actionBar.newTab().setText(this.getString(R.string.addevtab3));
-
- final Fragment f1 = new TrivialFragment();
- final Bundle b1=new Bundle();
- b1.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_basic_tab);
- b1.putParcelable(TrivialFragment.ARGUMENT_EVENT, event);
- f1.setArguments(b1);
-
- final Fragment f2 = new TrivialFragment();
- final Bundle b2=new Bundle();
- b2.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_details_tab);
- b2.putParcelable(TrivialFragment.ARGUMENT_EVENT, event);
- f2.setArguments(b2);
-
- final Fragment f3 = new TrivialFragment();
- final Bundle b3=new Bundle();
- b3.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_other_tab);
- b3.putParcelable(TrivialFragment.ARGUMENT_EVENT, event);
- f3.setArguments(b3);
-
- t1.setTabListener(new AddEventTabListener(f1, event, 0));
- t2.setTabListener(new AddEventTabListener(f2, event, 1));
- t3.setTabListener(new AddEventTabListener(f3, event, 2));
-
- actionBar.addTab(t1);
- actionBar.addTab(t2);
- actionBar.addTab(t3);
+ setContentView(R.layout.add_event);
+
+ if(getIntent().hasExtra(EXTRA_EVENT)) {
+ final LinearLayout layout = (LinearLayout) findViewById(R.id.repeat_layout);
+ final Switch repeatSwitch = (Switch) findViewById(R.id.repeat_switch);
+ Utils.setEnabledRecursively(layout, false);
+
+ repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener(layout));
+
+ EditText title = (EditText) findViewById(R.id.eventtitle);
+ title.setText(event.title);
+
+ TextView tstart = (TextView) findViewById(R.id.time_start);
+ TextView tend = (TextView) findViewById(R.id.time_end);
+ SimpleDateFormat sf=new SimpleDateFormat("HH:mm");
+ Date d=new Date(event.dtstart);
+ tstart.setText(sf.format(d).toString());
+ d.setTime(event.dtend);
+ tend.setText(sf.format(d).toString());
+
+ SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
+ TextView dstart = (TextView)findViewById(R.id.date_start);
+ TextView dend = (TextView)findViewById(R.id.date_end);
+ d.setTime(event.dtstart);
+ dstart.setText(sd.format(d).toString());
+ d.setTime(event.dtend);
+ dend.setText(sd.format(d).toString());
+ EditText description = (EditText) findViewById(R.id.description);
+ description.setText(event.description);
+ }
}
@Override
finish();
return true;
case R.id.save:
- //TODO Save event
+ System.out.println("MuieLaComisie\n"+event.title);
+
Toast toast = Toast.makeText(getApplicationContext(),"Event saved!",Toast.LENGTH_LONG);
toast.show();
finish();
+++ /dev/null
-package ro.ieval.unical;
-
-import android.app.ActionBar;
-import android.app.ActionBar.Tab;
-import android.app.Fragment;
-import android.app.FragmentTransaction;
-import android.util.Log;
-import android.widget.EditText;
-import android.widget.TextView;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public class AddEventTabListener implements ActionBar.TabListener {
- private Fragment fragment;
- private Event ev;
- private boolean isAdded = false;
- private int tabId;
-
- public AddEventTabListener(final Fragment fragment,Event e,int tabId) {
- this.fragment = fragment;
- this.ev = e;
- this.tabId=tabId;
- }
-
- @Override
- public void onTabSelected(final Tab tab, final FragmentTransaction ft) {
- ft.replace(android.R.id.content, fragment, null);
- }
-
- @Override
- public void onTabUnselected(final Tab tab, final FragmentTransaction ft) {
- switch (tabId) {
- case 0:
- ev.title=((TextView)fragment.getView().findViewById(R.id.eventtitle)).getText().toString();
- String start=((TextView)fragment.getView().findViewById(R.id.date_start)).getText()+ " " +
- ((TextView)fragment.getView().findViewById(R.id.time_start)).getText();
- String end=((TextView)fragment.getView().findViewById(R.id.date_end)).getText()+ " " +
- ((TextView)fragment.getView().findViewById(R.id.time_end)).getText();
- try {
- Date s=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(start);
- Date e=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(end);
- ev.dtstart=s.getTime();
- ev.dtend=s.getTime();
- } catch (ParseException e) {
- e.printStackTrace();
- }
-
- break;
- case 1:
- ev.description=fragment.getView().findViewById(R.id.description).toString();
- break;
- case 2:
- break;
- }
- }
-
- @Override
- public void onTabReselected(final Tab tab, final FragmentTransaction ft) {
- // do nothing
- }
-}
+++ /dev/null
-package ro.ieval.unical;
-
-import android.app.ActionBar;
-import android.app.Fragment;
-import android.app.FragmentTransaction;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.*;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public final class TrivialFragment extends Fragment {
- private static class OnItemSelectedListener implements android.widget.AdapterView.OnItemSelectedListener{
- private final View repeatCount;
- private final View repeatUntil;
-
- public OnItemSelectedListener(final View repeatCount, final View repeatUntil) {
- this.repeatCount=repeatCount;
- this.repeatUntil=repeatUntil;
- }
-
- @Override
- public void onItemSelected(final AdapterView<?> whatever, final View ignored, final int pos, final long id) {
- switch(pos){
- case 0:
- repeatCount.setVisibility(View.GONE);
- repeatUntil.setVisibility(View.GONE);
- break;
- case 1:
- repeatCount.setVisibility(View.GONE);
- repeatUntil.setVisibility(View.VISIBLE);
- break;
- case 2:
- repeatCount.setVisibility(View.VISIBLE);
- repeatUntil.setVisibility(View.GONE);
- break;
- default:
- }
- }
-
- @Override public void onNothingSelected(final AdapterView<?> arg0) { /* do nothing */ }
- }
-
- private static class OnCheckedChangeListener implements android.widget.CompoundButton.OnCheckedChangeListener{
- private final LinearLayout layout;
- private final View root;
- public OnCheckedChangeListener(final LinearLayout layout, final View root){
- this.layout=layout;
- this.root=root;
- }
-
- @Override
- public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
- if(isChecked) {
- Utils.setEnabledRecursively(layout, true);
- final Spinner repeatType = (Spinner) root.findViewById(R.id.repeat_type);
- repeatType.setOnItemSelectedListener(new OnItemSelectedListener(root.findViewById(R.id.repeat_count),root.findViewById(R.id.repeat_until)));
- }else {
- Utils.setEnabledRecursively(layout, false);
- }
- }
- }
-
- public static final String ARGUMENT_EVENT = "Event";
- public static final String ARGUMENT_LAYOUT = "layout";
- private Event ev;
-
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
- final View view=inflater.inflate(getArguments().getInt(ARGUMENT_LAYOUT), container, false);
-
- ev=getArguments().getParcelable(ARGUMENT_EVENT);
- switch (getArguments().getInt(ARGUMENT_LAYOUT)) {
- case R.layout.add_event_basic_tab:
- final LinearLayout layout = (LinearLayout) view.findViewById(R.id.repeat_layout);
- final Switch repeatSwitch = (Switch) view.findViewById(R.id.repeat_switch);
- Utils.setEnabledRecursively(layout, false);
-
- repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener(layout, view));
-
- EditText title = (EditText) view.findViewById(R.id.eventtitle);
- title.setText(ev.title);
-
- TextView tstart = (TextView) view.findViewById(R.id.time_start);
- TextView tend = (TextView) view.findViewById(R.id.time_end);
- SimpleDateFormat sf=new SimpleDateFormat("HH:mm");
- Date d=new Date(ev.dtstart);
- tstart.setText(sf.format(d).toString());
- d.setTime(ev.dtend);
- tend.setText(sf.format(d).toString());
-
- SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
- TextView dstart = (TextView)view.findViewById(R.id.date_start);
- TextView dend = (TextView)view.findViewById(R.id.date_end);
- d.setTime(ev.dtstart);
- dstart.setText(sd.format(d).toString());
- d.setTime(ev.dtend);
- dend.setText(sd.format(d).toString());
- break;
- case R.layout.add_event_details_tab:
- EditText description = (EditText) view.findViewById(R.id.description);
- description.setText(ev.description);
- break;
- case R.layout.add_event_other_tab:
- break;
- }
- return view;
- }
-}