Commit 379d6b7f authored by Thomas Krex's avatar Thomas Krex
Browse files

-added separators in the List of the feed items

- added date string to FeedItem object
-added helper Method to transform String to Date
parent 99575cea
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<intent-filter> <intent-filter>
<data android:scheme="http" /> <data android:scheme="http" />
<data android:host="ttt.in.tum.de" /> <data android:host="ttt.in.tum.de" />
<data android:pathPattern="\\/lectures\\/.*"/> <data android:pathPattern="\\/lectures\\/rss\\.php.*"/>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="60dp">
android:weightSum="5" > <LinearLayout
android:id="@+id/headerLayout"
android:layout_height="wrap_content"
android:layout_width="match_parent"
>
<TextView
android:id="@+id/listHeader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="@android:color/darker_gray"
android:text="TEST"
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="5" >
<TextView <TextView
android:id="@+id/itemTitle" android:id="@+id/itemTitle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_weight="4" android:layout_weight="4"
android:gravity="center_vertical" android:layout_gravity="center"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView <ImageView
android:id="@+id/statusIcon" android:id="@+id/statusIcon"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:layout_gravity="center"
android:gravity="center"
android:src="@drawable/ic_action_download" > android:src="@drawable/ic_action_download" >
</ImageView> </ImageView>
</LinearLayout>
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -198,8 +198,11 @@ public class FeedActivity extends SherlockActivity implements ...@@ -198,8 +198,11 @@ public class FeedActivity extends SherlockActivity implements
// delete all whitespaces from url before inserting into the // delete all whitespaces from url before inserting into the
// database // database
url.replaceAll("\\s+", ""); url.replaceAll("\\s+", "");
String beginDate = "&begindate="+datePicker.getYear()+"_"+"0"+(datePicker.getMonth()+1)+"_"+"0"+datePicker.getDayOfMonth(); int month= datePicker.getMonth()+1;
int day= datePicker.getDayOfMonth();
String beginDate = "&begindate="+datePicker.getYear()+"_"+(month <10 ? "0" :"")+month+"_"+(day<10 ? "0" :"" )+day;
url=url +beginDate; url=url +beginDate;
Log.d("FEED URL", url); Log.d("FEED URL", url);
......
...@@ -2,7 +2,9 @@ package tttclient.activities; ...@@ -2,7 +2,9 @@ package tttclient.activities;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.DateFormatSymbols;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
...@@ -11,6 +13,7 @@ import tttclient.models.FeedItem; ...@@ -11,6 +13,7 @@ import tttclient.models.FeedItem;
import tttclient.models.FeedItemDbManager; import tttclient.models.FeedItemDbManager;
import tttclient.services.DownloadService; import tttclient.services.DownloadService;
import tttclient.services.ParseService; import tttclient.services.ParseService;
import tttclient.utils.Utils;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
...@@ -27,12 +30,15 @@ import android.os.Handler; ...@@ -27,12 +30,15 @@ import android.os.Handler;
import android.os.ResultReceiver; import android.os.ResultReceiver;
import android.os.Vibrator; import android.os.Vibrator;
import android.support.v4.widget.SimpleCursorAdapter; import android.support.v4.widget.SimpleCursorAdapter;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener; import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.actionbarsherlock.app.SherlockActivity; import com.actionbarsherlock.app.SherlockActivity;
...@@ -144,7 +150,7 @@ public class FeedDetailActivity extends SherlockActivity implements ...@@ -144,7 +150,7 @@ public class FeedDetailActivity extends SherlockActivity implements
setContentView(R.layout.feed_details_activity); setContentView(R.layout.feed_details_activity);
// haptic feedback for longclick // haptic feedback for longclick
myVib = (Vibrator) this.getSystemService(VIBRATOR_SERVICE); myVib = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);
// init progress dialog for showing downloading/unzipping progress // init progress dialog for showing downloading/unzipping progress
progressDialog = new ProgressDialog(FeedDetailActivity.this); progressDialog = new ProgressDialog(FeedDetailActivity.this);
progressDialog.setIndeterminate(true); progressDialog.setIndeterminate(true);
...@@ -164,19 +170,48 @@ public class FeedDetailActivity extends SherlockActivity implements ...@@ -164,19 +170,48 @@ public class FeedDetailActivity extends SherlockActivity implements
feedItemLv.setEmptyView(findViewById(R.id.empty)); feedItemLv.setEmptyView(findViewById(R.id.empty));
// displaying items in listview // displaying items in listview
manager = new FeedItemDbManager(this); manager = new FeedItemDbManager(this);
Cursor cursor = manager.getAllFromDB(feed.getId()); Cursor cursor = manager.getAllFromDB(feed.getId());
adapter = new SimpleCursorAdapter(this, R.layout.list_feeditems, adapter = new SimpleCursorAdapter(this, R.layout.list_feeditems,
cursor, new String[] { FeedItemDbManager.COLUMN_TITLE, cursor, new String[] { FeedItemDbManager.COLUMN_TITLE,
FeedItemDbManager.COLUMN_STATUS }, new int[] { FeedItemDbManager.COLUMN_STATUS ,FeedItemDbManager.COLUMN_DATE}, new int[] {
R.id.itemTitle, R.id.statusIcon }); R.id.itemTitle, R.id.statusIcon,R.id.listHeader });
// set Binder to change icon depending on download status // set Binder to change icon depending on download status
adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
@Override @Override
public boolean setViewValue(View view, Cursor cursor, public boolean setViewValue(View view, Cursor cursor,
int columnIndex) { int columnIndex) {
boolean state=false;
// Log.d("FeedItems", "Month: " +currDate.getMonth());
if(view.getId()==R.id.listHeader){
Log.d("VIew Binder", "found header view");
TextView tx = (TextView) view;
Date currDate= Utils.stringToDate(cursor.getString(cursor.getColumnIndex(FeedItemDbManager.COLUMN_DATE)));
Date prevDate= null;
Log.d("ListView"," currDate: "+ currDate.toString());
if (cursor.getPosition() > 0 && cursor.moveToPrevious()) {
prevDate = Utils.stringToDate(cursor.getString(cursor.getColumnIndex(FeedItemDbManager.COLUMN_DATE)));
Log.d("ListView"," prevDate: "+ prevDate.toString());
cursor.moveToNext();
}
if(prevDate==null||prevDate.getMonth()!=currDate.getMonth()){
tx.setText(new DateFormatSymbols().getMonths()[currDate.getMonth()]);
tx.setVisibility(View.VISIBLE);
}
else{
tx.setVisibility(View.GONE);
}
state=true;
}
if (view.getId() == R.id.statusIcon) { if (view.getId() == R.id.statusIcon) {
ImageView icon = (ImageView) view; ImageView icon = (ImageView) view;
int status = cursor.getInt(cursor int status = cursor.getInt(cursor
...@@ -191,12 +226,11 @@ public class FeedDetailActivity extends SherlockActivity implements ...@@ -191,12 +226,11 @@ public class FeedDetailActivity extends SherlockActivity implements
(R.drawable.ic_action_download))); (R.drawable.ic_action_download)));
} }
state=true;
return true;
} }
return false; return state;
} }
}); });
feedItemLv.setAdapter(adapter); feedItemLv.setAdapter(adapter);
......
...@@ -116,6 +116,7 @@ public class PlayerActivity extends SherlockActivity implements ...@@ -116,6 +116,7 @@ public class PlayerActivity extends SherlockActivity implements
@Override @Override
public void onClick(View v) { public void onClick(View v) {
recording.previous(); recording.previous();
audioController.show(5000);
} }
}; };
...@@ -124,6 +125,7 @@ public class PlayerActivity extends SherlockActivity implements ...@@ -124,6 +125,7 @@ public class PlayerActivity extends SherlockActivity implements
@Override @Override
public void onClick(View v) { public void onClick(View v) {
recording.next(); recording.next();
audioController.show(5000);
} }
}; };
...@@ -132,6 +134,7 @@ public class PlayerActivity extends SherlockActivity implements ...@@ -132,6 +134,7 @@ public class PlayerActivity extends SherlockActivity implements
prevListener); prevListener);
audioController.setAnchorView(imgV); audioController.setAnchorView(imgV);
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
...@@ -145,7 +148,7 @@ public class PlayerActivity extends SherlockActivity implements ...@@ -145,7 +148,7 @@ public class PlayerActivity extends SherlockActivity implements
// close dialog // close dialog
dialog.dismiss(); dialog.dismiss();
// show control bar // show control bar
audioController.show(5000); audioController.show(8000);
} }
}; };
...@@ -163,7 +166,7 @@ public class PlayerActivity extends SherlockActivity implements ...@@ -163,7 +166,7 @@ public class PlayerActivity extends SherlockActivity implements
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
if (audioController != null) if (audioController != null)
audioController.show(); audioController.show(8000);
return true; return true;
} }
...@@ -327,10 +330,10 @@ public class PlayerActivity extends SherlockActivity implements ...@@ -327,10 +330,10 @@ public class PlayerActivity extends SherlockActivity implements
} }
} }
void switchLayout(int index) { void switchLayout(int mode) {
// switch to fullscreen // switch to fullscreen
if (index == LAYOUT_MODE_FULL) { if (mode == LAYOUT_MODE_FULL) {
imgV = (ImageView) findViewById(R.id.playerView_fullscreen); imgV = (ImageView) findViewById(R.id.playerView_fullscreen);
recording.graphicsContext().setImageView(imgV); recording.graphicsContext().setImageView(imgV);
recording.graphicsContext().updateView(true); recording.graphicsContext().updateView(true);
...@@ -338,12 +341,13 @@ public class PlayerActivity extends SherlockActivity implements ...@@ -338,12 +341,13 @@ public class PlayerActivity extends SherlockActivity implements
} }
// switch to extended View // switch to extended View
if (index == LAYOUT_MODE_EXTENDED) { if (mode == LAYOUT_MODE_EXTENDED) {
imgV = (ImageView) findViewById(R.id.playerView_extended); imgV = (ImageView) findViewById(R.id.playerView_extended);
recording.graphicsContext().setImageView(imgV); recording.graphicsContext().setImageView(imgV);
recording.graphicsContext().updateView(true); recording.graphicsContext().updateView(true);
switcher.setDisplayedChild(LAYOUT_MODE_EXTENDED); switcher.setDisplayedChild(LAYOUT_MODE_EXTENDED);
scrollView.scrollTo(0, recording.getIndex().scrollPos);
} }
......
...@@ -39,6 +39,7 @@ import android.graphics.Canvas; ...@@ -39,6 +39,7 @@ import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.LayoutParams;
...@@ -72,7 +73,7 @@ public class Index { ...@@ -72,7 +73,7 @@ public class Index {
private final Context context; private final Context context;
private final ScrollView indexViewer; private final ScrollView indexViewer;
private final Handler scrollHandler; private final Handler scrollHandler;
public int scrollPos;
int getWidth() { int getWidth() {
return recording.getProtocolPreferences().framebufferWidth; return recording.getProtocolPreferences().framebufferWidth;
} }
...@@ -95,9 +96,9 @@ public class Index { ...@@ -95,9 +96,9 @@ public class Index {
IndexEntry entry = get(indexNumber - 1); IndexEntry entry = get(indexNumber - 1);
entry.setBackgroundColor(color); entry.setBackgroundColor(color);
LinearLayout parent = (LinearLayout) entry.getParent(); LinearLayout parent = (LinearLayout) entry.getParent();
scrollPos=parent.getTop() - parent.getHeight()
indexViewer.scrollTo(0, parent.getTop() - parent.getHeight() / 2;
/ 2); indexViewer.scrollTo(0, scrollPos);
} }
}; };
...@@ -326,7 +327,7 @@ public class Index { ...@@ -326,7 +327,7 @@ public class Index {
static final public int PAINT_NO_ANNOTATIONS = 1; static final public int PAINT_NO_ANNOTATIONS = 1;
static final public int PAINT_NO_HIGHLIGHT_ANNOTATIONS = 2; static final public int PAINT_NO_HIGHLIGHT_ANNOTATIONS = 2;
// disabled because not working yet // disabled because not working yet
int annotationsPaintMode = PAINT_NO_ANNOTATIONS; int annotationsPaintMode = PAINT_ALL_ANNOTATIONS;
public int getAnnotationsPaintMode() { public int getAnnotationsPaintMode() {
return annotationsPaintMode; return annotationsPaintMode;
...@@ -361,6 +362,8 @@ public class Index { ...@@ -361,6 +362,8 @@ public class Index {
// read message // read message
Message message = recording.getMessages().get(message_nr); Message message = recording.getMessages().get(message_nr);
int start = message.getTimestamp(); int start = message.getTimestamp();
// delete flag // delete flag
boolean marked_to_be_deleted = false; boolean marked_to_be_deleted = false;
...@@ -407,6 +410,7 @@ public class Index { ...@@ -407,6 +410,7 @@ public class Index {
// set collected annotations // set collected annotations
recording.getIndex().get(i).setAnnotations(annotations); recording.getIndex().get(i).setAnnotations(annotations);
Log.d("Index annotations", "index "+i+" start "+start+" end" +end+" annotations " +annotations.size());
// clear buffer if index ended with a delete event, which was not // clear buffer if index ended with a delete event, which was not
// performed yet // performed yet
...@@ -612,7 +616,6 @@ public class Index { ...@@ -612,7 +616,6 @@ public class Index {
// /////////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////////
private int lastIndexFired = -1; private int lastIndexFired = -1;
public int getLastIndexFired() { public int getLastIndexFired() {
return lastIndexFired; return lastIndexFired;
} }
...@@ -626,7 +629,7 @@ public class Index { ...@@ -626,7 +629,7 @@ public class Index {
*/ */
public void fireIndexChangedEvent(int indexNumber) { public void fireIndexChangedEvent(int indexNumber) {
if (lastIndexFired != indexNumber) { if (lastIndexFired != indexNumber) {
Log.d("Index Update","index number: "+indexNumber);
// highlighting of index entry and scrolling has to be done in ui // highlighting of index entry and scrolling has to be done in ui
// thread // thread
if (lastIndexFired > 0) { if (lastIndexFired > 0) {
......
...@@ -79,4 +79,5 @@ public class FeedDbManager { ...@@ -79,4 +79,5 @@ public class FeedDbManager {
db.execSQL("DELETE FROM feeds WHERE id = ?", db.execSQL("DELETE FROM feeds WHERE id = ?",
new String[] { String.valueOf(id) }); new String[] { String.valueOf(id) });
} }
} }
package tttclient.models; package tttclient.models;
import java.util.Date;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
...@@ -15,7 +17,7 @@ public class FeedItem implements Parcelable { ...@@ -15,7 +17,7 @@ public class FeedItem implements Parcelable {
private String title; private String title;
private String link; private String link;
private String description; private String description;
private String pubDate; private String date;
private String length; private String length;
// private String[] enclosure; // private String[] enclosure;
...@@ -44,13 +46,7 @@ public class FeedItem implements Parcelable { ...@@ -44,13 +46,7 @@ public class FeedItem implements Parcelable {
this.description = description; this.description = description;
} }
public String getPupDate() {
return pubDate;
}
public void setPupDate(String pupDate) {
this.pubDate = pupDate;
}
public String getLength() { public String getLength() {
return length; return length;
...@@ -60,10 +56,19 @@ public class FeedItem implements Parcelable { ...@@ -60,10 +56,19 @@ public class FeedItem implements Parcelable {
this.length = length; this.length = length;
} }
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
@Override @Override
public String toString() { public String toString() {
return "FeedItem [title=" + title + ", link=" + link + ", description=" return "FeedItem [title=" + title + ", link=" + link + ", description="
+ description + ", pupDate=" + pubDate + ", length=" + length + description + ", date=" + date + ", length=" + length
+ "]"; + "]";
} }
...@@ -72,7 +77,7 @@ public class FeedItem implements Parcelable { ...@@ -72,7 +77,7 @@ public class FeedItem implements Parcelable {
copy.title = title; copy.title = title;
copy.link = link; copy.link = link;
copy.description = description; copy.description = description;
copy.pubDate = pubDate; copy.date = date;
copy.length = length; copy.length = length;
return copy; return copy;
...@@ -91,7 +96,7 @@ public class FeedItem implements Parcelable { ...@@ -91,7 +96,7 @@ public class FeedItem implements Parcelable {
title = in.readString(); title = in.readString();
link = in.readString(); link = in.readString();
description = in.readString(); description = in.readString();
pubDate = in.readString(); date = in.readString();
length = in.readString(); length = in.readString();
} }
...@@ -100,7 +105,7 @@ public class FeedItem implements Parcelable { ...@@ -100,7 +105,7 @@ public class FeedItem implements Parcelable {
dest.writeString(title); dest.writeString(title);
dest.writeString(link); dest.writeString(link);
dest.writeString(description); dest.writeString(description);
dest.writeString(pubDate); dest.writeString(date.toString());
dest.writeString(length); dest.writeString(length);
} }
......
...@@ -25,7 +25,7 @@ public class FeedItemDbManager { ...@@ -25,7 +25,7 @@ public class FeedItemDbManager {
public static final String COLUMN_TITLE = "title"; public static final String COLUMN_TITLE = "title";
public static final String COLUMN_LINK = "link"; public static final String COLUMN_LINK = "link";
public static final String COLUMN_DESCRIPTION = "description"; public static final String COLUMN_DESCRIPTION = "description";
public static final String COLUMN_PUBDATE = "pubDate"; public static final String COLUMN_DATE = "date";
public static final String COLUMN_PATH = "path"; public static final String COLUMN_PATH = "path";
public static final String COLUMN_STATUS = "status"; public static final String COLUMN_STATUS = "status";
...@@ -33,7 +33,7 @@ public class FeedItemDbManager { ...@@ -33,7 +33,7 @@ public class FeedItemDbManager {
+ TABLE_FEEDITEMS + " ( " + COLUMN_ID