summaryrefslogtreecommitdiff
path: root/vdrmanager/src
diff options
context:
space:
mode:
authorlado <herrlado@gmail.com>2011-10-15 02:57:34 +0200
committerlado <herrlado@gmail.com>2011-10-15 02:57:34 +0200
commit9e369f6edd85fcd77c1ce4009df63d9993e53d18 (patch)
tree86f9fc0f092354048cdb51a828bf2e61e87fc40b /vdrmanager/src
parente11ed9dce9afefb3818d64ac95ef24edf9f9c041 (diff)
downloadvdr-manager-9e369f6edd85fcd77c1ce4009df63d9993e53d18.tar.gz
vdr-manager-9e369f6edd85fcd77c1ce4009df63d9993e53d18.tar.bz2
implemented search (not yet 100% clean) and time search not know if
works, not yet tested. Added imdb support
Diffstat (limited to 'vdrmanager/src')
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/app/Intents.java1
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java6
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java38
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEpgListActivity.java110
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelAdapter.java84
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java163
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java104
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchActivity.java62
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java168
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java72
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java9
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EventListItemHolder.java1
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java48
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java3
14 files changed, 535 insertions, 334 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/app/Intents.java b/vdrmanager/src/de/bjusystems/vdrmanager/app/Intents.java
index 9b113e8..dc71105 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/app/Intents.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/app/Intents.java
@@ -3,5 +3,6 @@ package de.bjusystems.vdrmanager.app;
public interface Intents {
public static final String CURRENT_CHANNEL = "CURRENT_CHANNEL";
+ public static final String HIGHLIGHT = "HIGHLIGHT";
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java b/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java
index fd84f25..a714845 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java
@@ -23,12 +23,12 @@ public class VdrManagerApp extends Application {
private Timer currentTimer;
private Channel currentChannel;
- private ArrayList<Epg> currentEpgList = new ArrayList<Epg>();
- public ArrayList<Epg> getCurrentEpgList() {
+ private List<Epg> currentEpgList = new ArrayList<Epg>();
+ public List<Epg> getCurrentEpgList() {
return currentEpgList;
}
- public void setCurrentEpgList(ArrayList<Epg> currentEpgList) {
+ public void setCurrentEpgList(List<Epg> currentEpgList) {
this.currentEpgList = currentEpgList;
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java
index c415465..2570e67 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java
@@ -2,13 +2,13 @@ package de.bjusystems.vdrmanager.data;
import android.content.Context;
import android.content.SharedPreferences;
-import android.test.IsolatedContext;
import de.bjusystems.vdrmanager.R;
/**
* Class for all preferences
*
- * @author bju
+ * @author bju, lado
+ *
*/
public class Preferences {
@@ -110,6 +110,36 @@ public class Preferences {
* Quits the app on back button
*/
private boolean quiteOnBackButton = true;
+
+
+ /**
+ * Show IMDB buttons, where possible (e.g. EPG Details)
+ */
+ private boolean showImdbButton = true;
+
+
+ /**
+ * On Which imdb site to search?
+ */
+ private String imdbUrl = "imdb.de";
+
+
+ public String getImdbUrl() {
+ return imdbUrl;
+ }
+
+
+ public void setImdbUrl(String imdbUrl) {
+ this.imdbUrl = imdbUrl;
+ }
+
+
+ /**
+ * @return whether to shwo imdb button
+ */
+ public boolean isShowImdbButton() {
+ return showImdbButton;
+ }
/** Properties singleton */
private static Preferences thePrefs;
@@ -498,6 +528,10 @@ public class Preferences {
prefs.quiteOnBackButton = getBoolean(context, R.string.qui_quit_on_back_key, true);
+ prefs.showImdbButton = getBoolean(context, R.string.qui_show_imdb_button_key, true);
+
+ prefs.imdbUrl = getString(context, R.string.qui_imdb_url_key, "imdb.de");
+
thePrefs = prefs;
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEpgListActivity.java
index c1530dc..d298de1 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEpgListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEpgListActivity.java
@@ -30,33 +30,33 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent;
/**
* @author lado
- *
+ *
*/
-public abstract class BaseEpgListActivity extends BaseActivity implements SimpleGestureListener{
+public abstract class BaseEpgListActivity extends BaseActivity implements
+ SimpleGestureListener {
-
private static final int REQUEST_CODE_TIMED_EDIT = 41;
-
+
private SimpleGestureFilter detector;
-
+
protected EpgClient epgClient;
-
+
protected EventAdapter adapter;
-
+
protected SvdrpProgressDialog progress;
-
+
+ protected String highlight = null;
+
protected static final Date FUTURE = new Date(Long.MAX_VALUE);
-
- //private static final Date BEGIN = new Date(0);
+ // private static final Date BEGIN = new Date(0);
protected Channel currentChannel = null;
-
+
protected ListView listView;
abstract protected int getWindowTitle();
-
-
+
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -66,11 +66,12 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
setTitle(getWindowTitle());
initChannel();
}
-
- private void initChannel(){
- currentChannel = getIntent().getParcelableExtra(Intents.CURRENT_CHANNEL);
+
+ private void initChannel() {
+ currentChannel = getIntent()
+ .getParcelableExtra(Intents.CURRENT_CHANNEL);
}
-
+
protected void deleteTimer(final EventListItem item) {
final DeleteTimerTask task = new DeleteTimerTask(this, item.getEpg()
@@ -82,11 +83,13 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
};
task.start();
}
-
-
- /* (non-Javadoc)
- * @see de.bjusystems.vdrmanager.gui.BaseActivity#onCreateOptionsMenu(android.view.Menu)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * de.bjusystems.vdrmanager.gui.BaseActivity#onCreateOptionsMenu(android
+ * .view.Menu)
*/
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
@@ -97,11 +100,13 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
return true;
}
- protected void prepareTimer(EventListItem event){
-
+ protected void prepareTimer(EventListItem event) {
+
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see android.app.Activity#onContextItemSelected(android.view.MenuItem)
*/
@Override
@@ -137,9 +142,13 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
return true;
}
-
- /* (non-Javadoc)
- * @see de.bjusystems.vdrmanager.gui.BaseActivity#onOptionsItemSelected(android.view.MenuItem)
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * de.bjusystems.vdrmanager.gui.BaseActivity#onOptionsItemSelected(android
+ * .view.MenuItem)
*/
public boolean onOptionsItemSelected(final MenuItem item) {
@@ -147,9 +156,8 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
switch (item.getItemId()) {
case R.id.epg_menu_search:
- intent = new Intent();
- intent.setClass(this, EpgSearchActivity.class);
- startActivity(intent);
+ //startSearchManager();
+ super.onSearchRequested();
break;
case R.id.epg_menu_times:
intent = new Intent();
@@ -160,9 +168,11 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
return super.onOptionsItemSelected(item);
}
-
- /* (non-Javadoc)
- * @see android.app.Activity#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo)
+ /*
+ * (non-Javadoc)
+ *
+ * @see android.app.Activity#onCreateContextMenu(android.view.ContextMenu,
+ * android.view.View, android.view.ContextMenu.ContextMenuInfo)
*/
@Override
public void onCreateContextMenu(final ContextMenu menu, final View v,
@@ -201,7 +211,6 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
}
-
protected void toggleTimer(final EventListItem item) {
final ToggleTimerTask task = new ToggleTimerTask(this, item.getEpg()
.getTimer()) {
@@ -213,8 +222,11 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
task.start();
}
- /* (non-Javadoc)
- * @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see android.app.Activity#onActivityResult(int, int,
+ * android.content.Intent)
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
@@ -224,7 +236,7 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
}
}
}
-
+
/**
* @param parent
* @param view
@@ -247,10 +259,14 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
// show details
final Intent intent = new Intent();
intent.setClass(this, EpgDetailsActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
+ | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ if (highlight != null) {
+ intent.putExtra(Intents.HIGHLIGHT, highlight);
+ }
startActivity(intent);
}
-
@Override
protected void onPause() {
super.onPause();
@@ -262,7 +278,6 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
progress = null;
}
}
-
public void svdrpEvent(final SvdrpEvent event, final Epg result) {
@@ -285,7 +300,7 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
break;
}
}
-
+
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
@@ -293,6 +308,7 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
int top = savedInstanceState.getInt("TOP");
listView.setSelectionFromTop(index, top);
}
+
@Override
protected void onSaveInstanceState(Bundle outState) {
int index = listView.getFirstVisiblePosition();
@@ -302,7 +318,7 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
outState.putInt("TOP", top);
super.onSaveInstanceState(outState);
}
-
+
protected abstract void finishedSuccess();
public boolean onSearchRequested() {
@@ -311,6 +327,11 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
return true;
}
+ protected void startSearchManager() {
+ Bundle appData = new Bundle();
+ startSearch(highlight, false, appData, false);
+ }
+
@Override
public boolean dispatchTouchEvent(MotionEvent me) {
this.detector.onTouchEvent(me);
@@ -318,11 +339,12 @@ public abstract class BaseEpgListActivity extends BaseActivity implements Simple
}
public void onSwipe(int direction) {
-
+
}
+
public void onDoubleTap() {
// TODO Auto-generated method stub
-
+
}
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelAdapter.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelAdapter.java
index c712cdd..7c0ff05 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelAdapter.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelAdapter.java
@@ -7,6 +7,10 @@ import java.util.Map;
import android.content.Context;
import android.graphics.Color;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.TextUtils;
+import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -18,11 +22,11 @@ import android.widget.TextView;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.data.Channel;
import de.bjusystems.vdrmanager.data.Preferences;
+import de.bjusystems.vdrmanager.utils.svdrp.ChannelClient;
class ChannelAdapter extends BaseExpandableListAdapter implements Filterable// ,
- // SectionIndexer
+// SectionIndexer
{
-
@Override
public boolean areAllItemsEnabled() {
return true;
@@ -93,18 +97,20 @@ class ChannelAdapter extends BaseExpandableListAdapter implements Filterable// ,
view.setBackgroundColor(Color.BLACK);
- String name = item.getName();
+ CharSequence name = item.getName();
+ name = Utils.highlight(String.valueOf(name), channelFilter);
+
if (showChannelNumber) {
name = item.getNumber() + " - " + name;
}
itemHolder.name.setText(name);
-
- if(groupBy != ChannelListActivity.MENU_PROVIDER){
+
+ if (groupBy != ChannelListActivity.MENU_PROVIDER) {
itemHolder.aux.setText(item.getProvider());
} else {
itemHolder.aux.setText("");
}
-
+
return view;
}
@@ -132,6 +138,11 @@ class ChannelAdapter extends BaseExpandableListAdapter implements Filterable// ,
View convertView, ViewGroup parent) {
String group = (String) getGroup(groupPosition);
+
+ int channelCount = this.channels.get(group).size();
+
+ CharSequence groupDisplay = Utils.highlight(group, groupFilter);
+
ChannelHolder itemHolder = new ChannelHolder();
// recycle view?
@@ -149,8 +160,8 @@ class ChannelAdapter extends BaseExpandableListAdapter implements Filterable// ,
} else {
itemHolder = (ChannelHolder) view.getTag();
}
- itemHolder.name.setText(group);
- itemHolder.aux.setText(String.valueOf(this.channels.get(group).size()));
+ itemHolder.name.setText(groupDisplay);
+ itemHolder.aux.setText(String.valueOf(channelCount));
return view;
}
@@ -168,27 +179,64 @@ class ChannelAdapter extends BaseExpandableListAdapter implements Filterable// ,
return true;
}
- public Filter getFilter() {
- return new Filter() {
+ private String groupFilter = null;
- private ArrayList<Channel> ALL = channels.get(0);
+ private String channelFilter = null;
+ public Filter getFilter() {
+ return new Filter() {
@Override
protected FilterResults performFiltering(CharSequence arg0) {
- ArrayList<Channel> c = new ArrayList<Channel>(ALL);
- Iterator<Channel> ci = c.iterator();
- while (ci.hasNext()) {
- if (ci.next().getName().startsWith(arg0.toString()) == false) {
- ci.remove();
+ FilterResults fr = new FilterResults();
+ String q = String.valueOf(arg0).toLowerCase();
+ ArrayList<String> groups = new ArrayList<String>();
+ HashMap<String, ArrayList<Channel>> groupChannels = new HashMap<String, ArrayList<Channel>>();
+ if (groupBy == ChannelListActivity.MENU_GROUP) {
+ groupFilter = String.valueOf(arg0).toLowerCase();
+ for (String str : ChannelClient.getChannelGroups()) {
+ String g = str.toLowerCase();
+ if (g.indexOf(q) != -1) {
+ groups.add(str);
+ groupChannels.put(str, ChannelClient
+ .getGroupChannels().get(str));
+ }
+ }
+
+ } else if (groupBy == ChannelListActivity.MENU_PROVIDER) {
+ groupFilter = String.valueOf(arg0).toLowerCase();
+ for (Map.Entry<String, ArrayList<Channel>> p : ChannelClient
+ .getProviderChannels().entrySet()) {
+ String pr = p.getKey();
+ String g = pr.toLowerCase();
+ if (g.indexOf(q) != -1) {
+ groups.add(pr);
+ groupChannels.put(pr, p.getValue());
+ }
}
+
+ } else {
+ channelFilter = String.valueOf(arg0).toLowerCase();
+ ArrayList<Channel> channels = new ArrayList<Channel>();
+ for(Channel c : ChannelClient.getChannels()){
+ String cname = c.getName();
+ String tmp = cname.toLowerCase();
+ if(tmp.indexOf(channelFilter) != -1){
+ channels.add(c);
+ }
+ }
+ String fakeGroup = context.getString(R.string.groupby_name_all_channels_group);
+ groups.add (fakeGroup);
+ groupChannels.put(fakeGroup, channels);
}
- FilterResults fr = new FilterResults();
+ fr.values = Pair.create(groups, groupChannels);
return fr;
}
@Override
protected void publishResults(CharSequence arg0, FilterResults arg1) {
- notifyDataSetChanged();
+ Pair<ArrayList<String>, HashMap<String, ArrayList<Channel>>> res = (Pair<ArrayList<String>, HashMap<String, ArrayList<Channel>>>) arg1.values;
+ fill(res.first, res.second, groupBy);
+
}
};
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java
index a89034b..a2249b9 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java
@@ -4,7 +4,9 @@ import java.util.ArrayList;
import java.util.HashMap;
import android.app.Activity;
+import android.app.AlertDialog;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
@@ -17,6 +19,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
+import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
@@ -46,22 +49,14 @@ public class ChannelListActivity extends BaseActivity implements
ChannelAdapter adapter;
Preferences prefs;
SvdrpProgressDialog progress;
- private EditText searchBox;
- public static final int MENU_GROUP_GROUP = 1;
- public static final int MENU_GROUP_PROVIDER = 2;
- public static final int MENU_GROUP_NAME = 3;
- // public static final int MENU_GROUP_SHOW_CHANNEL_NUMBERS = 2;
-
- public static final int MENU_GROUP = 1;
- public static final int MENU_PROVIDER = 2;
- public static final int MENU_NAME = 3;
-
- private TextWatcher filterTextWatcher;
+ public static final int MENU_GROUP = 0;
+ public static final int MENU_PROVIDER = 1;
+ public static final int MENU_NAME = 2;
private int groupBy = MENU_GROUP;
- private final ArrayList<String> ALL_CHANNELS_GROUP = new ArrayList<String>(
+ final static ArrayList<String> ALL_CHANNELS_GROUP = new ArrayList<String>(
1);
ExpandableListView listView;
@@ -95,58 +90,17 @@ public class ChannelListActivity extends BaseActivity implements
setTitle(R.string.action_menu_channels);
adapter = new ChannelAdapter(this);
- searchBox = (EditText) findViewById(R.id.search_box);
-
- filterTextWatcher = new TextWatcher() {
-
- public void afterTextChanged(Editable s) {
- }
-
- public void beforeTextChanged(CharSequence s, int start, int count,
- int after) {
- }
-
- public void onTextChanged(CharSequence s, int start, int before,
- int count) {
- adapter.getFilter().filter(s);
- }
- };
- searchBox.addTextChangedListener(filterTextWatcher);
-
// Create adapter for ListView
listView = (ExpandableListView) findViewById(R.id.channel_list);
// listView.setOnItemClickListener(this);
listView.setOnChildClickListener(this);
- // listView.setOnGroupClickListener(this);
- //
- // public boolean onChildClick(ExpandableListView arg0, View arg1,
- // int arg2, int arg3, long arg4) {
- // Toast.makeText(getBaseContext(), "Child clicked",
- // Toast.LENGTH_LONG).show();
- // return false;
- // }
- // });
- //
- // listView.setOnGroupClickListener(new OnGroupClickListener() {
- //
- // public boolean onGroupClick(ExpandableListView arg0, View arg1,
- // int arg2, long arg3) {
- // Toast.makeText(getBaseContext(), "Group clicked",
- // Toast.LENGTH_LONG).show();
- // return false;
- // }
- // });
listView.setTextFilterEnabled(true);
listView.setFastScrollEnabled(true);
listView.setAdapter(adapter);
// register context menu
registerForContextMenu(listView);
startChannelQuery();
-
- // create channel list
-
- // listView.setOnItemClickListener(this);
}
//
@@ -167,6 +121,9 @@ public class ChannelListActivity extends BaseActivity implements
progress.dismiss();
progress = null;
}
+ if (groupByDialog != null) {
+ groupByDialog.dismiss();
+ }
}
private void startChannelQuery() {
@@ -196,7 +153,7 @@ public class ChannelListActivity extends BaseActivity implements
switch (groupBy) {
case MENU_GROUP:
adapter.fill(
- new ArrayList<String>(channelClient.getChannelGroups()),
+ channelClient.getChannelGroups(),
channelClient.getGroupChannels(), groupBy);
listView.collapseGroup(0);
updateWindowTitle(
@@ -204,7 +161,7 @@ public class ChannelListActivity extends BaseActivity implements
getString(R.string.groupby_window_title_templte,
getString(R.string.groupby_group)));
break;
- case MENU_GROUP_PROVIDER:
+ case MENU_PROVIDER:
adapter.fill(new ArrayList<String>(channelClient
.getProviderChannels().keySet()), channelClient
.getProviderChannels(), groupBy);
@@ -214,7 +171,7 @@ public class ChannelListActivity extends BaseActivity implements
getString(R.string.groupby_window_title_templte,
getString(R.string.groupby_provider)));
break;
- case MENU_GROUP_NAME:
+ case MENU_NAME:
if (ALL_CHANNELS_GROUP.isEmpty()) {
ALL_CHANNELS_GROUP
.add(getString(R.string.groupby_name_all_channels_group));
@@ -264,62 +221,69 @@ public class ChannelListActivity extends BaseActivity implements
}
public boolean onPrepareOptionsMenu(Menu menu) {
- switch (groupBy) {
- case MENU_GROUP:
- menu.setGroupVisible(MENU_GROUP_GROUP, false);
- menu.setGroupVisible(MENU_GROUP_PROVIDER, true);
- menu.setGroupVisible(MENU_GROUP_NAME, true);
- break;
-
- case MENU_PROVIDER:
- menu.setGroupVisible(MENU_GROUP_PROVIDER, false);
- menu.setGroupVisible(MENU_GROUP_GROUP, true);
- menu.setGroupVisible(MENU_GROUP_NAME, true);
- break;
-
- case MENU_NAME:
- menu.setGroupVisible(MENU_GROUP_NAME, false);
- menu.setGroupVisible(MENU_GROUP_GROUP, true);
- menu.setGroupVisible(MENU_GROUP_PROVIDER, true);
- break;
- default:
- return super.onPrepareOptionsMenu(menu);
- }
- return true;
-
+
+ return super.onPrepareOptionsMenu(menu);
}
+
@Override
public final boolean onCreateOptionsMenu(final Menu menu) {
super.onCreateOptionsMenu(menu);
MenuItem item;
- item = menu
- .add(MENU_GROUP_GROUP, MENU_GROUP, 0, R.string.groupby_group);
+ item = menu.add(MENU_GROUP, MENU_GROUP, 0, R.string.menu_groupby);
item.setIcon(android.R.drawable.ic_menu_sort_alphabetically);
item.setAlphabeticShortcut('g');
- item = menu.add(MENU_GROUP_PROVIDER, MENU_PROVIDER, 0,
- R.string.groupby_provider);
- item.setIcon(android.R.drawable.ic_menu_sort_alphabetically);
- item.setAlphabeticShortcut('p');
+ // item = menu.add(MENU_GROUP_PROVIDER, MENU_PROVIDER, 0,
+ // R.string.groupby_provider);
+ // item.setIcon(android.R.drawable.ic_menu_sort_alphabetically);
+ // item.setAlphabeticShortcut('p');
- item = menu.add(MENU_GROUP_NAME, MENU_NAME, 0, R.string.groupby_name);
- item.setIcon(android.R.drawable.ic_menu_sort_alphabetically);
- item.setAlphabeticShortcut('n');
+ // item = menu.add(MENU_GROUP_NAME, MENU_NAME, 0,
+ // R.string.groupby_name);
+ // item.setIcon(android.R.drawable.ic_menu_sort_alphabetically);
+ // item.setAlphabeticShortcut('n');
return true;
}
+ private static final String[] EMPTY = new String[] {};
+
+ private String[] getAvailableGroupByEntries() {
+ ArrayList<String> entries = new ArrayList<String>(2);
+ entries.add(getString(R.string.groupby_group));
+ entries.add(getString(R.string.groupby_provider));
+ entries.add(getString(R.string.groupby_name));
+ return entries.toArray(EMPTY);
+ }
+
+ AlertDialog groupByDialog = null;
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_GROUP:
- case MENU_PROVIDER:
- case MENU_NAME:
- groupBy = item.getItemId();
- fillAdapter();
+ // case MENU_PROVIDER:
+ // case MENU_NAME:
+ if (groupByDialog == null) {
+ groupByDialog = new AlertDialog.Builder(this)
+ .setTitle(R.string.menu_groupby)
+ .setIcon(android.R.drawable.ic_menu_sort_alphabetically)
+ .setSingleChoiceItems(getAvailableGroupByEntries(),
+ groupBy, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int which) {
+ groupBy = which;
+ fillAdapter();
+ groupByDialog.dismiss();
+ }
+ }).create();
+ }
+
+ groupByDialog.show();
+
return true;
default:
return super.onOptionsItemSelected(item);
@@ -418,11 +382,6 @@ public class ChannelListActivity extends BaseActivity implements
@Override
public boolean onSearchRequested() {
- if (groupBy != MENU_NAME) {
- return true;
- }
- searchBox.setVisibility(View.VISIBLE);
- searchBox.requestFocus();
InputMethodManager inputMgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMgr.toggleSoftInput(0, 0);
return true;
@@ -430,11 +389,7 @@ public class ChannelListActivity extends BaseActivity implements
@Override
public void onBackPressed() {
- if (searchBox.getVisibility() == View.VISIBLE) {
- searchBox.setVisibility(View.GONE);
- } else {
- super.onBackPressed();
- }
+ super.onBackPressed();
}
public boolean onGroupClick(ExpandableListView arg0, View arg1, int arg2,
@@ -445,8 +400,8 @@ public class ChannelListActivity extends BaseActivity implements
private void startChannelEPG(Channel channel) {
// find and remember item
// final Channel channel = adapter.getItem(position);
- //final VdrManagerApp app = (VdrManagerApp) getApplication();
- //app.setCurrentChannel(channel);
+ // final VdrManagerApp app = (VdrManagerApp) getApplication();
+ // app.setCurrentChannel(channel);
// show details
final Intent intent = new Intent();
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
index 6e61099..8c52801 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
@@ -1,11 +1,11 @@
package de.bjusystems.vdrmanager.gui;
import java.util.ArrayList;
-import java.util.LinkedList;
import java.util.List;
import android.app.Activity;
import android.content.Intent;
+import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.MotionEvent;
@@ -16,6 +16,7 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import de.bjusystems.vdrmanager.R;
+import de.bjusystems.vdrmanager.app.Intents;
import de.bjusystems.vdrmanager.app.VdrManagerApp;
import de.bjusystems.vdrmanager.data.Channel;
import de.bjusystems.vdrmanager.data.Epg;
@@ -33,10 +34,12 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
public class EpgDetailsActivity extends Activity implements OnClickListener,
SimpleGestureListener {
- Preferences prefs;
-
+ public static String IMDB_URL = "http://www.%s/find?s=all&q=%s";
+
private SimpleGestureFilter detector;
+ private String highlight = null;
+
ImageButton event_left;
ImageButton event_right;
@@ -45,8 +48,13 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ Intent i = getIntent();
+ highlight = i.getStringExtra(Intents.HIGHLIGHT);
+
// Attach view
setContentView(R.layout.epg_detail);
+
+
detector = new SimpleGestureFilter(this, this);
//event_left = (ImageButton) findViewById(R.id.epg_event_left);
@@ -89,53 +97,8 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
}.execute((Void)null);
publishEPG(epg);
- // final EventFormatter formatter = new EventFormatter(event);
- //
- // final TextView title = (TextView)
- // findViewById(R.id.epg_detail_title);
- // title.setText(formatter.getTitle());
- // title.setTextSize(TypedValue.COMPLEX_UNIT_PX, title.getTextSize()
- // * (float) 1.3);
- //
- // ((TextView) findViewById(R.id.epg_detail_time)).setText(formatter
- // .getTime());
- // ((TextView) findViewById(R.id.epg_detail_channel)).setText(event
- // .getChannelName());
- // ((TextView) findViewById(R.id.epg_detail_date)).setText(formatter
- // .getLongDate());
- // final TextView textView = (TextView)
- // findViewById(R.id.epg_detail_description);
- // textView.setText(formatter.getDescription());
- //
- // // copy color for separator lines
- // final int color = textView.getTextColors().getDefaultColor();
- // // ((TextView) findViewById(R.id.epg_detail_separator_1))
- // // .setBackgroundColor(color);
- //
- // ((ProgressBar) findViewById(R.id.epg_detail_progress))
- // .setProgress(Utils.getProgress(event));
- //
- // ((TextView) findViewById(R.id.epg_detail_separator_2))
- // .setBackgroundColor(color);
- //
- // // register button handler
- // final ImageButton timeButton = (ImageButton)
- // findViewById(R.id.epg_event_create_timer);
- // timeButton.setOnClickListener(this);
- //
- // final ImageButton livetvButton = (ImageButton)
- // findViewById(R.id.epg_event_livetv);
- // livetvButton.setOnClickListener(this);
- //
- //
- // // set button text
- // if (event.getTimer() == null) {
- // // timeButton.setText(R.string.epg_event_create_timer_text);
- // } else {
- // // timeButton.setText(R.string.epg_event_modify_timer_text);
- // }
-
- // clear list of activities to finish
+
+ //TODO was ist das?
app.clearActivitiesToFinish();
}
@@ -148,7 +111,8 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
final EventFormatter formatter = new EventFormatter(event);
final TextView title = (TextView) findViewById(R.id.epg_detail_title);
- title.setText(formatter.getTitle());
+ String titleText = formatter.getTitle();
+ title.setText(Utils.highlight(titleText, highlight));
// title.setTextSize(TypedValue.COMPLEX_UNIT_PX, title.getTextSize()
// * (float) 1.3);
@@ -163,11 +127,11 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
// .getLongDate());
final TextView shortText = (TextView) findViewById(R.id.epg_detail_shorttext);
- shortText.setText(formatter.getShortText());
+ shortText.setText(Utils.highlight(formatter.getShortText(), highlight));
final TextView textView = (TextView) findViewById(R.id.epg_detail_description);
- textView.setText(formatter.getDescription());
+ textView.setText(Utils.highlight(formatter.getDescription(), highlight));
// copy color for separator lines
final int color = textView.getTextColors().getDefaultColor();
@@ -191,7 +155,18 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
// register button handler
setThisAsOnClickListener(R.id.epg_event_create_timer);
- View b = findViewById(R.id.epg_event_livetv);
+
+
+ View b = findViewById(R.id.epg_event_imdb);
+
+ if(Preferences.get().isShowImdbButton() == false){
+ b.setVisibility(View.GONE);
+ } else {
+ b.setVisibility(View.VISIBLE);
+ setThisAsOnClickListener(b);
+ }
+
+ b = findViewById(R.id.epg_event_livetv);
if (Utils.isLive(event) == false) {
b.setVisibility(View.GONE);
} else {
@@ -223,6 +198,9 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
@Override
protected void onResume() {
super.onResume();
+ //TODO Check here whether the config has changed for imdb
+ //TODO check here if we are still live ?
+
}
@Override
@@ -241,13 +219,13 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
case R.id.epg_event_create_timer:
Toast.makeText(this, "Soon we get here the timer menu", Toast.LENGTH_SHORT).show();
break;
-
-// case R.id.epg_event_left:
-// prevEPG();
-// break;
-// case R.id.epg_event_right:
-// nextEPG();
-// break;
+ case R.id.epg_event_imdb:
+ final TextView title = (TextView) findViewById(R.id.epg_detail_title);
+ String url = String.format(IMDB_URL,Preferences.get().getImdbUrl(), String.valueOf(title.getText()));
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse(url));
+ startActivity(i);
+ break;
}
}
@@ -274,13 +252,11 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
}
- ArrayList<Epg> epgs = null;
+ List<Epg> epgs = null;
int counter = 0;
public void initEPGs() {
- // epgs = ((VdrManagerApp)getApplication()).getCurrentEpgList();
-
if (epgs != null) {
return;
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchActivity.java
deleted file mode 100644
index e6fbfdd..0000000
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchActivity.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package de.bjusystems.vdrmanager.gui;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-import android.widget.TextView;
-import de.bjusystems.vdrmanager.R;
-import de.bjusystems.vdrmanager.app.VdrManagerApp;
-import de.bjusystems.vdrmanager.data.EpgSearchParams;
-import de.bjusystems.vdrmanager.data.Preferences;
-
-/**
- * This class is used for showing what's current running on all channels
- *
- * @author bju
- */
-public class EpgSearchActivity extends Activity implements OnClickListener {
-
- Preferences prefs;
- TextView text;
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Attach view
- setContentView(R.layout.epg_search);
-
- // save fields
- text = (TextView) findViewById(R.id.epg_search_text);
-
- // register button
- final Button button = (Button) findViewById(R.id.epg_search_button);
- button.setOnClickListener(this);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- }
-
- public void onClick(final View v) {
-
- // Save search parameters
- final EpgSearchParams search = new EpgSearchParams();
- search.setTitle(text.getText().toString());
- ((VdrManagerApp) getApplication()).setCurrentSearch(search);
-
- // show timer details
- final Intent intent = new Intent();
- //intent.setClass(this, EpgListActivity.class);
- startActivity(intent);
- }
-}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java
new file mode 100644
index 0000000..4dba61d
--- /dev/null
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java
@@ -0,0 +1,168 @@
+package de.bjusystems.vdrmanager.gui;
+
+import java.util.Calendar;
+import java.util.List;
+
+import android.app.SearchManager;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ListView;
+import de.bjusystems.vdrmanager.R;
+import de.bjusystems.vdrmanager.app.VdrManagerApp;
+import de.bjusystems.vdrmanager.data.Epg;
+import de.bjusystems.vdrmanager.data.EpgSearchParams;
+import de.bjusystems.vdrmanager.data.EventListItem;
+import de.bjusystems.vdrmanager.utils.date.DateFormatter;
+import de.bjusystems.vdrmanager.utils.svdrp.EpgClient;
+import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener;
+import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncTask;
+import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient;
+import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
+
+/**
+ * This class is used for showing what's current running on all channels
+ *
+ * @author bju
+ */
+public class EpgSearchListActivity extends BaseEpgListActivity implements
+ OnItemClickListener, SvdrpAsyncListener<Epg> {
+
+ public List<Epg> results;
+
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Intent intent = getIntent();
+ if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
+ String query = intent.getStringExtra(SearchManager.QUERY);
+ if (TextUtils.isEmpty(query) == false) {
+ highlight = query.trim();
+ }
+ }
+ adapter = new ChannelEventAdapter(this);
+ adapter.setHideDescription(false);
+
+ // Create adapter for EPG list
+ listView = (ListView) findViewById(R.id.whatson_list);
+ listView.setAdapter(adapter);
+ listView.setFastScrollEnabled(true);
+ listView.setTextFilterEnabled(true);
+ registerForContextMenu(listView);
+
+ // register EPG item click
+ listView.setOnItemClickListener(this);
+
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ // adapter.notifyDataSetChanged();
+ startEpgQuery();
+ }
+
+
+
+ public void onNothingSelected(final AdapterView<?> arg0) {
+ // startTimeEpgQuery(((EpgTimeSpinnerValue)timeSpinner.getAdapter().getItem(0)).getValue());
+ }
+
+ //
+
+ private void startEpgQuery() {
+
+ EpgSearchParams sp = new EpgSearchParams();
+ sp.setTitle(highlight);
+ setTitle(getString(R.string.epg_by_search_param, highlight));
+ epgClient = new EpgClient(sp);
+
+ // remove old listeners
+ // epgClient.clearSvdrpListener();
+
+ // create background task
+ final SvdrpAsyncTask<Epg, SvdrpClient<Epg>> task = new SvdrpAsyncTask<Epg, SvdrpClient<Epg>>(
+ epgClient);
+
+ // create progress
+ progress = new SvdrpProgressDialog(this, epgClient);
+ // attach listener
+ task.addListener(this);
+
+ // start task
+ task.run();
+ }
+
+ /*
+ * (non-Javadoc) TODO this method also should be used in startEpgQuery on
+ * cache hit
+ *
+ * @see de.bjusystems.vdrmanager.gui.BaseEpgListActivity#finishedSuccess()
+ */
+ @Override
+ protected void finishedSuccess() {
+ adapter.clear();
+ adapter.highlight = this.highlight;
+
+ Calendar cal = Calendar.getInstance();
+ int day = -1;
+ results = epgClient.getResults();
+ for (Epg e : results) {
+ cal.setTime(e.getStart());
+ int eday = cal.get(Calendar.DAY_OF_YEAR);
+ if (eday != day) {
+ day = eday;
+ adapter.add(new EventListItem(new DateFormatter(cal)
+ .getDailyHeader()));
+ }
+ adapter.add(new EventListItem(e));
+ }
+ listView.setSelectionAfterHeaderView();
+ if (progress != null) {
+ progress.dismiss();
+ progress = null;
+ }
+ }
+
+ public void svdrpException(final SvdrpException exception) {
+ if (progress != null) {
+ progress.svdrpException(exception);
+ }
+ }
+
+ protected void prepareTimer(final EventListItem item) {
+ final VdrManagerApp app = (VdrManagerApp) getApplication();
+ app.setCurrentEvent(item.getEpg());
+ app.setCurrentEpgList(results);
+ }
+
+ @Override
+ protected int getMainLayout() {
+ return R.layout.search_epg_list;
+ }
+
+ @Override
+ protected void refresh() {
+ startEpgQuery();
+ }
+
+ @Override
+ protected void retry() {
+ startEpgQuery();
+ }
+
+ @Override
+ protected int getWindowTitle() {
+ return R.string.epg_by_search;
+ }
+
+ @Override
+ public boolean onSearchRequested() {
+ startSearchManager();
+ return true;
+ }
+
+}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java
index 78e5dc6..98adbb9 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java
@@ -9,6 +9,7 @@ import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
+import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -26,15 +27,16 @@ import de.bjusystems.vdrmanager.data.EventListItem;
abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
Filterable {
- private static final ForegroundColorSpan HIGHLIGHT = new ForegroundColorSpan(
- Color.RED);
-
protected final int layout;
protected final LayoutInflater inflater;
protected final List<EventListItem> items = new ArrayList<EventListItem>();
+ protected boolean hideDescription = true;
+
protected boolean hideChannelName = false;
+ String highlight;
+
public EventAdapter(final Context context, int layout) {
super(context, layout);
this.layout = layout;
@@ -47,8 +49,6 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
super.add(object);
}
- private String highlight;
-
@Override
public View getView(final int position, final View convertView,
final ViewGroup parent) {
@@ -76,6 +76,8 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
.findViewById(R.id.timer_item_shorttext);
itemHolder.duration = (TextView) view
.findViewById(R.id.timer_item_duration);
+ itemHolder.description = (TextView) view
+ .findViewById(R.id.event_item_description);
view.setTag(itemHolder);
} else {
itemHolder = (EventListItemHolder) view.getTag();
@@ -96,7 +98,7 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
itemHolder.progress.setVisibility(View.GONE);
itemHolder.shortText.setVisibility(View.GONE);
itemHolder.duration.setVisibility(View.GONE);
-
+ itemHolder.description.setVisibility(View.GONE);
} else {
view.setBackgroundColor(Color.BLACK);
@@ -130,12 +132,22 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
itemHolder.channel.setText(item.getChannelName());
}
-
- CharSequence title = highlight(formatter.getTitle(), highlight);
- CharSequence shortText = highlight(formatter.getShortText(), highlight);
-
+ CharSequence title = Utils.highlight(formatter.getTitle(),
+ highlight);
+ CharSequence shortText = Utils.highlight(formatter.getShortText(),
+ highlight);
itemHolder.title.setText(title);
itemHolder.shortText.setText(shortText);
+
+ if (hideDescription == false) {
+ Pair<Boolean, CharSequence> desc = Utils.highlight2(
+ formatter.getDescription(), highlight);
+ if (desc.first == true) {
+ itemHolder.description.setVisibility(View.VISIBLE);
+ itemHolder.description.setText(desc.second);
+ }
+ }
+
int p = Utils.getProgress(item);
if (p == -1) {
itemHolder.progress.setVisibility(View.GONE);
@@ -160,22 +172,6 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
return view;
}
- private CharSequence highlight(String where, String what){
- if(TextUtils.isEmpty(what)){
- return where;
- }
-
- String str = where.toLowerCase();
- int idx = str.indexOf(highlight);
- if(idx == -1){
- return where;
- }
- SpannableString ss = new SpannableString(str);
- ss.setSpan(HIGHLIGHT, idx, idx + highlight.length(),
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- return ss;
- }
-
protected EventFormatter getEventFormatter(Event event) {
return new EventFormatter(event);
}
@@ -184,7 +180,23 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
super.add(item);
}
- //TODO implement locking in performFiltering, check the parent class
+ public boolean isHideDescription() {
+ return hideDescription;
+ }
+
+ public void setHideDescription(boolean hideDescription) {
+ this.hideDescription = hideDescription;
+ }
+
+ public boolean isHideChannelName() {
+ return hideChannelName;
+ }
+
+ public void setHideChannelName(boolean hideChannelName) {
+ this.hideChannelName = hideChannelName;
+ }
+
+ // TODO implement locking in performFiltering, check the parent class
//
public Filter getFilter() {
return new Filter() {
@@ -199,8 +211,8 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
ArrayList<EventListItem> result = new ArrayList<EventListItem>();
for (EventListItem event : items) {
if (event.isHeader()) {
- prevHead = event;
- //result.add(event);
+ prevHead = event;
+ // result.add(event);
continue;
}
if (event.getTitle().toLowerCase()
@@ -208,7 +220,7 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
|| event.getShortText()
.toLowerCase()
.indexOf(String.valueOf(arg0).toLowerCase()) != -1) {
- if(prevHead != null){
+ if (prevHead != null) {
result.add(prevHead);
prevHead = null;
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
index 4e0987d..476bdd9 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
@@ -5,7 +5,10 @@ import java.util.Calendar;
import java.util.Date;
import java.util.List;
+import android.app.SearchManager;
+import android.content.Intent;
import android.os.Bundle;
+import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@@ -44,7 +47,7 @@ public class EventEpgListActivity extends BaseEpgListActivity implements
Spinner channelSpinner;
ArrayAdapter<Channel> channelSpinnerAdapter;
-
+
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -53,8 +56,8 @@ public class EventEpgListActivity extends BaseEpgListActivity implements
final List<Channel> channels = ChannelClient.getChannels();
// create adapter for channel spinner
- channelSpinnerAdapter = new ArrayAdapter<Channel>(
- this, android.R.layout.simple_spinner_item);
+ channelSpinnerAdapter = new ArrayAdapter<Channel>(this,
+ android.R.layout.simple_spinner_item);
channelSpinnerAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
channelSpinner = (Spinner) findViewById(R.id.epg_list_channel_spinner);
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventListItemHolder.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventListItemHolder.java
index f7086b0..7b9c93b 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventListItemHolder.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventListItemHolder.java
@@ -14,4 +14,5 @@ class EventListItemHolder {
public TextView shortText;
public ProgressBar progress;
public TextView duration;
+ public TextView description;
} \ No newline at end of file
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java
index f7d359c..ff51637 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java
@@ -4,11 +4,15 @@ import java.util.Date;
import android.app.Activity;
import android.app.AlertDialog;
-import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
+import android.graphics.Color;
import android.net.Uri;
-
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.TextUtils;
+import android.text.style.ForegroundColorSpan;
+import android.util.Pair;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.data.Channel;
import de.bjusystems.vdrmanager.data.Event;
@@ -16,6 +20,46 @@ import de.bjusystems.vdrmanager.data.Preferences;
public class Utils {
+ public static final ForegroundColorSpan HIGHLIGHT_TEXT = new ForegroundColorSpan(
+ Color.RED);
+
+
+
+ public static CharSequence highlight(String where, String what){
+ if(TextUtils.isEmpty(what)){
+ return where;
+ }
+
+ String str = where.toLowerCase();
+ what = what.toLowerCase();
+ int idx = str.indexOf(what);
+ if(idx == -1){
+ return where;
+ }
+ SpannableString ss = new SpannableString(where);
+ ss.setSpan(HIGHLIGHT_TEXT, idx, idx + what.length(),
+ Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ return ss;
+ }
+
+ public static Pair<Boolean,CharSequence> highlight2(String where, String what){
+ if(TextUtils.isEmpty(what)){
+ return Pair.create(Boolean.FALSE, (CharSequence)where);
+ }
+
+ String str = where.toLowerCase();
+ what = what.toLowerCase();
+ int idx = str.indexOf(what);
+ if(idx == -1){
+ return Pair.create(Boolean.FALSE, (CharSequence)where);
+ }
+ SpannableString ss = new SpannableString(where);
+ ss.setSpan(HIGHLIGHT_TEXT, idx, idx + what.length(),
+ Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ return Pair.create(Boolean.TRUE, (CharSequence)ss);
+ }
+
+
public static int getProgress(Date start, Date stop) {
long now = System.currentTimeMillis();
return getProgress(now, start.getTime(), stop.getTime());
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java
index 8aa4107..70a56dc 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java
@@ -101,7 +101,7 @@ public class VdrManagerActivity extends Activity implements OnClickListener {
startActivity(TimeEpgListActivity.class);
break;
case R.id.action_menu_search:
- startActivity(EpgSearchActivity.class);
+ onSearchRequested();
break;
case R.id.action_menu_wakeup:
final AsyncWakeupTask wakeupTask = new AsyncWakeupTask(this);
@@ -117,6 +117,5 @@ public class VdrManagerActivity extends Activity implements OnClickListener {
//appData.putBoolean(SearchableActivity.JARGON, true);
startSearch(null, false, appData, false);
return true;
-
}
}