Author: jerome
Date: 2009-04-09 12:20:11 +0200 (Thu, 09 Apr 2009)
New Revision: 4441

Added:
   
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/gadget/FrenchConfiguration.java
Modified:
   
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/gadget/Configuration.java
   
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/gadget/GadgetProgramsTvFr.java
   
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/programs/SimplePrograms.java
Log:
* Prepared french gadget interface.
* Added special configuration for french programs that can make use digital or 
standard channels.
* Fixed a bug while slitting the program.

Modified: 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/gadget/Configuration.java
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/gadget/Configuration.java
   2009-04-09 09:53:33 UTC (rev 4440)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/gadget/Configuration.java
   2009-04-09 10:20:11 UTC (rev 4441)
@@ -25,7 +25,7 @@
 
 public class Configuration extends SimpleGadgetConfiguration{
        
-       private String channel = "Discovery Channel";
+       private String channel = "ARTE";
        private boolean giveProgramDescription = true;
        private boolean giveMorning = true;
        private boolean giveAfternoon = true;

Added: 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/gadget/FrenchConfiguration.java
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/gadget/FrenchConfiguration.java
                             (rev 0)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/gadget/FrenchConfiguration.java
     2009-04-09 10:20:11 UTC (rev 4441)
@@ -0,0 +1,89 @@
+/* This file is part of "tuxdroid programs tv".
+ *    Copyright 2009, kysoh
+ *    Author : Conan Jerome
+ *    eMail  : jerome.conan AT kysoh.com
+ *
+ * "tuxdroid programs tv" is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * "tuxdroid programs tv" is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with "tuxdroid programs tv"; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package com.kysoh.tvPrograms.gadget;
+
+public class FrenchConfiguration extends Configuration{
+
+       private String digitalChannel = "Disney Channel";
+       private boolean useDigital    = false;
+       private boolean useStandard   = true;
+       
+       
+       /**
+        * Return the selected digital channel.
+        * @return
+        */
+       public String getDigitalChannel()
+       {
+               return this.digitalChannel;
+       }
+       
+       
+       /**
+        * Set the digital channel.
+        * @param aHertzChannel
+        */
+       public void setDigitalChannel(String aDigitalChannel)
+       {
+               this.digitalChannel = aDigitalChannel;
+       }
+       
+       
+       /**
+        * Return true if user wants to hear digitals channels.
+        * @return
+        */
+       public boolean getUseDigital()
+       {
+               return this.useDigital;
+       }
+       
+       
+       /**
+        * Set the 'use digital' parameter value.
+        * @param aUseDigital
+        */
+       public void setUseDigital(boolean aUseDigital)
+       {
+               this.useDigital = aUseDigital;
+       }
+       
+       
+       /**
+        * Return true if user wants to hear standart programs.
+        * @return
+        */
+       public boolean getUseStandard()
+       {
+               return this.useStandard;
+       }
+       
+       
+       /**
+        * Set the 'use standart' parameters.
+        * @param aUseStandart
+        */
+       public void setUseStandard(boolean aUseStandard)
+       {
+               this.useStandard = aUseStandard;
+       }
+}


Property changes on: 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/gadget/FrenchConfiguration.java
___________________________________________________________________
Name: svn:executable
   + *

Modified: 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/gadget/GadgetProgramsTvFr.java
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/gadget/GadgetProgramsTvFr.java
      2009-04-09 09:53:33 UTC (rev 4440)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/gadget/GadgetProgramsTvFr.java
      2009-04-09 10:20:11 UTC (rev 4441)
@@ -28,7 +28,7 @@
 import com.kysoh.tvPrograms.ProgramLoadListener;
 import com.kysoh.tvPrograms.programs.SimplePrograms;
 
-public class GadgetProgramsTvFr extends SimpleGadget<Configuration> implements 
ProgramLoadListener{
+public class GadgetProgramsTvFr extends SimpleGadget<FrenchConfiguration> 
implements ProgramLoadListener{
 
        SimplePrograms french;
        
@@ -39,7 +39,17 @@
        protected void start() throws Throwable 
        {
                SimplePrograms.addProgramLoadListener(this);
-               french = new SimplePrograms(SimplePrograms.FR, 
this.configuration().getChannel());
+               
+               //Make use of standard french channels.
+               if(this.configuration().getUseStandard())
+               {
+                       french = new SimplePrograms(SimplePrograms.FR, 
this.configuration().getChannel());
+               }
+               //Make use of digital programs
+               else if(this.configuration().getUseDigital())
+               {
+                       french = new 
SimplePrograms(SimplePrograms.DIGITAL_FRENCH, 
this.configuration().getDigitalChannel());
+               }
        }
 
        
@@ -63,6 +73,14 @@
                try
                {
                        GadgetProgramTV.giveProgram(this.configuration(), 
completeProgram, this);
+                       
+                       //Checking if gadget has to release digital program.
+                       if(this.configuration().getUseDigital())
+                       {
+                               french = new 
SimplePrograms(SimplePrograms.DIGITAL_FRENCH, 
this.configuration().getDigitalChannel());
+                               this.configuration().setUseDigital(false);
+                       }
+                       
                }
                catch(Exception error)
                {
@@ -77,6 +95,6 @@
         */
        public static void main(String[] args)
        {
-               new GadgetProgramsTvFr().boot(args, new Configuration());
+               new GadgetProgramsTvFr().boot(args, new FrenchConfiguration());
        }
 }

Modified: 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/programs/SimplePrograms.java
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/programs/SimplePrograms.java
        2009-04-09 09:53:33 UTC (rev 4440)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/programs/SimplePrograms.java
        2009-04-09 10:20:11 UTC (rev 4441)
@@ -42,17 +42,18 @@
        protected static Collection<ProgramLoadListener> listeners = new 
ArrayList<ProgramLoadListener>();
        
        
-       private static final int MORNING = 0;
+       private static final int MORNING   = 0;
        private static final int AFTERNOON = 1;
-       private static final int EVENING = 2;
+       private static final int EVENING   = 2;
        
-       public static final String BEFR = "All Belgian French</a>";
-       public static final String BEDU = "All Belgian Dutch</a>";
-       public static final String FR   = "France<p><a href";
-       public static final String UK   = "U.K.<p><a href";
-       public static final String GE   = "Germany<p><a href";
-       public static final String Nl   = "The Netherlands<p><a href";
-       public static final String SP   = "Spain<p><a href";
+       public static final String BEFR           = "All Belgian French</a>";
+       public static final String BEDU           = "All Belgian Dutch</a>";
+       public static final String FR             = "All French</a>";
+       public static final String DIGITAL_FRENCH = "All Digital French</a>";
+       public static final String UK             = "U.K.<p><a href";
+       public static final String GE             = "Germany<p><a href";
+       public static final String Nl             = "The Netherlands<p><a href";
+       public static final String SP             = "Spain<p><a href";
        
        public static final String US  = null; 
 
@@ -75,6 +76,8 @@
                        
                        channelsMap = this.getChannelsLinkByCountry(country, 
availables);
                        
+                       System.out.println(this.channelsMap);
+                       
                        program = this.parseProgramsForChannel(this.channel);
                        
                        if(program.size() > 0)
@@ -83,6 +86,7 @@
                        }
                        else
                        {
+                               
                                this.triggerError();
                        }
                }
@@ -90,6 +94,7 @@
                {
                        this.triggerError();
                }
+               
        }
        
        
@@ -135,6 +140,10 @@
                {
                        if(!str.contains("<p>"))
                        {
+                               if(str.contains("é"))
+                               {
+                                       str = str.replace("é", "é");
+                               }
                                spl.add(str);
                        }
                        else
@@ -253,11 +262,15 @@
                temp = temp.substring(temp.indexOf("</center></td>") + 
"</center></td>".length());
                temp = temp.substring(temp.indexOf("valign=top>") + 
"valign=top>".length());
                
-               String[] split = temp.split("<BR>");
+               temp = temp.replace("<BR>", "<END>");
+               temp = temp.replace("</ul>", "<END>");
                
+               String[] split = temp.split("<END>");
+               
+               
                for(String str : split)
                {
-                       //Handling possible error.
+                       /*//Handling possible error.
                        if(str.contains("<img src=\""))
                        {
                                int idx = str.indexOf("<img src=\"");
@@ -278,7 +291,6 @@
                                                String startTime = 
str.substring(0, str.indexOf("<B>"));
                                                
                                                rpl += startTime;
-                                               
                                                startTime = 
HTMLUtils.HtmlToString(startTime).substring(0, 5); 
                                                
                                                //Get title.
@@ -290,18 +302,35 @@
                                                title = title.replace("</B>", 
"");
                                                title = 
HTMLUtils.HtmlToString(title);
                                                
+                                               
                                                title = this.filter(title);
                                                
                                                //Getting description if it can 
be found.
                                                String description = null;
                                                
-                                               if(str.contains("<ul>"))
+                                               if(str.contains("<ul>") && 
str.contains("</ul>"))
                                                {
-                                                       description = 
str.substring(str.indexOf("<ul>"), str.indexOf("</ul>") + "</ul>".length());
-                                                       rpl += description;
+                                                       int idx = 
str.indexOf("<ul>");
+                                                       int endIdx = 
str.indexOf("</ul>") + "</ul>".length();
+                                                       
+                                                       try
+                                                       {
+                                                               description = 
str.substring(idx, endIdx);
+                                                       }
+                                                       
catch(StringIndexOutOfBoundsException endString)
+                                                       {
+                                                               description = 
str.substring(0, endIdx);                                                       
  
+                                                       }
+                                                       
+                                                       str = 
str.replace(description, "");
+                                                       
+                                                       
+                                                       
System.out.println(description);
+                                                       
                                                        description = 
description.replace("<ul>", "");
                                                        description = 
description.replace("</ul>", "");
                                                        description = 
HTMLUtils.HtmlToString(description);
+                                                       
                                                        description = 
this.filter(description);
                                                }
                                                
@@ -319,6 +348,10 @@
                                                str = str.replace(rpl, "");
                                        }
                                }
+                       }*/
+                       if(str.contains("<B>"))
+                       {
+                               System.out.println(str);
                        }
                }
                


------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to