summaryrefslogtreecommitdiff
path: root/vdrmanager/src/de/bjusystems
diff options
context:
space:
mode:
Diffstat (limited to 'vdrmanager/src/de/bjusystems')
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/Channel.java1
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/Event.java2
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java95
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/RecordingListItem.java43
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java12
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventAdapter.java (renamed from vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java)95
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java2
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelEventAdapter.java7
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchTimesListActivity.java36
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingAdapter.java98
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java181
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java2
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEventAdapter.java3
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java541
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpAsyncTask.java9
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java29
16 files changed, 791 insertions, 365 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Channel.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Channel.java
index d8ca9ec..2b7b0d1 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Channel.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Channel.java
@@ -63,6 +63,7 @@ public class Channel implements Parcelable {
}
public Channel(final String channelData) {
+ System.err.println(channelData);
String[] words = StringUtils.splitPreserveAllTokens(channelData,
C.DATA_SEPARATOR);
this.number = Integer.valueOf(words[0].substring(1));
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Event.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Event.java
index dcfb010..ef3fe0e 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Event.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Event.java
@@ -111,7 +111,7 @@ public abstract class Event {
}
return TextUtils.substring(description, 0, 30) + "…";
}
- return shortText;
+ return "";
}
public String getDescription() {
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java
index f2ad445..f510011 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java
@@ -1,15 +1,60 @@
package de.bjusystems.vdrmanager.data;
-import java.util.Date;
+import static de.bjusystems.vdrmanager.gui.Utils.mapSpecialChars;
+import java.util.Date;
import de.bjusystems.vdrmanager.StringUtils;
import de.bjusystems.vdrmanager.app.C;
-import static de.bjusystems.vdrmanager.gui.Utils.mapSpecialChars;
-
public class Recording extends Event{
+ public static String ROOT_FOLDER = "";
+ public static final String FOLDERDELIMCHAR = "~";
+
+ public class Folder {
+
+ public String name;
+
+ public Folder parent;
+
+ private String path;
+
+ public boolean isRoot(){
+ return parent == null;
+ }
+
+ public String getFullPath(){
+ if(this.path != null){
+ return this.path;
+ }
+ if(isRoot()){
+ this.path = "";
+ } else {
+ this.path = parent.getFullPath() + "/" + name;
+ }
+
+ return path;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if(o == this){
+ return true;
+ }
+ return ((Folder)o).name.equals(this.name);
+ }
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return name + "("+path+")";
+ }
+ };
+
public Recording(String line) {
final String[] words = StringUtils.splitPreserveAllTokens(line, C.DATA_SEPARATOR);
int idx = 0;
@@ -17,7 +62,7 @@ public class Recording extends Event{
start = new Date(Long.parseLong(words[idx++]) * 1000);
stop = new Date(Long.parseLong(words[idx++]) * 1000);
channelName = mapSpecialChars(words[idx++]);
- title = mapSpecialChars(words[idx++]);
+ eventTitle = mapSpecialChars(words[idx++]);
shortText = mapSpecialChars(words[idx++]);
description = mapSpecialChars(words[idx++]);
fileName = mapSpecialChars(words[idx++]);
@@ -39,8 +84,27 @@ public class Recording extends Event{
timerStopTime = new Date(Long.parseLong(data) * 1000L);
}
}
+
+ if(idx < words.length) { //name
+ String titleRaw = words[idx];
+ int idxdel = titleRaw.lastIndexOf(FOLDERDELIMCHAR);
+ if(idxdel == -1){
+ title = titleRaw;
+ folder = ROOT_FOLDER;
+ } else {
+ title = titleRaw.substring(idxdel+1);
+
+ String foldersRaw = titleRaw.substring(0, idxdel);
+
+ folder = foldersRaw;
+
+ }
+ }
+
}
+ private String folder;
+
private String fileName;
private int fileSize;
@@ -51,11 +115,21 @@ public class Recording extends Event{
private String devInode = null;
+ private String eventTitle = null;
+
/**
* If it is not null, recording is on going or will be on going until this date;
*/
private Date timerStopTime = null;
+ public String getEventTitle() {
+ return eventTitle;
+ }
+
+ public void setEventTitle(String eventTitle) {
+ this.eventTitle = eventTitle;
+ }
+
public Date getTimerStopTime() {
return timerStopTime;
}
@@ -123,4 +197,15 @@ public class Recording extends Event{
public String toString() {
return title;
}
-}
+
+
+ public String getFolder() {
+ return folder;
+ }
+
+ public void setFolder(String folder) {
+ this.folder = folder;
+ }
+
+
+} \ No newline at end of file
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/RecordingListItem.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/RecordingListItem.java
new file mode 100644
index 0000000..58d798c
--- /dev/null
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/RecordingListItem.java
@@ -0,0 +1,43 @@
+package de.bjusystems.vdrmanager.data;
+
+
+public class RecordingListItem extends EventListItem {
+
+ public String folder;
+
+ public Integer count = 0;
+
+ public RecordingListItem(Recording rec) {
+ super(rec);
+ }
+
+ public RecordingListItem(String dailyHeader) {
+ super(dailyHeader);
+ }
+
+
+
+ @Override
+ public String getTitle() {
+ if(isFolder()){
+ return folder;
+ }
+ return super.getTitle();
+ }
+
+ public boolean isFolder() {
+
+ return folder != null;
+
+ }
+
+ @Override
+ public String getHeader() {
+ if (isFolder()) {
+ return folder;
+ } else {
+ return super.getHeader();
+ }
+ }
+
+} \ No newline at end of file
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java
index cdf0842..73d858c 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java
@@ -206,7 +206,14 @@ SvdrpExceptionListener, SvdrpFinishedListener<Result> {
super.onCreate(savedInstanceState);
Preferences.setLocale(this);
progress = new ProgressDialog(this);
-
+ progress.setCancelable(false);
+ progress.setCanceledOnTouchOutside(false);
+ // progress.setOnCancelListener(new OnCancelListener() {
+ // @Override
+ // public void onCancel(DialogInterface dialog) {
+ //
+ // }
+ // });
initActionBar();
@@ -379,7 +386,8 @@ SvdrpExceptionListener, SvdrpFinishedListener<Result> {
@Override
public void svdrpEvent(final SvdrpEvent event, final Throwable t) {
- Utils.say(this, t.getLocalizedMessage());
+ progress.dismiss();
+ Utils.say(this, t.getMessage());
}
protected void addListener(final SvdrpAsyncTask<Result, SvdrpClient<Result>> task) {
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventAdapter.java
index e5a8cc4..b022311 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventAdapter.java
@@ -22,16 +22,16 @@ import de.bjusystems.vdrmanager.data.Recording;
import de.bjusystems.vdrmanager.data.TimerMatch;
import de.bjusystems.vdrmanager.data.Timerable;
-abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
+abstract class BaseEventAdapter<T extends EventListItem> extends ArrayAdapter<T> implements
Filterable
// , SectionIndexer
{
- private final int TYPE_ITEM = 0;
- private final int TYPE_HEADER = 1;
+ protected final static int TYPE_ITEM = 0;
+ protected final static int TYPE_HEADER = 1;
protected final int layout;
protected final LayoutInflater inflater;
- protected final List<EventListItem> items = new ArrayList<EventListItem>();
+ protected final List<T> items = new ArrayList<T>();
protected boolean hideDescription = true;
@@ -47,7 +47,7 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
*/
private final Object _Lock = new Object();
- public EventAdapter(final Context context, int layout) {
+ public BaseEventAdapter(final Context context, int layout) {
super(context, layout);
this.layout = layout;
inflater = LayoutInflater.from(context);
@@ -59,7 +59,7 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
}
@Override
- public void add(EventListItem object) {
+ public void add(T object) {
items.add(object);
// if (object.isHeader()) {
// sections.add(object.getHeader());
@@ -79,6 +79,28 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
return TYPE_ITEM;
}
+ public static class EventListItemHeaderHolder {
+ TextView header;
+ }
+
+ private boolean canReuseConvertView(View convertView, int itemViewType){
+ if(convertView == null){
+ return false;
+ }
+ Object o = convertView.getTag();
+ if(itemViewType == TYPE_ITEM){
+ return o instanceof EventListItemHolder;
+ }
+
+ if(itemViewType == TYPE_HEADER){
+ return o instanceof EventListItemHeaderHolder;
+ }
+
+ return false;
+
+ }
+
+
@Override
public View getView(final int position, View convertView,
final ViewGroup parent) {
@@ -88,7 +110,7 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
Object holder = null;
int type = getItemViewType(position);
- if (convertView == null) {
+ if (canReuseConvertView(convertView, type) == false) {
switch (type) {
case TYPE_ITEM:
convertView = inflater.inflate(layout, null);
@@ -104,17 +126,6 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
holder = convertView.getTag();
}
- switch (type) {
- case TYPE_ITEM:
- convertView = inflater.inflate(layout, null);
- holder = getEventViewHolder(item, convertView);
- break;
- case TYPE_HEADER:
- convertView = inflater.inflate(R.layout.header_item, null);
- holder = getHeaderViewHolder(item, convertView);
- break;
- }
-
if (type == TYPE_ITEM) {
fillEventViewHolder((EventListItemHolder) holder, item);
} else {
@@ -124,7 +135,7 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
return convertView;
}
- private EventListItemHolder getEventViewHolder(EventListItem item, View view) {
+ protected EventListItemHolder getEventViewHolder(EventListItem item, View view) {
EventListItemHolder itemHolder = new EventListItemHolder();
@@ -152,27 +163,30 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
itemHolder.state.setVisibility(View.VISIBLE);
if (item.getEvent() instanceof Recording) {
- Recording r = (Recording)item.getEvent();
- if(r.getTimerStopTime() != null){
+ Recording r = (Recording) item.getEvent();
+ if (r.getTimerStopTime() != null) {
itemHolder.state.setImageResource(R.drawable.timer_recording);
+ } else {
+ itemHolder.state.setImageResource(R.drawable.timer_none);
}
} else if (item.getEvent() instanceof Timerable == true) {
TimerMatch match = ((Timerable) item.getEvent()).getTimerMatch();
switch (((Timerable) item.getEvent()).getTimerState()) {
case Active:
- itemHolder.state.setImageResource(Utils.getTimerStateDrawable(match,
- R.drawable.timer_active, R.drawable.timer_active_begin,
+ itemHolder.state.setImageResource(Utils.getTimerStateDrawable(
+ match, R.drawable.timer_active,
+ R.drawable.timer_active_begin,
R.drawable.timer_active_end));
break;
case Inactive:
- itemHolder.state.setImageResource(Utils.getTimerStateDrawable(match,
- R.drawable.timer_inactive,
+ itemHolder.state.setImageResource(Utils.getTimerStateDrawable(
+ match, R.drawable.timer_inactive,
R.drawable.timer_inactive_begin,
R.drawable.timer_inactive_end));
break;
case Recording:
- itemHolder.state.setImageResource(Utils.getTimerStateDrawable(match,
- R.drawable.timer_recording,
+ itemHolder.state.setImageResource(Utils.getTimerStateDrawable(
+ match, R.drawable.timer_recording,
R.drawable.timer_recording_begin,
R.drawable.timer_recording_end));
break;
@@ -219,8 +233,8 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
itemHolder.progress.setProgress(p);
int dura = Utils.getDuration(item.getEvent());
int rest = dura - (dura * p / 100);
- //on live recordings the amount of already recorded time
- if(item.getEvent() instanceof Recording){
+ // on live recordings the amount of already recorded time
+ if (item.getEvent() instanceof Recording) {
rest = dura - rest;
}
itemHolder.duration.setText(getContext().getString(
@@ -228,11 +242,8 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
}
}
- class EventListItemHeaderHolder {
- public TextView header;
- }
- private EventListItemHeaderHolder getHeaderViewHolder(EventListItem item,
+ protected EventListItemHeaderHolder getHeaderViewHolder(EventListItem item,
View view) {
EventListItemHeaderHolder itemHolder = new EventListItemHeaderHolder();
itemHolder.header = (TextView) view.findViewById(R.id.header_item);
@@ -243,11 +254,11 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
return new EventFormatter(event);
}
- private void addSuper(EventListItem item) {
+ protected void addSuper(T item) {
super.add(item);
}
- private void clearSuper() {
+ protected void clearSuper() {
super.clear();
}
@@ -266,14 +277,18 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
public void setHideChannelName(boolean hideChannelName) {
this.hideChannelName = hideChannelName;
}
+
+ protected boolean isHeader(EventListItem item){
+ return item.isHeader();
+ }
// TODO implement locking in performFiltering, check the parent class
// http://stackoverflow.com/questions/5846385/how-to-update-android-listview-with-dynamic-data-in-real-time
public Filter getFilter() {
return new Filter() {
/**
- *
- */
+ *
+ */
EventListItem prevHead = null;
@Override
@@ -281,7 +296,7 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
highlight = arg0.toString().toLowerCase();
ArrayList<EventListItem> result = new ArrayList<EventListItem>();
for (EventListItem event : items) {
- if (event.isHeader()) {
+ if (isHeader(event)) {
prevHead = event;
// result.add(event);
continue;
@@ -308,7 +323,7 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
@Override
protected void publishResults(CharSequence arg0, FilterResults arg1) {
clearSuper();
- for (EventListItem item : (ArrayList<EventListItem>) arg1.values) {
+ for (T item : (ArrayList<T>) arg1.values) {
addSuper(item);
}
notifyDataSetChanged();
@@ -343,4 +358,4 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
super.clear();
items.clear();
}
-} \ No newline at end of file
+}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java
index 2723d41..58b88ea 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java
@@ -51,7 +51,7 @@ SimpleGestureListener {
private SimpleGestureFilter detector;
- protected EventAdapter adapter;
+ protected BaseEventAdapter<EventListItem> adapter;
protected String highlight = null;
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelEventAdapter.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelEventAdapter.java
index 7e3d575..475f3e6 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelEventAdapter.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelEventAdapter.java
@@ -4,16 +4,17 @@ import android.content.Context;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.EventFormatter;
+import de.bjusystems.vdrmanager.data.EventListItem;
-class ChannelEventAdapter extends EventAdapter
+class ChannelEventAdapter extends BaseEventAdapter<EventListItem>
{
-
+
public ChannelEventAdapter(final Context context) {
super(context, R.layout.epg_event_item);
hideChannelName = true;
}
-
+
@Override
protected EventFormatter getEventFormatter(Event event) {
return new EventFormatter(event,true);
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchTimesListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchTimesListActivity.java
index 6cc5a3d..9be94cb 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchTimesListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchTimesListActivity.java
@@ -1,12 +1,10 @@
package de.bjusystems.vdrmanager.gui;
-import java.util.Calendar;
import java.util.List;
-import java.util.TimeZone;
import android.app.Activity;
-import android.app.TimePickerDialog;
-import android.app.TimePickerDialog.OnTimeSetListener;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
@@ -27,13 +25,14 @@ import de.bjusystems.vdrmanager.data.Preferences;
/**
* This class is used for showing what's
* current running on all channels
+
* @author bju
*/
public class EpgSearchTimesListActivity extends Activity
- implements OnClickListener, OnTimeSetListener {
+ implements OnClickListener{
ArrayAdapter<EpgSearchTimeValue> adapter;
-
+
List<EpgSearchTimeValue> values;
@Override
@@ -44,7 +43,7 @@ public class EpgSearchTimesListActivity extends Activity
setContentView(R.layout.epg_search_times_list);
setTitle(R.string.epg_search_times_window);
-
+
// Create adapter for ListView
adapter = new ArrayAdapter<EpgSearchTimeValue>(this, R.layout.epg_search_times_item);
final ListView listView = (ListView) findViewById(R.id.epg_search_times_list);
@@ -60,13 +59,28 @@ public class EpgSearchTimesListActivity extends Activity
}
public void onClick(final View v) {
- final Calendar cal = Calendar.getInstance(TimeZone.getDefault());
// show time selection
- final TimePickerDialog dialog = new TimePickerDialog(this, this, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), Preferences.get().isUse24hFormat());
- dialog.show();
+ final TimePicker timePicker = new TimePicker(this);
+ timePicker.setIs24HourView(Preferences.get().isUse24hFormat());
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.set_time)
+ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ onTimeSet(timePicker.getCurrentHour(), timePicker.getCurrentMinute());
+ }
+ })
+ .setNegativeButton(android.R.string.cancel,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int which) {
+ dialog.dismiss();
+ }
+ }).setView(timePicker).show();
}
- public void onTimeSet(final TimePicker view, final int hourOfDay, final int minute) {
+ public void onTimeSet(final int hourOfDay, final int minute) {
final EpgSearchTimeValue time = new EpgSearchTimeValue(values.size(), String.format("%02d:%02d", hourOfDay, minute));
values.add(time);
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingAdapter.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingAdapter.java
index 3645596..9d537c1 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingAdapter.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingAdapter.java
@@ -1,13 +1,19 @@
package de.bjusystems.vdrmanager.gui;
import android.content.Context;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.EventFormatter;
+import de.bjusystems.vdrmanager.data.EventListItem;
+import de.bjusystems.vdrmanager.data.RecordingListItem;
-class RecordingAdapter extends EventAdapter
-{
+class RecordingAdapter extends BaseEventAdapter<EventListItem> {
+
+ protected final static int TYPE_FOLDER = 2;
public RecordingAdapter(final Context context) {
super(context, R.layout.epg_event_item);
@@ -16,8 +22,94 @@ class RecordingAdapter extends EventAdapter
@Override
protected EventFormatter getEventFormatter(Event event) {
- return new EventFormatter(event, true);
+ return new EventFormatter(event, true);
+ }
+
+ @Override
+ public int getViewTypeCount() {
+ return 3;
+ }
+
+ @Override
+ protected boolean isHeader(EventListItem item) {
+ if(item instanceof RecordingListItem == false){
+ return item.isHeader();
+ }
+
+ if(((RecordingListItem)item).isFolder() ){
+ return false;
+ }
+
+ return item.isHeader();
+ }
+
+
+ @Override
+ public int getItemViewType(int position) {
+
+ // get item
+ final RecordingListItem item = (RecordingListItem) getItem(position);
+
+ if (item.isHeader()) {
+ return TYPE_HEADER;
+ } else if (item.isFolder()) {
+ return TYPE_FOLDER;
+ }
+ return TYPE_ITEM;
+ }
+
+
+
+ class EventListItemFolderHolder {
+ public TextView folder;
+ public TextView count;
+ }
+
+ protected EventListItemFolderHolder getFolderViewHolder(EventListItem item,
+ View view) {
+ EventListItemFolderHolder itemHolder = new EventListItemFolderHolder();
+ itemHolder.folder = (TextView) view.findViewById(R.id.header_item);
+ itemHolder.count = (TextView) view.findViewById(R.id.count);
+ return itemHolder;
+ }
+
+
+ @Override
+ public View getView(final int position, View convertView,
+ final ViewGroup parent) {
+
+ // get item
+ final RecordingListItem item = (RecordingListItem) getItem(position);
+
+ if (item.isFolder() == false) {
+ return super.getView(position, convertView, parent);
+ }
+
+ EventListItemFolderHolder holder = null;
+ if (convertView == null || (convertView != null && convertView.getTag() instanceof EventListItemFolderHolder) == false) {
+ convertView = inflater.inflate(R.layout.folder_item, null);
+ holder = getFolderViewHolder(item, convertView);
+ convertView.setTag(holder);
+ } else {
+ holder = (EventListItemFolderHolder) convertView.getTag();
+ }
+
+ holder.folder.setText(Utils.highlight(item.folder, highlight));
+ holder.count.setText(String.valueOf(item.count));
+ return convertView;
}
+ @Override
+ public RecordingListItem getItem(int position) {
+ return (RecordingListItem) super.getItem(position);
+ }
+//
+// protected void addSuper(RecordingListItem item) {
+// super.addSuper(item);
+// }
+//
+// protected void clearSuper() {
+// super.clear();
+// }
} \ No newline at end of file
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java
index d369ca5..5a74852 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java
@@ -3,7 +3,13 @@ package de.bjusystems.vdrmanager.gui;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Stack;
+import java.util.TreeMap;
+import java.util.TreeSet;
import android.os.Bundle;
import android.view.ContextMenu;
@@ -14,12 +20,14 @@ import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ListView;
+import android.widget.TextView;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.EventFormatter;
import de.bjusystems.vdrmanager.data.EventListItem;
import de.bjusystems.vdrmanager.data.Preferences;
import de.bjusystems.vdrmanager.data.Recording;
+import de.bjusystems.vdrmanager.data.RecordingListItem;
import de.bjusystems.vdrmanager.tasks.DeleteRecordingTask;
import de.bjusystems.vdrmanager.utils.date.DateFormatter;
import de.bjusystems.vdrmanager.utils.svdrp.RecordingClient;
@@ -35,28 +43,42 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent;
public class RecordingListActivity extends BaseEventListActivity<Recording>
implements OnItemLongClickListener {
- //RecordingClient recordingClient;
+ // RecordingClient recordingClient;
- //public static final int MENU_GROUP_CHANNEL = 2;
+ // public static final int MENU_GROUP_CHANNEL = 2;
public static final int ASC = 0;
public static final int DESC = 1;
- protected static ArrayList<Recording> CACHE = new ArrayList<Recording>();
+ // protected static ArrayList<Recording> CACHE = new ArrayList<Recording>();
+ private static Map<String, List<Recording>> CACHE = new TreeMap<String, List<Recording>>();
+
+ public static final Map<String, Set<String>> FOLDERS = new TreeMap<String, Set<String>>();
+
+ private String currentFolder = Recording.ROOT_FOLDER;
private final int ASC_DESC = ASC;
+ private static final List<Recording> EMPTY = new ArrayList<Recording>(0);
+
+ private final Stack<String> stack = new Stack<String>();
+
+ private TextView folderInfo;
+
+ private TextView currentCount;
+
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // create an adapter
adapter = new RecordingAdapter(this);
// attach adapter to ListView
listView = (ListView) findViewById(R.id.recording_list);
+ folderInfo = (TextView) findViewById(R.id.folder_info);
+ currentCount = (TextView) findViewById(R.id.current_count);
listView.setAdapter(adapter);
// set click listener
@@ -116,6 +138,32 @@ implements OnItemLongClickListener {
// }
// }
+ @Override
+ public void onItemClick(final AdapterView<?> parent, final View view, final int position,
+ final long id) {
+
+ final RecordingListItem item = (RecordingListItem) adapter
+ .getItem(position);
+ if (item.isFolder()) {
+ if (currentFolder.equals(Recording.ROOT_FOLDER)) {
+ currentFolder = item.folder;
+ } else {
+ currentFolder = currentFolder + Recording.FOLDERDELIMCHAR
+ + item.folder;
+ }
+ stack.push(currentFolder);
+ fillAdapter();
+ } else {
+ super.onItemClick(parent, view, position, id);
+ }
+ }
+
+ private void updateCurrentFolderInfo() {
+ folderInfo.setText("/" + currentFolder.replaceAll("~", "/"));
+ final List<Recording> list = CACHE.get(currentFolder);
+ currentCount.setText(String.valueOf(list.size()));
+ }
+
/*
* (non-Javadoc)
*
@@ -139,7 +187,7 @@ implements OnItemLongClickListener {
@Override
protected void prepareDetailsViewData(final EventListItem event) {
getApp().setCurrentEvent(event.getEvent());
- getApp().setCurrentEpgList(CACHE);
+ getApp().setCurrentEpgList(CACHE.get(currentFolder));
}
@Override
@@ -168,9 +216,9 @@ implements OnItemLongClickListener {
super.onCreateContextMenu(menu, v, menuInfo);
//
// http://projects.vdr-developer.org/issues/863
- //if (Utils.isLive(item)) {
+ // if (Utils.isLive(item)) {
menu.removeItem(R.id.epg_item_menu_live_tv);
- //}
+ // }
}
@Override
@@ -251,16 +299,16 @@ implements OnItemLongClickListener {
/* */
switch (sortBy) {
case MENU_GROUP_DEFAULT: {
- sortItemsByTime(CACHE, true);
+ sortItemsByTime(CACHE.get(currentFolder), true);
break;
}
case MENU_GROUP_ALPHABET: {
- Collections.sort(CACHE, new TitleComparator());
+ Collections.sort(CACHE.get(currentFolder), new TitleComparator());
break;
}
- //case MENU_GROUP_CHANNEL: {
- //sortItemsByChannel(results);
- //}
+ // case MENU_GROUP_CHANNEL: {
+ // sortItemsByChannel(results);
+ // }
}
}
@@ -268,40 +316,118 @@ implements OnItemLongClickListener {
protected void fillAdapter() {
adapter.clear();
-
- if (CACHE.isEmpty()) {
+ final List<Recording> list = CACHE.get(currentFolder);
+ if (list == null || list.isEmpty()) {
return;
}
+ updateCurrentFolderInfo();
+
sort();
final Calendar cal = Calendar.getInstance();
int day = -1;
- for (final Event rec : CACHE) {
+ final Set<String> folders = FOLDERS.get(currentFolder);
+ if (folders != null) {
+ for (final String f : folders) {
+ final RecordingListItem recordingListItem = new RecordingListItem(f);
+ recordingListItem.folder = f;
+ final String sf = currentFolder.length() > 0 ? currentFolder
+ + Recording.FOLDERDELIMCHAR + f : f;
+ final List<Recording> list2 = CACHE.get(sf);
+ if (list2 != null) {
+ recordingListItem.count = list2.size();
+ }
+ adapter.add(recordingListItem);
+ }
+ }
+
+ for (final Event rec : CACHE.get(currentFolder)) {
cal.setTime(rec.getStart());
final int eday = cal.get(Calendar.DAY_OF_YEAR);
if (eday != day) {
day = eday;
- adapter.add(new EventListItem(new DateFormatter(cal)
+ adapter.add(new RecordingListItem(new DateFormatter(cal)
.getDailyHeader()));
}
- adapter.add(new EventListItem(rec));
+ adapter.add(new RecordingListItem((Recording) rec));
adapter.notifyDataSetChanged();
}
}
@Override
+ public void onBackPressed() {
+ if (stack.isEmpty()) {
+ super.onBackPressed();
+ } else {
+ stack.pop();
+ if (stack.isEmpty()) {
+ currentFolder = "";
+ } else {
+ currentFolder = stack.peek();
+ }
+ fillAdapter();
+ }
+
+ }
+
+ @Override
protected boolean finishedSuccessImpl(final List<Recording> results) {
clearCache();
- for(final Recording r :results){
- CACHE.add(r);
+ for (final Recording r : results) {
+ final String folder = r.getFolder();
+ if (folder.length() > 0) {
+ final String[] split = folder.split(Recording.FOLDERDELIMCHAR);
+ String key = null;
+ String value = null;
+ if (split.length == 1) {
+ key = Recording.ROOT_FOLDER;
+ value = split[0];
+ } else {
+ value = split[split.length - 1];
+ // StringBuilder sb = new StringBuilder();
+ // String sep = "";
+ // for(int i = 0; i < split.length - 1; ++i){
+ // sb.append(sep).append(split[i]);
+ // sep = Recording.FOLDERDELIMCHAR;
+ // }
+ key = folder.subSequence(0,
+ folder.length() - (value.length() + 1)).toString();
+
+ }
+
+ Set<String> list = FOLDERS.get(key);
+ if (list == null) {
+ list = new TreeSet<String>(new Comparator<String>() {
+ @Override
+ public int compare(final String lhs, final String rhs) {
+ return lhs.compareToIgnoreCase(rhs);
+ }
+ });
+ FOLDERS.put(key, list);
+ }
+
+ list.add(value);
+
+ // a b
+ // a
+ // c
+ // a~b > k
+
+ }
+ List<Recording> list = CACHE.get(folder);
+ if (list == null) {
+ list = new ArrayList<Recording>();
+ CACHE.put(folder, list);
+ }
+ list.add(r);
}
+
pushResultCountToTitle();
fillAdapter();
return adapter.isEmpty() == false;
-
}
@Override
@@ -317,8 +443,19 @@ implements OnItemLongClickListener {
}
@Override
- protected List<Recording> getCACHE() {
- return CACHE;
+ public void clearCache() {
+ CACHE.clear();
+ FOLDERS.clear();
}
+ @Override
+ protected List<Recording> getCACHE() {
+
+ final List<Recording> list = CACHE.get(currentFolder);
+
+ if (list != null) {
+ return list;
+ }
+ return EMPTY;
+ }
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java
index 4c72795..74cd502 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java
@@ -23,6 +23,8 @@ public class SvdrpProgressDialog<T> extends ProgressDialog implements
this.client = client;
progress = new ProgressDialog(context);
progress.setOnCancelListener(this);
+ progress.setCancelable(true);
+ progress.setCanceledOnTouchOutside(false);
}
public void svdrpEvent(final SvdrpEvent sevent) {
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEventAdapter.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEventAdapter.java
index dc7545e..f5cca64 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEventAdapter.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEventAdapter.java
@@ -4,8 +4,9 @@ import android.content.Context;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.EventFormatter;
+import de.bjusystems.vdrmanager.data.EventListItem;
-public class TimeEventAdapter extends EventAdapter {
+public class TimeEventAdapter extends BaseEventAdapter<EventListItem> {
public TimeEventAdapter(final Context context) {
super(context, R.layout.epg_event_item);
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java
index 27163e0..8a7330e 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java
@@ -29,223 +29,221 @@ import de.bjusystems.vdrmanager.data.db.EPGSearchSuggestionsProvider;
import de.bjusystems.vdrmanager.utils.wakeup.AsyncWakeupTask;
public class VdrManagerActivity extends SherlockActivity implements
-OnClickListener, OnQueryTextListener {
+ OnClickListener, OnQueryTextListener {
- public static final String TAG = "VdrManagerActivity";
+ public static final String TAG = "VdrManagerActivity";
- public static final String VDR_PORTAL = "http://www.vdr-portal.de";
+ public static final String VDR_PORTAL = "http://www.vdr-portal.de";
- private com.actionbarsherlock.widget.SearchView search;
+ private com.actionbarsherlock.widget.SearchView search;
- private View actionMenuWakup;
+ private View actionMenuWakup;
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
- // Preferences.initVDR(this);
+ // Preferences.initVDR(this);
- // if(Preferences.get().getCurrentVdr() == null){
- // finish();
- // return;
- // }
+ // if(Preferences.get().getCurrentVdr() == null){
+ // finish();
+ // return;
+ // }
- if (Preferences.initVDR(this) == false) {
+ if (Preferences.initVDR(this) == false) {
final Intent intent = new Intent();
- intent.setClass(this, VdrListActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(Intents.EMPTY_CONFIG, Boolean.TRUE);
- startActivity(intent);
- Toast.makeText(this, R.string.no_vdr, Toast.LENGTH_SHORT).show();
- finish();
- return;
- }
-
- Preferences.setLocale(this);
-
- // this.getActionBar().setDisplayShowCustomEnabled(true);
- // this.getActionBar().setDisplayShowTitleEnabled(false);
- // setTitle(getString(R.string.app_name));
- // attach view
- setContentView(R.layout.vdrmanager);
-
- // Preferences.loadPreferences(this);
-
- findViewById(R.id.action_menu_channels).setOnClickListener(this);
- findViewById(R.id.action_menu_recordings).setOnClickListener(this);
- findViewById(R.id.action_menu_timers).setOnClickListener(this);
- findViewById(R.id.action_menu_epg).setOnClickListener(this);
- final View v = findViewById(R.id.action_menu_search);
- if (v != null) {
- v.setOnClickListener(this);
- }
- findViewById(R.id.main_logo).setOnClickListener(this);
- actionMenuWakup = findViewById(R.id.action_menu_wakeup);
-
- // add and register buttons
- // createButtons();
- }
-
- @Override
- public boolean onCreateOptionsMenu(final com.actionbarsherlock.view.Menu menu) {
- final com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
- inflater.inflate(R.menu.main_menu, menu);
-
- // search = new SearchView(getSupportActionBar().getThemedContext());
-
- search = (SearchView) menu.findItem(R.id.menu_search).getActionView();
-
- // search = (SearchView)
- // .getActionView();
- //
- // Object o = menu.findItem(R.id.menu_search);
-
- final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
- search.setSearchableInfo(searchManager
- .getSearchableInfo(getComponentName()));
-
- // search.setOnQueryTextListener(this);
- return true;
- }
-
- @Override
- protected void onResume() {
- Preferences.setLocale(this);
- if (Preferences.get().isWakeupEnabled() == false) {
- actionMenuWakup.setVisibility(View.GONE);
- actionMenuWakup.setOnClickListener(null);
- } else {
- actionMenuWakup.setVisibility(View.VISIBLE);
- actionMenuWakup.setOnClickListener(this);
- }
- super.onResume();
- }
-
- @Override
- public boolean onOptionsItemSelected(
- final com.actionbarsherlock.view.MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.main_menu_preferences: {
- final Intent intent = new Intent(this, PreferencesActivity.class);
- final int flags = Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_SINGLE_TOP
- | Intent.FLAG_ACTIVITY_CLEAR_TOP;
- intent.setFlags(flags);
- startActivity(intent);
- finish();
- break;
- }
- case R.id.main_menu_info: {
- if(!isFinishing()){
- return true;
- }
- About.show(this);
- break;
- }
- case R.id.main_menu_exit: {
- finish();
- break;
- }
-
- case R.id.main_menu_clear_search: {
- final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(
- this, EPGSearchSuggestionsProvider.AUTHORITY,
- EPGSearchSuggestionsProvider.MODE);
- suggestions.clearHistory();
- break;
- }
-
- // case R.id.menu_search: {
- // if(Build.VERSION.SDK_INT <11){
- // onSearchRequested();
- // }
- // break;
- // }
- case R.id.main_menu_goto: {
- try {
- final Cursor cursor = ((AndroidDatabaseResults) DBAccess
- .get(this).getVdrDAO().iterator().getRawResults())
- .getRawCursor();
- startManagingCursor(cursor);
- final AlertDialog ad = new AlertDialog.Builder(this)
- .setSingleChoiceItems(cursor, findVdrCursor(cursor),
- "name", new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(final DialogInterface dialog,
- final int which) {
- cursor.moveToPosition(which);
- final int id = cursor.getInt(cursor
- .getColumnIndex("_id"));
- final Vdr vdr = DBAccess
- .get(VdrManagerActivity.this)
- .getVdrDAO().queryForId(id);
- if (vdr == null) {
- Toast.makeText(
- VdrManagerActivity.this,
- R.string.main_menu_goto_no_vdr,
- Toast.LENGTH_SHORT).show();
- } else {
- Preferences.setCurrentVdr(
- VdrManagerActivity.this,
- vdr);
- Toast.makeText(
- VdrManagerActivity.this,
- getString(
- R.string.main_menu_switched_to,
- vdr.getName()),
- Toast.LENGTH_SHORT).show();
- final Intent intent = getIntent();
- overridePendingTransition(0, 0);
- intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- finish();
-
- overridePendingTransition(0, 0);
- startActivity(intent);
- }
- dialog.dismiss();
- }
- })//
- .setTitle(R.string.main_menu_goto_title)//
- .create();
- ad.show();
-
- } catch (final Exception ex) {
- Log.w(TAG, ex);
- }
-
- break;
- }
- }
- return true;
- }
-
- private int findVdrCursor(final Cursor c) {
- if (Preferences.get().getCurrentVdr() == null) {
- return -1;
- }
-
- final int cid = Preferences.get().getCurrentVdr().getId();
-
- int position = 0;
- c.moveToPosition(-1);
- while (c.moveToNext()) {
- if (c.getInt(c.getColumnIndex("_id")) == cid) {
- break;
- }
- position++;
- }
- return position;
- }
-
- @Override
- public void onBackPressed() {
- if (Preferences.get().isQuiteOnBackButton()) {
+ intent.setClass(this, VdrListActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.putExtra(Intents.EMPTY_CONFIG, Boolean.TRUE);
+ startActivity(intent);
+ Toast.makeText(this, R.string.no_vdr, Toast.LENGTH_SHORT).show();
+ finish();
+ return;
+ }
+
+ Preferences.setLocale(this);
+
+ // this.getActionBar().setDisplayShowCustomEnabled(true);
+ // this.getActionBar().setDisplayShowTitleEnabled(false);
+ // setTitle(getString(R.string.app_name));
+ // attach view
+ setContentView(R.layout.vdrmanager);
+
+ // Preferences.loadPreferences(this);
+
+ findViewById(R.id.action_menu_channels).setOnClickListener(this);
+ findViewById(R.id.action_menu_recordings).setOnClickListener(this);
+ findViewById(R.id.action_menu_timers).setOnClickListener(this);
+ findViewById(R.id.action_menu_epg).setOnClickListener(this);
+// View v = findViewById(R.id.action_menu_search);
+// if (v != null) {
+// v.setOnClickListener(this);
+// }
+ findViewById(R.id.main_logo).setOnClickListener(this);
+ actionMenuWakup = findViewById(R.id.action_menu_wakeup);
+
+ // add and register buttons
+ // createButtons();
+ }
+
+ public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
+ com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
+ inflater.inflate(R.menu.main_menu, menu);
+
+ // search = new SearchView(getSupportActionBar().getThemedContext());
+
+ search = (SearchView) menu.findItem(R.id.menu_search).getActionView();
+
+ // search = (SearchView)
+ // .getActionView();
+ //
+ // Object o = menu.findItem(R.id.menu_search);
+
+ SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
+ search.setSearchableInfo(searchManager
+ .getSearchableInfo(getComponentName()));
+
+ // search.setOnQueryTextListener(this);
+ return true;
+ }
+
+ @Override
+ protected void onResume() {
+ Preferences.setLocale(this);
+ if (Preferences.get().isWakeupEnabled() == false) {
+ actionMenuWakup.setVisibility(View.GONE);
+ actionMenuWakup.setOnClickListener(null);
+ } else {
+ actionMenuWakup.setVisibility(View.VISIBLE);
+ actionMenuWakup.setOnClickListener(this);
+ }
+ super.onResume();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(
+ final com.actionbarsherlock.view.MenuItem item) {
+
+ switch (item.getItemId()) {
+ case R.id.main_menu_preferences: {
+ Intent intent = new Intent(this, PreferencesActivity.class);
+ int flags = Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_SINGLE_TOP
+ | Intent.FLAG_ACTIVITY_CLEAR_TOP;
+ intent.setFlags(flags);
+ startActivity(intent);
+ finish();
+ break;
+ }
+ case R.id.main_menu_info: {
+ if(isFinishing()){
+ break;
+ }
+ About.show(this);
+ break;
+ }
+ case R.id.main_menu_exit: {
+ finish();
+ break;
+ }
+
+ case R.id.main_menu_clear_search: {
+ SearchRecentSuggestions suggestions = new SearchRecentSuggestions(
+ this, EPGSearchSuggestionsProvider.AUTHORITY,
+ EPGSearchSuggestionsProvider.MODE);
+ suggestions.clearHistory();
+ break;
+ }
+
+ // case R.id.menu_search: {
+ // if(Build.VERSION.SDK_INT <11){
+ // onSearchRequested();
+ // }
+ // break;
+ // }
+ case R.id.main_menu_goto: {
+ try {
+ final Cursor cursor = ((AndroidDatabaseResults) DBAccess
+ .get(this).getVdrDAO().iterator().getRawResults())
+ .getRawCursor();
+ startManagingCursor(cursor);
+ final AlertDialog ad = new AlertDialog.Builder(this)
+ .setSingleChoiceItems(cursor, findVdrCursor(cursor),
+ "name", new DialogInterface.OnClickListener() {
+
+ public void onClick(DialogInterface dialog,
+ int which) {
+ cursor.moveToPosition(which);
+ int id = cursor.getInt(cursor
+ .getColumnIndex("_id"));
+ Vdr vdr = DBAccess
+ .get(VdrManagerActivity.this)
+ .getVdrDAO().queryForId(id);
+ if (vdr == null) {
+ Toast.makeText(
+ VdrManagerActivity.this,
+ R.string.main_menu_goto_no_vdr,
+ Toast.LENGTH_SHORT).show();
+ } else {
+ Preferences.setCurrentVdr(
+ VdrManagerActivity.this,
+ vdr);
+ Toast.makeText(
+ VdrManagerActivity.this,
+ getString(
+ R.string.main_menu_switched_to,
+ vdr.getName()),
+ Toast.LENGTH_SHORT).show();
+ Intent intent = getIntent();
+ overridePendingTransition(0, 0);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
+ finish();
+
+ overridePendingTransition(0, 0);
+ startActivity(intent);
+ }
+ dialog.dismiss();
+ }
+ })//
+ .setTitle(R.string.main_menu_goto_title)//
+ .create();
+ ad.show();
+
+ } catch (Exception ex) {
+ Log.w(TAG, ex);
+ }
+
+ break;
+ }
+ }
+ return true;
+ }
+
+ private int findVdrCursor(Cursor c) {
+ if (Preferences.get().getCurrentVdr() == null) {
+ return -1;
+ }
+
+ int cid = Preferences.get().getCurrentVdr().getId();
+
+ int position = 0;
+ c.moveToPosition(-1);
+ while (c.moveToNext()) {
+ if (c.getInt(c.getColumnIndex("_id")) == cid) {
+ break;
+ }
+ position++;
+ }
+ return position;
+ }
+
+ @Override
+ public void onBackPressed() {
+ if (Preferences.get().isQuiteOnBackButton()) {
finish();
} else {
- super.onBackPressed();
- }
+ super.onBackPressed();
+ }
try {
// reassign a new and empty key store
@@ -254,70 +252,69 @@ OnClickListener, OnQueryTextListener {
Log.e(getClass().getName(), "Can't clear session key store");
}
- }
-
- public void startActivity(final Class<?> clazz) {
- final Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setClass(this, clazz);
- startActivity(intent);
- }
-
- @Override
- public void onClick(final View v) {
- final int id = v.getId();
-
- switch (id) {
- case R.id.action_menu_channels:
- startActivity(ChannelListActivity.class);
- break;
- case R.id.action_menu_recordings:
- startActivity(RecordingListActivity.class);
- break;
- case R.id.action_menu_timers:
- startActivity(TimerListActivity.class);
- break;
- case R.id.action_menu_epg:
- startActivity(TimeEpgListActivity.class);
- break;
- case R.id.action_menu_search:
- onSearchRequested();
- break;
- case R.id.action_menu_wakeup:
- final AsyncWakeupTask wakeupTask = new AsyncWakeupTask(this);
- wakeupTask.execute();
- break;
- case R.id.main_logo:
- final Intent i = new Intent(Intent.ACTION_VIEW);
- i.setData(Uri.parse(VDR_PORTAL));
- startActivity(i);
- break;
- }
-
- }
-
- protected void startSearchManager() {
- final Bundle appData = new Bundle();
- startSearch(null, false, appData, false);
- }
-
- @Override
- public boolean onSearchRequested() {
- search.setVisibility(View.VISIBLE);
- // Bundle appData = new Bundle();
- // appData.putBoolean(SearchableActivity.JARGON, true);
- // startSearch(null, false, appData, false);
- return true;
- }
-
- @Override
- public boolean onQueryTextSubmit(final String query) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean onQueryTextChange(final String newText) {
- // TODO Auto-generated method stub
- return false;
- }
+ }
+
+ public void startActivity(Class<?> clazz) {
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setClass(this, clazz);
+ startActivity(intent);
+ }
+
+ public void onClick(View v) {
+ int id = v.getId();
+
+ switch (id) {
+ case R.id.action_menu_channels:
+ startActivity(ChannelListActivity.class);
+ break;
+ case R.id.action_menu_recordings:
+ startActivity(RecordingListActivity.class);
+ break;
+ case R.id.action_menu_timers:
+ startActivity(TimerListActivity.class);
+ break;
+ case R.id.action_menu_epg:
+ startActivity(TimeEpgListActivity.class);
+ break;
+// case R.id.action_menu_search:
+// onSearchRequested();
+// break;
+ case R.id.action_menu_wakeup:
+ final AsyncWakeupTask wakeupTask = new AsyncWakeupTask(this);
+ wakeupTask.execute();
+ break;
+ case R.id.main_logo:
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse(VDR_PORTAL));
+ startActivity(i);
+ break;
+ }
+
+ }
+
+ protected void startSearchManager() {
+ Bundle appData = new Bundle();
+ startSearch(null, false, appData, false);
+ }
+
+ @Override
+ public boolean onSearchRequested() {
+ search.setVisibility(View.VISIBLE);
+ // Bundle appData = new Bundle();
+ // appData.putBoolean(SearchableActivity.JARGON, true);
+ // startSearch(null, false, appData, false);
+ return true;
+ }
+
+ @Override
+ public boolean onQueryTextSubmit(String query) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean onQueryTextChange(String newText) {
+ // TODO Auto-generated method stub
+ return false;
+ }
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpAsyncTask.java b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpAsyncTask.java
index 224ca48..505b084 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpAsyncTask.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpAsyncTask.java
@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List;
import android.os.AsyncTask;
-import de.bjusystems.vdrmanager.utils.svdrp.CertificateProblemListener.CertificateProblemAction;
public class SvdrpAsyncTask<Result, Client extends SvdrpClient<Result>> extends
AsyncTask<Void, Object, Void> implements SvdrpListener,
@@ -22,9 +21,9 @@ SvdrpExceptionListener, SvdrpResultListener<Result> {
List<SvdrpFinishedListener<Result>> finishedListeners = new ArrayList<SvdrpFinishedListener<Result>>();
- CertificateProblemListener certificateProblemListener = null;
+ //CertificateProblemListener certificateProblemListener = null;
- CertificateProblemAction certificateProblemAction;
+ //CertificateProblemAction certificateProblemAction;
public SvdrpAsyncTask(final Client client) {
this.client = client;
@@ -159,4 +158,8 @@ SvdrpExceptionListener, SvdrpResultListener<Result> {
public void svdrpEvent(final Result result) {
results.add(result);
}
+
+ public void abort(){
+ client.abort();
+ }
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java
index ba87100..e269a5b 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java
@@ -12,6 +12,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.InflaterInputStream;
import android.util.Log;
import de.bjusystems.vdrmanager.app.C;
@@ -374,14 +376,39 @@ public abstract class SvdrpClient<Result> {
return;
}
+ // activate compression
+ Log.i(TAG, "Activate compression");
+ writeLine("compress");
+
// send command
informListener(SvdrpEvent.COMMAND_SENDING);
writeLine(command);
informListener(SvdrpEvent.COMMAND_SENT);
Log.i(TAG, SvdrpEvent.COMMAND_SENT + ":" + command);
- // read first line
+ // get the answer for the compress command or
+ // the first line of the answer for the command
String line = readLine();
+ if (line.startsWith("!OK")) {
+ final String[] words = line.split(" ");
+ if (words.length > 1) {
+ final String mode = words[1].toUpperCase();
+ if (mode.equals("ZLIB")) {
+ Log.i(TAG, "ZLIB compression activated");
+ inputStream = new InflaterInputStream(inputStream);
+ } else if (mode.equals("GZIP")) {
+ Log.i(TAG, "GZIP compression activated");
+ inputStream = new GZIPInputStream(inputStream);
+ } else {
+ Log.i(TAG, "NO compression activated");
+ }
+ }
+ line = readLine();
+ } else {
+ Log.i(TAG, "NO compression activated");
+ }
+
+ // correct answer?
if (!line.startsWith("START")) {
Log.w(TAG, line);
throw new IOException("Answer not wellformed: " + line);