From 6d7e08bf032626962f50c8d9db6c1c5b3d978271 Mon Sep 17 00:00:00 2001 From: Petru Trimbitas Date: Tue, 11 Jun 2013 12:55:32 +0300 Subject: [PATCH] adds beautiful interface for adding events --- res/layout/add_event.xml | 63 ++++--------------- res/layout/add_event_basic_tab.xml | 18 ++++++ res/layout/add_event_details_tab.xml | 18 ++++++ res/layout/add_event_other_tab.xml | 12 ++++ res/menu/add_event.xml | 7 +++ res/menu/main.xml | 2 +- res/values/strings.xml | 8 ++- src/ro/ieval/unical/AddEventActivity.java | 45 +++++++++++++ .../unical/AddEventBasicTabFragment.java | 16 +++++ .../unical/AddEventDetailsTabFragment.java | 15 +++++ .../unical/AddEventOtherTabFragment.java | 15 +++++ src/ro/ieval/unical/AddEventTabListener.java | 30 +++++++++ src/ro/ieval/unical/EventListActivity.java | 2 +- 13 files changed, 197 insertions(+), 54 deletions(-) create mode 100644 res/layout/add_event_basic_tab.xml create mode 100644 res/layout/add_event_details_tab.xml create mode 100644 res/layout/add_event_other_tab.xml create mode 100644 res/menu/add_event.xml create mode 100644 src/ro/ieval/unical/AddEventBasicTabFragment.java create mode 100644 src/ro/ieval/unical/AddEventDetailsTabFragment.java create mode 100644 src/ro/ieval/unical/AddEventOtherTabFragment.java create mode 100644 src/ro/ieval/unical/AddEventTabListener.java diff --git a/res/layout/add_event.xml b/res/layout/add_event.xml index 6840e24..885c616 100644 --- a/res/layout/add_event.xml +++ b/res/layout/add_event.xml @@ -1,52 +1,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + \ No newline at end of file diff --git a/res/layout/add_event_basic_tab.xml b/res/layout/add_event_basic_tab.xml new file mode 100644 index 0000000..6eb886e --- /dev/null +++ b/res/layout/add_event_basic_tab.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/res/layout/add_event_details_tab.xml b/res/layout/add_event_details_tab.xml new file mode 100644 index 0000000..10d8b77 --- /dev/null +++ b/res/layout/add_event_details_tab.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/res/layout/add_event_other_tab.xml b/res/layout/add_event_other_tab.xml new file mode 100644 index 0000000..c71af2d --- /dev/null +++ b/res/layout/add_event_other_tab.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/res/menu/add_event.xml b/res/menu/add_event.xml new file mode 100644 index 0000000..67850a8 --- /dev/null +++ b/res/menu/add_event.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/res/menu/main.xml b/res/menu/main.xml index 6cc0074..799568d 100644 --- a/res/menu/main.xml +++ b/res/menu/main.xml @@ -1,6 +1,6 @@ - diff --git a/res/values/strings.xml b/res/values/strings.xml index 2109079..7f54470 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -25,6 +25,12 @@ Friday Saturday Save + Basic info + Details + Other + Event Name + Cancel + New Event Daily @@ -32,4 +38,4 @@ Monthly Yearly - + \ No newline at end of file diff --git a/src/ro/ieval/unical/AddEventActivity.java b/src/ro/ieval/unical/AddEventActivity.java index 95b66a3..0fc26ab 100644 --- a/src/ro/ieval/unical/AddEventActivity.java +++ b/src/ro/ieval/unical/AddEventActivity.java @@ -1,6 +1,16 @@ package ro.ieval.unical; +import android.app.ActionBar; import android.app.Activity; +import android.app.Fragment; +import android.app.FragmentTransaction; +import android.app.ActionBar.Tab; +import android.content.Intent; import android.os.Bundle; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.widget.TabHost; +import android.widget.TabHost.TabSpec; public final class AddEventActivity extends Activity { @Override @@ -8,5 +18,40 @@ public final class AddEventActivity extends Activity { super.onCreate(savedInstanceState); setContentView(R.layout.add_event); setTitle(R.string.addeventtitle); + ActionBar actionBar = getActionBar(); + actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); + ActionBar.Tab t1 = actionBar.newTab().setText(this.getString(R.string.addevtab1)); + ActionBar.Tab t2 = actionBar.newTab().setText(this.getString(R.string.addevtab2)); + ActionBar.Tab t3 = actionBar.newTab().setText(this.getString(R.string.addevtab3)); + + Fragment f1 = new AddEventBasicTabFragment(); + Fragment f2 = new AddEventDetailsTabFragment(); + Fragment f3 = new AddEventOtherTabFragment(); + + t1.setTabListener(new AddEventTabListener(f1)); + t2.setTabListener(new AddEventTabListener(f2)); + t3.setTabListener(new AddEventTabListener(f3)); + + actionBar.addTab(t1); + actionBar.addTab(t2); + actionBar.addTab(t3); + } + + @Override + public boolean onCreateOptionsMenu(final Menu menu) { + final MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.add_event, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(final MenuItem item) { + switch (item.getItemId()) { + case R.id.cancel: + finish(); + return true; + default: + return false; + } } } diff --git a/src/ro/ieval/unical/AddEventBasicTabFragment.java b/src/ro/ieval/unical/AddEventBasicTabFragment.java new file mode 100644 index 0000000..53596d2 --- /dev/null +++ b/src/ro/ieval/unical/AddEventBasicTabFragment.java @@ -0,0 +1,16 @@ +package ro.ieval.unical; +import ro.ieval.unical.R; +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + + +public class AddEventBasicTabFragment extends Fragment { + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.add_event_basic_tab, container, false); + } +} diff --git a/src/ro/ieval/unical/AddEventDetailsTabFragment.java b/src/ro/ieval/unical/AddEventDetailsTabFragment.java new file mode 100644 index 0000000..20def85 --- /dev/null +++ b/src/ro/ieval/unical/AddEventDetailsTabFragment.java @@ -0,0 +1,15 @@ +package ro.ieval.unical; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +public class AddEventDetailsTabFragment extends Fragment { + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.add_event_details_tab, container, false); + } +} diff --git a/src/ro/ieval/unical/AddEventOtherTabFragment.java b/src/ro/ieval/unical/AddEventOtherTabFragment.java new file mode 100644 index 0000000..5e28544 --- /dev/null +++ b/src/ro/ieval/unical/AddEventOtherTabFragment.java @@ -0,0 +1,15 @@ +package ro.ieval.unical; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +public class AddEventOtherTabFragment extends Fragment { + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.add_event_other_tab, container, false); + } +} diff --git a/src/ro/ieval/unical/AddEventTabListener.java b/src/ro/ieval/unical/AddEventTabListener.java new file mode 100644 index 0000000..1a4661a --- /dev/null +++ b/src/ro/ieval/unical/AddEventTabListener.java @@ -0,0 +1,30 @@ +package ro.ieval.unical; + +import android.app.ActionBar; +import android.app.ActionBar.Tab; +import android.app.Fragment; +import android.app.FragmentTransaction; + +public class AddEventTabListener implements ActionBar.TabListener { + public Fragment fragment; + + public AddEventTabListener(Fragment fragment) { + this.fragment = fragment; + } + + @Override + public void onTabSelected(Tab tab, FragmentTransaction ft) { + ft.replace(R.id.fragment_container, fragment); + } + + @Override + public void onTabUnselected(Tab tab, FragmentTransaction ft) { + ft.remove(fragment); + } + + @Override + public void onTabReselected(Tab tab, FragmentTransaction ft) { + // TODO Auto-generated method stub + + } +} diff --git a/src/ro/ieval/unical/EventListActivity.java b/src/ro/ieval/unical/EventListActivity.java index c9ccd44..67e0a7f 100644 --- a/src/ro/ieval/unical/EventListActivity.java +++ b/src/ro/ieval/unical/EventListActivity.java @@ -75,7 +75,7 @@ public class EventListActivity extends Activity { @Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { - case R.id.NewEvent: + case R.id.add_event: final Intent i=new Intent(this,AddEventActivity.class); startActivity(i); return true; -- 2.39.2