Author: jerome
Date: 2009-10-09 12:57:58 +0200 (Fri, 09 Oct 2009)
New Revision: 5622
Modified:
software_suite_v3/software/plugin/plugin-twitter/branches/october_release/plugin-twitter/pom.xml
software_suite_v3/software/plugin/plugin-twitter/branches/october_release/plugin-twitter/src/TwitterDatasStruct.java
software_suite_v3/software/plugin/plugin-twitter/branches/october_release/plugin-twitter/src/TwitterPlugin.java
Log:
* Reverted save directory ( user session only ).
* Fixed a bug when user has only one message in alert mode.
* Improved the tts sentenses.
Modified:
software_suite_v3/software/plugin/plugin-twitter/branches/october_release/plugin-twitter/pom.xml
===================================================================
---
software_suite_v3/software/plugin/plugin-twitter/branches/october_release/plugin-twitter/pom.xml
2009-10-09 10:57:45 UTC (rev 5621)
+++
software_suite_v3/software/plugin/plugin-twitter/branches/october_release/plugin-twitter/pom.xml
2009-10-09 10:57:58 UTC (rev 5622)
@@ -14,11 +14,6 @@
<groupId>com.kysoh</groupId>
<artifactId>tuxdroid-plugin-java-kit</artifactId>
<version>0.0.3</version>
- </dependency>
- <dependency>
- <groupId>com.kysoh</groupId>
- <artifactId>smart-core-paths</artifactId>
- <version>0.0.1</version>
</dependency>
<dependency>
<groupId>jtwitter</groupId>
Modified:
software_suite_v3/software/plugin/plugin-twitter/branches/october_release/plugin-twitter/src/TwitterDatasStruct.java
===================================================================
---
software_suite_v3/software/plugin/plugin-twitter/branches/october_release/plugin-twitter/src/TwitterDatasStruct.java
2009-10-09 10:57:45 UTC (rev 5621)
+++
software_suite_v3/software/plugin/plugin-twitter/branches/october_release/plugin-twitter/src/TwitterDatasStruct.java
2009-10-09 10:57:58 UTC (rev 5622)
@@ -27,14 +27,10 @@
import java.io.Serializable;
import java.util.Vector;
-import com.kysoh.SmartCorePaths;
-
public class TwitterDatasStruct extends Object implements Serializable{
private static final long serialVersionUID = 8395814134877723558L;
- private static String linuxDatasSav = "";
- private static String windowsDatasSav = "";
public static final byte FRIENDS_STATUSES = 0;
public static final byte REPLIES = 1;
@@ -45,51 +41,13 @@
private boolean firstCycle;
- /**
- * Path initialization.
- */
- static
- {
- if ( SmartCorePaths.isLinux() )
- {
- TwitterDatasStruct.linuxDatasSav = System.getenv("HOME") +
"/.tuxdroid/plugins_conf/Twitter";
-
- if (! ( new File(linuxDatasSav)).exists())
- {
- if ( ! ( new File(linuxDatasSav) ).mkdirs() )
- {
- ( new File(linuxDatasSav) ).mkdir();
- }
- }
- }
- else
- {
- TwitterDatasStruct.windowsDatasSav =
System.getenv("ALLUSERSDIR") + "/tuxdroid/plugins_conf/Twitter";
-
- if (! ( new File(windowsDatasSav)).exists())
- {
- if ( ! ( new File(windowsDatasSav) ).mkdirs() )
- {
- ( new File(windowsDatasSav) ).mkdir();
- }
- }
- }
- }
-
-
public TwitterDatasStruct(String username)
{
//tds = tuxdroid datas saved.
- if (SmartCorePaths.isLinux())
- {
- structFile = new File(linuxDatasSav + File.separator +
username + "@twitter.sav");
- }
- else
- {
- structFile = new File(windowsDatasSav + File.separator
+ username + "@twitter.sav");
- }
+ File path = new File("");
+ structFile = new File( path.getAbsolutePath() + File.separator
+ username + "@twitter.sav");
if(structFile.exists())
{
Modified:
software_suite_v3/software/plugin/plugin-twitter/branches/october_release/plugin-twitter/src/TwitterPlugin.java
===================================================================
---
software_suite_v3/software/plugin/plugin-twitter/branches/october_release/plugin-twitter/src/TwitterPlugin.java
2009-10-09 10:57:45 UTC (rev 5621)
+++
software_suite_v3/software/plugin/plugin-twitter/branches/october_release/plugin-twitter/src/TwitterPlugin.java
2009-10-09 10:57:58 UTC (rev 5622)
@@ -24,6 +24,8 @@
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
+import java.util.Vector;
+
import com.kysoh.tuxdroid.plugin.framework.plugin.SimplePlugin;
import winterwell.jtwitter.Twitter;
import winterwell.jtwitter.TwitterException;
@@ -41,6 +43,7 @@
private List<String> messagesList = new ArrayList<String>();
private List<String> repliesList = new ArrayList<String>();
+ private boolean throwed = false;
/***
This function set the new user status.
@@ -62,7 +65,10 @@
}
catch(TwitterException notConnected)
{
- throwMessage("You do not seem to be
connected. Please, verify you username and password, then try again.");
+ if
(!this.getCommand().equalsIgnoreCase("check"))
+ {
+ throwMessage("You do not seem to be
connected. Please, verify you username and password, then try again.");
+ }
this.quitGadget();
}
}
@@ -191,7 +197,17 @@
}
+ private void throwRes()
+ {
+ if ( ( !throwed ) && (
this.getCommand().equalsIgnoreCase("check") ))
+ {
+ this.throwed = true;
+ this.throwResult(true);
+ }
+ this.throwMessage("Twitter");
+ }
+
@Override
protected void start() throws Throwable
{
@@ -212,13 +228,16 @@
{
//Getting new friend statuses count.
int updateCount =
getNewFriendStatusesCount(twitter);
+
if ( updateCount == 1 )
{
+ throwRes();
throwMessage("You have a new friend
update");
}
else if ( updateCount > 1 )
{
- throwMessage("Yo have {0} friend
updates", String.valueOf(updateCount));
+ throwRes();
+ throwMessage("You have {0} friend
updates", String.valueOf(updateCount));
}
else
{
@@ -227,34 +246,35 @@
throwMessage("You don't have any
friend updates.");
}
}
-
- //Getting and sorting new user replies.
- if ( getPublicMessagesCount(twitter) > 0 )
+
+ //Getting and sorting new user private messages.
+ if ( getPrivateMessagesCount(twitter) > 0 )
{
- this.sort(this.repliesList);
- //Counting by name and throwing messages.
- this.getByNames(this.repliesList, REPLY);
+
+ this.sort(this.messagesList);
+ //Counting by name and throwing messages.
+ this.getByNames(this.messagesList, MESSAGE);
}
else
{
if ( !
this.getCommand().equalsIgnoreCase("check") )
{
- throwMessage("You don't have any
replies");
+ throwMessage("You don't have any messages");
}
}
- //Getting and sorting new user private messages.
- if ( getPrivateMessagesCount(twitter) > 0 )
+ //Getting and sorting new user replies.
+ if ( getPublicMessagesCount(twitter) > 0 )
{
- this.sort(this.messagesList);
- //Counting by name and throwing messages.
- this.getByNames(this.messagesList, MESSAGE);
+ this.sort(this.repliesList);
+ //Counting by name and throwing messages.
+ this.getByNames(this.repliesList, REPLY);
}
else
{
if ( !
this.getCommand().equalsIgnoreCase("check") )
{
- throwMessage("You don't have any messages");
+ throwMessage("You don't have any
replies");
}
}
@@ -297,7 +317,8 @@
*/
private void getByNames(List<String> list, byte type)
{
- Hashtable<String, Integer> dtUsers = new Hashtable<String,
Integer>();
+ Vector<String> dtUsers = new Vector<String>();
+ Vector<Integer> dtCount = new Vector<Integer>();
int count = 1;
//Handling no replies / no messages.
@@ -305,31 +326,31 @@
{
return;
}
- else
- {
- throwMessage("You have");
- }
-
//Counting by names.
- for( int i = 0 ; i != list.size() - 1 ; i ++)
+ for( int i = 0 ; i != list.size() ; i ++)
{
- if ( list.get( i ).equals(list.get( i + 1 )))
+
+ if (dtUsers.contains(list.get(i)))
{
- count += 1;
+ dtCount.set(dtUsers.indexOf(list.get(i)),
dtCount.get(dtUsers.indexOf(list.get(i))) + 1);
}
else
{
- dtUsers.put(list.get(i),
Integer.valueOf(count));
- count = 1;
+ dtUsers.add(list.get(i));
+ dtCount.add(1);
}
+
}
- Enumeration<String> enu = dtUsers.keys();
- while( enu.hasMoreElements())
+ if (dtUsers.size() > 0)
{
- String it = enu.nextElement();
- count = dtUsers.get(it).intValue();
+ throwRes();
+ }
+
+ for(String it : dtUsers)
+ {
+ count = dtCount.get(dtUsers.indexOf(it));
if ( type == REPLY )
{
@@ -439,10 +460,10 @@
*/
public void quitGadget()
{
- //if(this.getCommand().equalsIgnoreCase("check") &&
this.throwed)
- //{
- //this.throwResult(false);
- //}
+ if(this.getCommand().equalsIgnoreCase("check") && this.throwed)
+ {
+ this.throwResult(false);
+ }
System.exit(0);
}
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn