Skip to content
This repository has been archived by the owner on Dec 12, 2020. It is now read-only.

Commit

Permalink
Code formatting; Change 'Add reminder' to 'Schedule' and move above S…
Browse files Browse the repository at this point in the history
…hare in overflow menu
  • Loading branch information
ginatrapani committed Jul 30, 2013
1 parent bb9b4d7 commit d53c535
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 42 deletions.
10 changes: 5 additions & 5 deletions res/menu/main_long.xml
Expand Up @@ -49,16 +49,16 @@ You should have received a copy of the GNU General Public License along with Tod
android:icon="@drawable/ic_action_delete"
android:showAsAction="ifRoom"
android:title="@string/delete"/>
<item
android:id="@+id/share"
android:icon="@drawable/ic_action_share"
android:showAsAction="never"
android:title="@string/share"/>
<item
android:id="@+id/calendar"
android:showAsAction="never"
android:title="@string/add_to_calendar"
android:enabled="@bool/api_14_or_above"/>
<item
android:id="@+id/share"
android:icon="@drawable/ic_action_share"
android:showAsAction="never"
android:title="@string/share"/>
<item
android:id="@+id/url"
android:visible="false"/>
Expand Down
2 changes: 1 addition & 1 deletion res/values/strings.xml
Expand Up @@ -49,7 +49,7 @@ You should have received a copy of the GNU General Public License along with Tod
<string name="update">Update</string>
<string name="delete">Delete</string>
<string name="share">Share</string>
<string name="add_to_calendar">Add reminder</string>
<string name="add_to_calendar">Schedule</string>
<string name="calendar_title">Todo.txt reminder</string>
<string name="archive">Archive</string>
<string name="unComplete">Undo complete</string>
Expand Down
64 changes: 35 additions & 29 deletions src/com/todotxt/todotxttouch/TodoApplication.java
Expand Up @@ -64,14 +64,15 @@ public class TodoApplication extends Application {
public void onCreate() {
super.onCreate();
TodoApplication.appContext = getApplicationContext();
m_prefs = new TodoPreferences(appContext, PreferenceManager.getDefaultSharedPreferences(this));

m_prefs = new TodoPreferences(appContext,
PreferenceManager.getDefaultSharedPreferences(this));

try {
new UpgradeHandler(this).run();
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Failed to run Uprade Tasks", e);
}

remoteClientManager = new RemoteClientManager(this, m_prefs);
this.taskBag = TaskBagFactory.getTaskBag(this, m_prefs);

Expand Down Expand Up @@ -101,9 +102,10 @@ public void onTerminate() {
}
super.onTerminate();
}

/**
* Are we currently pushing or pulling remote data?
*
* @return true iff a remote operation currently in progress.
*/
public boolean syncInProgress() {
Expand All @@ -127,7 +129,8 @@ private void syncWithRemote(boolean force, boolean suppressToast) {
/**
* Check network status, then push.
*/
private void pushToRemote(boolean force, boolean overwrite, boolean suppressToast) {
private void pushToRemote(boolean force, boolean overwrite,
boolean suppressToast) {
pushQueue += 1;
m_prefs.storeNeedToPush(true);
if (!force && m_prefs.isManualModeEnabled()) {
Expand All @@ -137,12 +140,12 @@ private void pushToRemote(boolean force, boolean overwrite, boolean suppressToas
Log.i(TAG, "Working online; should push if file revisions match");
backgroundPushToRemote(overwrite, suppressToast);
} else if (m_pulling) {
Log.d(TAG, "app is pulling right now. don't start push.");
Log.d(TAG, "app is pulling right now. don't start push.");
} else {
Log.i(TAG, "Not connected, don't push now");
if (!suppressToast) {
showToast(R.string.toast_notconnected);
updateSyncUI(true);
showToast(R.string.toast_notconnected);
updateSyncUI(true);
}
}
}
Expand All @@ -163,13 +166,13 @@ private void pullFromRemote(boolean force, boolean suppressToast) {
Log.i(TAG, "Working online; should pull file");
backgroundPullFromRemote();
} else if (m_pushing) {
Log.d(TAG, "app is pushing right now. don't start pull.");
Log.d(TAG, "app is pushing right now. don't start pull.");
} else {
Log.i(TAG, "Not connected, don't pull now");

if (!suppressToast) {
showToast(R.string.toast_notconnected);
updateSyncUI(true);
showToast(R.string.toast_notconnected);
updateSyncUI(true);
}
}
}
Expand Down Expand Up @@ -197,9 +200,10 @@ public void showToast(String string) {
/**
* Do asynchronous push with gui changes. Do availability check first.
*/
void backgroundPushToRemote(final boolean overwrite, final boolean suppressToast) {
void backgroundPushToRemote(final boolean overwrite,
final boolean suppressToast) {
if (getRemoteClientManager().getRemoteClient().isAuthenticated()) {
if(!(m_pushing || m_pulling)) {
if (!(m_pushing || m_pulling)) {
new AsyncPushTask(overwrite, suppressToast).execute();
}
} else {
Expand All @@ -214,20 +218,20 @@ private class AsyncPushTask extends AsyncTask<Void, Void, Integer> {
static final int ERROR = 2;

private boolean overwrite;
private boolean suppressToast;
private boolean suppressToast;

public AsyncPushTask(boolean overwrite, boolean suppressToast) {
this.overwrite = overwrite;
this.suppressToast = suppressToast;
}

@Override
protected void onPreExecute() {
m_pushing = true;
pushQueue = 0;
updateSyncUI(false);
}

@Override
protected Integer doInBackground(Void... params) {
try {
Expand All @@ -250,7 +254,8 @@ protected void onPostExecute(Integer result) {
if (result == SUCCESS) {
if (pushQueue > 0) {
m_pushing = true;
Log.d(TAG, "pushQueue == " + pushQueue + ". Need to push again.");
Log.d(TAG, "pushQueue == " + pushQueue
+ ". Need to push again.");
new AsyncPushTask(false, suppressToast).execute();
} else {
Log.d(TAG, "taskBag.pushToRemote done");
Expand Down Expand Up @@ -316,7 +321,7 @@ protected void onPostExecute(Boolean result) {
private void updateSyncUI(boolean redrawList) {
sendBroadcast(new Intent(Constants.INTENT_UPDATE_UI).putExtra(
"redrawList", redrawList));
if(redrawList) {
if (redrawList) {
broadcastWidgetUpdate();
}
}
Expand All @@ -329,7 +334,7 @@ public void onReceive(Context context, Intent intent) {
boolean overwrite = intent.getBooleanExtra(
Constants.EXTRA_OVERWRITE, false);
boolean suppressToast = intent.getBooleanExtra(
Constants.EXTRA_SUPPRESS_TOAST, false);
Constants.EXTRA_SUPPRESS_TOAST, false);
if (intent.getAction().equalsIgnoreCase(
Constants.INTENT_START_SYNC_WITH_REMOTE)) {
syncWithRemote(force_sync, suppressToast);
Expand All @@ -341,9 +346,9 @@ public void onReceive(Context context, Intent intent) {
pullFromRemote(force_sync, suppressToast);
} else if (intent.getAction().equalsIgnoreCase(
Constants.INTENT_ASYNC_FAILED)) {
if (!suppressToast) {
showToast("Synchronizing Failed");
}
if (!suppressToast) {
showToast("Synchronizing Failed");
}
m_pulling = false;
m_pushing = false;
updateSyncUI(true);
Expand All @@ -361,13 +366,14 @@ public void storeSort() {
m_prefs.storeSort(sort);
broadcastWidgetUpdate();
}

public void getStoredSort() {
sort = m_prefs.getSort();
}

public void storeFilters() {
m_prefs.storeFilters(m_prios, m_contexts, m_projects, m_search, m_filters);
m_prefs.storeFilters(m_prios, m_contexts, m_projects, m_search,
m_filters);
broadcastWidgetUpdate();
}

Expand All @@ -376,7 +382,7 @@ public void getStoredFilters() {
m_contexts = m_prefs.getFilteredContexts();
m_projects = m_prefs.getFilteredProjects();
m_search = m_prefs.getSearch();
//split on tab just in case there is a space in the text
// split on tab just in case there is a space in the text
m_filters = m_prefs.getFilterSummaries();
}

Expand Down
14 changes: 7 additions & 7 deletions src/com/todotxt/todotxttouch/TodoTxtTouch.java
Expand Up @@ -488,14 +488,14 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (m_drawerToggle!=null) {
if (m_drawerToggle != null) {
m_drawerToggle.onConfigurationChanged(newConfig);
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home && m_drawerLayout!=null) {
if (item.getItemId() == android.R.id.home && m_drawerLayout != null) {

if (m_drawerLayout.isDrawerOpen(m_drawerList)) {
m_drawerLayout.closeDrawer(m_drawerList);
Expand Down Expand Up @@ -524,7 +524,7 @@ private String selectedTasksAsString(List<Task> tasks) {
}
return text;
}

private void shareTasks(List<Task> tasks) {
String shareText = selectedTasksAsString(tasks);
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
Expand Down Expand Up @@ -556,7 +556,7 @@ private void addToCalendar(List<Task> checkedTasks) {
.putExtra(Events.DESCRIPTION, calendarDescription);
startActivity(intent);
}

private void prioritizeTasks(final ArrayList<Task> tasks) {
final String[] prioArr = Priority
.rangeInCode(Priority.NONE, Priority.E).toArray(new String[0]);
Expand Down Expand Up @@ -914,9 +914,9 @@ private void handleSyncConflict() {
*/
@SuppressWarnings("deprecation")
private void syncClient(boolean force) {

m_pullToRefreshAttacher.setRefreshing(true);

if (!force && m_app.m_prefs.isManualModeEnabled()) {
Log.v(TAG,
"Manual mode, choice forced; prompt user to ask which way to sync");
Expand Down Expand Up @@ -1555,7 +1555,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position,

setDrawerChoices();
m_app.storeFilters();
if (m_drawerLayout!=null) {
if (m_drawerLayout != null) {
m_drawerLayout.closeDrawer(m_drawerList);
}
setFilteredTasks(false);
Expand Down

0 comments on commit d53c535

Please sign in to comment.