diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagUpdatesFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagUpdatesFragment.java index 07ec8ee2e..9c24c604e 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagUpdatesFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagUpdatesFragment.java @@ -5,13 +5,13 @@ import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.graphics.Bitmap; -import android.graphics.Color; import android.os.Bundle; import android.support.v4.app.ActionBar; import android.support.v4.app.ListFragment; import android.support.v4.view.Menu; import android.support.v4.view.MenuItem; import android.text.Editable; +import android.text.TextUtils; import android.text.TextWatcher; import android.util.Log; import android.view.KeyEvent; @@ -58,6 +58,7 @@ public class TagUpdatesFragment extends ListFragment { private TagData tagData; private UpdateAdapter updateAdapter; private EditText addCommentField; + private ViewGroup listHeader; private ImageButton pictureButton; @@ -131,23 +132,6 @@ public class TagUpdatesFragment extends ListFragment { ((TextView) ab.getCustomView().findViewById(R.id.title)).setText(title); } - if (AndroidUtilities.isTabletSized(getActivity()) && tagData != null) { - getView().setBackgroundColor(Color.rgb(200, 200, 200)); - TextView tagTitle = (TextView) getView().findViewById(R.id.tag_title); - String tagName = tagData.getValue(TagData.NAME); - tagTitle.setText(tagName); - TextView descriptionTitle = (TextView) getView().findViewById(R.id.tag_description); - descriptionTitle.setText(tagData.getValue(TagData.TAG_DESCRIPTION)); - - AsyncImageView imageView = (AsyncImageView) getView().findViewById(R.id.tag_picture); - imageView.setDefaultImageResource(TagService.getDefaultImageIDForTag(tagName)); - imageView.setUrl(tagData.getValue(TagData.PICTURE)); - } - else { - getView().findViewById(R.id.tag_header).setVisibility(View.GONE); - getView().findViewById(R.id.activity_header).setVisibility(View.GONE); - } - final ImageButton commentButton = (ImageButton) getView().findViewById(R.id.commentButton); addCommentField = (EditText) getView().findViewById(R.id.commentField); addCommentField.setOnEditorActionListener(new OnEditorActionListener() { @@ -216,16 +200,47 @@ public class TagUpdatesFragment extends ListFragment { updateAdapter = new UpdateAdapter(this, R.layout.update_adapter_row, currentCursor, false, null, fromUpdateClass); - ((ListView) getView().findViewById(android.R.id.list)).setAdapter(updateAdapter); + ListView listView = ((ListView) getView().findViewById(android.R.id.list)); + addHeaderToListView(listView); + listView.setAdapter(updateAdapter); } else { Cursor cursor = updateAdapter.getCursor(); cursor.requery(); getActivity().startManagingCursor(cursor); + populateListHeader(listHeader); } if (getActivity() instanceof TagUpdatesActivity) setLastViewed(); } + private void addHeaderToListView(ListView listView) { + if (AndroidUtilities.isTabletSized(getActivity()) && tagData != null) { + listHeader = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.tag_updates_header, listView, false); + populateListHeader(listHeader); + listView.addHeaderView(listHeader); + } + } + private void populateListHeader(ViewGroup header) { + if (header == null) return; + TextView tagTitle = (TextView) header.findViewById(R.id.tag_title); + String tagName = tagData.getValue(TagData.NAME); + tagTitle.setText(tagName); + TextView descriptionTitle = (TextView) header.findViewById(R.id.tag_description); + String description = tagData.getValue(TagData.TAG_DESCRIPTION); + if (!TextUtils.isEmpty(description)) { + descriptionTitle.setText(description); + descriptionTitle.setVisibility(View.VISIBLE); + } + else { + descriptionTitle.setVisibility(View.GONE); + } + + + AsyncImageView imageView = (AsyncImageView) header.findViewById(R.id.tag_picture); + imageView.setDefaultImageResource(TagService.getDefaultImageIDForTag(tagName)); + imageView.setUrl(tagData.getValue(TagData.PICTURE)); + } + public void setLastViewed() { if(tagData != null && tagData.getValue(TagData.REMOTE_ID) > 0) { Preferences.setLong(UPDATES_LAST_VIEWED + tagData.getValue(TagData.REMOTE_ID), DateUtilities.now()); diff --git a/astrid/res/layout/tag_updates_fragment.xml b/astrid/res/layout/tag_updates_fragment.xml index 2ec85a3e2..9bcf7dfce 100644 --- a/astrid/res/layout/tag_updates_fragment.xml +++ b/astrid/res/layout/tag_updates_fragment.xml @@ -6,66 +6,6 @@ android:layout_height="fill_parent" android:orientation="vertical" > - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/astrid/res/layout/update_adapter_row.xml b/astrid/res/layout/update_adapter_row.xml index 773793923..7f5c9f0a5 100644 --- a/astrid/res/layout/update_adapter_row.xml +++ b/astrid/res/layout/update_adapter_row.xml @@ -32,7 +32,7 @@ android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:paddingLeft="50dip" - android:paddingRight="75dip" + android:paddingRight="5dip" style="@style/TextAppearance.TAd_ItemTitle" android:textSize="16sp"/>