summaryrefslogtreecommitdiff
path: root/vdrmanager/src/de
diff options
context:
space:
mode:
authorlado <herrlado@gmail.com>2012-01-20 13:12:43 +0100
committerlado <herrlado@gmail.com>2012-01-20 13:12:43 +0100
commit87ae5319f8870032e87b3c5f2ff8a72d5dff48c6 (patch)
tree1070b855ee68c75c035bc4cf02df35c01169721d /vdrmanager/src/de
parentfb3e8078a0168b36e954352f68da02e73c3c4b0c (diff)
downloadvdr-manager-87ae5319f8870032e87b3c5f2ff8a72d5dff48c6.tar.gz
vdr-manager-87ae5319f8870032e87b3c5f2ff8a72d5dff48c6.tar.bz2
support multiple vdr devices
Diffstat (limited to 'vdrmanager/src/de')
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/app/Intents.java4
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java23
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/OrmLiteBasePreferenceActivity.java89
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java491
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java478
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/VdrSharedPreferences.java171
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/db/OrmDatabaseHelper.java19
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java120
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java6
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BasePreferencesActivity.java5
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java8
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java5
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java28
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java59
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/PreferencesActivity.java48
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java7
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrListActivity.java133
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java115
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java167
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/ChannelClient.java10
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java4
21 files changed, 1596 insertions, 394 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/app/Intents.java b/vdrmanager/src/de/bjusystems/vdrmanager/app/Intents.java
index 853f772..ecac814 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/app/Intents.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/app/Intents.java
@@ -8,4 +8,8 @@ public interface Intents {
public static final int EDIT_TIMER = 0;
public static final int ADD_TIMER = 1;
+ public static final String VDR_ID = "VDR_ID";
+
+ public static final int EDIT_VDR = 2;
+
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java b/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java
index 73391d7..d2b5e3f 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java
@@ -12,24 +12,23 @@ import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.Preferences;
import de.bjusystems.vdrmanager.data.Timer;
import de.bjusystems.vdrmanager.data.Vdr;
+import de.bjusystems.vdrmanager.gui.Cache;
public class VdrManagerApp extends Application {
public enum EpgListState {
- EPG_TIME,
- EPG_CHANNEL,
- EPG_SEARCH
+ EPG_TIME, EPG_CHANNEL, EPG_SEARCH
}
private EpgListState epgListState;
private Event currentEvent;
private Timer currentTimer;
private Channel currentChannel;
-
- public static final Locale SYSTEM_LOCALE = Locale.getDefault() ;
-
+
+ public static final Locale SYSTEM_LOCALE = Locale.getDefault();
+
private Vdr currentVDR;
-
+
public Vdr getCurrentVDR() {
return currentVDR;
}
@@ -39,7 +38,7 @@ public class VdrManagerApp extends Application {
}
private List<Event> currentEpgList = new ArrayList<Event>();
-
+
public List<Event> getCurrentEpgList() {
return currentEpgList;
}
@@ -58,7 +57,7 @@ public class VdrManagerApp extends Application {
super.onCreate();
Preferences.init(this);
}
-
+
public void clear() {
this.currentEvent = null;
this.currentTimer = null;
@@ -94,7 +93,6 @@ public class VdrManagerApp extends Application {
this.epgListState = EpgListState.EPG_CHANNEL;
}
-
public EpgSearchParams getCurrentSearch() {
return currentSearch;
}
@@ -130,7 +128,10 @@ public class VdrManagerApp extends Application {
}
public void finishActivities() {
- for(final Activity activity : activitiesToFinish) {
+ for (final Activity activity : activitiesToFinish) {
+ if (activity instanceof Cache) {
+ ((Cache) activity).reset();
+ }
activity.finish();
}
activitiesToFinish.clear();
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/OrmLiteBasePreferenceActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/OrmLiteBasePreferenceActivity.java
new file mode 100644
index 0000000..eae8302
--- /dev/null
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/OrmLiteBasePreferenceActivity.java
@@ -0,0 +1,89 @@
+package de.bjusystems.vdrmanager.data;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+
+import com.j256.ormlite.android.apptools.OpenHelperManager;
+import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
+import com.j256.ormlite.support.ConnectionSource;
+
+public abstract class OrmLiteBasePreferenceActivity<H extends OrmLiteSqliteOpenHelper> extends PreferenceActivity {
+
+
+ private volatile H helper;
+ private volatile boolean created = false;
+ private volatile boolean destroyed = false;
+
+ /**
+ * Get a helper for this action.
+ */
+ public H getHelper() {
+ if (helper == null) {
+ if (!created) {
+ throw new IllegalStateException("A call has not been made to onCreate() yet so the helper is null");
+ } else if (destroyed) {
+ throw new IllegalStateException(
+ "A call to onDestroy has already been made and the helper cannot be used after that point");
+ } else {
+ throw new IllegalStateException("Helper is null for some unknown reason");
+ }
+ } else {
+ return helper;
+ }
+ }
+
+ /**
+ * Get a connection source for this action.
+ */
+ public ConnectionSource getConnectionSource() {
+ return getHelper().getConnectionSource();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ if (helper == null) {
+ helper = getHelperInternal(this);
+ created = true;
+ }
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ releaseHelper(helper);
+ destroyed = true;
+ }
+
+ /**
+ * This is called internally by the class to populate the helper object instance. This should not be called directly
+ * by client code unless you know what you are doing. Use {@link #getHelper()} to get a helper instance. If you are
+ * managing your own helper creation, override this method to supply this activity with a helper instance.
+ *
+ * <p>
+ * <b> NOTE: </b> If you override this method, you most likely will need to override the
+ * {@link #releaseHelper(OrmLiteSqliteOpenHelper)} method as well.
+ * </p>
+ */
+ protected H getHelperInternal(Context context) {
+ @SuppressWarnings({ "unchecked", "deprecation" })
+ H newHelper = (H) OpenHelperManager.getHelper(context);
+ return newHelper;
+ }
+
+ /**
+ * Release the helper instance created in {@link #getHelperInternal(Context)}. You most likely will not need to call
+ * this directly since {@link #onDestroy()} does it for you.
+ *
+ * <p>
+ * <b> NOTE: </b> If you override this method, you most likely will need to override the
+ * {@link #getHelperInternal(Context)} method as well.
+ * </p>
+ */
+ protected void releaseHelper(H helper) {
+ OpenHelperManager.releaseHelper();
+ this.helper = null;
+ }
+
+} \ No newline at end of file
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java
index 33a248b..9ad1e8e 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java
@@ -1,11 +1,16 @@
package de.bjusystems.vdrmanager.data;
+import java.util.List;
import java.util.Locale;
import android.content.Context;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
+import android.widget.Toast;
import de.bjusystems.vdrmanager.R;
+import de.bjusystems.vdrmanager.data.db.OrmDatabaseHelper;
+import de.bjusystems.vdrmanager.gui.VdrListActivity;
/**
* Class for all preferences
@@ -16,108 +21,33 @@ import de.bjusystems.vdrmanager.R;
public class Preferences {
public static final String DEFAULT_LANGUAGE_VALUE = "DEFAULT";
-
+
public static final String PREFERENCE_FILE_NAME = "VDR-Manager";
- private boolean ssl;
- /** SVDRP host name or ip */
- private String svdrpHost;
- /** SVDRP port */
- private int svdrpPort;
- /** Password */
- private String password;
- /** should channels be filtered? */
- private boolean filterChannels;
- /** last channel to retrieve */
- private String channels;
- /** Enable remote wakeup */
- private boolean wakeupEnabled;
- /** URL of the wakeup script */
- private String wakeupUrl;
- /** User for wakeup */
- private String wakeupUser;
- /** Password for wakeup */
- private String wakeupPassword;
- /**
- * vdr mac for wol
- *
- * @since 0.2
- */
- private String vdrMac;
- /**
- * which wakeup method to use
- *
- * @since 0.2
- *
- */
- private String wakeupMethod;
- /** Check for running VDR is enabled */
- private boolean aliveCheckEnabled;
- /** Intervall for alive test */
- private int aliveCheckInterval;
- /** Buffer before event */
- private int timerPreMargin;
- /** Buffer after event */
- private int timerPostMargin;
- /** Default priority */
- private int timerDefaultPriority;
- /** Default lifetime */
- private int timerDefaultLifetime;
- /** user defined epg search times */
- private String epgSearchTimes;
- /**
- * Which port to use for streaming
- *
- * @since 0.2
- */
- private int streamPort = 3000;
-
- private String streamingUsername = "";
-
- private String streamingPassword = "";
+ private static Vdr current;
- /**
- * Which format to use for streaming
- *
- * @since 0.2
- */
- private String streamFormat = "TS";
+ private static OrmDatabaseHelper db;
- /**
- * format times AM/PM or 24H
- *
- * @since 0.2
- */
- private boolean use24hFormat;
+ public static OrmDatabaseHelper getDatabaseHelper() {
+ return db;
+ }
- /**
- * Do not send broadcasts, send directly to the host (router problem)
- *
- * @since 0.2
- */
- private String wolCustomBroadcast = "";
+ public static void setCurrentVdr(Context context, Vdr vdr) {
+ setCurrentInternal(context, vdr);
+ }
+
+ public Vdr getCurrentVdr() {
+ return current;
+ }
+ /** user defined epg search times */
+ private String epgSearchTimes;
/**
- * Whether to show channel numbers in the overviews
+ * format times AM/PM or 24H
*
* @since 0.2
*/
- private boolean showChannelNumbers = false;
-
- /**
- * Use remux ?
- */
- private boolean enableRemux;
-
- /**
- * Remux command
- */
- private String remuxCommand;
-
- /**
- * Remux command Parameter
- */
- private String remuxParameter;
+ private boolean use24hFormat;
/**
* Quits the app on back button
@@ -134,50 +64,22 @@ public class Preferences {
*/
private String imdbUrl = "akas.imdb.com";
- /**
- * Connection timeout
- */
- private int connectionTimeout;
-
- /**
- * Read Timeout
- */
- private int readTimeout;
-
- /**
- * Timeout for a whole command run
- */
- private int timeout;
+ private boolean showChannelNumbers = false;
- private String encoding = "utf-8";
-
-
public String getEncoding() {
- return encoding;
+ return getCurrentVdr().getEncoding();
}
public int getConnectionTimeout() {
- return connectionTimeout;
+ return getCurrentVdr().getConnectionTimeout();
}
public int getReadTimeout() {
- return readTimeout;
+ return getCurrentVdr().getReadTimeout();
}
public int getTimeout() {
- return timeout;
- }
-
- public void setConnectionTimeout(int connectionTimeout) {
- this.connectionTimeout = connectionTimeout;
- }
-
- public void setReadTimeout(int readTimeout) {
- this.readTimeout = readTimeout;
- }
-
- public void setTimeout(int timeout) {
- this.timeout = timeout;
+ return getCurrentVdr().getTimeout();
}
public String getImdbUrl() {
@@ -195,13 +97,12 @@ public class Preferences {
return showImdbButton;
}
-
public String getStreamingUsername() {
- return streamingUsername;
+ return getCurrentVdr().getStreamingUsername();
}
public String getStreamingPassword() {
- return streamingPassword;
+ return getCurrentVdr().getStreamingPassword();
}
/** Properties singleton */
@@ -215,7 +116,7 @@ public class Preferences {
* @since 0.2
*/
public String getWolCustomBroadcast() {
- return wolCustomBroadcast;
+ return getCurrentVdr().getWolCustomBroadcast();
}
/**
@@ -233,8 +134,8 @@ public class Preferences {
*
* @return true, if use SSL connections
*/
- public boolean isSSL() {
- return ssl;
+ public boolean isSecure() {
+ return getCurrentVdr().isSecure();
}
/**
@@ -243,7 +144,7 @@ public class Preferences {
* @return true, if channels will be filtered
*/
public boolean isFilterChannels() {
- return filterChannels;
+ return getCurrentVdr().isFilterChannels();
}
/**
@@ -252,7 +153,7 @@ public class Preferences {
* @return channel number
*/
public String getChannels() {
- return filterChannels ? channels : "";
+ return isFilterChannels() ? getCurrentVdr().getChannelFilter() : "";
}
/**
@@ -261,7 +162,7 @@ public class Preferences {
* @return SVDRP host
*/
public String getSvdrpHost() {
- return svdrpHost;
+ return getCurrentVdr().getHost();
}
/**
@@ -270,7 +171,7 @@ public class Preferences {
* @return SVDRP port
*/
public int getSvdrpPort() {
- return svdrpPort;
+ return getCurrentVdr().getPort();
}
/**
@@ -279,7 +180,7 @@ public class Preferences {
* @return SVDRO password
*/
public String getPassword() {
- return password;
+ return getCurrentVdr().getPassword();
}
/**
@@ -288,7 +189,9 @@ public class Preferences {
* @return true, if remote wakeup is enabled
*/
public boolean isWakeupEnabled() {
- return wakeupEnabled;
+ return true;
+ // TODO
+ // return getCurrentVdr().isWakeupEnabled();
}
/**
@@ -297,7 +200,7 @@ public class Preferences {
* @return wakeup url
*/
public String getWakeupUrl() {
- return wakeupUrl;
+ return getCurrentVdr().getWakeupUrl();
}
/**
@@ -306,7 +209,7 @@ public class Preferences {
* @return user name
*/
public String getWakeupUser() {
- return wakeupUser;
+ return getCurrentVdr().getWakeupUser();
}
/**
@@ -315,7 +218,7 @@ public class Preferences {
* @return password
*/
public String getWakeupPassword() {
- return wakeupPassword;
+ return getCurrentVdr().getWakeupPassword();
}
/**
@@ -324,7 +227,7 @@ public class Preferences {
* @return true, if enabled
*/
public boolean isAliveCheckEnabled() {
- return aliveCheckEnabled;
+ return getCurrentVdr().isAliveCheckEnabled();
}
/**
@@ -333,7 +236,7 @@ public class Preferences {
* @return time in seconds
*/
public int getAliveCheckInterval() {
- return aliveCheckInterval;
+ return getCurrentVdr().getAliveCheckInterval();
}
/**
@@ -342,7 +245,7 @@ public class Preferences {
* @return pre event buffer
*/
public int getTimerPreMargin() {
- return timerPreMargin;
+ return getCurrentVdr().getTimerPreMargin();
}
/**
@@ -351,7 +254,7 @@ public class Preferences {
* @return post event buffer
*/
public int getTimerPostMargin() {
- return timerPostMargin;
+ return getCurrentVdr().getTimerPostMargin();
}
/**
@@ -360,7 +263,7 @@ public class Preferences {
* @return default priority
*/
public int getTimerDefaultPriority() {
- return timerDefaultPriority;
+ return getCurrentVdr().getTimerDefaultPriority();
}
/**
@@ -369,7 +272,7 @@ public class Preferences {
* @return default lifetime
*/
public int getTimerDefaultLifetime() {
- return timerDefaultLifetime;
+ return getCurrentVdr().getTimerDefaultLifetime();
}
/**
@@ -388,7 +291,7 @@ public class Preferences {
* @since 0.2
*/
public String getVdrMac() {
- return vdrMac;
+ return getCurrentVdr().getMac();
}
/**
@@ -398,7 +301,7 @@ public class Preferences {
* @since 0.2
*/
public String getWakeupMethod() {
- return wakeupMethod;
+ return getCurrentVdr().getWakeupMethod();
}
/**
@@ -408,9 +311,9 @@ public class Preferences {
* @since 02.
*/
public int getStreamPort() {
- return streamPort;
+ return getCurrentVdr().getStreamPort();
}
-
+
/**
* Getter for selected streaming format
*
@@ -418,7 +321,7 @@ public class Preferences {
* @since 0.2
*/
public String getStreamFormat() {
- return streamFormat;
+ return getCurrentVdr().getStreamFormat();
}
/**
@@ -467,7 +370,7 @@ public class Preferences {
* @return
*/
public boolean isEnableRemux() {
- return enableRemux;
+ return getCurrentVdr().isEnableRemux();
}
/**
@@ -476,7 +379,7 @@ public class Preferences {
* @return
*/
public String getRemuxCommand() {
- return remuxCommand;
+ return getCurrentVdr().getRemuxCommand();
}
/**
@@ -485,7 +388,7 @@ public class Preferences {
* @return
*/
public String getRemuxParameter() {
- return remuxParameter;
+ return getCurrentVdr().getRemuxParameter();
}
/**
@@ -519,65 +422,69 @@ public class Preferences {
private static void initInternal(final Context context) {
final Preferences prefs = new Preferences();
-
- prefs.svdrpHost = getString(context, R.string.vdr_host_key, "0.0.0.0");
- prefs.svdrpPort = getInt(context, R.string.vdr_port_key, 6420);
- prefs.password = getString(context, R.string.vdr_password_key, "");
- prefs.ssl = getBoolean(context, R.string.vdr_ssl_key, false);
- prefs.streamPort = getInt(context, R.string.vdr_stream_port, 3000);
- prefs.streamFormat = getString(context, R.string.vdr_stream_format,
- "TS");
-
- prefs.aliveCheckEnabled = getBoolean(context,
- R.string.alive_check_enabled_key, false);
- prefs.aliveCheckInterval = getInt(context,
- R.string.alive_check_interval_key, 60);
-
- prefs.channels = getString(context, R.string.channel_filter_last_key,
- "").replace(" ", "");
- prefs.filterChannels = getBoolean(context,
- R.string.channel_filter_filter_key, false);
-
- prefs.wakeupEnabled = getBoolean(context, R.string.wakeup_enabled_key,
- false);
- prefs.wakeupUrl = getString(context, R.string.wakeup_url_key, "");
- prefs.wakeupUser = getString(context, R.string.wakeup_user_key, "");
- prefs.wakeupPassword = getString(context, R.string.wakeup_password_key,
- "");
-
- prefs.timerPreMargin = getInt(context,
- R.string.timer_pre_start_buffer_key, 5);
- prefs.timerPostMargin = getInt(context,
- R.string.timer_post_end_buffer_key, 30);
- prefs.timerDefaultPriority = getInt(context,
- R.string.timer_default_priority_key, 99);
- prefs.timerDefaultLifetime = getInt(context,
- R.string.timer_default_lifetime_key, 99);
-
+ //
+ // prefs.svdrpHost = getString(context, R.string.vdr_host_key,
+ // "0.0.0.0");
+ // prefs.svdrpPort = getInt(context, R.string.vdr_port_key, 6420);
+ // prefs.password = getString(context, R.string.vdr_password_key, "");
+ // prefs.ssl = getBoolean(context, R.string.vdr_ssl_key, false);
+ // prefs.streamPort = getInt(context, R.string.vdr_stream_port, 3000);
+ // prefs.streamFormat = getString(context, R.string.vdr_stream_format,
+ // "TS");
+ //
+ // prefs.aliveCheckEnabled = getBoolean(context,
+ // R.string.alive_check_enabled_key, false);
+ // prefs.aliveCheckInterval = getInt(context,
+ // R.string.alive_check_interval_key, 60);
+ //
+ // prefs.channels = getString(context, R.string.channel_filter_last_key,
+ // "").replace(" ", "");
+ // prefs.filterChannels = getBoolean(context,
+ // R.string.channel_filter_filter_key, false);
+ //
+ // prefs.wakeupEnabled = getBoolean(context,
+ // R.string.wakeup_enabled_key,
+ // false);
+ // prefs.wakeupUrl = getString(context, R.string.wakeup_url_key, "");
+ // prefs.wakeupUser = getString(context, R.string.wakeup_user_key, "");
+ // prefs.wakeupPassword = getString(context,
+ // R.string.wakeup_password_key,
+ // "");
+ //
+ // prefs.timerPreMargin = getInt(context,
+ // R.string.timer_pre_start_buffer_key, 5);
+ // prefs.timerPostMargin = getInt(context,
+ // R.string.timer_post_end_buffer_key, 30);
+ // prefs.timerDefaultPriority = getInt(context,
+ // R.string.timer_default_priority_key, 99);
+ // prefs.timerDefaultLifetime = getInt(context,
+ // R.string.timer_default_lifetime_key, 99);
+ //
prefs.epgSearchTimes = getString(context,
R.string.epg_search_times_key, "");
-
- prefs.vdrMac = getString(context, R.string.wakeup_wol_mac_key, "");
- prefs.wakeupMethod = getString(context, R.string.wakeup_method_key,
- "url");
-
- prefs.use24hFormat = getBoolean(context,
- R.string.gui_enable_24h_format_key, true);
-
- prefs.wolCustomBroadcast = getString(context,
- R.string.wakeup_wol_custom_broadcast_key, "");
-
+ //
+ // prefs.vdrMac = getString(context, R.string.wakeup_wol_mac_key, "");
+ // prefs.wakeupMethod = getString(context, R.string.wakeup_method_key,
+ // "url");
+ //
+ // prefs.use24hFormat = getBoolean(context,
+ // R.string.gui_enable_24h_format_key, true);
+ //
+ // prefs.wolCustomBroadcast = getString(context,
+ // R.string.wakeup_wol_custom_broadcast_key, "");
+ //
prefs.showChannelNumbers = getBoolean(context,
R.string.gui_channels_show_channel_numbers_key, false);
-
- prefs.enableRemux = getBoolean(context, R.string.key_remux_enable,
- false);
-
- prefs.remuxCommand = getString(context, R.string.key_remux_command,
- "EXT");
-
- prefs.remuxParameter = getString(context, R.string.key_remux_parameter,
- "");
+ //
+ // prefs.enableRemux = getBoolean(context, R.string.key_remux_enable,
+ // false);
+ //
+ // prefs.remuxCommand = getString(context, R.string.key_remux_command,
+ // "EXT");
+ //
+ // prefs.remuxParameter = getString(context,
+ // R.string.key_remux_parameter,
+ // "");
prefs.quiteOnBackButton = getBoolean(context,
R.string.qui_quit_on_back_key, true);
@@ -586,18 +493,23 @@ public class Preferences {
R.string.qui_show_imdb_button_key, true);
prefs.imdbUrl = getString(context, R.string.qui_imdb_url_key, "imdb.de");
-
- prefs.connectionTimeout = getInt(context, R.string.vdr_conntimeout_key,
- 10);
- prefs.readTimeout = getInt(context, R.string.vdr_readtimeout_key, 10);
- prefs.timeout = getInt(context, R.string.vdr_timeout_key, 120);
-
- prefs.streamingUsername = getString(context, R.string.streaming_username_key, "");
-
- prefs.streamingPassword = getString(context, R.string.streaming_password_key, "");
-
- prefs.encoding = getString(context, R.string.vdr_encoding_key, "utf-8");
-
+ //
+ // prefs.connectionTimeout = getInt(context,
+ // R.string.vdr_conntimeout_key,
+ // 10);
+ // prefs.readTimeout = getInt(context, R.string.vdr_readtimeout_key,
+ // 10);
+ // prefs.timeout = getInt(context, R.string.vdr_timeout_key, 120);
+ //
+ // prefs.streamingUsername = getString(context,
+ // R.string.streaming_username_key, "");
+ //
+ // prefs.streamingPassword = getString(context,
+ // R.string.streaming_password_key, "");
+ //
+ // prefs.encoding = getString(context, R.string.vdr_encoding_key,
+ // "utf-8");
+ //
thePrefs = prefs;
}
@@ -613,10 +525,12 @@ public class Preferences {
* @return Preferences
*/
public static void init(final Context context) {
-
// if (thePrefs != null) {
// return;
// }
+ if (db == null) {
+ db = new OrmDatabaseHelper(context);
+ }
synchronized (Preferences.class) {
// if (thePrefs != null) {
@@ -626,6 +540,130 @@ public class Preferences {
setLocale(context);
}
+ // if (current != null) {
+ // return;
+ // }
+
+ final SharedPreferences sharedPrefs = getSharedPreferences(context);
+ int id = sharedPrefs.getInt(
+ context.getString(R.string.current_vdr_id_key), -1);
+
+ Vdr vdr = null;
+ if (id != -1) {
+ vdr = db.getVdrDAO().queryForId(id);
+ }
+
+ if (vdr != null) {
+ setCurrentInternal(context, vdr);
+ return;
+ }
+
+ List<Vdr> list = db.getVdrDAO().queryForAll();
+ if (list != null && list.isEmpty() == false) {
+ vdr = list.get(0);
+ setCurrentInternal(context, vdr);
+ return;
+ }
+ if (initFromOldVersion(context) == false) {
+ Intent intent = new Intent();
+ intent.setClass(context, VdrListActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(intent);
+ Toast.makeText(context, R.string.no_vdr, Toast.LENGTH_SHORT).show();
+ }
+
+ }
+
+ 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"));
+ vdr.setName("Default");
+ vdr.setPort(getInt(context, R.string.vdr_port_key, 6420));
+ vdr.setPassword(getString(context, R.string.vdr_password_key, ""));
+ vdr.setSecure(getBoolean(context, R.string.vdr_ssl_key, false));
+ vdr.setStreamPort(getInt(context, R.string.vdr_stream_port, 3000));
+ vdr.setStreamFormat(getString(context, R.string.vdr_stream_format, "TS"));
+
+ vdr.setAliveCheckEnabled(getBoolean(context,
+ R.string.alive_check_enabled_key, false));
+ vdr.setAliveCheckInterval(getInt(context,
+ R.string.alive_check_interval_key, 60));
+
+ vdr.setChannelFilter(getString(context,
+ R.string.channel_filter_last_key, "").replace(" ", ""));
+ vdr.setFilterChannels(getBoolean(context,
+ R.string.channel_filter_filter_key, false));
+ vdr.setWakeupEnabled(getBoolean(context, R.string.wakeup_enabled_key,
+ false));
+ vdr.setWakeupUrl(getString(context, R.string.wakeup_url_key, ""));
+ vdr.setWakeupUser(getString(context, R.string.wakeup_user_key, ""));
+ vdr.setWakeupPassword(getString(context, R.string.wakeup_password_key,
+ ""));
+
+ vdr.setTimerPreMargin(getInt(context,
+ R.string.timer_pre_start_buffer_key, 5));
+ vdr.setTimerPostMargin(getInt(context,
+ R.string.timer_post_end_buffer_key, 30));
+
+ vdr.setTimerDefaultPriority(getInt(context,
+ R.string.timer_default_priority_key, 99));
+
+ vdr.setTimerDefaultLifetime(getInt(context,
+ R.string.timer_default_lifetime_key, 99));
+
+ vdr.setEpgSearchTimes(getString(context, R.string.epg_search_times_key,
+ ""));
+
+ vdr.setMac(getString(context, R.string.wakeup_wol_mac_key, ""));
+
+ vdr.setWakeupMethod(getString(context, R.string.wakeup_method_key,
+ "url"));
+
+ vdr.setWolCustomBroadcast(getString(context,
+ R.string.wakeup_wol_custom_broadcast_key, ""));
+
+ vdr.setConnectionTimeout(getInt(context, R.string.vdr_conntimeout_key,
+ 10));
+ vdr.setReadTimeout(getInt(context, R.string.vdr_readtimeout_key, 10));
+ vdr.setTimeout(getInt(context, R.string.vdr_timeout_key, 120));
+
+ vdr.setStreamingUsername(getString(context,
+ R.string.streaming_username_key, ""));
+
+ vdr.setStreamingPassword(getString(context,
+ R.string.streaming_password_key, ""));
+
+ vdr.setEncoding(getString(context, R.string.vdr_encoding_key, "utf-8"));
+
+ if (db.getVdrDAO().create(vdr) != 1) {
+ return false;
+ }
+
+ setCurrentInternal(context, vdr);
+
+ return true;
}
/**
@@ -705,18 +743,19 @@ public class Preferences {
* {@link Context}
*/
public static void setLocale(final Context context) {
- String lc = getString(context, R.string.gui_custom_locale_key, DEFAULT_LANGUAGE_VALUE);
+ String lc = getString(context, R.string.gui_custom_locale_key,
+ DEFAULT_LANGUAGE_VALUE);
Locale locale = null;
- //TODO lado this is very bad.
+ // TODO lado this is very bad.
if (lc.equals(DEFAULT_LANGUAGE_VALUE)) {
String lang = Locale.getDefault().toString();
if (lang.startsWith("de")) {
locale = Locale.GERMAN;
- } else if(lang.startsWith("it")){
+ } else if (lang.startsWith("it")) {
locale = Locale.ITALIAN;
} else {
locale = Locale.ENGLISH;
- }
+ }
} else {
locale = new Locale(lc);
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java
index 51eb82b..3369334 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java
@@ -1,73 +1,108 @@
package de.bjusystems.vdrmanager.data;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.j256.ormlite.field.DatabaseField;
+import com.j256.ormlite.table.DatabaseTable;
+
+@DatabaseTable
public class Vdr {
-
+
+ /**
+ *
+ */
+ @DatabaseField(columnName = "_id", generatedId = true)
+ private Integer id;
+
+ @DatabaseField(columnName = "name")
+ private String name;
+
/**
- * Use secure channel
+ * Use secure channel
*/
+ @DatabaseField(defaultValue = "false")
private boolean secure;
-
+
/** SVDRP host name or ip */
+ @DatabaseField
private String host;
-
+
/** SVDRP port */
+ @DatabaseField
private int port;
-
+
/** Password */
+ @DatabaseField
private String password;
-
+
/** should channels be filtered? */
+ @DatabaseField
private boolean filterChannels;
-
+
/** last channel to retrieve */
+ @DatabaseField
private String channelFilter;
-
+
/** Enable remote wakeup */
+ @DatabaseField
private boolean wakeupEnabled;
-
+
/** URL of the wakeup script */
+ @DatabaseField
private String wakeupUrl;
-
+
/** User for wakeup */
+ @DatabaseField
private String wakeupUser;
-
+
/** Password for wakeup */
+ @DatabaseField
private String wakeupPassword;
-
+
/**
* vdr mac for wol
*
* @since 0.2
*/
+ @DatabaseField
private String mac;
-
+
/**
* which wakeup method to use
*
* @since 0.2
*
*/
+ @DatabaseField
private String wakeupMethod;
-
+
/** Check for running VDR is enabled */
+ @DatabaseField
private boolean aliveCheckEnabled;
-
+
/** Intervall for alive test */
+ @DatabaseField
private int aliveCheckInterval;
-
+
/** Buffer before event */
+ @DatabaseField
private int timerPreMargin;
-
+
/** Buffer after event */
+ @DatabaseField
private int timerPostMargin;
-
+
/** Default priority */
+ @DatabaseField
private int timerDefaultPriority;
-
+
/** Default lifetime */
+ @DatabaseField
private int timerDefaultLifetime;
-
+
/** user defined epg search times */
+ @DatabaseField
private String epgSearchTimes;
/**
@@ -75,6 +110,7 @@ public class Vdr {
*
* @since 0.2
*/
+ @DatabaseField
private int streamPort = 3000;
/**
@@ -82,6 +118,7 @@ public class Vdr {
*
* @since 0.2
*/
+ @DatabaseField
private String streamFormat = "TS";
/**
@@ -89,22 +126,421 @@ public class Vdr {
*
* @since 0.2
*/
+ @DatabaseField
private String wolCustomBroadcast = "";
-
/**
* Use remux ?
*/
+ @DatabaseField
private boolean enableRemux;
/**
* Remux command
*/
+ @DatabaseField
private String remuxCommand;
/**
* Remux command Parameter
*/
+ @DatabaseField
private String remuxParameter;
+ @DatabaseField
+ private String encoding = "utf-8";
+
+ /**
+ * Connection timeout
+ */
+ @DatabaseField
+ private int connectionTimeout;
+
+ /**
+ * Read Timeout
+ */
+ @DatabaseField
+ private int readTimeout;
+
+ /**
+ * Timeout for a whole command run
+ */
+ @DatabaseField
+ private int timeout;
+
+ @DatabaseField
+ private String streamingUsername;
+
+ @DatabaseField
+ private String streamingPassword;
+
+ public String getStreamingPassword() {
+ return streamingPassword;
+ }
+
+ public void setStreamingPassword(String streamingPassword) {
+ this.streamingPassword = streamingPassword;
+ }
+
+ public String getStreamingUsername() {
+ return streamingUsername;
+ }
+
+ public void setStreamingUsername(String streamingUsername) {
+ this.streamingUsername = streamingUsername;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isSecure() {
+ return secure;
+ }
+
+ public void setSecure(boolean secure) {
+ this.secure = secure;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public boolean isFilterChannels() {
+ return filterChannels;
+ }
+
+ public void setFilterChannels(boolean filterChannels) {
+ this.filterChannels = filterChannels;
+ }
+
+ public String getChannelFilter() {
+ return channelFilter;
+ }
+
+ public void setChannelFilter(String channelFilter) {
+ this.channelFilter = channelFilter;
+ }
+
+ public boolean isWakeupEnabled() {
+ return wakeupEnabled;
+ }
+
+ public void setWakeupEnabled(boolean wakeupEnabled) {
+ this.wakeupEnabled = wakeupEnabled;
+ }
+
+ public String getWakeupUrl() {
+ return wakeupUrl;
+ }
+
+ public void setWakeupUrl(String wakeupUrl) {
+ this.wakeupUrl = wakeupUrl;
+ }
+
+ public String getWakeupUser() {
+ return wakeupUser;
+ }
+
+ public void setWakeupUser(String wakeupUser) {
+ this.wakeupUser = wakeupUser;
+ }
+
+ public String getWakeupPassword() {
+ return wakeupPassword;
+ }
+
+ public void setWakeupPassword(String wakeupPassword) {
+ this.wakeupPassword = wakeupPassword;
+ }
+
+ public String getMac() {
+ return mac;
+ }
+
+ public void setMac(String mac) {
+ this.mac = mac;
+ }
+
+ public String getWakeupMethod() {
+ return wakeupMethod;
+ }
+
+ public void setWakeupMethod(String wakeupMethod) {
+ this.wakeupMethod = wakeupMethod;
+ }
+
+ public boolean isAliveCheckEnabled() {
+ return aliveCheckEnabled;
+ }
+
+ public void setAliveCheckEnabled(boolean aliveCheckEnabled) {
+ this.aliveCheckEnabled = aliveCheckEnabled;
+ }
+
+ public int getAliveCheckInterval() {
+ return aliveCheckInterval;
+ }
+
+ public void setAliveCheckInterval(int aliveCheckInterval) {
+ this.aliveCheckInterval = aliveCheckInterval;
+ }
+
+ public int getTimerPreMargin() {
+ return timerPreMargin;
+ }
+
+ public void setTimerPreMargin(int timerPreMargin) {
+ this.timerPreMargin = timerPreMargin;
+ }
+
+ public int getTimerPostMargin() {
+ return timerPostMargin;
+ }
+
+ public void setTimerPostMargin(int timerPostMargin) {
+ this.timerPostMargin = timerPostMargin;
+ }
+
+ public int getTimerDefaultPriority() {
+ return timerDefaultPriority;
+ }
+
+ public void setTimerDefaultPriority(int timerDefaultPriority) {
+ this.timerDefaultPriority = timerDefaultPriority;
+ }
+
+ public int getTimerDefaultLifetime() {
+ return timerDefaultLifetime;
+ }
+
+ public void setTimerDefaultLifetime(int timerDefaultLifetime) {
+ this.timerDefaultLifetime = timerDefaultLifetime;
+ }
+
+ public String getEpgSearchTimes() {
+ return epgSearchTimes;
+ }
+
+ public void setEpgSearchTimes(String epgSearchTimes) {
+ this.epgSearchTimes = epgSearchTimes;
+ }
+
+ public int getStreamPort() {
+ return streamPort;
+ }
+
+ public void setStreamPort(int streamPort) {
+ this.streamPort = streamPort;
+ }
+
+ public String getStreamFormat() {
+ return streamFormat;
+ }
+
+ public void setStreamFormat(String streamFormat) {
+ this.streamFormat = streamFormat;
+ }
+
+ public String getWolCustomBroadcast() {
+ return wolCustomBroadcast;
+ }
+
+ public void setWolCustomBroadcast(String wolCustomBroadcast) {
+ this.wolCustomBroadcast = wolCustomBroadcast;
+ }
+
+ public boolean isEnableRemux() {
+ return enableRemux;
+ }
+
+ public void setEnableRemux(boolean enableRemux) {
+ this.enableRemux = enableRemux;
+ }
+
+ public String getRemuxCommand() {
+ return remuxCommand;
+ }
+
+ public void setRemuxCommand(String remuxCommand) {
+ this.remuxCommand = remuxCommand;
+ }
+
+ public String getRemuxParameter() {
+ return remuxParameter;
+ }
+
+ public void setRemuxParameter(String remuxParameter) {
+ this.remuxParameter = remuxParameter;
+ }
+
+ public String getEncoding() {
+ return encoding;
+ }
+
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
+ public int getConnectionTimeout() {
+ return connectionTimeout;
+ }
+
+ public void setConnectionTimeout(int connectionTimeout) {
+ this.connectionTimeout = connectionTimeout;
+ }
+
+ public int getReadTimeout() {
+ return readTimeout;
+ }
+
+ public void setReadTimeout(int readTimeout) {
+ this.readTimeout = readTimeout;
+ }
+
+ public int getTimeout() {
+ return timeout;
+ }
+
+ public void setTimeout(int timeout) {
+ this.timeout = timeout;
+ }
+
+ private static <T> T get(Map<String, Object> map, String key) {
+ return (T) map.get(key);
+ }
+
+ private static Integer getInteger(Map<String, Object> map, String key) {
+ if (map.containsKey(key) == false) {
+ return Integer.valueOf(0);
+ }
+
+ Object obj = get(map, key);
+ if (obj instanceof Integer) {
+ return (Integer) obj;
+ }
+ return Integer.valueOf(String.valueOf(obj));
+ }
+
+ private static Boolean getBoolean(Map<String, Object> map, String key) {
+ if (map.containsKey(key) == false) {
+ return Boolean.FALSE;
+ }
+ Object obj = get(map, key);
+ if (obj instanceof Boolean) {
+ return (Boolean) obj;
+ }
+ return Boolean.valueOf(String.valueOf(obj));
+ }
+
+ public HashMap<String, Object> toMap() {
+ HashMap<String, Object> map = new HashMap<String, Object>();
+ map.put("vdr_name", name);
+ map.put("vdr_host", host);
+ map.put("vdr_port", port);
+ map.put("vdr_password", password);
+ map.put("vdr_secure", secure);
+
+ map.put("limit_channels", filterChannels);
+ map.put("last_channel", channelFilter);
+
+ map.put("key_wakeup_enabled", wakeupEnabled);
+ map.put("key_wakeup_url", wakeupUrl);
+ map.put("key_wakeup_user", wakeupUser);
+ map.put("key_wakeup_password", wakeupPassword);
+ map.put("key_wakeup_method", wakeupMethod);
+ map.put("key_wol_custom_broadcast", wolCustomBroadcast);
+ map.put("key_wakeup_wol_mac", mac);
+
+ map.put("key_conntimeout_key", connectionTimeout);
+ map.put("key_vdr_readtimeout", readTimeout);
+ map.put("key_vdr_timeout", timeout);
+
+ map.put("timer_pre_start_buffer", timerPreMargin);
+ map.put("timer_post_end_buffer", timerPreMargin);
+ map.put("timer_default_priority", timerDefaultPriority);
+ map.put("timer_default_lifetime", timerDefaultLifetime);
+
+ map.put("streamingport", streamPort);
+ map.put("key_streaming_password", streamingPassword);
+ map.put("key_streaming_username", streamingUsername);
+ map.put("key_vdr_encoding", encoding);
+ map.put("livetv_streamformat", streamFormat);
+ map.put("remux_command", remuxCommand);
+ map.put("remux_parameter", remuxParameter);
+ map.put("remux_enable", enableRemux);
+
+ return map;
+ }
+
+ public void init(Map<String, Object> map) {
+ name = get(map, "vdr_name");
+ host = get(map, "vdr_host");
+ port = getInteger(map, "vdr_port");
+ password = get(map, "vdr_password");
+ secure = getBoolean(map, "vdr_secure");
+
+ filterChannels = getBoolean(map, "limit_channels");
+ 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");
+
+ connectionTimeout = getInteger(map, "key_conntimeout_key");
+ readTimeout = getInteger(map, "key_vdr_readtimeout");
+ timeout = getInteger(map, "key_vdr_timeout");
+
+ timerPreMargin = getInteger(map, "timer_pre_start_buffer");
+ timerPreMargin = getInteger(map, "timer_post_end_buffer");
+ timerDefaultPriority = getInteger(map, "timer_default_priority");
+ timerDefaultLifetime = getInteger(map, "timer_default_lifetime");
+
+ streamPort = getInteger(map, "streamingport");
+ streamingPassword = get(map, "key_streaming_password");
+ streamingUsername = get(map, "key_streaming_username");
+ encoding = get(map, "key_vdr_encoding");
+ streamFormat = get(map, "livetv_streamformat");
+ remuxCommand = get(map, "remux_command");
+ remuxParameter = get(map, "remux_parameter");
+ enableRemux = get(map, "remux_enable");
+
+ }
+
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/VdrSharedPreferences.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/VdrSharedPreferences.java
new file mode 100644
index 0000000..bbaa74e
--- /dev/null
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/VdrSharedPreferences.java
@@ -0,0 +1,171 @@
+package de.bjusystems.vdrmanager.data;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import android.content.SharedPreferences;
+
+import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus;
+import com.j256.ormlite.dao.RuntimeExceptionDao;
+
+public class VdrSharedPreferences implements SharedPreferences {
+
+ private static final String EMPTY_STRING = "";
+
+ public RuntimeExceptionDao<Vdr, Integer> dao;
+
+ public Vdr instance;
+
+ protected List<OnSharedPreferenceChangeListener> listeners = new LinkedList<OnSharedPreferenceChangeListener>();
+
+ Map<String, Object> map = new HashMap<String, Object>();
+
+ public VdrSharedPreferences(){
+
+ }
+ public VdrSharedPreferences (Vdr vdr){
+ map.putAll(vdr.toMap());
+ instance = vdr;
+ }
+
+ public boolean contains(String key) {
+ return map.containsKey(key);
+ }
+
+ public Editor edit() {
+ return new Editor();
+ }
+
+ public Map<String, Object> getAll() {
+ return map;
+ }
+
+ public boolean getBoolean(String key, boolean defValue) {
+ return get(key, defValue);
+ }
+
+ public float getFloat(String key, float defValue) {
+ return get(key, defValue);
+ }
+
+ public int getInt(String key, int defValue) {
+ return get(key, defValue);
+ }
+
+ public long getLong(String key, long defValue) {
+ return get(key, defValue);
+ }
+
+ public <T> T get(String key, T defValue) {
+ if (map.containsKey(key)) {
+ return (T) map.get(key);
+ }
+ return defValue;
+ }
+
+ public String getString(String key, String defValue) {
+ Object obj = get(key, defValue);
+ if(obj == null){
+ return EMPTY_STRING;
+ }
+ return String.valueOf(obj);
+ }
+
+ public Set<String> getStringSet(String arg0, Set<String> arg1) {
+ return null;
+ }
+
+ public void registerOnSharedPreferenceChangeListener(
+ OnSharedPreferenceChangeListener listener) {
+ listeners.add(listener);
+ }
+
+ public void unregisterOnSharedPreferenceChangeListener(
+ OnSharedPreferenceChangeListener listener) {
+ listeners.remove(listener);
+ }
+
+
+ public class Editor implements SharedPreferences.Editor {
+
+ Map<String, Object> data = new HashMap<String, Object>();
+
+ public SharedPreferences.Editor clear() {
+ data.clear();
+ return this;
+ }
+
+ public boolean commit() {
+ instance.init(map);
+ CreateOrUpdateStatus custatus = dao.createOrUpdate(instance);
+
+
+ boolean status = custatus.isCreated() || custatus.isUpdated();
+
+ if(status == false)
+ return false;
+
+ // and update any listeners
+ for (OnSharedPreferenceChangeListener listener : listeners) {
+ listener.onSharedPreferenceChanged(
+ VdrSharedPreferences.this, null);
+ }
+
+ return true;
+ }
+
+
+ public android.content.SharedPreferences.Editor put(
+ String key, Object value) {
+ map.put(key, value);
+ return this;
+
+ }
+ public android.content.SharedPreferences.Editor putBoolean(
+ String key, boolean value) {
+ return put(key,value);
+ }
+
+ public android.content.SharedPreferences.Editor putFloat(
+ String key, float value) {
+ return put(key,value);
+ }
+
+ public android.content.SharedPreferences.Editor putInt(String key,
+ int value) {
+ return put(key,value);
+ }
+
+ public android.content.SharedPreferences.Editor putLong(String key,
+ long value) {
+ return put(key,value);
+ }
+
+ public android.content.SharedPreferences.Editor putString(
+ String key, String value) {
+ return put(key,value);
+ }
+
+ public android.content.SharedPreferences.Editor remove(String key) {
+ map.remove(key);
+ return this;
+ }
+
+
+ public void apply() {
+ commit();
+ }
+
+
+ public android.content.SharedPreferences.Editor putStringSet(
+ String arg0, Set<String> arg1) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ }
+
+}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/db/OrmDatabaseHelper.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/db/OrmDatabaseHelper.java
index 348260c..a9e0dd9 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/db/OrmDatabaseHelper.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/db/OrmDatabaseHelper.java
@@ -3,11 +3,16 @@ package de.bjusystems.vdrmanager.data.db;
import java.sql.SQLException;
import android.content.Context;
+import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
+import com.j256.ormlite.android.AndroidCompiledStatement;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.dao.RuntimeExceptionDao;
+import com.j256.ormlite.stmt.PreparedQuery;
+import com.j256.ormlite.stmt.QueryBuilder;
+import com.j256.ormlite.stmt.StatementBuilder.StatementType;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
@@ -80,7 +85,7 @@ public class OrmDatabaseHelper extends OrmLiteSqliteOpenHelper {
* Returns the Database Access Object (DAO) for our Label class. It will create it or just give the cached
* value.
*/
- public RuntimeExceptionDao<Vdr, Integer> getVDRDAO() {
+ public RuntimeExceptionDao<Vdr, Integer> getVdrDAO() {
if (vdrDAO == null) {
vdrDAO = getRuntimeExceptionDao(Vdr.class);
}
@@ -95,4 +100,16 @@ public class OrmDatabaseHelper extends OrmLiteSqliteOpenHelper {
super.close();
vdrDAO = null;
}
+
+ public Cursor getVdrCursor() throws SQLException {
+ QueryBuilder<Vdr, Integer> qb = getVdrDAO().queryBuilder();
+
+ PreparedQuery<Vdr> preparedQuery = qb.prepare();
+
+ AndroidCompiledStatement compiledStatement = (AndroidCompiledStatement) preparedQuery
+ .compile(getConnectionSource()
+ .getReadOnlyConnection(), StatementType.SELECT);
+
+ return compiledStatement.getCursor();
+ }
} \ No newline at end of file
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java
index e65f2eb..2d892e9 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java
@@ -1,15 +1,25 @@
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;
@@ -22,7 +32,7 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
public abstract class BaseActivity<Result, T extends ListView> extends Activity
- implements OnClickListener, SvdrpAsyncListener<Result> {
+ implements OnClickListener, SvdrpAsyncListener<Result>, Cache {
public static final String TAG = BaseActivity.class.getName();
@@ -35,9 +45,10 @@ public abstract class BaseActivity<Result, T extends ListView> extends Activity
protected ViewFlipper flipper;
private Button retry;
-
+
private ProgressDialog progress;
- //protected SvdrpProgressDialog progress;
+
+ // protected SvdrpProgressDialog progress;
abstract protected String getWindowTitle();
@@ -49,6 +60,20 @@ public abstract class BaseActivity<Result, T extends ListView> extends Activity
abstract protected boolean displayingResults();
+ protected boolean isForceRefresh() {
+ if (forceRefresh == false) {
+ return false;
+ }
+ forceRefresh = false;
+ return true;
+ }
+
+ protected boolean forceRefresh = false;
+
+ public void reset() {
+
+ }
+
protected void switchNoConnection() {
if (flipper == null) {
say(R.string.no_connection);
@@ -65,10 +90,10 @@ public abstract class BaseActivity<Result, T extends ListView> extends Activity
@Override
protected void onResume() {
Preferences.setLocale(this);
- //Preferences.init(this);
+ // Preferences.init(this);
super.onResume();
}
-
+
protected void initFlipper() {
this.flipper = (ViewFlipper) findViewById(R.id.flipper);
retry = (Button) findViewById(R.id.retry_button);
@@ -99,35 +124,92 @@ 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) {
super.onCreate(savedInstanceState);
Preferences.setLocale(this);
progress = new ProgressDialog(this);
+ getApp().addActivityToFinish(this);
+ initActionBar();
+
+ // your logic for click listner
+ // setListenerForActionBarCustomView(actionBarView);
+
+ // private void setListenerForActionBarCustomView(View actionBarView) {
+ // ActionBarCustomViewOnClickListener actionBarCustomViewOnClickListener
+ // = new ActionBarCustomViewOnClickListener();
+ // actionBarView.findViewById(R.id.text_view_title).setOnClickListener(actionBarCustomViewOnClickListener);
+ // }
+
}
-
+
@Override
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');
+
+ // MenuItem item;
+ // item = menu.add(MENU_GROUP_REFRESH, MENU_REFRESH, 0,
+ // R.string.refresh);
+ // item.setIcon(R.drawable.ic_menu_refresh);
+ // item.setAlphabeticShortcut('r');
+ MenuInflater inf = getMenuInflater();
+ inf.inflate(R.menu.refresh_menu, menu);
+
+ // SearchView searchView = (SearchView)
+ // menu.findItem(R.id.menu_search).getActionView();
+ // searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
+
return true;
}
abstract protected void refresh();
abstract protected void retry();
-
+
abstract protected SvdrpClient<Result> getClient();
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case MENU_REFRESH:
+ case R.id.list_refresh:
backupViewSelection();
refresh();
return true;
+ case android.R.id.home:
+ Intent intent = new Intent(this, VdrManagerActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(intent);
+ return true;
default:
return false;
}
@@ -205,7 +287,7 @@ public abstract class BaseActivity<Result, T extends ListView> extends Activity
int top;
protected boolean checkInternetConnection() {
- if(Utils.checkInternetConnection(this)){
+ if (Utils.checkInternetConnection(this)) {
return true;
}
noInternetConnection();
@@ -240,9 +322,9 @@ public abstract class BaseActivity<Result, T extends ListView> extends Activity
break;
case ERROR:
alert(R.string.epg_client_errors);
- progress.dismiss();
+ progress.dismiss();
break;
-
+
case CONNECTED:
connected();
break;
@@ -278,7 +360,7 @@ public abstract class BaseActivity<Result, T extends ListView> extends Activity
}
protected boolean finishedSuccess = false;
-
+
protected void cacheHit() {
}
@@ -298,14 +380,14 @@ public abstract class BaseActivity<Result, T extends ListView> extends Activity
}
public void svdrpException(final SvdrpException exception) {
-// svdrpException(exception);
+ // svdrpException(exception);
// Log.w(TAG, exception);
alert(getString(R.string.vdr_error_text, exception.getMessage()));
}
-
+
@Override
protected void onDestroy() {
- if(progress.isShowing()){
+ if (progress.isShowing()) {
progress.dismiss();
}
super.onDestroy();
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java
index 52be349..e37caf2 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java
@@ -155,6 +155,12 @@ public abstract class BaseEventListActivity<T extends Event> extends
*/
public boolean onOptionsItemSelected(final MenuItem item) {
+ switch(item.getItemId()){
+ case R.id.epg_list_menu_channels:
+ startActivity(new Intent(this, ChannelListActivity.class));
+ return true;
+ }
+
// switch (item.getItemId()) {
// case R.id.epg_menu_search:
// startSearchManager();
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BasePreferencesActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BasePreferencesActivity.java
index ced04c7..bf525f4 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BasePreferencesActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BasePreferencesActivity.java
@@ -4,11 +4,12 @@ import android.preference.DialogPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.text.TextUtils;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import de.bjusystems.vdrmanager.R;
+import de.bjusystems.vdrmanager.data.OrmLiteBasePreferenceActivity;
+import de.bjusystems.vdrmanager.data.db.OrmDatabaseHelper;
/**
*
@@ -16,7 +17,7 @@ import de.bjusystems.vdrmanager.R;
* @author lado
*
*/
-public abstract class BasePreferencesActivity extends PreferenceActivity {
+public abstract class BasePreferencesActivity extends OrmLiteBasePreferenceActivity<OrmDatabaseHelper> {
protected void updateSummary(Preference ep) {
if (ep instanceof EditTextPreference) {
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java
index 5dd1aff..c435499 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java
@@ -1,9 +1,5 @@
package de.bjusystems.vdrmanager.gui;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
import android.content.Intent;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
@@ -36,8 +32,8 @@ public abstract class BaseTimerEditActivity<T extends Event> extends
BaseEventListActivity<T> implements OnClickListener // SvdrpAsyncListener<Timer>,
{
- private static final ScheduledExecutorService worker = Executors
- .newSingleThreadScheduledExecutor();
+ //private static final ScheduledExecutorService worker = Executors
+ //.newSingleThreadScheduledExecutor();
// /@Override
// public boolean onPrepareOptionsMenu(Menu menu) {
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java
index 70823c2..d685df7 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java
@@ -107,6 +107,11 @@ public class ChannelListActivity extends
task.run();
}
+ @Override
+ public void reset() {
+ channelClient.clearCache();
+ }
+
private void fillAdapter() {
switch (groupBy) {
case MENU_GROUP:
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
index 3f8167f..cb0f2ae 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
@@ -17,6 +17,7 @@ import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
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;
@@ -304,7 +305,7 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
String url = String.format(IMDB_URL,
Preferences.get().getImdbUrl(),
String.valueOf(title.getText()));
- encode(url,"utf-8");
+ url = encode(url,"utf-8");
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
@@ -573,23 +574,19 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
// return super.dispatchTouchEvent(me);
// }
- private static final int MENU_SHARE = 0;
-
- private static final int MENU_SEARCH_REPEAT = 1;
@Override
public final boolean onCreateOptionsMenu(final Menu menu) {
super.onCreateOptionsMenu(menu);
- MenuItem item;
+
+ final MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.epg_details, menu);
- item = menu.add(MENU_SEARCH_REPEAT, MENU_SEARCH_REPEAT, 0,
- R.string.search_reapt);
- item.setIcon(android.R.drawable.ic_menu_search);
- item.setAlphabeticShortcut('r');
+
+ //mShareActionProvider = (ShareActionProvider) menu.findItem(R.id.epg_details_menu_share).getActionProvider();
+ //mShareActionProvider.setShareIntent(getDefaultShareIntent());
- item = menu.add(MENU_SHARE, MENU_SHARE, 0, R.string.share);
- item.setIcon(android.R.drawable.ic_menu_share);
- item.setAlphabeticShortcut('s');
+
return true;
}
@@ -599,11 +596,11 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == MENU_SHARE) {
+ if (item.getItemId() == R.id.epg_details_menu_share) {
shareEvent(cEvent);
return true;
}
- if (item.getItemId() == MENU_SEARCH_REPEAT) {
+ if (item.getItemId() == R.id.epg_details_menu_search_repeat) {
Intent intent = new Intent(this, EpgSearchListActivity.class);
intent.setAction(Intent.ACTION_SEARCH);
intent.putExtra(SearchManager.QUERY, cEvent.getTitle());
@@ -686,5 +683,8 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
setTitle(getString(R.string.epg_of_a_channel, cn, current + 1,
epgs.size()));
}
+
+ //private ShareActionProvider mShareActionProvider;
+
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
index 1df7c29..14273c2 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
@@ -38,8 +38,9 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
private final static ArrayList<Event> CACHE = new ArrayList<Event>();
- private static final String TAG = EventEpgListActivity.class.getSimpleName();
-
+ private static final String TAG = EventEpgListActivity.class
+ .getSimpleName();
+
protected static Date nextForceCache = null;
private static Channel cachedChannel = null;
@@ -51,6 +52,13 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
ArrayAdapter<Channel> channelSpinnerAdapter;
@Override
+ public void reset() {
+ CACHE.clear();
+ ChannelClient.clearCache();
+ super.reset();
+ }
+
+ @Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//
@@ -62,7 +70,7 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
channelSpinner = (Spinner) findViewById(R.id.epg_list_channel_spinner);
channelSpinner.setAdapter(channelSpinnerAdapter);
-
+
switcher = findViewById(R.id.switch_epg_view);
switcher.setOnClickListener(this);
@@ -73,7 +81,6 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
adapter = new ChannelEventAdapter(this);
-
// if (currentChannel != null) {
// }
@@ -90,17 +97,17 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
// register EPG item click
listView.setOnItemClickListener(this);
-
- if(checkInternetConnection() == false){
+
+ if (checkInternetConnection() == false) {
return;
}
startQuery();
-
+
}
- private void startQuery(){
- new ChannelsTask(this, new ChannelClient()){
+ private void startQuery() {
+ new ChannelsTask(this, new ChannelClient(true)) {
public void finished(SvdrpEvent event) {
if (event == SvdrpEvent.CACHE_HIT
|| event == SvdrpEvent.FINISHED_SUCCESS) {
@@ -110,8 +117,8 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
int count = 0;
for (final Channel c : channels) {
channelSpinnerAdapter.add(c);
- if(currentChannel != null && !found){
- if(currentChannel.equals(c)){
+ if (currentChannel != null && !found) {
+ if (currentChannel.equals(c)) {
found = true;
} else {
count++;
@@ -119,11 +126,13 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
}
}
channelSpinner.setSelection(count);
- channelSpinner.setOnItemSelectedListener(EventEpgListActivity.this);
+ channelSpinner
+ .setOnItemSelectedListener(EventEpgListActivity.this);
} else {
noConnection(event);
}
- }}.start();
+ }
+ }.start();
}
@@ -148,7 +157,6 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
startEpgQuery(false);
}
-
public void onNothingSelected(final AdapterView<?> arg0) {
// startTimeEpgQuery(((EpgTimeSpinnerValue)timeSpinner.getAdapter().getItem(0)).getValue());
}
@@ -174,7 +182,6 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
return true;
}
-
@Override
public void onClick(View view) {
if (view == switcher) {
@@ -188,7 +195,7 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
}
}
- private void startEpgQuery(final boolean force) {
+ private void startEpgQuery(final boolean force) {
if (useCache() && !force) {
Calendar cal = Calendar.getInstance();
int day = -1;
@@ -229,11 +236,11 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
task.run();
}
-
- @Override
- protected SvdrpClient<Epg> getClient() {
- return this.epgClient;
- }
+ @Override
+ protected SvdrpClient<Epg> getClient() {
+ return this.epgClient;
+ }
+
/*
* (non-Javadoc) TODO this method also should be used in startEpgQuery on
* cache hit
@@ -241,7 +248,7 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
* @see de.bjusystems.vdrmanager.gui.BaseEpgListActivity#finishedSuccess()
*/
@Override
- synchronized protected boolean finishedSuccessImpl() {
+ synchronized protected boolean finishedSuccessImpl() {
adapter.clear();
CACHE.clear();
Date now = new Date();
@@ -324,9 +331,9 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
}
}
-// @Override
-// protected void timerModified() {
-// cachedChannel = null;
-// }
+ // @Override
+ // protected void timerModified() {
+ // cachedChannel = null;
+ // }
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/PreferencesActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/PreferencesActivity.java
index c633b50..7451043 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/PreferencesActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/PreferencesActivity.java
@@ -5,17 +5,10 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
-import android.preference.DialogPreference;
-import android.preference.EditTextPreference;
-import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
-import android.text.TextUtils;
-import android.view.inputmethod.EditorInfo;
-import android.widget.EditText;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.app.VdrManagerApp;
import de.bjusystems.vdrmanager.data.Preferences;
@@ -42,10 +35,6 @@ public class PreferencesActivity extends BasePreferencesActivity implements
this.addPreferencesFromResource(R.xml.preferences);
updateChildPreferences();
-
- findPreference(getString(R.string.wakeup_wol_mac_key))
- .setOnPreferenceClickListener(this);
-
}
// /** Return a properly configured SharedPreferences instance */
@@ -70,46 +59,10 @@ public class PreferencesActivity extends BasePreferencesActivity implements
}
- private void enableWolPreferences() {
- findPreference(getString(R.string.wakeup_wol_mac_key)).setEnabled(true);
- findPreference(getString(R.string.wakeup_wol_custom_broadcast_key))
- .setEnabled(true);
- }
-
- private void disableWolPreferences() {
- findPreference(getString(R.string.wakeup_wol_mac_key))
- .setEnabled(false);
- findPreference(getString(R.string.wakeup_wol_custom_broadcast_key))
- .setEnabled(false);
- }
-
- private void disableWakeupUrlPreferences() {
- findPreference(getString(R.string.wakeup_url_key)).setEnabled(false);
- findPreference(getString(R.string.wakeup_password_key)).setEnabled(
- false);
- findPreference(getString(R.string.wakeup_user_key)).setEnabled(false);
- }
-
- private void enableWakeupUrlPrefenreces() {
- findPreference(getString(R.string.wakeup_url_key)).setEnabled(true);
- findPreference(getString(R.string.wakeup_password_key))
- .setEnabled(true);
- findPreference(getString(R.string.wakeup_user_key)).setEnabled(true);
- }
private void updateChildPreferences() {
SharedPreferences sp = Preferences.getSharedPreferences(this);
- String wakup = sp.getString(getString(R.string.wakeup_method_key),
- "wol");
-
- if (wakup.equals("url")) {
- disableWolPreferences();
- enableWakeupUrlPrefenreces();
- } else {// remote url
- disableWakeupUrlPreferences();
- enableWolPreferences();
- }
for (String key : sp.getAll().keySet()) {
Preference p = findPreference(key);
@@ -127,6 +80,7 @@ public class PreferencesActivity extends BasePreferencesActivity implements
app.addActivityToFinish(this);
app.finishActivities();
+ Preferences.init(this);
// restart main activity because
// the buttons needs refreshing
final Intent intent = new Intent();
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java
index 7d5d8a3..4d69659 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java
@@ -56,6 +56,13 @@ public class TimeEpgListActivity extends BaseTimerEditActivity<Epg> implements
int selectedIndex = 0;
+ @Override
+ public void reset() {
+ CACHE.clear();
+ cachedTime = null;
+ super.reset();
+ }
+
@Override
protected SvdrpClient<Epg> getClient() {
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrListActivity.java
index d0955cf..61f6385 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrListActivity.java
@@ -1,8 +1,135 @@
package de.bjusystems.vdrmanager.gui;
-import android.app.ListActivity;
-import android.preference.PreferenceActivity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.database.Cursor;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.AdapterView.OnItemLongClickListener;
+import android.widget.SimpleCursorAdapter;
-public class VdrListActivity extends ListActivity {
+import com.j256.ormlite.android.apptools.OrmLiteBaseListActivity;
+import de.bjusystems.vdrmanager.R;
+import de.bjusystems.vdrmanager.app.Intents;
+import de.bjusystems.vdrmanager.data.db.OrmDatabaseHelper;
+
+public class VdrListActivity extends OrmLiteBaseListActivity<OrmDatabaseHelper> implements OnItemClickListener, OnItemLongClickListener {
+
+ SimpleCursorAdapter adapter = null;
+
+ Cursor cursor;
+
+ String[] listItems = {};
+
+ private void initCursor() {
+
+ if(cursor != null){
+ if(!cursor.isClosed()){
+ cursor.close();
+ }
+ }
+ try {
+ cursor = getHelper().getVdrCursor();;
+ startManagingCursor(cursor);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.vdr_list_add_delete);
+
+ findViewById(R.id.add_item).setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ editVdr(null);
+ }
+ });
+ // PreparedQuery<Vdr> query = qb.prepare();
+ //
+ // AndroidCompiledStatement compiledStatement =
+ // (AndroidCompiledStatement)query.compile(getHelper().getConnectionSource().getReadOnlyConnection());
+ // Cursor cursor = compiledStatement.getCursor();
+ //
+ //
+ // getHelper().getConnectionSource().
+
+// View view = findViewById(R.id.add_item);
+
+
+
+ initCursor();
+ adapter= new SimpleCursorAdapter(this,android.R.layout.simple_list_item_2, cursor, new String[] {"name","host"}, new int[] { android.R.id.text1, android.R.id.text2 });
+ setListAdapter(adapter);
+ registerForContextMenu(getListView());
+ getListView().setOnItemClickListener(this);
+ getListView().setOnItemLongClickListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see android.widget.AdapterView.OnItemClickListener#onItemClick(android.widget.AdapterView, android.view.View, int, long)
+ */
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ editVdr(Long.valueOf(id).intValue());
+ }
+
+ /**
+ * Start {@link VdrPreferencesActivity} to create or edit a vdr
+ * @param id may be null. Then a new vdr is created
+ */
+ private void editVdr(Integer id){
+ Intent intent = new Intent(this, VdrPreferencesActivity.class);
+ intent.putExtra(Intents.VDR_ID, id);
+ startActivityForResult(intent, Intents.EDIT_VDR);
+ }
+
+ /* (non-Javadoc)
+ * @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
+ */
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+
+ if (resultCode != RESULT_OK) {
+ return;
+ }
+ if (requestCode == Intents.EDIT_VDR) {
+ refresh();
+ return;
+ }
+
+ }
+
+
+ /**
+ * Refresh the list
+ */
+ private void refresh() {
+ initCursor();
+ adapter.changeCursor(cursor);
+ }
+
+ public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, final long id) {
+
+ new AlertDialog.Builder(this)
+ .setMessage(R.string.vdr_device_delete_qeustion)//
+ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
+ public void onClick(DialogInterface dialog, int which) {
+ if(getHelper().getVdrDAO().deleteById((int)id) > 0 ){
+ initCursor();
+ adapter.changeCursor(cursor);
+ }
+
+ }})//
+ .setNegativeButton(android.R.string.cancel, null)//
+ .create()//
+ .show();
+ return false;
+ }
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java
index 8a05778..de70e2c 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java
@@ -1,29 +1,45 @@
package de.bjusystems.vdrmanager.gui;
import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.SearchManager;
+import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
+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.SearchView;
+import android.widget.Toast;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.app.VdrManagerApp;
import de.bjusystems.vdrmanager.data.Preferences;
+import de.bjusystems.vdrmanager.data.Vdr;
import de.bjusystems.vdrmanager.utils.wakeup.AsyncWakeupTask;
public class VdrManagerActivity extends Activity implements OnClickListener {
+ public static final String TAG = "VdrManagerActivity";
+
+ public static final String VDR_PORTAL = "http://www.vdr-portal.de";
+
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Preferences.setLocale(this);
- setTitle(getString(R.string.app_name));
+ // this.getActionBar().setDisplayShowCustomEnabled(true);
+ // this.getActionBar().setDisplayShowTitleEnabled(false);
+ // setTitle(getString(R.string.app_name));
// attach view
setContentView(R.layout.vdrmanager);
-
// Preferences.loadPreferences(this);
findViewById(R.id.action_menu_channels).setOnClickListener(this);
@@ -31,7 +47,7 @@ public class VdrManagerActivity extends Activity implements OnClickListener {
findViewById(R.id.action_menu_timers).setOnClickListener(this);
findViewById(R.id.action_menu_epg).setOnClickListener(this);
findViewById(R.id.action_menu_search).setOnClickListener(this);
-
+ findViewById(R.id.main_logo).setOnClickListener(this);
if (Preferences.get().isWakeupEnabled() == false) {
findViewById(R.id.action_menu_wakeup).setVisibility(View.GONE);
} else {
@@ -48,9 +64,20 @@ public class VdrManagerActivity extends Activity implements OnClickListener {
final MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
+
+ int api = Build.VERSION.SDK_INT;
+ if ( api >= 11){
+ SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
+ SearchView searchView = (SearchView) menu.findItem(R.id.menu_search)
+ .getActionView();
+ searchView.setSearchableInfo(searchManager
+ .getSearchableInfo(getComponentName()));
+ searchView.setIconifiedByDefault(false); // Do not iconify the widget;
+
+ }
return true;
}
-
+
@Override
protected void onResume() {
Preferences.setLocale(this);
@@ -76,13 +103,86 @@ public class VdrManagerActivity extends Activity implements OnClickListener {
About.show(this);
break;
}
- case R.id.main_menu_exit:
+ case R.id.main_menu_exit: {
finish();
break;
}
+ case R.id.menu_search: {
+ if(Build.VERSION.SDK_INT <11){
+ onSearchRequested();
+ }
+ break;
+ }
+ case R.id.main_menu_goto: {
+ try {
+ final Cursor cursor = Preferences.getDatabaseHelper()
+ .getVdrCursor();
+ startManagingCursor(cursor);
+ final AlertDialog ad = new AlertDialog.Builder(this)
+ .setSingleChoiceItems(cursor, findVdrCursor(cursor),
+ "name", new DialogInterface.OnClickListener() {
+
+ public void onClick(DialogInterface dialog,
+ int which) {
+ cursor.moveToPosition(which);
+ int id = cursor.getInt(cursor
+ .getColumnIndex("_id"));
+ Vdr vdr = Preferences
+ .getDatabaseHelper()
+ .getVdrDAO().queryForId(id);
+ if (vdr == null) {
+ Toast.makeText(
+ VdrManagerActivity.this,
+ R.string.main_menu_goto_no_vdr,
+ Toast.LENGTH_SHORT).show();
+ } else {
+ Preferences.setCurrentVdr(
+ VdrManagerActivity.this,
+ vdr);
+ Toast.makeText(
+ VdrManagerActivity.this,
+ getString(
+ R.string.main_menu_switched_to,
+ vdr.getName()),
+ Toast.LENGTH_SHORT).show();
+ ((VdrManagerApp) getApplication())
+ .finishActivities();
+ }
+ dialog.dismiss();
+ }
+ })//
+ .setTitle(R.string.main_menu_goto_title)//
+ .create();
+ ad.show();
+
+ } catch (Exception ex) {
+ Log.w(TAG, ex);
+ }
+
+ break;
+ }
+ }
return true;
}
+ private int findVdrCursor(Cursor c) {
+ if (Preferences.get().getCurrentVdr() == null) {
+ return -1;
+ }
+
+ int cid = Preferences.get().getCurrentVdr().getId();
+
+ int position = 0;
+ c.moveToPosition(-1);
+ while (c.moveToNext()) {
+ if (c.getInt(c.getColumnIndex("_id")) == cid) {
+ break;
+ }
+ position++;
+ }
+ return position;
+ }
+
@Override
public void onBackPressed() {
if (Preferences.get().isQuiteOnBackButton()) {
@@ -119,6 +219,11 @@ public class VdrManagerActivity extends Activity implements OnClickListener {
final AsyncWakeupTask wakeupTask = new AsyncWakeupTask(this);
wakeupTask.execute();
break;
+ case R.id.main_logo:
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse(VDR_PORTAL));
+ startActivity(i);
+ break;
}
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java
index 62f9953..b373c8e 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java
@@ -1,21 +1,176 @@
package de.bjusystems.vdrmanager.gui;
-import de.bjusystems.vdrmanager.R;
-import de.bjusystems.vdrmanager.data.Preferences;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceClickListener;
+import de.bjusystems.vdrmanager.R;
+import de.bjusystems.vdrmanager.app.Intents;
+import de.bjusystems.vdrmanager.data.Vdr;
+import de.bjusystems.vdrmanager.data.VdrSharedPreferences;
-public class VdrPreferencesActivity extends BasePreferencesActivity {
+public class VdrPreferencesActivity extends BasePreferencesActivity implements
+ OnSharedPreferenceChangeListener, OnPreferenceClickListener {
+
+ Vdr vdr;
+ VdrSharedPreferences pref;
+
+ @Override
+ public SharedPreferences getSharedPreferences(String name, int mode) {
+ return this.pref;
+ }
+
+ @Override
+ public Preference findPreference(CharSequence key) {
+ return super.findPreference(key);
+ }
+
+ private void initVDR() {
+ Integer id = getIntent().getExtras().getInt(Intents.VDR_ID);
+ if (id == null) {// new vdr
+ vdr = new Vdr();
+ pref = new VdrSharedPreferences();
+ pref.instance = vdr;
+ } else {// edit
+ Vdr v = getHelper().getVdrDAO().queryForId(id);
+ if (v != null) {
+ vdr = v;
+ pref = new VdrSharedPreferences(vdr);
+ } else {
+ vdr = new Vdr();
+ pref = new VdrSharedPreferences();
+ pref.instance = vdr;
+ }
+ }
+ }
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- this.getPreferenceManager().setSharedPreferencesName(
- Preferences.getPreferenceFile(this));
+ initVDR();
+
+ // this.getPreferenceManager().setSharedPreferencesName(Preferences.getPreferenceFile(this));
+
+ pref.instance = vdr;
+ pref.dao = getHelper().getVdrDAO();
+ pref.registerOnSharedPreferenceChangeListener(this);
+
this.addPreferencesFromResource(R.xml.vdr_prefs);
+ updateChildPreferences();
+
+ findPreference(getString(R.string.wakeup_wol_mac_key))
+ .setOnPreferenceClickListener(this);
+
+ }
+
+ public void onSharedPreferenceChanged(SharedPreferences arg0, String key) {
+ updateChildPreferences();
+ Preference p = findPreference(key);
+ updateSummary(p);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ // Set up a listener whenever a key changes
+ pref.registerOnSharedPreferenceChangeListener(this);
+
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ // Unregister the listener whenever a key changes
+ pref.unregisterOnSharedPreferenceChangeListener(this);
+ }
+
+ private void enableWolPreferences() {
+ Preference p = findPreference(getString(R.string.wakeup_wol_mac_key));
+ if(p != null)
+
+ p.setEnabled(true);
+ p =
+ findPreference(getString(R.string.wakeup_wol_custom_broadcast_key));
+ if(p!=null){
+ p.setEnabled(true);
+ }
+ }
+
+ private void disableWolPreferences() {
+ Preference p = findPreference(getString(R.string.wakeup_wol_mac_key));
+ if (p != null)
+ p.setEnabled(false);
+
+ p = findPreference(getString(R.string.wakeup_wol_custom_broadcast_key));
+ if (p != null)
+ p.setEnabled(false);
+
+ }
+
+ private void disableWakeupUrlPreferences() {
+ Preference p = findPreference(getString(R.string.wakeup_url_key));
+ if (p != null) {
+ p.setEnabled(false);
+ }
+ p = findPreference(getString(R.string.wakeup_password_key));
+ if (p != null) {
+ p.setEnabled(false);
+ }
+
+ p = findPreference(getString(R.string.wakeup_user_key));
+ if (p != null) {
+ p.setEnabled(false);
+ }
+ }
+
+ private void enableWakeupUrlPrefenreces() {
+ Preference p = findPreference(getString(R.string.wakeup_url_key));
+ if(p!=null){
+ p.setEnabled(true);
+ }
+ p = findPreference(getString(R.string.wakeup_password_key));
+ if(p != null){
+ p.setEnabled(true);
+ }
+ p = findPreference(getString(R.string.wakeup_user_key));
+ if(p != null){
+ p.setEnabled(true);
+ }
}
+
+ private void updateChildPreferences() {
+ String wakup = pref.getString(getString(R.string.wakeup_method_key),
+ "wol");
+
+ if (wakup.equals("url")) {
+ disableWolPreferences();
+ enableWakeupUrlPrefenreces();
+ } else {// remote url
+ disableWakeupUrlPreferences();
+ enableWolPreferences();
+ }
+
+ for (String key : pref.getAll().keySet()) {
+ Preference p = findPreference(key);
+ updateSummary(p);
+ }
+
+ }
+
+ public boolean onPreferenceClick(Preference arg0) {
+
+ return false;
+ }
+
+ @Override
+ public void onBackPressed() {
+ setResult(RESULT_OK);
+ finish();
+ }
+
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/ChannelClient.java b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/ChannelClient.java
index e367bd6..8f60124 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/ChannelClient.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/ChannelClient.java
@@ -36,7 +36,7 @@ public class ChannelClient extends SvdrpClient<Channel> implements
addSvdrpListener(this);
}
- private void clearCache() {
+ public static void clearCache() {
channelGroups.clear();
groupChannels.clear();
providerChannels.clear();
@@ -70,10 +70,10 @@ public class ChannelClient extends SvdrpClient<Channel> implements
* @param ssl
* use ssl
*/
- public ChannelClient() {
- this(true);
-
- }
+// public ChannelClient() {
+// this(true);
+//
+// }
/**
* Starts the EPG request
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java
index 86240eb..1b97237 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java
@@ -244,7 +244,7 @@ public abstract class SvdrpClient<Result> {
protected void writeLine(final String line) throws IOException {
String command = line + "\r\n";
- if(false && Preferences.get().isSSL()){
+ if(false && Preferences.get().isSecure()){
command = crypt.encrypt(command, Preferences.get().getPassword());
}
final byte[] bytes = command.getBytes("utf-8");
@@ -294,7 +294,7 @@ public abstract class SvdrpClient<Result> {
Log.w(TAG, usex);
line = lineBytes.toString();
}
- if(false && Preferences.get().isSSL()){
+ if(false && Preferences.get().isSecure()){
line = crypt.decrypt(line, Preferences.get().getPassword());
}
return line;