diff options
Diffstat (limited to 'vdrmanager/src/de/bjusystems')
17 files changed, 866 insertions, 621 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java index 7a63af5..d4cb2d9 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java @@ -47,7 +47,6 @@ public class Preferences { } - public static boolean get(Context context, String key, boolean defValue) { final SharedPreferences sharedPrefs = getSharedPreferences(context); return sharedPrefs.getBoolean(key, defValue); @@ -101,7 +100,7 @@ public class Preferences { private boolean showTmdbButton = false; private int maxRecentChannels = 10; - + private boolean clearTermAfterSearch = false; public int getMaxRecentChannels() { @@ -391,6 +390,14 @@ public class Preferences { return getCurrentVdr().getStreamFormat(); } + public int getSmarttvewebPort() { + return getCurrentVdr().getSmarttvwebPort(); + } + + public String getSmarttvewebType() { + return getCurrentVdr().getSmarttvwebType(); + } + /** * Sets the time values for the epg search * @@ -520,8 +527,9 @@ public class Preferences { prefs.maxRecentChannels = getInt(context, R.string.gui_max_recent_channels_key, 10); - - prefs.clearTermAfterSearch = getBoolean(context, R.string.clear_term_after_search_key, false); + + prefs.clearTermAfterSearch = getBoolean(context, + R.string.clear_term_after_search_key, false); thePrefs = prefs; } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java index f61bc26..74ed48f 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java @@ -180,6 +180,12 @@ public class Vdr { @DatabaseField private String recStreamMethod = "vdr-live"; + + @DatabaseField(columnName="smarttvwebPort") + private int smarttvwebPort = 8000; + + @DatabaseField(columnName="smarttvwebType") + private String smarttvwebType="ts"; @DatabaseField private boolean enableRecStreaming = false; @@ -584,6 +590,10 @@ public class Vdr { map.put("key_live_port", livePort); map.put("key_recstream_method", recStreamMethod); map.put("key_timezone", serverTimeZone); + + + map.put("key_smarttvweb_port", smarttvwebPort); + map.put("key_smarttvweb_recstream_method", smarttvwebType); return map; } @@ -672,6 +682,25 @@ public class Vdr { livePort = getInteger(map, "key_live_port", 8008); recStreamMethod = get(map, "key_recstream_method", "vdr-live"); serverTimeZone = get(map, "key_timezone", TimeZone.getDefault().getID()); + + smarttvwebPort= getInteger(map, "key_smarttvweb_port", 8000); + smarttvwebType= get(map, "key_smarttvweb_recstream_method", "progressive"); + } + + public int getSmarttvwebPort() { + return smarttvwebPort; + } + + public void setSmarttvwebPort(int smarttvwebPort) { + this.smarttvwebPort = smarttvwebPort; + } + + public String getSmarttvwebType() { + return smarttvwebType; + } + + public void setSmarttvwebType(String smarttvwebType) { + this.smarttvwebType = smarttvwebType; } } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/db/DBAccess.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/db/DBAccess.java index f9ae121..75bd892 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/db/DBAccess.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/db/DBAccess.java @@ -32,7 +32,7 @@ public class DBAccess extends OrmLiteSqliteOpenHelper { // any time you make changes to your database objects, you may have to // increase the database version // Version 3 since 0.6 - private static final int DATABASE_VERSION = 3; + private static final int DATABASE_VERSION = 4; private RuntimeExceptionDao<Vdr, Integer> vdrDAO = null; @@ -91,6 +91,23 @@ public class DBAccess extends OrmLiteSqliteOpenHelper { "UPDATE `vdr` set stz = ?", tz); } + if(oldVersion < 4){ + getVdrDAO() + .executeRaw( + "ALTER TABLE `vdr` ADD COLUMN smarttvwebType varchar;"); + getVdrDAO() + .executeRaw( + "ALTER TABLE `vdr` ADD COLUMN smarttvwebPort int;"); + + getVdrDAO() + .executeRaw( + "UPDATE `vdr` set smarttvwebPort = ?", "8000"); + getVdrDAO() + .executeRaw( + "UPDATE `vdr` set smarttvwebType = ?", "progressive"); + + + } } catch (SQLException e) { Log.e(DBAccess.class.getName(), "Can't drop databases", e); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java index cb2672f..b2ba4d8 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java @@ -7,15 +7,21 @@ import android.app.ProgressDialog; import android.content.Intent; import android.content.res.Configuration; import android.os.Bundle; +import android.support.v4.app.ActionBarDrawerToggle; +import android.support.v4.view.GravityCompat; +import android.support.v4.view.MenuCompat; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarActivity; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; +import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.ViewFlipper; - -import com.actionbarsherlock.app.ActionBar.OnNavigationListener; - import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.app.VdrManagerApp; import de.bjusystems.vdrmanager.data.Channel; @@ -29,7 +35,7 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpFinishedListener; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpListener; public abstract class BaseActivity<Result, T extends ListView> extends - ICSBaseActivity implements OnClickListener, SvdrpListener, + ActionBarActivity implements OnClickListener, SvdrpListener, SvdrpExceptionListener, SvdrpFinishedListener<Result> { public static final String TAG = BaseActivity.class.getName(); @@ -48,6 +54,12 @@ public abstract class BaseActivity<Result, T extends ListView> extends // protected SvdrpProgressDialog progress; + private CharSequence mDrawerTitle; + private DrawerLayout mDrawerLayout; + private ListView mDrawerList; + private ActionBarDrawerToggle mDrawerToggle; + private String[] mTitles; + abstract protected String getWindowTitle(); abstract protected int getMainLayout(); @@ -58,6 +70,18 @@ public abstract class BaseActivity<Result, T extends ListView> extends abstract protected boolean displayingResults(); + /** + * When using the ActionBarDrawerToggle, you must call it during + * onPostCreate() and onConfigurationChanged()... + */ + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + // Sync the toggle state after onRestoreInstanceState has occurred. + mDrawerToggle.syncState(); + } + protected boolean isForceRefresh() { if (forceRefresh == false) { return false; @@ -81,10 +105,15 @@ public abstract class BaseActivity<Result, T extends ListView> extends } } + protected CertificateProblemDialog getCertificateProblemDialog() { + return new CertificateProblemDialog(this); + } + @Override public void onConfigurationChanged(final Configuration newConfig) { Preferences.setLocale(this); super.onConfigurationChanged(newConfig); + mDrawerToggle.onConfigurationChanged(newConfig); } @Override @@ -143,60 +172,60 @@ public abstract class BaseActivity<Result, T extends ListView> extends return; } - getSupportActionBar().setDisplayShowTitleEnabled(false); - - getSupportActionBar().setNavigationMode( - getSupportActionBar().NAVIGATION_MODE_LIST); - - final ArrayAdapter<CharSequence> mSpinnerAdapter = ArrayAdapter - .createFromResource(this, R.array.navigation_array, - android.R.layout.simple_spinner_dropdown_item); - - getSupportActionBar().setListNavigationCallbacks(mSpinnerAdapter, - new OnNavigationListener() { - - private boolean firstHit = true; - - @Override - public boolean onNavigationItemSelected( - final int itemPosition, final long itemId) { - - if (firstHit == true) { - firstHit = false; - return false; - } - switch (itemPosition) { - - case LIST_NAVIGATION_CHANNELS: { - startActivity(ChannelListActivity.class); - return true; - } - case LIST_NAVIGATION_EPG_BY_TIME: { - startActivity(TimeEpgListActivity.class); - return true; - } - - case LIST_NAVIGATION_EPG_BY_CHANNEL: { - startActivity(EventEpgListActivity.class); - return true; - } - - case LIST_NAVIGATION_RECORDINGS: { - startActivity(RecordingListActivity.class); - return true; - } - - case LIST_NAVIGATION_TIMERS: { - startActivity(TimerListActivity.class); - return true; - } - - } - return false; - } - }); - getSupportActionBar().setSelectedNavigationItem( - getListNavigationIndex()); + // getSupportActionBar().setDisplayShowTitleEnabled(false); + // + // getSupportActionBar().setNavigationMode( + // getSupportActionBar().NAVIGATION_MODE_LIST); + // + // final ArrayAdapter<CharSequence> mSpinnerAdapter = ArrayAdapter + // .createFromResource(this, R.array.navigation_array, + // android.R.layout.simple_spinner_dropdown_item); + // + // getSupportActionBar().setListNavigationCallbacks(mSpinnerAdapter, + // new OnNavigationListener() { + // + // private boolean firstHit = true; + // + // @Override + // public boolean onNavigationItemSelected( + // final int itemPosition, final long itemId) { + // + // if (firstHit == true) { + // firstHit = false; + // return false; + // } + // switch (itemPosition) { + // + // case LIST_NAVIGATION_CHANNELS: { + // startActivity(ChannelListActivity.class); + // return true; + // } + // case LIST_NAVIGATION_EPG_BY_TIME: { + // startActivity(TimeEpgListActivity.class); + // return true; + // } + // + // case LIST_NAVIGATION_EPG_BY_CHANNEL: { + // startActivity(EventEpgListActivity.class); + // return true; + // } + // + // case LIST_NAVIGATION_RECORDINGS: { + // startActivity(RecordingListActivity.class); + // return true; + // } + // + // case LIST_NAVIGATION_TIMERS: { + // startActivity(TimerListActivity.class); + // return true; + // } + // + // } + // return false; + // } + // }); + // getSupportActionBar().setSelectedNavigationItem( + // getListNavigationIndex()); } @@ -204,6 +233,7 @@ public abstract class BaseActivity<Result, T extends ListView> extends protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); Preferences.setLocale(this); + setContentView(getMainLayout()); progress = new ProgressDialog(this); progress.setCancelable(false); progress.setCanceledOnTouchOutside(false); @@ -218,6 +248,8 @@ public abstract class BaseActivity<Result, T extends ListView> extends initListNavigation(); + initLeftDrawer(savedInstanceState); + // new OnNavigationListener() { // @Override // public boolean onNavigationItemSelected(int itemPosition, long @@ -239,6 +271,105 @@ public abstract class BaseActivity<Result, T extends ListView> extends } + protected void initLeftDrawer(final Bundle savedInstanceState) { + + mDrawerTitle = getTitle(); + + mTitles = getResources().getStringArray(R.array.navigation_array); + + mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); + mDrawerList = (ListView) findViewById(R.id.left_drawer); + + // set a custom shadow that overlays the main content when the drawer + // opens + mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, + GravityCompat.START); + // set up the drawer's list view with items and click listener + mDrawerList.setAdapter(new ArrayAdapter<String>(this, + R.layout.drawer_list_item, mTitles)); + mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); + + // enable ActionBar app icon to behave as action to toggle nav drawer + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + // ActionBarDrawerToggle ties together the the proper interactions + // between the sliding drawer and the action bar app icon + mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ + mDrawerLayout, /* DrawerLayout object */ + R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ + R.string.drawer_open, /* "open drawer" description for accessibility */ + R.string.drawer_close /* "close drawer" description for accessibility */ + ) { + public void onDrawerClosed(View view) { + // getSupportActionBar().setTitle(mTitle); + //invalidateOptionsMenu(); // creates call to + // onPrepareOptionsMenu() + } + + public void onDrawerOpened(View drawerView) { + // getSupportActionBar().setTitle(mDrawerTitle); + //invalidateOptionsMenu(); // creates call to + // onPrepareOptionsMenu() + } + }; + mDrawerLayout.setDrawerListener(mDrawerToggle); + +// if (savedInstanceState == null) { +// selectItem(0); +// } + + } + + /* The click listner for ListView in the navigation drawer */ + private class DrawerItemClickListener implements + ListView.OnItemClickListener { + @Override + public void onItemClick(AdapterView<?> parent, View view, int position, + long id) { + selectItem(position); + } + } + + private void selectItem(int position) { + + // update selected item and title, then close the drawer + mDrawerList.setItemChecked(position, true); + // setTitle(mPlanetTitles[position]); + + switch (position) { + + case LIST_NAVIGATION_CHANNELS: { + startActivity(ChannelListActivity.class); + break; + } + case LIST_NAVIGATION_EPG_BY_TIME: { + startActivity(TimeEpgListActivity.class); + break; + } + + case LIST_NAVIGATION_EPG_BY_CHANNEL: { + startActivity(EventEpgListActivity.class); + break; + } + + case LIST_NAVIGATION_RECORDINGS: { + startActivity(RecordingListActivity.class); + break; + } + + case LIST_NAVIGATION_TIMERS: { + startActivity(TimerListActivity.class); + break; + } + } + + mDrawerLayout.closeDrawer(mDrawerList); + } + + protected void initActionBar() { + getSupportActionBar().setHomeButtonEnabled(true); + } + public void startActivity(final Class<?> clazz) { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass(this, clazz); @@ -251,15 +382,14 @@ public abstract class BaseActivity<Result, T extends ListView> extends } @Override - public boolean onCreateOptionsMenu( - final com.actionbarsherlock.view.Menu menu) { + public boolean onCreateOptionsMenu(final Menu menu) { // MenuItem item; // item = menu.add(MENU_GROUP_REFRESH, MENU_REFRESH, 0, // R.string.refresh); // item.setIcon(R.drawable.ic_menu_refresh); // item.setAlphabeticShortcut('r'); - final com.actionbarsherlock.view.MenuInflater inf = getSupportMenuInflater(); + final MenuInflater inf = getMenuInflater(); inf.inflate(getBaseMenu(), menu); // SearchView searchView = (SearchView) @@ -276,8 +406,12 @@ public abstract class BaseActivity<Result, T extends ListView> extends // abstract protected SvdrpClient<Result> getClient(); @Override - public boolean onOptionsItemSelected( - final com.actionbarsherlock.view.MenuItem item) { + public boolean onOptionsItemSelected(final MenuItem item) { + + if (mDrawerToggle != null && mDrawerToggle.onOptionsItemSelected(item)) { + return true; + } + switch (item.getItemId()) { case R.id.list_refresh: backupViewSelection(); @@ -508,13 +642,4 @@ public abstract class BaseActivity<Result, T extends ListView> extends } } - /** - * Creates a dialog for showing certificate problems - * - * @return dialog - */ - @Override - protected CertificateProblemDialog getCertificateProblemDialog() { - return new CertificateProblemDialog(this); - } } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java index 3557630..f1779d8 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java @@ -1,5 +1,6 @@ package de.bjusystems.vdrmanager.gui; +import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Date; @@ -13,6 +14,8 @@ import android.os.Bundle; import android.util.Log; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; +import android.view.Menu; +import android.view.MenuInflater; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; @@ -22,6 +25,7 @@ import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; 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.Event; import de.bjusystems.vdrmanager.data.EventListItem; @@ -82,7 +86,6 @@ public abstract class BaseEventListActivity<T extends Event> extends sortBy = Preferences.get(this, getViewID() + "_" + P.EPG_LAST_SORT, MENU_GROUP_DEFAULT); // Attach view - setContentView(getMainLayout()); setTitle(getWindowTitle()); initFlipper(); detector = new SimpleGestureFilter(this, this); @@ -113,9 +116,9 @@ public abstract class BaseEventListActivity<T extends Event> extends */ @Override public boolean onCreateOptionsMenu( - final com.actionbarsherlock.view.Menu menu) { + final Menu menu) { super.onCreateOptionsMenu(menu); - final com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); + final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.epg_list_menu, menu); return true; } @@ -125,7 +128,24 @@ public abstract class BaseEventListActivity<T extends Event> extends * * @param event */ - protected int prepareDetailsViewData(final EventListItem event, int pos) { + protected int prepareDetailsViewData(final EventListItem item, int pos) { + final VdrManagerApp app = (VdrManagerApp) getApplication(); + // remember event for details view and timer things + app.setCurrentEvent(item.getEvent()); + ArrayList<Event> current = new ArrayList<Event>(); + for (int i = 0; i < adapter.getCount(); ++i) { + EventListItem item2 = adapter.getItem(i); + if(item2.isHeader()){ + continue; + } + current.add(item2.getEvent()); + } + app.setCurrentEpgList(current); + for (int i = 0; i < pos; ++i) { + if (current.get(i) == item.getEvent()) { + return i; + } + } return 0; } @@ -189,7 +209,7 @@ public abstract class BaseEventListActivity<T extends Event> extends * .view.MenuItem) */ public boolean onOptionsItemSelected( - final com.actionbarsherlock.view.MenuItem item) { + final MenuItem item) { switch (item.getItemId()) { diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java index 91741d2..0b51f5e 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java @@ -11,21 +11,28 @@ import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.res.Configuration; import android.os.Build; import android.os.Bundle; +import android.support.v4.app.ActionBarDrawerToggle; +import android.support.v4.view.GravityCompat; +import android.support.v4.widget.DrawerLayout; import android.text.TextUtils; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; +import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; +import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ExpandableListView; import android.widget.ExpandableListView.ExpandableListContextMenuInfo; import android.widget.ExpandableListView.OnChildClickListener; import android.widget.ExpandableListView.OnGroupClickListener; +import android.widget.ListView; import android.widget.TextView; import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.data.Channel; @@ -76,12 +83,14 @@ public class ChannelListActivity extends super.onResume(); } + + @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Attach view - setContentView(getMainLayout()); + setTitle(getWindowTitle()); initFlipper(); @@ -98,11 +107,14 @@ public class ChannelListActivity extends listView.setAdapter(adapter); // register context menu registerForContextMenu(listView); + + + startChannelQuery(); } - // + @Override protected void onPause() { @@ -247,10 +259,10 @@ public class ChannelListActivity extends public int compare(Channel lhs, Channel rhs) { String lhsn = lhs.getName(); String rhsn = rhs.getName(); - if(lhsn == null){ + if (lhsn == null) { return 1; } - if(rhsn == null){ + if (rhsn == null) { return -1; } return lhsn.compareToIgnoreCase(rhsn); @@ -265,17 +277,11 @@ public class ChannelListActivity extends adapter.notifyDataSetChanged(); } - public boolean onPrepareOptionsMenu( - final com.actionbarsherlock.view.Menu menu) { - return super.onPrepareOptionsMenu(menu); - } - @Override - public final boolean onCreateOptionsMenu( - final com.actionbarsherlock.view.Menu menu) { + public final boolean onCreateOptionsMenu(final Menu menu) { super.onCreateOptionsMenu(menu); - final com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); + MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.channellist, menu); return true; @@ -288,9 +294,8 @@ public class ChannelListActivity extends AlertDialog groupByDialog = null; @Override - public boolean onOptionsItemSelected( - final com.actionbarsherlock.view.MenuItem item) { - + public boolean onOptionsItemSelected(final MenuItem item) { + switch (item.getItemId()) { case R.id.channels_groupby: // case MENU_PROVIDER: diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListFragment.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListFragment.java new file mode 100644 index 0000000..0ce4cc2 --- /dev/null +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListFragment.java @@ -0,0 +1,8 @@ +package de.bjusystems.vdrmanager.gui; + +import android.support.v4.app.Fragment; + +public class ChannelListFragment extends Fragment { + + +} diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java index 33af528..c1daefa 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java @@ -15,7 +15,11 @@ import android.os.Parcelable; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; +import android.support.v7.app.ActionBarActivity; import android.util.Log; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; @@ -50,7 +54,7 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; * * @author bju */ -public class EpgDetailsActivity extends ICSBaseActivity implements +public class EpgDetailsActivity extends ActionBarActivity implements OnClickListener, OnPageChangeListener { public static final String TAG = "EpgDetailsActivity"; @@ -133,7 +137,7 @@ public class EpgDetailsActivity extends ICSBaseActivity implements @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + getSupportActionBar().setHomeButtonEnabled(true); // requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); Intent i = getIntent(); @@ -141,7 +145,7 @@ public class EpgDetailsActivity extends ICSBaseActivity implements highlight = i.getStringExtra(Intents.HIGHLIGHT); final int preselect = i.getIntExtra(Intents.CURRENT_EPG, 0); - initActionBar(); + // requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, @@ -648,10 +652,10 @@ public class EpgDetailsActivity extends ICSBaseActivity implements @Override public final boolean onCreateOptionsMenu( - com.actionbarsherlock.view.Menu menu) { + Menu menu) { super.onCreateOptionsMenu(menu); - final com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); + final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.epg_details, menu); // mShareActionProvider = (ShareActionProvider) @@ -667,7 +671,7 @@ public class EpgDetailsActivity extends ICSBaseActivity implements @Override public boolean onOptionsItemSelected( - com.actionbarsherlock.view.MenuItem item) { + MenuItem item) { Event cEvent = epgs.get(pager.getCurrentItem()); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java index 1662903..0c08670 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java @@ -10,12 +10,12 @@ import android.content.Intent; import android.os.Bundle; import android.provider.SearchRecentSuggestions; import android.text.TextUtils; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; - -import com.actionbarsherlock.view.MenuItem; - import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.app.VdrManagerApp; import de.bjusystems.vdrmanager.data.Epg; @@ -205,19 +205,19 @@ public class EpgSearchListActivity extends BaseTimerEditActivity<Epg> implements return adapter.getCount() > 0; } - @Override - protected int prepareDetailsViewData(final EventListItem item, int position) { - final VdrManagerApp app = (VdrManagerApp) getApplication(); - app.setCurrentEvent(item.getEvent()); - app.setCurrentEpgList(CACHE); - for(int i = 0; i < position; ++i){ - if(CACHE.get(i) == item.getEvent()){ - return i; - } - } - - return 0; - } +// @Override +// protected int prepareDetailsViewData(final EventListItem item, int position) { +// final VdrManagerApp app = (VdrManagerApp) getApplication(); +// app.setCurrentEvent(item.getEvent()); +// app.setCurrentEpgList(CACHE); +// for (int i = 0; i < position; ++i) { +// if (CACHE.get(i) == item.getEvent()) { +// return i; +// } +// } +// +// return 0; +// } @Override protected int getMainLayout() { @@ -235,15 +235,14 @@ public class EpgSearchListActivity extends BaseTimerEditActivity<Epg> implements } @Override - public boolean onCreateOptionsMenu( - final com.actionbarsherlock.view.Menu menu) { + public boolean onCreateOptionsMenu(final Menu menu) { // MenuItem item; // item = menu.add(MENU_GROUP_NEW_TIMER, MENU_NEW_TIMER, 0, // R.string.new_timer); // item.setIcon(android.R.drawable.ic_menu_add);; // /item.setAlphabeticShortcut('r'); - final com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); + MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.epg_search_menu, menu); return super.onCreateOptionsMenu(menu); } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java index c9281ae..3e73729 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java @@ -8,6 +8,9 @@ import java.util.List; import android.content.Intent; import android.os.Bundle; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; @@ -17,10 +20,6 @@ import android.widget.ListView; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; - -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; - import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.app.VdrManagerApp; import de.bjusystems.vdrmanager.data.Channel; @@ -394,20 +393,20 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements } - @Override - protected int prepareDetailsViewData(final EventListItem item, int position) { - final VdrManagerApp app = (VdrManagerApp) getApplication(); - app.setCurrentEvent(item.getEvent()); - ArrayList<Epg> cache = getCache(); - app.setCurrentEpgList(cache); - for (int i = 0; i < position; ++i) { - if (cache.get(i) == item.getEvent()) { - return i; - } - } - - return 0; - } +// @Override +// protected int prepareDetailsViewData(final EventListItem item, int position) { +// final VdrManagerApp app = (VdrManagerApp) getApplication(); +// app.setCurrentEvent(item.getEvent()); +// ArrayList<Epg> cache = getCache(); +// app.setCurrentEpgList(cache); +// for (int i = 0; i < position; ++i) { +// if (cache.get(i) == item.getEvent()) { +// return i; +// } +// } +// +// return 0; +// } @Override protected int getMainLayout() { @@ -473,7 +472,7 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements @Override public boolean onCreateOptionsMenu(final Menu menu) { super.onCreateOptionsMenu(menu); - final com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); + final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.epg_event_list_menu, menu); return true; } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ICSBaseActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ICSBaseActivity.java deleted file mode 100644 index b34219f..0000000 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ICSBaseActivity.java +++ /dev/null @@ -1,22 +0,0 @@ -package de.bjusystems.vdrmanager.gui; - -import com.actionbarsherlock.app.SherlockActivity; - -public abstract class ICSBaseActivity extends SherlockActivity { - - public void initActionBar() { - // int api = Build.VERSION.SDK_INT; - // if (api < 14) { - // return; - //} - final com.actionbarsherlock.app.ActionBar actionBar = getSupportActionBar(); - if(actionBar == null){ - return; - } - actionBar.setHomeButtonEnabled(true); - } - - protected CertificateProblemDialog getCertificateProblemDialog() { - return new CertificateProblemDialog(this); - } -} diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java index a03b09c..50f0971 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java @@ -11,6 +11,7 @@ import android.os.Bundle; import android.util.Log; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; +import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; @@ -193,8 +194,8 @@ public class RecordingListActivity extends BaseEventListActivity<Recording> */ @Override public boolean onCreateOptionsMenu( - final com.actionbarsherlock.view.Menu menu) { - final com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); + final Menu menu) { + final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.recording_list_menu, menu); return super.onCreateOptionsMenu(menu); } @@ -204,20 +205,20 @@ public class RecordingListActivity extends BaseEventListActivity<Recording> super.onPause(); } - @Override - protected int prepareDetailsViewData(final EventListItem event, int position) { - getApp().setCurrentEvent(event.getEvent()); - List<Recording> cachEget = CACHEget(currentFolder); - getApp().setCurrentEpgList(cachEget); - - for(int i = 0; i < position; ++i){ - if(cachEget.get(i) == event.getEvent()){ - return i; - } - } - - return 0; - } +// @Override +// protected int prepareDetailsViewData(final EventListItem event, int position) { +// getApp().setCurrentEvent(event.getEvent()); +// List<Recording> cachEget = CACHEget(currentFolder); +// getApp().setCurrentEpgList(cachEget); +// +// for(int i = 0; i < position; ++i){ +// if(cachEget.get(i) == event.getEvent()){ +// return i; +// } +// } +// +// return 0; +// } @Override public void onCreateContextMenu(final ContextMenu menu, final View v, diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java index 7d5b89d..c9c6a57 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java @@ -39,386 +39,390 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient; * @author bju */ public class TimeEpgListActivity extends BaseTimerEditActivity<Epg> implements -OnItemClickListener, OnItemSelectedListener, OnTimeSetListener { + OnItemClickListener, OnItemSelectedListener, OnTimeSetListener { - protected Spinner timeSpinner; - - protected View switcher; + protected Spinner timeSpinner; - protected View clock; - - ArrayAdapter<EpgSearchTimeValue> timeSpinnerAdapter; - - protected static Date nextForceCache = null; - - private static String cachedTime = null; - - int selectedIndex = 0; - - protected static ArrayList<Epg> CACHE = new ArrayList<Epg>(); - - @Override - public int getProgressTextId() { - return R.string.progress_whatson_loading; - } - - @Override - protected void onCreate(final Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // create adapter for time spinner - timeSpinnerAdapter = new ArrayAdapter<EpgSearchTimeValue>(this, - android.R.layout.simple_spinner_item); - timeSpinnerAdapter - .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - timeSpinner = (Spinner) findViewById(R.id.epg_list_time_spinner); - timeSpinner.setAdapter(timeSpinnerAdapter); - - switcher = findViewById(R.id.switch_epg_view); - switcher.setOnClickListener(this); - - clock = findViewById(R.id.epg_list_times); - clock.setOnClickListener(this); - - // update gui - adapter = new TimeEventAdapter(this); - // searchLabel.setVisibility(View.GONE); - timeSpinner.setOnItemSelectedListener(this); - - fillTimeSpinnerValues(); - - // Create adapter for EPG list - listView = (ListView) findViewById(R.id.whatson_list); - listView.setFastScrollEnabled(true); - listView.setTextFilterEnabled(true); - - listView.setAdapter(adapter); - registerForContextMenu(listView); - - // register EPG item click - listView.setOnItemClickListener(this); - - } - - private void fillTimeSpinnerValues() { - final EpgSearchTimeValues values = new EpgSearchTimeValues(this); - timeSpinnerAdapter.clear(); - for (final EpgSearchTimeValue value : values.getValues()) { - timeSpinnerAdapter.add(value); - } - } - - @Override - protected void onResume() { - super.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - - } - - @Override - public void onClick(final View view) { - if (view == switcher) { - final Intent intent = new Intent(); - intent.setClass(this, EventEpgListActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT - | Intent.FLAG_ACTIVITY_SINGLE_TOP); - startActivity(intent); - finish(); - } else if (view == clock) { - final Intent intent = new Intent(); - intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT - | Intent.FLAG_ACTIVITY_SINGLE_TOP); - intent.setClass(this, EpgSearchTimesListActivity.class); - startActivity(intent); - } else { - super.onClick(view); - } - } - - @Override - public void onTimeSet(final TimePicker view, final int hourOfDay, - final int minute) { - final String tm = String.format("%02d:%02d", hourOfDay, minute); - - // timeSpinnerAdapter.add(time); - final EpgSearchTimeValues values = new EpgSearchTimeValues(this); - final List<EpgSearchTimeValue> vs = values.getValues(); - final EpgSearchTimeValue time = new EpgSearchTimeValue(3, tm); - vs.add(vs.size() - 1, time); - timeSpinnerAdapter.clear(); - int select = -1; - int counter = 0; - for (final EpgSearchTimeValue value : vs) { - timeSpinnerAdapter.add(value); - if (select == -1 && value.getText().equals(tm)) { - select = counter; - } - counter++; - } - timeSpinner.setSelection(select); - setTitle(resolveWindowTitle()); - // update search - startEpgQuery(time.getValue(), false); - } - - private String resolveWindowTitle() { - if (timeSpinner == null) { - return getString(R.string.epg_by_time); - } - final EpgSearchTimeValue v = (EpgSearchTimeValue) timeSpinner - .getSelectedItem(); - if (v == null) { - return getString(R.string.epg_by_time); - } - return getString(R.string.epg_by_time_args, v.getText()); - } - - @Override - public void onItemSelected(final AdapterView<?> parent, final View view, - final int position, final long id) { - - // get spinner value - final EpgSearchTimeValue selection = (EpgSearchTimeValue) timeSpinner - .getSelectedItem(); - - if (selection.getValue().equals("adhoc")) { - 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.setOnDismissListener(new OnDismissListener() { - - // @Override - // public void onDismiss(DialogInterface dialog) { - - - // } - //}); - - dialog.show(); - } else { - // update search - setTitle(getString(R.string.epg_by_time_args, selection.getText())); - startEpgQuery(selection.getValue(), false); - } - } - - @Override - public void onNothingSelected(final AdapterView<?> arg0) { - // startTimeEpgQuery(((EpgTimeSpinnerValue)timeSpinner.getAdapter().getItem(0)).getValue()); - } - - @Override - public void clearCache() { - super.clearCache(); - cachedTime = null; - } - - private boolean useCache(final String time) { - - if (cachedTime == null) { - return false; - } - - if (cachedTime.equals(time) == false) { - return false; - } - - if (nextForceCache == null) { - return false; - } - final Date now = new Date(); - if (nextForceCache.before(now)) { - return false; - } - return true; - } - - private void startEpgQuery(final String time, final boolean force) { - - if (useCache(time) && !force) { - fillAdapter(); - return; - } - - if (checkInternetConnection() == false) { - return; - } - - final EpgClient epgClient = new EpgClient(time, getCertificateProblemDialog()); - - // remove old listeners - // epgClient.clearSvdrpListener(); - - // create background task - final SvdrpAsyncTask<Epg, SvdrpClient<Epg>> task = new SvdrpAsyncTask<Epg, SvdrpClient<Epg>>( - epgClient); - - // create progress - addListener(task); - - // start task - task.run(); - } - - @Override - protected synchronized void fillAdapter() { - - adapter.clear(); - - if (CACHE.isEmpty()) { - return; - } - - sort(); - listView.setFastScrollEnabled(false); - adapter.add(new EventListItem( - new DateFormatter(CACHE.get(0).getStart()).getDailyHeader())); - - for (final Event e : CACHE) { - adapter.add(new EventListItem(e)); - } - adapter.notifyDataSetChanged(); - listView.setFastScrollEnabled(true); - } - - void sort() { - if (sortBy == BaseEventListActivity.MENU_GROUP_ALPHABET) { - Collections.sort(CACHE, new TitleComparator()); - } else if (sortBy == BaseEventListActivity.MENU_GROUP_DEFAULT) { - Collections.sort(CACHE, new ChannelComparator()); - } - } - - @Override - protected int getAvailableSortByEntries() { - return R.array.epg_sort_by_channels_alpha; - } - - @Override - protected String getViewID() { - return TimeEpgListActivity.class.getSimpleName(); - } - - @Override - protected boolean finishedSuccessImpl(final List<Epg> results) { - clearCache(); - - if (results.isEmpty()) { - return false; - } - - // get spinner value - final EpgSearchTimeValue selection = (EpgSearchTimeValue) timeSpinner - .getSelectedItem(); - nextForceCache = FUTURE; - cachedTime = selection.getValue(); - final Date now = new Date(); - - // adapter.add(new EventListItem(new DateFormatter(results.get(0) - // .getStart()).getDailyHeader())); - - for (final Epg e : results) { - CACHE.add(e); - if (e.getStop().before(nextForceCache) && e.getStop().after(now)) { - nextForceCache = e.getStop(); - } - } - fillAdapter(); - pushResultCountToTitle(); - listView.setSelectionAfterHeaderView(); - return results.isEmpty() == false; - - } - - @Override - protected int prepareDetailsViewData(final EventListItem item, int position) { - final VdrManagerApp app = (VdrManagerApp) getApplication(); - // remember event for details view and timer things - app.setCurrentEvent(item.getEvent()); - app.setCurrentEpgList(CACHE); - for(int i = 0; i < position; ++i){ - if(CACHE.get(i) == item.getEvent()){ - return i; + protected View switcher; + + protected View clock; + + ArrayAdapter<EpgSearchTimeValue> timeSpinnerAdapter; + + protected static Date nextForceCache = null; + + private static String cachedTime = null; + + int selectedIndex = 0; + + protected static ArrayList<Epg> CACHE = new ArrayList<Epg>(); + + @Override + public int getProgressTextId() { + return R.string.progress_whatson_loading; + } + + @Override + protected void onCreate(final Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // create adapter for time spinner + timeSpinnerAdapter = new ArrayAdapter<EpgSearchTimeValue>(this, + android.R.layout.simple_spinner_item); + timeSpinnerAdapter + .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + timeSpinner = (Spinner) findViewById(R.id.epg_list_time_spinner); + timeSpinner.setAdapter(timeSpinnerAdapter); + + switcher = findViewById(R.id.switch_epg_view); + switcher.setOnClickListener(this); + + clock = findViewById(R.id.epg_list_times); + clock.setOnClickListener(this); + + // update gui + adapter = new TimeEventAdapter(this); + // searchLabel.setVisibility(View.GONE); + timeSpinner.setOnItemSelectedListener(this); + + fillTimeSpinnerValues(); + + // Create adapter for EPG list + listView = (ListView) findViewById(R.id.whatson_list); + listView.setFastScrollEnabled(true); + listView.setTextFilterEnabled(true); + + listView.setAdapter(adapter); + registerForContextMenu(listView); + + // register EPG item click + listView.setOnItemClickListener(this); + + } + + private void fillTimeSpinnerValues() { + final EpgSearchTimeValues values = new EpgSearchTimeValues(this); + timeSpinnerAdapter.clear(); + for (final EpgSearchTimeValue value : values.getValues()) { + timeSpinnerAdapter.add(value); + } + } + + @Override + protected void onResume() { + super.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + + } + + @Override + public void onClick(final View view) { + if (view == switcher) { + final Intent intent = new Intent(); + intent.setClass(this, EventEpgListActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT + | Intent.FLAG_ACTIVITY_SINGLE_TOP); + startActivity(intent); + finish(); + } else if (view == clock) { + final Intent intent = new Intent(); + intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT + | Intent.FLAG_ACTIVITY_SINGLE_TOP); + intent.setClass(this, EpgSearchTimesListActivity.class); + startActivity(intent); + } else { + super.onClick(view); + } + } + + @Override + public void onTimeSet(final TimePicker view, final int hourOfDay, + final int minute) { + final String tm = String.format("%02d:%02d", hourOfDay, minute); + + // timeSpinnerAdapter.add(time); + final EpgSearchTimeValues values = new EpgSearchTimeValues(this); + final List<EpgSearchTimeValue> vs = values.getValues(); + final EpgSearchTimeValue time = new EpgSearchTimeValue(3, tm); + vs.add(vs.size() - 1, time); + timeSpinnerAdapter.clear(); + int select = -1; + int counter = 0; + for (final EpgSearchTimeValue value : vs) { + timeSpinnerAdapter.add(value); + if (select == -1 && value.getText().equals(tm)) { + select = counter; + } + counter++; + } + timeSpinner.setSelection(select); + setTitle(resolveWindowTitle()); + // update search + startEpgQuery(time.getValue(), false); + } + + private String resolveWindowTitle() { + if (timeSpinner == null) { + return getString(R.string.epg_by_time); + } + final EpgSearchTimeValue v = (EpgSearchTimeValue) timeSpinner + .getSelectedItem(); + if (v == null) { + return getString(R.string.epg_by_time); + } + return getString(R.string.epg_by_time_args, v.getText()); + } + + @Override + public void onItemSelected(final AdapterView<?> parent, final View view, + final int position, final long id) { + + // get spinner value + final EpgSearchTimeValue selection = (EpgSearchTimeValue) timeSpinner + .getSelectedItem(); + + if (selection.getValue().equals("adhoc")) { + 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.setOnDismissListener(new OnDismissListener() { + + // @Override + // public void onDismiss(DialogInterface dialog) { + + // } + // }); + + dialog.show(); + } else { + // update search + setTitle(getString(R.string.epg_by_time_args, selection.getText())); + startEpgQuery(selection.getValue(), false); + } + } + + @Override + public void onNothingSelected(final AdapterView<?> arg0) { + // startTimeEpgQuery(((EpgTimeSpinnerValue)timeSpinner.getAdapter().getItem(0)).getValue()); + } + + @Override + public void clearCache() { + super.clearCache(); + cachedTime = null; + } + + private boolean useCache(final String time) { + + if (cachedTime == null) { + return false; + } + + if (cachedTime.equals(time) == false) { + return false; + } + + if (nextForceCache == null) { + return false; + } + final Date now = new Date(); + if (nextForceCache.before(now)) { + return false; + } + return true; + } + + private void startEpgQuery(final String time, final boolean force) { + + if (useCache(time) && !force) { + fillAdapter(); + return; + } + + if (checkInternetConnection() == false) { + return; } + + final EpgClient epgClient = new EpgClient(time, + getCertificateProblemDialog()); + + // remove old listeners + // epgClient.clearSvdrpListener(); + + // create background task + final SvdrpAsyncTask<Epg, SvdrpClient<Epg>> task = new SvdrpAsyncTask<Epg, SvdrpClient<Epg>>( + epgClient); + + // create progress + addListener(task); + + // start task + task.run(); } - return 0; - } - - @Override - protected int getMainLayout() { - return R.layout.time_epg_list; - } - - @Override - protected void refresh() { - // get spi - final EpgSearchTimeValue selection = (EpgSearchTimeValue) timeSpinner - .getSelectedItem(); - // update search - startEpgQuery(selection.getValue(), true); - } - - @Override - protected void retry() { - refresh(); - } - - @Override - protected String getWindowTitle() { - return resolveWindowTitle(); - } - - private void nextEvent() { - final int pos = timeSpinner.getSelectedItemPosition(); - if (pos + 1 >= timeSpinnerAdapter.getCount()) { - say(R.string.navigae_at_the_end); - return; - } - timeSpinner.setSelection(pos + 1, true); - } - - private void prevEvent() { - final int pos = timeSpinner.getSelectedItemPosition(); - if (pos <= 0) { - say(R.string.navigae_at_the_start); - return; - } - timeSpinner.setSelection(pos - 1, true); - } - - @Override - public void onSwipe(final int direction) { - switch (direction) { - case SimpleGestureFilter.SWIPE_RIGHT: - prevEvent(); - break; - case SimpleGestureFilter.SWIPE_LEFT: - nextEvent(); - break; - } - } - - @Override - protected int getListNavigationIndex() { - return LIST_NAVIGATION_EPG_BY_TIME; - } - - @Override - protected List<Epg> getCACHE() { - return CACHE; - } - - @Override - protected void timerModified(final Timer timer) { - clearCache(); - super.timerModified(timer); - } + @Override + protected synchronized void fillAdapter() { + + adapter.clear(); + + if (CACHE.isEmpty()) { + return; + } + + sort(); + listView.setFastScrollEnabled(false); + adapter.add(new EventListItem( + new DateFormatter(CACHE.get(0).getStart()).getDailyHeader())); + + for (final Event e : CACHE) { + adapter.add(new EventListItem(e)); + } + adapter.notifyDataSetChanged(); + listView.setFastScrollEnabled(true); + } + + void sort() { + if (sortBy == BaseEventListActivity.MENU_GROUP_ALPHABET) { + Collections.sort(CACHE, new TitleComparator()); + } else if (sortBy == BaseEventListActivity.MENU_GROUP_DEFAULT) { + Collections.sort(CACHE, new ChannelComparator()); + } + } + + @Override + protected int getAvailableSortByEntries() { + return R.array.epg_sort_by_channels_alpha; + } + + @Override + protected String getViewID() { + return TimeEpgListActivity.class.getSimpleName(); + } + + @Override + protected boolean finishedSuccessImpl(final List<Epg> results) { + clearCache(); + + if (results.isEmpty()) { + return false; + } + + // get spinner value + final EpgSearchTimeValue selection = (EpgSearchTimeValue) timeSpinner + .getSelectedItem(); + nextForceCache = FUTURE; + cachedTime = selection.getValue(); + final Date now = new Date(); + + // adapter.add(new EventListItem(new DateFormatter(results.get(0) + // .getStart()).getDailyHeader())); + + for (final Epg e : results) { + CACHE.add(e); + if (e.getStop().before(nextForceCache) && e.getStop().after(now)) { + nextForceCache = e.getStop(); + } + } + fillAdapter(); + pushResultCountToTitle(); + listView.setSelectionAfterHeaderView(); + return results.isEmpty() == false; + + } + +// @Override +// protected int prepareDetailsViewData(final EventListItem item, int position) { +// final VdrManagerApp app = (VdrManagerApp) getApplication(); +// // remember event for details view and timer things +// app.setCurrentEvent(item.getEvent()); +// ArrayList<EventListItem> current = new ArrayList<EventListItem>(); +// for (int i = 0; i < adapter.getCount(); ++i) { +// current.add(adapter.getItem(i)); +// } +// app.setCurrentEpgList(current); +// for (int i = 0; i < position; ++i) { +// if (current.get(i) == item.getEvent()) { +// return i; +// } +// } +// +// return 0; +// } + + @Override + protected int getMainLayout() { + return R.layout.time_epg_list; + } + + @Override + protected void refresh() { + // get spi + final EpgSearchTimeValue selection = (EpgSearchTimeValue) timeSpinner + .getSelectedItem(); + // update search + startEpgQuery(selection.getValue(), true); + } + + @Override + protected void retry() { + refresh(); + } + + @Override + protected String getWindowTitle() { + return resolveWindowTitle(); + } + + private void nextEvent() { + final int pos = timeSpinner.getSelectedItemPosition(); + if (pos + 1 >= timeSpinnerAdapter.getCount()) { + say(R.string.navigae_at_the_end); + return; + } + timeSpinner.setSelection(pos + 1, true); + } + + private void prevEvent() { + final int pos = timeSpinner.getSelectedItemPosition(); + if (pos <= 0) { + say(R.string.navigae_at_the_start); + return; + } + timeSpinner.setSelection(pos - 1, true); + } + + @Override + public void onSwipe(final int direction) { + switch (direction) { + case SimpleGestureFilter.SWIPE_RIGHT: + prevEvent(); + break; + case SimpleGestureFilter.SWIPE_LEFT: + nextEvent(); + break; + } + } + + @Override + protected int getListNavigationIndex() { + return LIST_NAVIGATION_EPG_BY_TIME; + } + + @Override + protected List<Epg> getCACHE() { + return CACHE; + } + + @Override + protected void timerModified(final Timer timer) { + clearCache(); + super.timerModified(timer); + } } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java index 57882ad..ae07e1c 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java @@ -7,6 +7,8 @@ import java.util.Comparator; import java.util.List; import android.os.Bundle; +import android.view.Menu; +import android.view.MenuInflater; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import de.bjusystems.vdrmanager.R; @@ -112,20 +114,20 @@ OnItemClickListener { * de.bjusystems.vdrmanager.gui.BaseEventListActivity#prepareTimer(de.bjusystems * .vdrmanager.data.EventListItem) */ - @Override - protected int prepareDetailsViewData(final EventListItem item, int position) { - final VdrManagerApp app = (VdrManagerApp) getApplication(); - // remember event for details view and timer things - app.setCurrentEvent(item.getEvent()); - app.setCurrentEpgList(CACHE); - for(int i = 0; i < position; ++i){ - if(CACHE.get(i) == item.getEvent()){ - return i; - } - } - - return 0; - } +// @Override +// protected int prepareDetailsViewData(final EventListItem item, int position) { +// final VdrManagerApp app = (VdrManagerApp) getApplication(); +// // remember event for details view and timer things +// app.setCurrentEvent(item.getEvent()); +// app.setCurrentEpgList(CACHE); +// for(int i = 0; i < position; ++i){ +// if(CACHE.get(i) == item.getEvent()){ +// return i; +// } +// } +// +// return 0; +// } protected Comparator<Timer> getTimeComparator(final boolean reverse) { return new Comparator<Timer>() { @@ -264,14 +266,14 @@ OnItemClickListener { return R.array.epg_sort_by_time_alpha; } - public boolean onCreateOptionsMenu(final com.actionbarsherlock.view.Menu menu) { + public boolean onCreateOptionsMenu(final Menu menu) { // MenuItem item; // item = menu.add(MENU_GROUP_NEW_TIMER, MENU_NEW_TIMER, 0, // R.string.new_timer); // item.setIcon(android.R.drawable.ic_menu_add);; // /item.setAlphabeticShortcut('r'); - final com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); + final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.timer_list_menu, menu); return super.onCreateOptionsMenu(menu); } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java index 8d2fca8..a414725 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java @@ -362,6 +362,23 @@ public class Utils { .append(Integer.valueOf(Preferences.get().getStreamPort())) // .append("/").append(rec.getDevInode()); + } else if (StringUtils.equals(m, "vdr-smarttvweb")) { + + String type = Preferences.get().getSmarttvewebType(); + + url.append("http://") + .append(Preferences.get().getSvdrpHost()) + // + .append(":") + .append(Integer.valueOf(Preferences.get() + .getSmarttvewebPort())) + // + .append(Utils.encodeUrlPath(rec.getFileName())); + if (StringUtils.equals(type, "has") == true) { + url.append("/manifest-seg.mpd"); + } else if (StringUtils.equals(type, "hls")) { + url.append("/manifest-seg.m3u8"); + } } return url.toString(); } @@ -420,6 +437,9 @@ public class Utils { t.setGravity(Gravity.CENTER, 0, 0); t.show(); } + public static String encodeUrlPath(String path){ + return path.replaceAll("%", "%25"); + } public static void say(final Context ctx, final int msg) { final Toast t = Toast.makeText(ctx, msg, Toast.LENGTH_SHORT); @@ -447,16 +467,16 @@ public class Utils { public static int getTimerStateDrawable(final TimerMatch match, final int full, final int begin, final int end, final int conflict) { - switch (match) { - case Begin: - return begin; - case End: - return end; - case Conflict: - return conflict; - default: - return full; - } + switch (match) { + case Begin: + return begin; + case End: + return end; + case Conflict: + return conflict; + default: + return full; + } } public static String formatAudio(final Context context, diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java index 8a7330e..37eb6b2 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java @@ -9,14 +9,18 @@ import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.SearchRecentSuggestions; +import android.support.v4.view.MenuItemCompat; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.SearchView; +import android.support.v7.widget.SearchView.OnQueryTextListener; import android.util.Log; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Toast; -import com.actionbarsherlock.app.SherlockActivity; -import com.actionbarsherlock.widget.SearchView; -import com.actionbarsherlock.widget.SearchView.OnQueryTextListener; import com.j256.ormlite.android.AndroidDatabaseResults; import de.bjusystems.vdrmanager.R; @@ -28,14 +32,14 @@ import de.bjusystems.vdrmanager.data.db.DBAccess; import de.bjusystems.vdrmanager.data.db.EPGSearchSuggestionsProvider; import de.bjusystems.vdrmanager.utils.wakeup.AsyncWakeupTask; -public class VdrManagerActivity extends SherlockActivity implements +public class VdrManagerActivity extends ActionBarActivity implements OnClickListener, OnQueryTextListener { public static final String TAG = "VdrManagerActivity"; public static final String VDR_PORTAL = "http://www.vdr-portal.de"; - private com.actionbarsherlock.widget.SearchView search; + private SearchView search; private View actionMenuWakup; @@ -48,7 +52,7 @@ public class VdrManagerActivity extends SherlockActivity implements // if(Preferences.get().getCurrentVdr() == null){ // finish(); // return; - // } + // } android.support.v7.appcompat.R if (Preferences.initVDR(this) == false) { final Intent intent = new Intent(); @@ -86,13 +90,12 @@ public class VdrManagerActivity extends SherlockActivity implements // createButtons(); } - public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) { - com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); // search = new SearchView(getSupportActionBar().getThemedContext()); - - search = (SearchView) menu.findItem(R.id.menu_search).getActionView(); + search = (SearchView) MenuItemCompat.getActionView( menu.findItem(R.id.menu_search)); // search = (SearchView) // .getActionView(); @@ -103,7 +106,7 @@ public class VdrManagerActivity extends SherlockActivity implements search.setSearchableInfo(searchManager .getSearchableInfo(getComponentName())); - // search.setOnQueryTextListener(this); + //search.setOnQueryTextListener(this); return true; } @@ -122,7 +125,7 @@ public class VdrManagerActivity extends SherlockActivity implements @Override public boolean onOptionsItemSelected( - final com.actionbarsherlock.view.MenuItem item) { + final MenuItem item) { switch (item.getItemId()) { case R.id.main_menu_preferences: { diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java index 1bf81b8..0d01737 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java @@ -68,7 +68,6 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements super.updateSummary(ep); } - private boolean isNew = false; private boolean hasChanged = false; @@ -137,16 +136,15 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements return null; } -// private String getIp() throws Exception { -// final Preferences prefs = Preferences.get(); -// String host = prefs.getSvdrpHost(); -// return InetAddress.getByName(host).getHostAddress(); -// } + // private String getIp() throws Exception { + // final Preferences prefs = Preferences.get(); + // String host = prefs.getSvdrpHost(); + // return InetAddress.getByName(host).getHostAddress(); + // } private void ping(String ip, int port) throws Exception { Socket socket = new Socket(); - socket.connect(new InetSocketAddress(ip, port), - 5 * 1000); + socket.connect(new InetSocketAddress(ip, port), 5 * 1000); socket.setSoTimeout(5 * 1000); } @@ -171,9 +169,15 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements // PreferenceCategory cat = (PreferenceCategory) // findPreference("key_streaming_category"); // cat.removePreference(p); - } - + } + + if (recstream.equals("vdr-smarttvweb") == false) { + Preference p = findPreference("key_smarttvweb_port"); + p.setEnabled(false); + p = findPreference("key_smarttvweb_recstream_method"); + p.setEnabled(false); + } // create background task @@ -181,7 +185,7 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements final FetchEditTextPreference macedit = (FetchEditTextPreference) findPreference(getString(R.string.wakeup_wol_mac_key)); String mac = vdr.getMac(); - if(mac == null){ + if (mac == null) { mac = ""; } macedit.setText(mac); @@ -221,7 +225,8 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements @Override protected Void doInBackground(Void... params) { try { - String ip = InetAddress.getByName(host).getHostAddress(); + String ip = InetAddress.getByName(host) + .getHostAddress(); ping(ip, vdr.getPort()); mac = getMacFromArpCache(ip); } catch (Exception ex) { @@ -260,24 +265,26 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements return; } - if(ips.isEmpty()){ - Utils.say(VdrPreferencesActivity.this, R.string.no_results); + if (ips.isEmpty()) { + Utils.say(VdrPreferencesActivity.this, + R.string.no_results); return; } if (ips.size() == 1) { ipEdit.setEditText(ips.get(0).toString()); } else { - new AlertDialog.Builder(VdrPreferencesActivity.this).setItems( - ips.toArray(new CharSequence[] {}), - new DialogInterface.OnClickListener() { - @Override - public void onClick( - DialogInterface dialog, - int which) { - String ip = ips.get(which); - ipEdit.setEditText(ip); - } - }).show(); + new AlertDialog.Builder(VdrPreferencesActivity.this) + .setItems( + ips.toArray(new CharSequence[] {}), + new DialogInterface.OnClickListener() { + @Override + public void onClick( + DialogInterface dialog, + int which) { + String ip = ips.get(which); + ipEdit.setEditText(ip); + } + }).show(); } } @@ -329,6 +336,7 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements "vdr-live"); Preference pk = findPreference("key_live_port"); if (recstream.equals("vdr-live") == false) { + pk.setEnabled(false); // PreferenceCategory cat = (PreferenceCategory) // findPreference("key_streaming_category"); @@ -337,6 +345,20 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements pk.setEnabled(true); } + if (recstream.equals("vdr-smarttvweb") == false) { + p = findPreference("key_smarttvweb_port"); + p.setEnabled(false); + p = findPreference("key_smarttvweb_recstream_method"); + p.setEnabled(false); + + } else { + p = findPreference("key_smarttvweb_port"); + p.setEnabled(true); + p = findPreference("key_smarttvweb_recstream_method"); + p.setEnabled(true); + + } + // if(pk) // cat.addPreference(pk); // } else { @@ -440,8 +462,8 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements finish(); return; } - if(isNew == true && hasChanged == false) { - //if (pref.commits < 2) {// user has not changed anything + if (isNew == true && hasChanged == false) { + // if (pref.commits < 2) {// user has not changed anything DBAccess.get(this).getVdrDAO().delete(pref.getVdr()); finish(); return; @@ -467,7 +489,8 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements return; } - //never mind, onResume also registers this, but the listenres are held in a map (as key) so that no double occurance + // never mind, onResume also registers this, but the listenres are held + // in a map (as key) so that no double occurance pref.registerOnSharedPreferenceChangeListener(this); if (requestCode == REQUEST_CODE_PICK_A_TIME_ZONE) { |