diff options
12 files changed, 66 insertions, 215 deletions
diff --git a/vdrmanager/AndroidManifest.xml b/vdrmanager/AndroidManifest.xml index bdaeece..b3314ed 100644 --- a/vdrmanager/AndroidManifest.xml +++ b/vdrmanager/AndroidManifest.xml @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="de.bjusystems.vdrmanager" android:versionName="0.4.0" - android:versionCode="400"> + package="de.bjusystems.vdrmanager" android:versionName="0.4.3" + android:versionCode="403"> <application android:icon="@drawable/app_logo" - android:label="@string/app_name" android:debuggable="true" + android:label="@string/app_name" android:debuggable="false" android:name=".app.VdrManagerApp"> <activity android:label="@string/app_name" android:name=".gui.VdrManagerActivity" android:configChanges="locale"> <intent-filter> @@ -47,7 +47,7 @@ <meta-data android:name="android.app.default_searchable" android:value=".gui.EpgSearchListActivity" /> </activity> - <activity android:name=".gui.EpgDetailsActivity" android:launchMode="singleTask" + <activity android:name=".gui.EpgDetailsActivity" android:configChanges="orientation|locale"> <intent-filter> <action android:name="android.intent.action.SEARCH" /> diff --git a/vdrmanager/res/layout/vdrmanager.xml b/vdrmanager/res/layout/vdrmanager.xml index bbbae38..2d541bd 100644 --- a/vdrmanager/res/layout/vdrmanager.xml +++ b/vdrmanager/res/layout/vdrmanager.xml @@ -13,7 +13,6 @@ <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="10dip"> <Button android:text="@string/action_menu_channels" - xmlns:android="http://schemas.android.com/apk/res/android" android:drawableTop="@drawable/btn_channels" android:layout_width="wrap_content" android:id="@+id/action_menu_channels" android:layout_height="wrap_content" android:textColor="#FFF" android:layout_weight="1" diff --git a/vdrmanager/res/menu-v11/epg_details.xml b/vdrmanager/res/menu-v11/epg_details.xml index fbbc9d6..339d423 100644 --- a/vdrmanager/res/menu-v11/epg_details.xml +++ b/vdrmanager/res/menu-v11/epg_details.xml @@ -11,7 +11,6 @@ android:showAsAction="ifRoom|withText" android:id="@+id/epg_details_menu_share" android:icon="@android:drawable/ic_menu_share" - android:actionProviderClass="android.widget.ShareActionProvider" android:title="@string/share"/> </menu> diff --git a/vdrmanager/res/values/preferences.xml b/vdrmanager/res/values/preferences.xml index 25bc675..71523ae 100644 --- a/vdrmanager/res/values/preferences.xml +++ b/vdrmanager/res/values/preferences.xml @@ -42,7 +42,7 @@ </string-array> - <string name="default_wakeup_method">url</string> + <string name="default_wakeup_method">wol</string> <string name="wakeup_wol_custom_boradcast_title">Destination IP address</string> <string name="wakeup_wol_custom_boradcast_summary">Unless you have static ARP tables you should use some kind of broadcast address.</string> diff --git a/vdrmanager/res/xml/vdr_prefs.xml b/vdrmanager/res/xml/vdr_prefs.xml index e985efc..b5a48a2 100644 --- a/vdrmanager/res/xml/vdr_prefs.xml +++ b/vdrmanager/res/xml/vdr_prefs.xml @@ -3,7 +3,7 @@ <PreferenceCategory android:title="@string/vdr_prefs_category"> - <EditTextPreference android:inputType="textCapWords" + <EditTextPreference android:inputType="textCapWords" android:defaultValue="-" android:key="@string/vdr_name_key" android:summary="@string/vdr_name_summary" android:title="@string/vdr_name_title" /> @@ -13,6 +13,7 @@ android:title="@string/vdr_preferences"> <EditTextPreference android:inputType="textNoSuggestions" + android:defaultValue="0.0.0.0" android:key="@string/vdr_host_key" android:summary="@string/vdr_host_summary" android:title="@string/vdr_host_title" /> @@ -49,7 +50,8 @@ <PreferenceCategory android:key="wakeup_preferences" android:title="@string/wakeup_preferences"> - <CheckBoxPreference android:key="@string/wakeup_enabled_key" + <CheckBoxPreference android:key="@string/wakeup_enabled_key" + android:defaultValue="false" android:summary="@string/wakeup_enabled_summary" android:title="@string/wakeup_enabled_title" /> <ListPreference android:defaultValue="@string/default_wakeup_method" @@ -117,6 +119,7 @@ android:key="livetv_streamformat" android:title="@string/settings_livetv_streamformat" /> <CheckBoxPreference android:key="remux_enable" + android:defaultValue="false" android:summary="@string/remux_enable_summary" android:title="@string/remux_enable_title" /> <ListPreference android:defaultValue="EXT" diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java index 652fd31..ea3cfa2 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java @@ -34,9 +34,15 @@ public class Preferences { } public static void setCurrentVdr(Context context, Vdr vdr) { - setCurrentInternal(context, vdr); + final SharedPreferences sharedPrefs = getSharedPreferences(context); + current = vdr; + sharedPrefs + .edit() + .putInt(context.getString(R.string.current_vdr_id_key), + current.getId()).commit(); } + public Vdr getCurrentVdr() { return current; } @@ -190,9 +196,7 @@ public class Preferences { * @return true, if remote wakeup is enabled */ public boolean isWakeupEnabled() { - return true; - // TODO - // return getCurrentVdr().isWakeupEnabled(); + return getCurrentVdr().isWakeupEnabled(); } /** @@ -447,7 +451,8 @@ public class Preferences { public static void reset() { thePrefs = null; } - + + /** * Loads all preferences * @@ -471,9 +476,9 @@ public class Preferences { setLocale(context); } - // if (current != null) { - // return; - // } + // if (current != null) { + // return; + // } final SharedPreferences sharedPrefs = getSharedPreferences(context); int id = sharedPrefs.getInt( @@ -485,14 +490,14 @@ public class Preferences { } if (vdr != null) { - setCurrentInternal(context, vdr); + setCurrentVdr(context, vdr); return; } List<Vdr> list = db.getVdrDAO().queryForAll(); if (list != null && list.isEmpty() == false) { vdr = list.get(0); - setCurrentInternal(context, vdr); + setCurrentVdr(context, vdr); return; } if (initFromOldVersion(context) == false) { @@ -505,31 +510,15 @@ public class Preferences { } - private static void setCurrentInternal(Context context, Vdr vdr) { - final SharedPreferences sharedPrefs = getSharedPreferences(context); - current = vdr; - sharedPrefs - .edit() - .putInt(context.getString(R.string.current_vdr_id_key), - current.getId()).commit(); - } - private static boolean initFromOldVersion(Context context) { - int version = -1; - try { - version = context.getPackageManager().getPackageInfo( - context.getPackageName(), 0).versionCode; - } catch (Exception ex) { - return false; - } - - if (version != 40) { - return false; - } Vdr vdr = new Vdr(); - vdr.setHost(getString(context, R.string.vdr_host_key, "0.0.0.0")); + String host = getString(context, R.string.vdr_host_key, null); + if(host == null){ + return false; + } + vdr.setHost(host); vdr.setName("Default"); vdr.setPort(getInt(context, R.string.vdr_port_key, 6420)); vdr.setPassword(getString(context, R.string.vdr_password_key, "")); @@ -592,7 +581,7 @@ public class Preferences { return false; } - setCurrentInternal(context, vdr); + setCurrentVdr(context, vdr); return true; } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java index fd75033..6b8c6dd 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java @@ -16,7 +16,7 @@ public class Vdr { private Integer id; @DatabaseField(columnName = "name") - private String name; + private String name = "-"; /** * Use secure channel @@ -439,6 +439,10 @@ public class Vdr { } private static <T> T get(Map<String, Object> map, String key) { + return get(map, key, null); + } + + private static <T> T get(Map<String, Object> map, String key, Object def) { return (T) map.get(key); } @@ -506,8 +510,8 @@ public class Vdr { } public void init(Map<String, Object> map) { - name = get(map, "vdr_name"); - host = get(map, "vdr_host"); + name = get(map, "vdr_name", name); + host = get(map, "vdr_host" ); port = getInteger(map, "vdr_port"); password = get(map, "vdr_password"); secure = getBoolean(map, "vdr_secure"); @@ -516,12 +520,12 @@ public class Vdr { channelFilter = get(map, "last_channel"); wakeupEnabled = getBoolean(map, "key_wakeup_enabled"); - wakeupUrl = get(map, "key_wakeup_url"); - wakeupUser = get(map, "key_wakeup_user"); - wakeupPassword = get(map, "key_wakeup_password"); - wakeupMethod = get(map, "key_wakeup_method"); - wolCustomBroadcast = get(map, "key_wol_custom_broadcast"); - mac = get(map, "key_wakeup_wol_mac"); + wakeupUrl = get(map, "key_wakeup_url", "0.0.0.0"); + wakeupUser = get(map, "key_wakeup_user",""); + wakeupPassword = get(map, "key_wakeup_password",""); + wakeupMethod = get(map, "key_wakeup_method","wol"); + wolCustomBroadcast = get(map, "key_wol_custom_broadcast",""); + mac = get(map, "key_wakeup_wol_mac",""); connectionTimeout = getInteger(map, "key_conntimeout_key"); readTimeout = getInteger(map, "key_vdr_readtimeout"); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/VdrSharedPreferences.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/VdrSharedPreferences.java index bbaa74e..86103bf 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/VdrSharedPreferences.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/VdrSharedPreferences.java @@ -15,6 +15,8 @@ public class VdrSharedPreferences implements SharedPreferences { private static final String EMPTY_STRING = ""; + public int commits = 0; + public RuntimeExceptionDao<Vdr, Integer> dao; public Vdr instance; @@ -108,6 +110,8 @@ public class VdrSharedPreferences implements SharedPreferences { if(status == false) return false; + ++commits; + // and update any listeners for (OnSharedPreferenceChangeListener listener : listeners) { listener.onSharedPreferenceChanged( diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java index 2d892e9..c88ba8c 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java @@ -1,25 +1,16 @@ package de.bjusystems.vdrmanager.gui; -import android.app.ActionBar; -import android.app.ActionBar.OnNavigationListener; -import android.app.Activity; import android.app.AlertDialog; import android.app.ProgressDialog; -import android.app.SearchManager; -import android.content.Context; import android.content.Intent; -import android.os.Build; import android.os.Bundle; 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; import android.widget.Button; import android.widget.ListView; -import android.widget.SearchView; -import android.widget.SpinnerAdapter; import android.widget.Toast; import android.widget.ViewFlipper; import de.bjusystems.vdrmanager.R; @@ -31,7 +22,7 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException; -public abstract class BaseActivity<Result, T extends ListView> extends Activity +public abstract class BaseActivity<Result, T extends ListView> extends ICSBaseActivity implements OnClickListener, SvdrpAsyncListener<Result>, Cache { public static final String TAG = BaseActivity.class.getName(); @@ -124,36 +115,6 @@ public abstract class BaseActivity<Result, T extends ListView> extends Activity // setTitle(title); // } - public void initActionBar() { - int api = Build.VERSION.SDK_INT; - if (api < 11) { - return; - } - - ActionBar actionBar = getActionBar(); - actionBar.setHomeButtonEnabled(true); - // actionBar.setDisplayShowHomeEnabled(false); - // actionBar.setDisplayShowTitleEnabled(false); - // View actionBarView = - // getLayoutInflater().inflate(R.layout.action_bar_custom_view, null); - // actionBar.setCustomView(actionBarView); - // actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); - - // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); - // ArrayAdapter<String> mSpinnerAdapter = new ArrayAdapter<String>(this, - // android.R.layout.simple_spinner_dropdown_item); - // mSpinnerAdapter.add("A"); - // actionBar.setListNavigationCallbacks(mSpinnerAdapter, new - // OnNavigationListener() { - - // public boolean onNavigationItemSelected(int itemPosition, long - // itemId) { - // // TODO Auto-generated method stub - // return false; - // } - // }); - - } @Override protected void onCreate(Bundle savedInstanceState) { @@ -161,6 +122,7 @@ public abstract class BaseActivity<Result, T extends ListView> extends Activity Preferences.setLocale(this); progress = new ProgressDialog(this); getApp().addActivityToFinish(this); + initActionBar(); // your logic for click listner diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java index e1b3723..7a0f1e8 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java @@ -205,7 +205,7 @@ public abstract class BaseEventListActivity<T extends Event> extends super.onCreateContextMenu(menu, v, menuInfo); } - + /** * @param parent * @param view @@ -225,8 +225,7 @@ public abstract class BaseEventListActivity<T extends Event> extends prepareDetailsViewData(item); // show details - final Intent intent = new Intent(); - intent.setClass(this, EpgDetailsActivity.class); + final Intent intent = new Intent(this, EpgDetailsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); if (highlight != null) { diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java index 28d989d..7843844 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java @@ -4,15 +4,12 @@ import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; -import android.app.ActionBar; -import android.app.Activity; import android.app.AlertDialog; import android.app.SearchManager; import android.content.ActivityNotFoundException; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.Parcelable; import android.support.v4.view.PagerAdapter; @@ -53,12 +50,14 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; * * @author bju */ -public class EpgDetailsActivity extends Activity implements OnClickListener, +public class EpgDetailsActivity extends ICSBaseActivity implements OnClickListener, OnPageChangeListener { public static final String TAG = "EpgDetailsActivity"; public static String IMDB_URL = "http://%s/find?s=all&q=%s"; + + private static final String IMDB_URL_ENCODING = "ISO-8859-1"; private String highlight = null; @@ -119,37 +118,6 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, } } - public void initActionBar() { - int api = Build.VERSION.SDK_INT; - if (api < 11) { - return; - } - - ActionBar actionBar = getActionBar(); - actionBar.setHomeButtonEnabled(true); - // actionBar.setDisplayShowHomeEnabled(false); - // actionBar.setDisplayShowTitleEnabled(false); - // View actionBarView = - // getLayoutInflater().inflate(R.layout.action_bar_custom_view, null); - // actionBar.setCustomView(actionBarView); - // actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); - - // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); - // ArrayAdapter<String> mSpinnerAdapter = new ArrayAdapter<String>(this, - // android.R.layout.simple_spinner_dropdown_item); - // mSpinnerAdapter.add("A"); - // actionBar.setListNavigationCallbacks(mSpinnerAdapter, new - // OnNavigationListener() { - - // public boolean onNavigationItemSelected(int itemPosition, long - // itemId) { - // // TODO Auto-generated method stub - // return false; - // } - // }); - - } - @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -343,8 +311,8 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, final TextView title = (TextView) view .findViewById(R.id.epg_detail_title); String url = String.format(IMDB_URL, Preferences.get() - .getImdbUrl(), String.valueOf(title.getText())); - url = encode(url, "utf-8"); + .getImdbUrl(), encode(String.valueOf(title.getText()), IMDB_URL_ENCODING)); + //url = encode(url, "utf-8"); Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); i.addCategory(Intent.CATEGORY_BROWSABLE); @@ -435,7 +403,7 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, break; case R.id.epg_event_create_timer: final ArrayAdapter<Wrapper> ada = new ArrayAdapter<Wrapper>(this, - R.layout.timer_operation_list_item); + android.R.layout.simple_dropdown_item_1line); final Timer timer = getTimer(cEvent); // remove unneeded menu items if (timer != null) { @@ -534,71 +502,9 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, task.start(); } - // EditTimerViewHolder tView = null; - - // public void onSwipe(int direction) { - // switch (direction) { - // case SimpleGestureFilter.SWIPE_RIGHT: - // // prevEPG(); - // break; - // case SimpleGestureFilter.SWIPE_LEFT: - // nextEPG(); - // break; - // } - // } - - // private void prevEPG() { - // if(counter == -1){ - // return; - // } - // Event epg; - // if (counter == 0) { - // say(R.string.navigae_at_the_start); - // return; - // } - // epg = epgs.get(--counter); - // publishEPG(epg); - // } - - List<Event> epgs = new ArrayList<Event>(); - - // /int counter = 0; - - /* - * public void initEPGs() { - * - * if (epgs != null) { return; } epgs = new ArrayList<Event>(); - * - * final VdrManagerApp app = (VdrManagerApp) getApplication(); final Event - * event = app.getCurrentEvent(); EpgClient c = new EpgClient(new Channel() - * { - * - * @Override public String getName() { return event.getChannelName(); } - * - * @Override public int getNumber() { return - * Integer.valueOf(event.getChannelNumber()); } }); - * - * try { c.run(); } catch (SvdrpException e) { // TODO Auto-generated catch - * block e.printStackTrace(); } - * - * List<Epg> e = c.getResults(); if (e == null || e.isEmpty()) { return; } - * - * epgs.addAll(e); Event fe = epgs.get(0); if - * (event.getStart().equals(fe.getStart()) == false) { epgs.set(0, event); ; - * } } - */ - // private void nextEPG() { - // if (counter == -1) { - // return; - // } - // if (counter < epgs.size() - 1) { - // counter++; - // Event epg = epgs.get(counter); - // // publishEPG(epg); - // } else { - // say(R.string.navigae_at_the_end); - // } - // } + + private List<Event> epgs = new ArrayList<Event>(); + protected void say(int res) { Toast.makeText(this, res, Toast.LENGTH_SHORT).show(); @@ -608,15 +514,6 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); } - // public void onDoubleTap() { - // - // } - - // @Override - // public boolean dispatchTouchEvent(MotionEvent me) { - // // this.detector.onTouchEvent(me); - // return super.dispatchTouchEvent(me); - // } @Override public final boolean onCreateOptionsMenu(final Menu menu) { @@ -652,15 +549,6 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, return super.onOptionsItemSelected(item); } - // protected void modifyTimer(Timer timer) { - // final ModifyTimerTask task = new ModifyTimerTask(this, timer) { - // @Override - // public void finished(SvdrpEvent event) { - // modifed = true; - // } - // }; - // task.start(); - // } protected void deleteTimer(final Timer timer) { final DeleteTimerTask task = new DeleteTimerTask(this, timer) { diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/PreferencesActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/PreferencesActivity.java index 7451043..0015492 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/PreferencesActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/PreferencesActivity.java @@ -74,13 +74,17 @@ public class PreferencesActivity extends BasePreferencesActivity implements @Override public void onBackPressed() { + + + //Preferences.getSharedPreferences(this) + //.registerOnSharedPreferenceChangeListener(this); // finish this activity final VdrManagerApp app = (VdrManagerApp) getApplication(); app.addActivityToFinish(this); app.finishActivities(); - Preferences.init(this); + //Preferences.init(this); // restart main activity because // the buttons needs refreshing final Intent intent = new Intent(); |