Ran findbugs on my code, fixed some bugs. Also, changed the auto sort algorithm to move "in progress" tasks to the top, and also fixed a bug with sync remembering.

pull/14/head
Tim Su 16 years ago
parent bf282c128b
commit 8bb97a73df

@ -21,7 +21,6 @@ package com.mdt.rtm;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.Socket;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@ -94,7 +93,7 @@ public class Invoker {
public static final String ENCODING = "UTF-8";
public static String API_SIG_PARAM = "api_sig";
public static final String API_SIG_PARAM = "api_sig";
public static final long INVOCATION_INTERVAL = 750;
@ -104,18 +103,8 @@ public class Invoker {
private final MessageDigest digest;
private String proxyHostName;
private int proxyPortNumber;
private String proxyLogin;
private String proxyPassword;
private String serviceRelativeUri;
private HttpHost host;
private HttpContext context;
private BasicHttpParams globalHttpParams;
@ -132,7 +121,7 @@ public class Invoker {
throws ServiceInternalException
{
this.serviceRelativeUri = serviceRelativeUri;
host = new HttpHost(serverHostName, serverPortNumber);
new HttpHost(serverHostName, serverPortNumber);
context = new BasicHttpContext();
globalHttpParams = new BasicHttpParams();
HttpProtocolParams.setVersion(globalHttpParams, HttpVersion.HTTP_1_1);
@ -165,37 +154,6 @@ public class Invoker {
}
}
public void setHttpProxySettings(String proxyHostName, int proxyPortNumber, String proxyLogin, String proxyPassword)
{
this.proxyHostName = proxyHostName;
this.proxyPortNumber = proxyPortNumber;
this.proxyLogin = proxyLogin;
this.proxyPassword = proxyPassword;
}
private void prepareConnection()
throws ServiceInternalException
{
connection = new DefaultHttpClientConnection();
// We open the necessary socket connection
try
{
if (connection.isOpen() == false)
{
final Socket socket = new Socket(host.getHostName(), host.getPort());
connection.bind(socket, globalHttpParams);
}
}
catch (Exception exception)
{
final StringBuffer message = new StringBuffer("Cannot open a socket connection to '").append(host.getHostName()).append("' on port number ").append(
host.getPort()).append(": cannot execute query");
Log.e(TAG, message.toString(), exception);
throw new ServiceInternalException(message.toString());
}
}
private StringBuffer computeRequestUri(Param... params)
throws ServiceInternalException
{

@ -24,7 +24,7 @@ import java.util.Date;
import com.mdt.rtm.data.RtmData;
/**
*
*
* @author Will Ross Jun 21, 2007
*/
public class Param

@ -47,6 +47,7 @@ import com.mdt.rtm.data.RtmTask.Priority;
*
* @author Will Ross Jun 21, 2007
* @author Edouard Mercier, since 2008.04.15
* @author timsu January 2009
*/
public class ServiceImpl implements Service
{
@ -83,24 +84,6 @@ public class ServiceImpl implements Service
}
}
/**
* If you want to go through an HTTP proxy.
*
* @param proxyHostName
* the host name of the HTTP proxy machine (if <code>null</code>, no proxy is set, and all parameters are ignored)
* @param proxyPortNumber
* the port number the HTTP proxy listens to
* @param proxyLogin
* the account identifier against the HTTP proxy: if set to <code>null</code>, no authentication will be performed and the HTTP is
* considered working anonymously, and the last <code>proxyPassword</code> parameter is not taken into account
* @param proxyPassword
* the previous identifier related password
*/
public void setHttpProxySettings(String proxyHostName, int proxyPortNumber, String proxyLogin, String proxyPassword)
{
invoker.setHttpProxySettings(proxyHostName, proxyPortNumber, proxyLogin, proxyPassword);
}
public boolean isServiceAuthorized()
throws ServiceException
{

@ -631,7 +631,7 @@ public class TaskList extends Activity {
return;
sortReverse = sortId < 0;
sortMode = SortMode.values()[Math.abs(sortId)];
sortMode = SortMode.values()[Math.abs(sortId - 1)];
}
@Override
@ -688,43 +688,43 @@ public class TaskList extends Activity {
return true;
case CONTEXT_FILTER_HIDDEN:
filterShowHidden = !filterShowHidden;
TaskList.filterShowHidden = !filterShowHidden;
fillData();
return true;
case CONTEXT_FILTER_DONE:
filterShowDone = !filterShowDone;
TaskList.filterShowDone = !filterShowDone;
fillData();
return true;
case CONTEXT_FILTER_TAG:
filterTag = null;
TaskList.filterTag = null;
fillData();
return true;
case CONTEXT_SORT_AUTO:
if(sortMode == SortMode.AUTO)
return true;
sortReverse = false;
sortMode = SortMode.AUTO;
TaskList.sortReverse = false;
TaskList.sortMode = SortMode.AUTO;
saveTaskListSort();
fillData();
return true;
case CONTEXT_SORT_ALPHA:
if(sortMode == SortMode.ALPHA)
return true;
sortReverse = false;
sortMode = SortMode.ALPHA;
TaskList.sortReverse = false;
TaskList.sortMode = SortMode.ALPHA;
saveTaskListSort();
fillData();
return true;
case CONTEXT_SORT_DUEDATE:
if(sortMode == SortMode.DUEDATE)
return true;
sortReverse = false;
sortMode = SortMode.DUEDATE;
TaskList.sortReverse = false;
TaskList.sortMode = SortMode.DUEDATE;
saveTaskListSort();
fillData();
return true;
case CONTEXT_SORT_REVERSE:
sortReverse = !sortReverse;
TaskList.sortReverse = !sortReverse;
saveTaskListSort();
fillData();
return true;

@ -32,8 +32,8 @@ public class TagModelForView extends AbstractTagModel {
NAME,
};
public static TagModelForView UNTAGGED_TASKS = new TagModelForView("[untagged]");
public static String HIDDEN_FROM_MAIN_LIST_PREFIX = "_";
public static final TagModelForView UNTAGGED_TASKS = new TagModelForView("[untagged]");
public static final String HIDDEN_FROM_MAIN_LIST_PREFIX = "_";
// --- constructors

@ -51,6 +51,10 @@ public class TaskModelForList extends AbstractTaskModel {
public int getTaskWeight() {
int weight = 0;
// bubble tasks with timers to the top
if(getTimerStart() != null)
weight -= 10000;
// importance
weight += getImportance().ordinal() * 80;

@ -45,7 +45,7 @@ public abstract class SynchronizationService {
// called off the UI thread. does some setup
void synchronizeService(final Activity activity) {
syncHandler = new Handler();
progressDialog = new ProgressDialog(activity);
SynchronizationService.progressDialog = new ProgressDialog(activity);
progressDialog.setIcon(android.R.drawable.ic_dialog_alert);
progressDialog.setTitle("Synchronization");
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
@ -333,6 +333,7 @@ public abstract class SynchronizationService {
mapping);
} catch (Exception e) {
// unique violation: ignore - it'll get merged later
Log.e("astrid-sync", "Exception creating mapping", e);
}
}
stats.localCreatedTasks++;
@ -490,7 +491,7 @@ public abstract class SynchronizationService {
}
}
protected class ProgressUpdater implements Runnable {
protected static class ProgressUpdater implements Runnable {
int step, outOf;
public ProgressUpdater(int step, int outOf) {
this.step = step;
@ -501,7 +502,7 @@ public abstract class SynchronizationService {
}
}
protected class ProgressLabelUpdater implements Runnable {
protected static class ProgressLabelUpdater implements Runnable {
String label;
public ProgressLabelUpdater(String label) {
this.label = label;

@ -67,15 +67,15 @@ public class DateControlSet implements OnTimeSetListener,
/** Initialize the components for the given date field */
public void setDate(Date newDate) {
this.date = newDate;
if(newDate == null) {
date = new Date();
Integer days = Preferences.getDefaultDeadlineDays(activity);
if(days == null)
days = 1;
date.setTime(date.getTime() + days*24*3600*1000);
date.setTime(date.getTime() + days*24L*3600*1000);
date.setMinutes(0);
}
} else
this.date = new Date(newDate.getTime());
updateDate();
updateTime();

@ -295,7 +295,7 @@ public class NumberPicker extends LinearLayout implements OnClickListener,
/*
* When focus is lost check that the text field has valid values.
*/
if (!hasFocus) {
if (!hasFocus && v instanceof TextView) {
String str = String.valueOf(((TextView) v).getText());
if ("".equals(str)) {

Loading…
Cancel
Save