From 989493fe0400037641607b6bd8ed3d703aff6841 Mon Sep 17 00:00:00 2001 From: spike Date: Wed, 30 Nov 2011 16:39:26 +0100 Subject: [PATCH] Added user profile page, implementing user data passing --- LeWebConnect2011/AndroidManifest.xml | 11 +--- LeWebConnect2011/res/layout/mainxml | 22 ------- LeWebConnect2011/res/layout/perticipents.xml | 2 +- LeWebConnect2011/res/layout/profile.xml | 14 +++++ LeWebConnect2011/res/layout/rowlayout.xml | 27 ++++++++- LeWebConnect2011/res/values/strings.xml | 12 +++- .../thinkit/lewebconnect/LeWebAdapter.java | 55 +++++++++++++---- .../thinkit/lewebconnect/LeWebConnect.java | 6 -- .../thinkit/lewebconnect/Perticipents.java | 60 +++++++++++++++++-- .../src/com/thinkit/lewebconnect/Search.java | 15 ----- .../com/thinkit/lewebconnect/UserProfile.java | 25 ++++++++ 11 files changed, 177 insertions(+), 72 deletions(-) delete mode 100644 LeWebConnect2011/res/layout/mainxml create mode 100644 LeWebConnect2011/res/layout/profile.xml delete mode 100644 LeWebConnect2011/src/com/thinkit/lewebconnect/Search.java create mode 100644 LeWebConnect2011/src/com/thinkit/lewebconnect/UserProfile.java diff --git a/LeWebConnect2011/AndroidManifest.xml b/LeWebConnect2011/AndroidManifest.xml index fd030a6..b401540 100644 --- a/LeWebConnect2011/AndroidManifest.xml +++ b/LeWebConnect2011/AndroidManifest.xml @@ -4,7 +4,7 @@ android:versionCode="1" android:versionName="1.0" > - + - - - - + + diff --git a/LeWebConnect2011/res/layout/mainxml b/LeWebConnect2011/res/layout/mainxml deleted file mode 100644 index a51c7c7..0000000 --- a/LeWebConnect2011/res/layout/mainxml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/LeWebConnect2011/res/layout/perticipents.xml b/LeWebConnect2011/res/layout/perticipents.xml index 7d31d93..bf5b1ac 100644 --- a/LeWebConnect2011/res/layout/perticipents.xml +++ b/LeWebConnect2011/res/layout/perticipents.xml @@ -11,7 +11,7 @@ android:id="@+building_list/search_box" android:layout_width="fill_parent" android:layout_height="wrap_content" - android:hint="type to filter" + android:hint="type to filter or use menu" android:maxLines="1" /> + + + + + \ No newline at end of file diff --git a/LeWebConnect2011/res/layout/rowlayout.xml b/LeWebConnect2011/res/layout/rowlayout.xml index a0b3945..b564f37 100644 --- a/LeWebConnect2011/res/layout/rowlayout.xml +++ b/LeWebConnect2011/res/layout/rowlayout.xml @@ -53,7 +53,32 @@ android:layout_marginTop="2px" android:text="Medium Text" android:textAppearance="?android:attr/textAppearanceMedium" - android:textSize="25px" /> + android:textSize="25px" /> + + + + + + + + + diff --git a/LeWebConnect2011/res/values/strings.xml b/LeWebConnect2011/res/values/strings.xml index bd499ba..f9a5f97 100644 --- a/LeWebConnect2011/res/values/strings.xml +++ b/LeWebConnect2011/res/values/strings.xml @@ -2,9 +2,17 @@ Hello World, LeWebConnectActivity! LeWebConnect - Type in a persone or a company name + type to filter or use menu By Name By Company - By Country + By Country + Facebook + Linkedin + Twitter + User Profile + id_text + fb_text + ld_text + tw_text \ No newline at end of file diff --git a/LeWebConnect2011/src/com/thinkit/lewebconnect/LeWebAdapter.java b/LeWebConnect2011/src/com/thinkit/lewebconnect/LeWebAdapter.java index 62e72b9..c02c5e6 100644 --- a/LeWebConnect2011/src/com/thinkit/lewebconnect/LeWebAdapter.java +++ b/LeWebConnect2011/src/com/thinkit/lewebconnect/LeWebAdapter.java @@ -194,10 +194,7 @@ public class LeWebAdapter extends ArrayAdapter { company.setText(user.getCompany()); if (country != null) country.setText(user.getCountry()); - ImageView imageView = (ImageView) rowview.findViewById(R.id.icons); - setImage(imageView, user); -// imageView.setVisibility(View.GONE); - + setSocial(rowview, user); if(enableSections && getSectionForPosition(position) != getSectionForPosition(position - 1)) { // Log.d("getView", "Setting Header ........ " + String.valueOf(position)); @@ -221,30 +218,62 @@ public class LeWebAdapter extends ArrayAdapter { } - private void setImage(ImageView imageView, Attendee user) { + private void setSocial(View rowview, Attendee user) { // TODO Auto-generated method stub boolean facebook = false; boolean twitter = false; boolean linkedin = false; + + ImageView imageView = (ImageView) rowview.findViewById(R.id.icons); + TextView id = (TextView) rowview.findViewById(R.id.id_text); + TextView fb = (TextView) rowview.findViewById(R.id.fb_text); + TextView tw = (TextView) rowview.findViewById(R.id.tw_text); + TextView ld = (TextView) rowview.findViewById(R.id.ld_text); + + id.setText(String.valueOf(user.getId())); + facebook = ( user.getFacebook() != null && !user.getFacebook().equals("null") && !user.getFacebook().isEmpty()); linkedin = ( user.getLinkedin() != null && !user.getLinkedin().equals("null") && !user.getLinkedin().isEmpty()); twitter = ( user.getTwitter() != null && !user.getTwitter().equals("null") && !user.getTwitter().isEmpty()); - if (facebook && twitter && linkedin) + fb.setText("null"); + ld.setText("null"); + tw.setText("null"); + + if (facebook && twitter && linkedin){ imageView.setImageResource(R.drawable.social_all); - else if (facebook && twitter) + fb.setText(user.getFacebook()); + tw.setText(user.getTwitter()); + ld.setText(user.getLinkedin()); + } + else if (facebook && twitter) { imageView.setImageResource(R.drawable.no_linkedin); - else if (facebook && linkedin) + fb.setText(user.getFacebook()); + tw.setText(user.getTwitter()); + } + else if (facebook && linkedin) { imageView.setImageResource(R.drawable.no_twitter); - else if (twitter && linkedin) + fb.setText(user.getFacebook()); + ld.setText(user.getLinkedin()); + } + else if (twitter && linkedin) { imageView.setImageResource(R.drawable.no_fb); - else if (twitter) + tw.setText(user.getTwitter()); + ld.setText(user.getLinkedin()); + } + else if (twitter) { imageView.setImageResource(R.drawable.twitter); - else if (facebook) + tw.setText(user.getTwitter()); + } + else if (facebook) { imageView.setImageResource(R.drawable.fb); - else if (linkedin) + fb.setText(user.getFacebook()); + } + else if (linkedin) { imageView.setImageResource(R.drawable.linkedin); - else + ld.setText(user.getLinkedin()); + } + else imageView.setImageResource(R.drawable.no_all); } diff --git a/LeWebConnect2011/src/com/thinkit/lewebconnect/LeWebConnect.java b/LeWebConnect2011/src/com/thinkit/lewebconnect/LeWebConnect.java index 3b9d7e4..80d0aab 100644 --- a/LeWebConnect2011/src/com/thinkit/lewebconnect/LeWebConnect.java +++ b/LeWebConnect2011/src/com/thinkit/lewebconnect/LeWebConnect.java @@ -30,12 +30,6 @@ public class LeWebConnect extends TabActivity{ .setContent(intent); tabHost.addTab(spec); // Do the same for the other tabs - intent = new Intent().setClass(this, Search.class); - spec = tabHost - .newTabSpec("search") - .setIndicator("", res.getDrawable(R.drawable.ic_tab_search)) - .setContent(intent); - tabHost.addTab(spec); intent = new Intent().setClass(this, Likes.class); spec = tabHost .newTabSpec("likes") diff --git a/LeWebConnect2011/src/com/thinkit/lewebconnect/Perticipents.java b/LeWebConnect2011/src/com/thinkit/lewebconnect/Perticipents.java index 623a1f6..b89c855 100644 --- a/LeWebConnect2011/src/com/thinkit/lewebconnect/Perticipents.java +++ b/LeWebConnect2011/src/com/thinkit/lewebconnect/Perticipents.java @@ -15,6 +15,7 @@ import com.thinkit.lewebconnect.Attendee.LeWebByLnameComparator; import android.app.ListActivity; import android.content.Context; +import android.content.Intent; import android.os.Bundle; import android.sax.Element; import android.text.Editable; @@ -31,13 +32,19 @@ import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.Filterable; import android.widget.ListView; +import android.widget.TextView; import android.widget.Toast; +import android.widget.AdapterView.AdapterContextMenuInfo; public class Perticipents extends ListActivity { /** Called when the activity is first created. */ + private static final int FACEBOOK = Menu.FIRST; + private static final int TWITTER = Menu.FIRST + 1; + private static final int LINKEDIN = Menu.FIRST + 2; + private static String TAG = "Perticipents"; private ArrayList users; private EditText filterText = null; @@ -71,7 +78,6 @@ public class Perticipents extends ListActivity { Collections.sort(users, new LeWebByLnameComparator()); - setContentView(R.layout.perticipents); filterText= (EditText) findViewById(R.building_list.search_box); filterText.addTextChangedListener(filterTextWatcher); @@ -80,12 +86,13 @@ public class Perticipents extends ListActivity { ListView lv = getListView(); lv.setFastScrollEnabled(true); lv.setTextFilterEnabled(false); + registerForContextMenu(lv); adapter = new LeWebAdapter(this, users, true, false, false); setListAdapter(adapter); - + registerForContextMenu(getListView()); @@ -96,7 +103,7 @@ public class Perticipents extends ListActivity { } - private TextWatcher filterTextWatcher = new TextWatcher() { + private TextWatcher filterTextWatcher = new TextWatcher() { public void afterTextChanged(Editable s) { } @@ -124,7 +131,27 @@ public class Perticipents extends ListActivity { filterText.removeTextChangedListener(filterTextWatcher); } - + + + @Override + protected void onListItemClick(ListView l, View v, int position, long id) { + // TODO Auto-generated method stub + super.onListItemClick(l, v, position, id); + + try { + Intent i = new Intent(this, UserProfile.class); + Attendee user = (Attendee) l.getItemAtPosition(position); + Toast.makeText(this, user.getLname(), Toast.LENGTH_LONG).show(); + + i.putExtra("user_name", user.getLinkedin()); + startActivity(i); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override public boolean onCreateOptionsMenu(Menu menu) { // TODO Auto-generated method stub @@ -191,7 +218,32 @@ public class Perticipents extends ListActivity { return super.onOptionsItemSelected(item); } + public void onCreateContextMenu(ContextMenu menu, View v, + ContextMenu.ContextMenuInfo menuInfo) { + super.onCreateContextMenu((ContextMenu) menu, v, menuInfo); + menu.add(0, FACEBOOK, 0, R.string.facebook_menu); + menu.add(0, TWITTER, 0, R.string.twitter_menu); + menu.add(0, LINKEDIN, 0, R.string.linkedin_menu); + } + + public boolean onContextItemSelected(MenuItem item) { + switch(item.getItemId()) { + case FACEBOOK: + { + AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); + int id = (int) info.position; + Toast.makeText(this, String.valueOf(id), Toast.LENGTH_LONG).show(); + return true; + } + case TWITTER: + return true; + case LINKEDIN: + return true; + } + return super.onContextItemSelected(item); + } + public Attendee NodeToAttendee(Node userNode) { NamedNodeMap attrs = userNode.getAttributes(); diff --git a/LeWebConnect2011/src/com/thinkit/lewebconnect/Search.java b/LeWebConnect2011/src/com/thinkit/lewebconnect/Search.java deleted file mode 100644 index 202c1d9..0000000 --- a/LeWebConnect2011/src/com/thinkit/lewebconnect/Search.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.thinkit.lewebconnect; - -import android.app.Activity; -import android.os.Bundle; -import android.widget.TextView; - -public class Search extends Activity { - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - TextView textview = new TextView(this); - textview.setText("search view"); - setContentView(textview); } -} \ No newline at end of file diff --git a/LeWebConnect2011/src/com/thinkit/lewebconnect/UserProfile.java b/LeWebConnect2011/src/com/thinkit/lewebconnect/UserProfile.java new file mode 100644 index 0000000..1a1a6e4 --- /dev/null +++ b/LeWebConnect2011/src/com/thinkit/lewebconnect/UserProfile.java @@ -0,0 +1,25 @@ +package com.thinkit.lewebconnect; +import com.thinkit.lewebconnect.R; + +import android.app.Activity; +import android.os.Bundle; +import android.widget.TextView; + + +public class UserProfile extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onCreate(savedInstanceState); + + setContentView(R.layout.profile); + setTitle(R.string.user_profile); + TextView mUserName = (TextView) findViewById(R.id.profile_name); + Bundle extras = getIntent().getExtras(); + if (extras != null) { + String name = extras.getString("user_name"); + mUserName.setText(name); + } + } +}