From 80968a77fdab56fb71b68051e7fa14d96a645a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20Sowi=C5=84ski?= Date: Mon, 12 Dec 2011 20:30:58 +0100 Subject: [PATCH 1/7] Updates and corrections (spelling, grammar) in Polish translation. --- astrid/res/values-pl/strings.xml | 232 +++++++++++++++---------------- 1 file changed, 116 insertions(+), 116 deletions(-) diff --git a/astrid/res/values-pl/strings.xml b/astrid/res/values-pl/strings.xml index 1c7a12aaf..41e5bcd57 100644 --- a/astrid/res/values-pl/strings.xml +++ b/astrid/res/values-pl/strings.xml @@ -5,10 +5,10 @@ - Udostęp + Udostępnij - Contact or Email + Kontakt lub e-mail Kontakt lub lista udostępionych @@ -17,7 +17,7 @@ Zapisano na serwerze - Save Failed: %s + Błąd zapisu: %s Niestety, ale ta operacja nie jest jeszcze obsługiwana przez udostepnione tagi. @@ -26,10 +26,10 @@ Zrób zdjęcie - Wynierz z galerii + Wybierz z galerii - Clear Picture + Usuń obrazek Odśwież listy @@ -56,7 +56,7 @@ %s\'s tasks. Tap for all. - Private: tap to share this list + Prywatna: puknij by udostępnić Odśwież @@ -91,13 +91,13 @@ Zapisz i udostępnij - Who + Kto Ja - Anyone + Ktokolwiek Inny... @@ -106,7 +106,7 @@ Dodaj współpracowników: - Share with Friends + Udostępnij znajomym Lista: %s @@ -118,7 +118,7 @@ Widomość zaproszenia: - Pomoc mi to zrobić! + Pomóż mi to zrobić! Utwórz tag udostępnienia? @@ -153,13 +153,13 @@ Astrid.com umożliwia dostęp do zadań online, udostępniania i przekazywania innym. - Login with Facebook + Zaloguj przez Facebook - Login with Google + Zaloguj przez Google - Don\'t use Google or Facebook? + Nie używasz Google ani Facebooka? Zarejestruj się tutaj @@ -186,28 +186,28 @@ Utwórz nowe konto - Zalogój sie do Astrid.com + Zaloguj sie do Astrid.com Proszę połączyć się z Google: - Astrid nie wysyła wiadomości email bez zezwolenia. + Astrid nie wysyła wiadomości e-mail bez zezwolenia. Astrid.com (Beta!) - Use HTTPS - HTTPS enabled (slower) - HTTPS disabled (faster) + Użycie HTTPS + HTTPS włączone (wolniej) + HTTPS wyłączone (szybciej) Synchronizuj - Nowe komentarze otrzymano / kliknij po więcej informacji + Otrzymano nowe komentarze / kliknij po więcej informacji @@ -244,9 +244,9 @@ Stan - Latest backup:\n%s + Ostatnia kopia zapasowa:\n%s - Ostatnie niepowodzenie kopii zapasowej + Błąd zapisu ostatniej kopii (dotknij, aby zobaczyć błąd) @@ -375,11 +375,11 @@ Ładowanie... - Dismiss + Porzuć OK - Cancel + Anuluj @@ -394,7 +394,7 @@ - Accept EULA to get started! + Zaakceptuj EULA by rozpocząć! @@ -406,7 +406,7 @@ Komentarze - Nic do pokazania + Brak komentarzy Odśwież komentarze @@ -429,7 +429,7 @@ Ustawienia - Support + Wsparcie Przeszukaj tą listę @@ -438,7 +438,7 @@ Własny filtr - Add a task + Dodaj zadanie Tap to assign %s a task @@ -447,15 +447,15 @@ Powiadomienia są wyciszone. Nie będziesz w stanie usłyszeć Astrid! - Astrid reminders are disabled! You will not receive any reminders + Powiadomienia są wyłączone! Nie otrzymasz żadnych powiadomień - Active + Aktywne Dzisiaj - Soon - Late + Wkrótce + Spóźnione Gotowe - Hidden + Ukryte @@ -485,7 +485,7 @@ Usuń zadanie - Przywrócone zadanie + Przywróć zadanie Usuń zadanie na trwałe @@ -564,7 +564,7 @@ Utworzono skrót: %s - New Filter + Nowy filtr @@ -578,7 +578,7 @@ Podstawowe - Udostęp + Udostępnij Alarmy @@ -590,7 +590,7 @@ Tytuł - When + Kiedy Podsumowanie zadania @@ -608,7 +608,7 @@ Brak - Show Task + Pokaż zadanie Ładowanie... @@ -658,28 +658,28 @@ Przyszły miesiąc - No time + Bez godziny Zawsze - At due date - Dzień przez wymaganiem - Tydzień przed wymaganiem + W terminie + Dzień przed terminem + Tydzień przed terminem Konkretny dzień/godzina - Task Title - Who - When - More Section + Tytuł zadania + Kto + Kiedy + Sekcja "Więcej" Skala ważności Listy Notatki - Reminders - Timer Controls - Share With Friends + Przypomnienia + Kontrola czasu + Udostępnij @@ -695,7 +695,7 @@ @string/TEA_control_share - Show in my list + Pokaż na mojej liście Szukasz więcej funkcji? @@ -707,9 +707,9 @@ Więcej - When is this due? + Na kiedy ma być zrobione? - Date/Time + Data/Godzina @@ -739,7 +739,7 @@ Astrid: Właściwości - deactivated + nieaktywne Wygląd @@ -752,9 +752,9 @@ Pokaż notatki w zadaniu - Beast Mode - Customize the layout of the Task Edit Page - Reset to defaults + Tryb "Beast" + Dostosuj układ strony edycji zadania + Powrót domyślne Notatki będą wyświetlane na pasku szybkiego działania @@ -762,7 +762,7 @@ Notatki będą zawsze wyświetlane - Color Theme + Kolorystyka Aktualnie: %s @@ -777,10 +777,10 @@ - Day - Night - Transparent (White Text) - Transparent (Black Text) + Dzień + Noc + Przezroczysty (biały tekst) + Przezroczysty (czarny tekst) @@ -796,15 +796,15 @@ Oczyszczone %d zadań! Uwaga! Oczyszczone zadania nie mogą być odzyskane bez pliku kopii zapasowej! - Delete Calendar Events for Completed Tasks - Do you really want to delete all your events for completed tasks? + Usuń wydarzenia kalendarza dla zakończonych zadań + Na pewno chcesz usunąć wszystkie wydarzenia dla zakończonych zadań? - Deleted %d calendar events! + Usunięto %d wydarzeń kalendarza! - Delete All Calendar Events for Tasks - Do you really want to delete all your events for tasks? + Usuń wszystkie zdarzenia kalendarza dla zadań + Na pewno chcesz usunąć wszystkie wydarzenia dla zadań? - Deleted %d calendar events! + Usunięto %d wydarzeń kalendarza! @@ -846,7 +846,7 @@ O Astrid -Bieżąca wersja: %s\n\n Astrid is open-source and proudly maintained by Todoroo, Inc. +Bieżąca wersja: %s\n\n Astrid ma otwarte źródła i jest zarządzana z dumą przez Todoroo, Inc. Pomoc @@ -893,14 +893,14 @@ Aktualnie: %s - Default Add To Calendar + Domyślnie dodawaj do kalendarza - New tasks will not create an event in the Google Calendar + Nowe zadania nie utworzą wydarzeń w Kalendarzu Google - New tasks will be in the calendar: \"%s\" + Nowe zadania będą w kalendarzu: \"%s\" - Default Ring/Vibrate type + Domyślny dzwonek/wibracja Aktualnie: %s @@ -924,17 +924,17 @@ Nie ukrywaj - Zadanie jest wymagane - Dzień przez wymaganiem - Tydzień przed wymaganiem + Do terminu zadania + Do dnia przed terminem + Do tygodnia przed terminem - Brak przypomnień dla terminu nieprzekraczalnego - W dniu terminu nieprzekraczalnego + Brak przypomnień + W dniu terminu Gdy zaległe - W nieprzekraczalnym terminie lub gdy zaległe + W terminie lub gdy zaległe @@ -963,7 +963,7 @@ Własny filtr... - Filters + Filtry Usuń filtr @@ -1062,19 +1062,19 @@ Integracja z kalendarzem: - Add to Calendar + Dodaj do kalendarza - Otwórz zdarzenie kalendarza + Otwórz wydarzenie kalendarza - Błąd podczas otwierania zdarzenia! + Błąd podczas otwierania wydarzenia! - Zdarzenie kalendarza również uaktualnione! + Wydarzenie kalendarza również uaktualnione! - Don\'t add + Nie dodawaj @@ -1102,7 +1102,7 @@ Zadania Google: %s - Creating list... + Tworzenie listy... Nowa nazwa listy: @@ -1121,10 +1121,10 @@ Na liście GTasks... - Clearing completed tasks... + Czyszczenie zakończonych zadań... - Clear Completed + Wyczyść zakończone @@ -1168,9 +1168,9 @@ Google Tasks (Beta!) - Synch przy Zapisie + Synch. przy Zapisie - Synch poszczególne zadania, ponieważ są one zapisane + Synch. poszczególne zadania, gdy są one zapisane @@ -1178,16 +1178,16 @@ Astrid: Zadania Google - Google\'s Task API is in beta and has encountered an error. The service may be down, please try again later. + API Zadań Google jest w fazie beta i napotkano błąd. Serwis może być niedostępny, spróbuj ponownie później. - Account %s not found--please log out and log back in from the Google Tasks settings. + Nie znaleziono konta %s --proszę wyloguj się i zaloguj ponownie w ustawieniach Google Zadań. - Unable to authenticate with Google Tasks. Please check your account password or try again later. + Uwierzytelnienie w Google Zadania nieudane. Proszę, sprawdź poprawność swego hasła lub spróbuj ponownie później. - Error in your phone\'s account manager. Please log out and log back in from the Google Tasks settings. + Błąd w menadżerze kont Twojego telefonu. Proszę, wyloguj się i zaloguj ponownie w ustawieniach Google Zadań. @@ -1223,7 +1223,7 @@ - Ustaw synch z Astrid.com + Ustaw synch. z Astrid.com @@ -1237,39 +1237,39 @@ - Add a task here + Dodaj zadanie tutaj - Tap task to edit and share + Puknij zadanie by je edytować i udostępnić - Tap list settings to share the entire list + Puknij ustawienia listy by udostępnić całą listę - Collaborators can help you build your list or finish tasks + Współpracownicy mogą Ci pomóc stworzyć listę lub wykonać zadania Witaj w Astrid! - By using Astrid you agree to the + Używając Astrid zgadzasz się na - \"Terms of Service\" + \"Warunki korzystania z usług\" - Login with Username/Password + Zaloguj za pomocą loginu/hasła - Login Later + Zaloguj później - Why not sign in? + Czemu by się nie zalogować? - I\'ll do it! + Zrobię to! - No thanks + Nie, dzięki - Sign in to get the most out of Astrid! - For free, you get online backup, full synchronization with Astrid.com, the - ability to add tasks via email, and you can even share task lists with friends! + Zaloguj się by wyciągnąć z Astrid jeszcze więcej! + Za darmo otrzymasz kopię zapasową online, pełną synchronizację z Astrid.com, + możliwość dodawania zadań przez e-mail i będziesz mógł dzielić się swoimi listami zadań ze znajomymi! @@ -1389,7 +1389,7 @@ - Zalogój do OpenCRX + Zaloguj do OpenCRX Zaloguj się na konto OpenCRX @@ -1617,7 +1617,7 @@ - Reminders + Przypomnienia Przypomnij mi: @@ -1673,11 +1673,11 @@ Ustawienia przypomnienia - Reminders Enabled? + Przypomnienia włączone? - Astrid reminders are enabled (this is normal) + Przypomnienia Astrid są włączone (to normalne) - Astrid reminders will never appear on your phone + Przypomnienia Astrid nigdy nie pojawią się na Twoim telefonie Początek czasu wyciszenia @@ -1732,7 +1732,7 @@ Astrid nie będzie powiadamiał wibracjami podczas wysyłania powiadomienia - Astrid Zachęta + Zachęta Astrid Astrid pojawi się podczas przypomnienia @@ -1961,9 +1961,9 @@ Odstęp powtarzania - Never + Nigdy - Don\'t repeat + Nie powtarzaj @@ -2112,7 +2112,7 @@ Not in any List - Not in an Astrid List + Poza listą Astrid Lista: %s From f5bc5fbca2601d40b50d4e9d4575d47fc7a1ab8c Mon Sep 17 00:00:00 2001 From: Andrew Shaw Date: Wed, 18 Jan 2012 22:04:43 -0800 Subject: [PATCH 2/7] Fixed regular expression error where task only added the first word of the tag --- .../todoroo/astrid/utility/TitleParser.java | 19 +++++--- .../andlib/utility/TitleParserTest.java | 44 +++++++++++++++++++ 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/utility/TitleParser.java b/astrid/src/com/todoroo/astrid/utility/TitleParser.java index 33a1f918a..556f5916a 100644 --- a/astrid/src/com/todoroo/astrid/utility/TitleParser.java +++ b/astrid/src/com/todoroo/astrid/utility/TitleParser.java @@ -29,19 +29,28 @@ public class TitleParser { priorityHelper(task); } - private static void listHelper(Task task, ArrayList tags) { + public static String trimParenthesis(String pattern){ + if (pattern.charAt(0) == '#' || pattern.charAt(0) == '@') { + pattern = pattern.substring(1); + } + if ('(' == pattern.charAt(0)) { + return pattern.substring(1, pattern.length()-2); + } + return pattern; + } + public static void listHelper(Task task, ArrayList tags) { String inputText = task.getValue(Task.TITLE); - Pattern tagPattern = Pattern.compile("(\\s|^)#([^\\s]+)"); - Pattern contextPattern = Pattern.compile("(\\s|^)(@[^\\s]+)"); + Pattern tagPattern = Pattern.compile("(\\s|^)#(\\(.*\\)|[^\\s]+)"); + Pattern contextPattern = Pattern.compile("(\\s|^)@(\\(.*\\)|[^\\s]+)"); while(true) { Matcher m = tagPattern.matcher(inputText); if(m.find()) { - tags.add(m.group(2)); + tags.add(TitleParser.trimParenthesis(m.group(2))); } else { m = contextPattern.matcher(inputText); if(m.find()) { - tags.add(m.group(2)); + tags.add(TitleParser.trimParenthesis(m.group(2))); }else{ break; } diff --git a/tests/src/com/todoroo/andlib/utility/TitleParserTest.java b/tests/src/com/todoroo/andlib/utility/TitleParserTest.java index 27ab7a4ed..704b0d3ed 100644 --- a/tests/src/com/todoroo/andlib/utility/TitleParserTest.java +++ b/tests/src/com/todoroo/andlib/utility/TitleParserTest.java @@ -1,6 +1,7 @@ package com.todoroo.andlib.utility; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -10,6 +11,7 @@ import com.timsu.astrid.R; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.test.DatabaseTestCase; +import com.todoroo.astrid.utility.TitleParser; public class TitleParserTest extends DatabaseTestCase { @@ -504,6 +506,48 @@ public class TitleParserTest extends DatabaseTestCase { //----------------Repeats end----------------// + //----------------Tags begin----------------// + /** tests all words using priority 0 */ + public void testTagsPound() throws Exception { + String[] acceptedStrings = { + "#tag", + "#a", + "#(a cool tag)", + "#(cool)" + }; + TaskService taskService = new TaskService(); + Task task = new Task(); + for (String acceptedString:acceptedStrings){ + task = new Task(); + task.setValue(Task.TITLE, "Jog " + acceptedString); //test at end of task. should set importance. + ArrayList tags = new ArrayList(); + TitleParser.listHelper(task, tags); + assertTrue("test pound at failed for string: " + acceptedString + " for tags: " + tags.toString(),tags.contains(TitleParser.trimParenthesis(acceptedString))); + } + } + + /** tests all words using priority 0 */ + public void testTagsAt() throws Exception { + String[] acceptedStrings = { + "@tag", + "@a", + "@(a cool tag)", + "@(cool)" + }; + TaskService taskService = new TaskService(); + Task task = new Task(); + for (String acceptedString:acceptedStrings){ + task = new Task(); + task.setValue(Task.TITLE, "Jog " + acceptedString); //test at end of task. should set importance. + ArrayList tags = new ArrayList(); + TitleParser.listHelper(task, tags); + assertTrue("testTagsAt failed for string: " + acceptedString+ " for tags: " + tags.toString(),tags.contains(TitleParser.trimParenthesis(acceptedString))); + } + } + + + + //----------------Priority end----------------// } From 8ffe684d94a77ca10946f77a2863a82ee77a0dbc Mon Sep 17 00:00:00 2001 From: Tim Su Date: Thu, 19 Jan 2012 00:28:16 -0800 Subject: [PATCH 3/7] Bring back a menu item for synchronizing with Astrid.com from task list activity. Modified the abstract provider class to make that happen --- .../astrid/actfm/ActFmSyncActionExposer.java | 6 +- .../actfm/sync/ActFmSyncV2Provider.java | 9 ++- .../astrid/activity/TaskListActivity.java | 78 ++++++++++++------- .../astrid/service/StartupService.java | 54 +------------ .../todoroo/astrid/service/SyncV2Service.java | 47 +++++++++-- 5 files changed, 102 insertions(+), 92 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmSyncActionExposer.java b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmSyncActionExposer.java index d3a0c0cd8..35ba9c285 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmSyncActionExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmSyncActionExposer.java @@ -3,7 +3,6 @@ */ package com.todoroo.astrid.actfm; -import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -38,11 +37,8 @@ public class ActFmSyncActionExposer extends BroadcastReceiver { if(!actFmPreferenceService.isLoggedIn()) return; - Intent syncIntent = new Intent(null, null, - context, ActFmBackgroundService.class); - PendingIntent pendingIntent = PendingIntent.getService(context, 0, syncIntent, PendingIntent.FLAG_UPDATE_CURRENT); SyncAction syncAction = new SyncAction(context.getString(R.string.actfm_APr_header), - pendingIntent); + null); Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_SYNC_ACTIONS); broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, ActFmPreferenceService.IDENTIFIER); diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java index 78dc16837..b9d22f6eb 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java @@ -8,8 +8,10 @@ import java.util.concurrent.atomic.AtomicInteger; import org.json.JSONException; +import com.timsu.astrid.R; import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.service.Autowired; +import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.ExceptionService; import com.todoroo.andlib.sql.Criterion; @@ -29,7 +31,7 @@ import com.todoroo.astrid.tags.TagService; * Exposes sync action * */ -public class ActFmSyncV2Provider implements SyncV2Provider { +public class ActFmSyncV2Provider extends SyncV2Provider { @Autowired ActFmPreferenceService actFmPreferenceService; @@ -47,6 +49,11 @@ public class ActFmSyncV2Provider implements SyncV2Provider { DependencyInjectionService.getInstance().inject(this); } + @Override + public String getName() { + return ContextManager.getString(R.string.actfm_APr_header); + } + @Override public boolean isActive() { return actFmPreferenceService.isLoggedIn(); diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index 6709f6fa8..392fc3ab2 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -105,6 +105,8 @@ import com.todoroo.astrid.service.StartupService; import com.todoroo.astrid.service.StatisticsConstants; import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.service.SyncV2Service; +import com.todoroo.astrid.service.SyncV2Service.SyncResultCallback; +import com.todoroo.astrid.service.SyncV2Service.SyncV2Provider; import com.todoroo.astrid.service.TagDataService; import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.service.ThemeService; @@ -204,6 +206,8 @@ public class TaskListActivity extends ListActivity implements OnScrollListener, private boolean isFilter; private final TaskListContextMenuExtensionLoader contextMenuExtensionLoader = new TaskListContextMenuExtensionLoader(); + + private SyncResultCallback syncResultCallback; private VoiceInputAssistant voiceInputAssistant; /* ====================================================================== @@ -498,6 +502,14 @@ public class TaskListActivity extends ListActivity implements OnScrollListener, // dithering getWindow().setFormat(PixelFormat.RGBA_8888); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER); + + syncResultCallback = new ProgressBarSyncResultCallback(this, + R.id.progressBar, new Runnable() { + @Override + public void run() { + ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH)); + } + }); } // Subclasses can override these to customize extras in quickadd intent @@ -514,9 +526,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener, } public void transitionForTaskEdit() { - AndroidUtilities.callApiMethod(5, this, "overridePendingTransition", - new Class[] { Integer.TYPE, Integer.TYPE }, - R.anim.slide_left_in, R.anim.slide_left_out); + overridePendingTransition(R.anim.slide_left_in, R.anim.slide_left_out); } private void setUpBackgroundJobs() { @@ -618,9 +628,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener, public void finish() { super.finish(); if (overrideFinishAnim) { - AndroidUtilities.callApiMethod(5, this, "overridePendingTransition", - new Class[] { Integer.TYPE, Integer.TYPE }, - R.anim.slide_right_in, R.anim.slide_right_out); + overridePendingTransition(R.anim.slide_right_in, R.anim.slide_right_out); } } @@ -1138,18 +1146,15 @@ public class TaskListActivity extends ListActivity implements OnScrollListener, } protected void performSyncServiceV2Sync(boolean manual) { - syncService.synchronizeActiveTasks(manual, new ProgressBarSyncResultCallback(this, - R.id.progressBar, new Runnable() { - @Override - public void run() { - ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH)); - } - })); + syncService.synchronizeActiveTasks(manual, syncResultCallback); Preferences.setLong(PREF_LAST_AUTO_SYNC, DateUtilities.now()); } protected void performSyncAction() { - if (syncActions.size() == 0 && !syncService.isActive()) { + List activeV2Providers = syncService.activeProviders(); + int activeSyncs = syncActions.size() + activeV2Providers.size(); + + if (activeSyncs == 0) { String desiredCategory = getString(R.string.SyP_label); // Get a list of all sync plugins and bring user to the prefs pane @@ -1189,21 +1194,35 @@ public class TaskListActivity extends ListActivity implements OnScrollListener, }; showSyncOptionMenu(actions, listener); - } - else { - performSyncServiceV2Sync(true); - - if(syncActions.size() > 0) { - for(SyncAction syncAction : syncActions) { - try { - syncAction.intent.send(); - } catch (CanceledException e) { - // + + } else { + // We have sync actions, pop up a dialogue so the user can + // select just one of them (only sync one at a time) + final Object[] actions = new Object[activeSyncs]; + + int i; + for(i = 0; i < activeV2Providers.size(); i++) + actions[i] = activeV2Providers.get(i); + for(SyncAction syncAction : syncActions) + actions[i++] = syncAction; + + DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface click, int which) { + if(actions[which] instanceof SyncAction) { + try { + ((SyncAction)actions[which]).intent.send(); + Toast.makeText(TaskListActivity.this, R.string.SyP_progress_toast, + Toast.LENGTH_LONG).show(); + } catch (CanceledException e) { + // + } + } else { + ((SyncV2Provider)actions[which]).synchronizeActiveTasks(true, syncResultCallback); } } - Toast.makeText(TaskListActivity.this, R.string.SyP_progress_toast, - Toast.LENGTH_LONG).show(); - } + }; + showSyncOptionMenu(actions, listener); } } @@ -1215,6 +1234,11 @@ public class TaskListActivity extends ListActivity implements OnScrollListener, * @param listener */ private void showSyncOptionMenu(TYPE[] items, DialogInterface.OnClickListener listener) { + if(items.length == 1) { + listener.onClick(null, 0); + return; + } + ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, items); diff --git a/astrid/src/com/todoroo/astrid/service/StartupService.java b/astrid/src/com/todoroo/astrid/service/StartupService.java index 9b9dfa251..ef8127a63 100644 --- a/astrid/src/com/todoroo/astrid/service/StartupService.java +++ b/astrid/src/com/todoroo/astrid/service/StartupService.java @@ -16,7 +16,6 @@ import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; -import android.content.res.Resources; import android.media.AudioManager; import android.util.Log; import android.widget.Toast; @@ -37,7 +36,6 @@ import com.todoroo.astrid.backup.BackupConstants; import com.todoroo.astrid.backup.BackupService; import com.todoroo.astrid.backup.TasksXmlImporter; import com.todoroo.astrid.dao.Database; -import com.todoroo.astrid.data.Task; import com.todoroo.astrid.gtasks.GtasksPreferenceService; import com.todoroo.astrid.gtasks.sync.GtasksSyncOnSaveService; import com.todoroo.astrid.opencrx.OpencrxCoreUtils; @@ -139,9 +137,9 @@ public class StartupService { int defaultTheme = abChooser.getChoiceForOption(ABOptions.AB_THEME_KEY); if (defaultTheme == 0) - Preferences.setString(R.string.p_theme, "white"); + Preferences.setString(R.string.p_theme, "white"); //$NON-NLS-1$ else - Preferences.setString(R.string.p_theme, "black"); + Preferences.setString(R.string.p_theme, "black"); //$NON-NLS-1$ } else { abChooser.setChoiceForOption(ABOptions.AB_THEME_KEY, 0); Preferences.setLong(AstridPreferences.P_FIRST_LAUNCH, 0); @@ -170,10 +168,6 @@ public class StartupService { } AstridPreferences.setCurrentVersion(version); } - //Startup tasks -// if(latestSetVersion == 0) { -// onFirstTime(); -// } upgradeService.performSecondaryUpgrade(context); @@ -224,49 +218,7 @@ public class StartupService { hasStartedUp = true; } - /** - * Create tasks for first time users - */ - private void onFirstTime() { - final Resources r = ContextManager.getResources(); - try { - new Thread(new Runnable() { - @Override - public void run() { - database.openForWriting(); - - if(taskService.countTasks() > 0) - return; - - for(int i = 0; i < INTRO_TASKS.length; i += 3) - addIntroTask(r, INTRO_TASKS[i], INTRO_TASKS[i + 1], INTRO_TASKS[i + 2]); - Preferences.setBoolean(AstridPreferences.P_FIRST_ACTION, true); - Preferences.setBoolean(AstridPreferences.P_FIRST_LIST, true); - } - }).start(); - } catch (Exception e) { - exceptionService.reportError("on-first-time", e); //$NON-NLS-1$ - } - } - - private static final int[] INTRO_TASKS = new int[] { - R.string.intro_task_2_summary, - R.string.intro_task_2_note, - Task.URGENCY_DAY_AFTER, - R.string.intro_task_3_summary, - R.string.intro_task_3_note, - Task.URGENCY_NONE, - }; - public static final int INTRO_TASK_SIZE = INTRO_TASKS.length / 3; - - private void addIntroTask(Resources r, int summary, int note, int dueSetting) { - Task task = new Task(); - task.setValue(Task.TITLE, r.getString(summary)); - task.setValue(Task.NOTES, r.getString(note)); - long dueDate = Task.createDueDate(dueSetting, 0); - task.setValue(Task.DUE_DATE, dueDate); - taskService.save(task); - } + public static final int INTRO_TASK_SIZE = 0; /** * If database exists, no tasks but metadata, and a backup file exists, restore it diff --git a/astrid/src/com/todoroo/astrid/service/SyncV2Service.java b/astrid/src/com/todoroo/astrid/service/SyncV2Service.java index b6545e8d0..b4796b067 100644 --- a/astrid/src/com/todoroo/astrid/service/SyncV2Service.java +++ b/astrid/src/com/todoroo/astrid/service/SyncV2Service.java @@ -1,5 +1,9 @@ package com.todoroo.astrid.service; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import com.todoroo.astrid.actfm.sync.ActFmSyncV2Provider; /** @@ -35,10 +39,36 @@ public class SyncV2Service { public void finished(); } - public interface SyncV2Provider { - public boolean isActive(); - public void synchronizeActiveTasks(boolean manual, SyncResultCallback callback); - public void synchronizeList(Object list, boolean manual, SyncResultCallback callback); + abstract public static class SyncV2Provider { + /** + * @return sync provider name (displayed in sync menu) + */ + abstract public String getName(); + + /** + * @return true if this provider is logged in + */ + abstract public boolean isActive(); + + /** + * Synchronize all of user's active tasks + * @param manual whether manually triggered + * @param callback callback object + */ + abstract public void synchronizeActiveTasks(boolean manual, SyncResultCallback callback); + + /** + * Synchronize a single list + * @param list object representing list (TaskListActivity-dependent) + * @param manual whether was manually triggered + * @param callback callback object + */ + abstract public void synchronizeList(Object list, boolean manual, SyncResultCallback callback); + + @Override + public String toString() { + return getName(); + } } /* @@ -51,16 +81,17 @@ public class SyncV2Service { }; /** - * Determine if synchronization is available + * Returns active sync providers * * @param callback */ - public boolean isActive() { + public List activeProviders() { + ArrayList actives = new ArrayList(); for(SyncV2Provider provider : providers) { if(provider.isActive()) - return true; + actives.add(provider); } - return false; + return Collections.unmodifiableList(actives); } /** From cf64d736cdc8a4e505902410721245c9036755f5 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Thu, 19 Jan 2012 00:32:05 -0800 Subject: [PATCH 4/7] Removed sync code from filter list activity in preparation for fragments --- .../astrid/activity/FilterListActivity.java | 246 +----------------- 1 file changed, 2 insertions(+), 244 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/activity/FilterListActivity.java b/astrid/src/com/todoroo/astrid/activity/FilterListActivity.java index 63920c95c..a44a01d47 100644 --- a/astrid/src/com/todoroo/astrid/activity/FilterListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/FilterListActivity.java @@ -3,28 +3,12 @@ */ package com.todoroo.astrid.activity; -import java.io.IOException; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; - -import org.json.JSONException; -import org.weloveastrid.rmilk.MilkPreferences; -import org.weloveastrid.rmilk.MilkUtilities; - import android.app.AlertDialog; import android.app.ExpandableListActivity; -import android.app.Notification; -import android.app.PendingIntent; import android.app.PendingIntent.CanceledException; -import android.app.ProgressDialog; import android.app.SearchManager; -import android.content.BroadcastReceiver; -import android.content.Context; import android.content.DialogInterface; import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Rect; @@ -41,7 +25,6 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.Window; import android.view.inputmethod.EditorInfo; -import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ExpandableListView; @@ -56,17 +39,9 @@ import com.timsu.astrid.R; import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.ExceptionService; -import com.todoroo.andlib.service.NotificationManager; import com.todoroo.andlib.sql.Functions; import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.andlib.utility.AndroidUtilities; -import com.todoroo.andlib.utility.DateUtilities; -import com.todoroo.andlib.utility.DialogUtilities; -import com.todoroo.andlib.utility.Preferences; -import com.todoroo.astrid.actfm.ActFmPreferences; -import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; -import com.todoroo.astrid.actfm.sync.ActFmSyncService; -import com.todoroo.astrid.activity.TaskListActivity.IntentWithLabel; import com.todoroo.astrid.adapter.FilterAdapter; import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.Filter; @@ -74,17 +49,14 @@ import com.todoroo.astrid.api.FilterCategory; import com.todoroo.astrid.api.FilterListItem; import com.todoroo.astrid.api.FilterWithCustomIntent; import com.todoroo.astrid.api.IntentFilter; -import com.todoroo.astrid.api.SyncAction; import com.todoroo.astrid.core.CustomFilterActivity; import com.todoroo.astrid.core.SearchFilter; import com.todoroo.astrid.data.Task; -import com.todoroo.astrid.helper.MetadataHelper; import com.todoroo.astrid.service.StartupService; import com.todoroo.astrid.service.StatisticsConstants; import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.tags.TagsPlugin; -import com.todoroo.astrid.utility.Constants; /** * Activity that displays a user's task lists and allows users @@ -102,11 +74,8 @@ public class FilterListActivity extends ExpandableListActivity { private static final int MENU_SEARCH_ID = Menu.FIRST + 0; private static final int MENU_HELP_ID = Menu.FIRST + 1; - private static final int MENU_REFRESH_ID = Menu.FIRST + 2; private static final int MENU_NEW_FILTER_ID = Menu.FIRST + 3; - private static final String LAST_TAG_REFRESH_KEY = "last_tag_refresh"; //$NON-NLS-1$ - private static final int CONTEXT_MENU_SHORTCUT = Menu.FIRST + 4; private static final int CONTEXT_MENU_INTENT = Menu.FIRST + 5; @@ -117,11 +86,7 @@ public class FilterListActivity extends ExpandableListActivity { // --- instance variables @Autowired ExceptionService exceptionService; - @Autowired ActFmPreferenceService actFmPreferenceService; - @Autowired ActFmSyncService actFmSyncService; - protected SyncActionReceiver syncActionReceiver = new SyncActionReceiver(); - private final LinkedHashSet syncActions = new LinkedHashSet(); protected FilterAdapter adapter = null; /* ====================================================================== @@ -157,9 +122,7 @@ public class FilterListActivity extends ExpandableListActivity { public void onClick(View v) { Intent intent = TagsPlugin.newTagDialog(FilterListActivity.this); startActivity(intent); - AndroidUtilities.callApiMethod(5, FilterListActivity.this, "overridePendingTransition", - new Class[] { Integer.TYPE, Integer.TYPE }, - R.anim.slide_left_in, R.anim.slide_left_out); + overridePendingTransition(R.anim.slide_left_in, R.anim.slide_left_out); } }); @@ -169,9 +132,7 @@ public class FilterListActivity extends ExpandableListActivity { @Override public void finish() { super.finish(); - AndroidUtilities.callApiMethod(5, FilterListActivity.this, "overridePendingTransition", //$NON-NLS-1$ - new Class[] { Integer.TYPE, Integer.TYPE }, - R.anim.slide_left_in, R.anim.slide_left_out); + overridePendingTransition(R.anim.slide_left_in, R.anim.slide_left_out); } /** @@ -197,8 +158,6 @@ public class FilterListActivity extends ExpandableListActivity { startActivity(intent); } else { setUpList(); - if (actFmPreferenceService.isLoggedIn()) - onRefreshRequested(false); } } @@ -252,8 +211,6 @@ public class FilterListActivity extends ExpandableListActivity { adapter.registerRecevier(); // also load sync actions - registerReceiver(syncActionReceiver, new android.content.IntentFilter(AstridApiConstants.BROADCAST_SEND_SYNC_ACTIONS)); - syncActions.clear(); Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_REQUEST_SYNC_ACTIONS); sendOrderedBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); } @@ -264,7 +221,6 @@ public class FilterListActivity extends ExpandableListActivity { super.onPause(); if(adapter != null) adapter.unregisterRecevier(); - unregisterReceiver(syncActionReceiver); } /* ====================================================================== @@ -429,12 +385,6 @@ public class FilterListActivity extends ExpandableListActivity { return true; } - case MENU_REFRESH_ID: { - performSyncAction(); - //onRefreshRequested(true); - return true; - } - case MENU_HELP_ID: { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://weloveastrid.com/help-user-guide-astrid-v3/filters/")); //$NON-NLS-1$ @@ -469,77 +419,6 @@ public class FilterListActivity extends ExpandableListActivity { return false; } - /** - * Refresh user tags - */ - private void onRefreshRequested(final boolean manual) { - if (!manual) { - long lastFetchDate = Preferences.getLong(LAST_TAG_REFRESH_KEY, 0); - if(DateUtilities.now() < lastFetchDate + 300000L) { - return; - } - } - final ProgressDialog progressDialog; - - final NotificationManager nm = new NotificationManager.AndroidNotificationManager(this); - final Notification notification = new Notification(android.R.drawable.stat_notify_sync, null, System.currentTimeMillis()); - final int notificationId = updateNotification(this, notification); - notification.flags |= Notification.FLAG_ONGOING_EVENT; - - if (manual) { - progressDialog = DialogUtilities.progressDialog(this, getString(R.string.DLG_please_wait)); - } else { - progressDialog = null; - nm.notify(notificationId, notification); - } - - new Thread(new Runnable() { - @SuppressWarnings("nls") - @Override - public void run() { - try { - Preferences.setLong(LAST_TAG_REFRESH_KEY, DateUtilities.now()); - actFmSyncService.fetchTags(0); - - runOnUiThread(new Runnable() { - @Override - public void run() { - adapter.clear(); - adapter.getLists(); - } - }); - - } catch (IOException e) { - if (manual) - exceptionService.displayAndReportError(FilterListActivity.this, "refresh-tags-io", e); - else - exceptionService.reportError("refresh-tags-io", e); - } catch (JSONException e) { - if (manual) - exceptionService.displayAndReportError(FilterListActivity.this, "refresh-tags-json", e); - else - exceptionService.reportError("refresh-tags-io", e); - } finally { - if (manual) - DialogUtilities.dismissDialog(FilterListActivity.this, progressDialog); - else - nm.cancel(notificationId); - } - } - }).start(); - } - - private int updateNotification(Context context, Notification notification) { - String notificationTitle = context.getString(R.string.actfm_notification_title); - Intent intent = new Intent(context, ActFmPreferences.class); - PendingIntent notificationIntent = PendingIntent.getActivity(context, 0, - intent, 0); - notification.setLatestEventInfo(context, - notificationTitle, context.getString(R.string.SyP_progress), - notificationIntent); - return Constants.NOTIFICATION_SYNC; - } - private void showCreateShortcutDialog(final Intent shortcutIntent, final Filter filter) { FrameLayout frameLayout = new FrameLayout(this); @@ -593,125 +472,4 @@ public class FilterListActivity extends ExpandableListActivity { super.onActivityResult(requestCode, resultCode, data); } - /** - * Receiver which receives sync provider intents - * - * @author Tim Su - * - */ - protected class SyncActionReceiver extends BroadcastReceiver { - @Override - public void onReceive(Context context, Intent intent) { - if(intent == null || !AstridApiConstants.BROADCAST_SEND_SYNC_ACTIONS.equals(intent.getAction())) - return; - - try { - Bundle extras = intent.getExtras(); - SyncAction syncAction = extras.getParcelable(AstridApiConstants.EXTRAS_RESPONSE); - syncActions.add(syncAction); - } catch (Exception e) { - exceptionService.reportError("receive-sync-action-" + //$NON-NLS-1$ - intent.getStringExtra(AstridApiConstants.EXTRAS_ADDON), e); - } - } - } - - private void performSyncAction() { - if (syncActions.size() == 0) { - String desiredCategory = getString(R.string.SyP_label); - - // Get a list of all sync plugins and bring user to the prefs pane - // for one of them - Intent queryIntent = new Intent(AstridApiConstants.ACTION_SETTINGS); - PackageManager pm = getPackageManager(); - List resolveInfoList = pm.queryIntentActivities( - queryIntent, PackageManager.GET_META_DATA); - int length = resolveInfoList.size(); - ArrayList syncIntents = new ArrayList(); - - // Loop through a list of all packages (including plugins, addons) - // that have a settings action: filter to sync actions - for (int i = 0; i < length; i++) { - ResolveInfo resolveInfo = resolveInfoList.get(i); - Intent intent = new Intent(AstridApiConstants.ACTION_SETTINGS); - intent.setClassName(resolveInfo.activityInfo.packageName, - resolveInfo.activityInfo.name); - - String category = MetadataHelper.resolveActivityCategoryName(resolveInfo, pm); - if(MilkPreferences.class.getName().equals(resolveInfo.activityInfo.name) && - !MilkUtilities.INSTANCE.isLoggedIn()) - continue; - - if (category.equals(desiredCategory)) { - syncIntents.add(new IntentWithLabel(intent, - resolveInfo.activityInfo.loadLabel(pm).toString())); - } - } - - final Intent[] actions = syncIntents.toArray(new Intent[syncIntents.size()]); - DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface click, int which) { - startActivity(actions[which]); - } - }; - - showSyncOptionMenu(actions, listener); - } - else if(syncActions.size() == 1) { - SyncAction syncAction = syncActions.iterator().next(); - try { - if (actFmPreferenceService.isLoggedIn()) - onRefreshRequested(true); - else { - syncAction.intent.send(); - Toast.makeText(this, R.string.SyP_progress_toast, - Toast.LENGTH_LONG).show(); - } - } catch (CanceledException e) { - // - } - } else { - // We have >1 sync actions, pop up a dialogue so the user can - // select just one of them (only sync one at a time) - final SyncAction[] actions = syncActions.toArray(new SyncAction[syncActions.size()]); - DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface click, int which) { - try { - SyncAction action = actions[which]; - if (action.label.contains("Astrid")) - onRefreshRequested(true); - else { - action.intent.send(); - Toast.makeText(FilterListActivity.this, R.string.SyP_progress_toast, - Toast.LENGTH_LONG).show(); - } - } catch (CanceledException e) { - // - } - } - }; - showSyncOptionMenu(actions, listener); - } - } - - /** - * Show menu of sync options. This is shown when you're not logged into any services, or logged into - * more than one. - * @param - * @param items - * @param listener - */ - private void showSyncOptionMenu(TYPE[] items, DialogInterface.OnClickListener listener) { - ArrayAdapter syncAdapter = new ArrayAdapter(this, - android.R.layout.simple_spinner_dropdown_item, items); - - // show a menu of available options - new AlertDialog.Builder(this) - .setTitle(R.string.SyP_label) - .setAdapter(syncAdapter, listener) - .show().setOwnerActivity(this); - } - } From b3f3bd02ea1bb98a6843d6b61fb9c9f9a7a7fd20 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Thu, 19 Jan 2012 00:55:46 -0800 Subject: [PATCH 5/7] If you haven't saved a tag, don't transmit picture until after you have. --- .../astrid/actfm/TagSettingsActivity.java | 56 +++++++++++++------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java index 9ee1f7979..0d8133e02 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java @@ -63,6 +63,7 @@ public class TagSettingsActivity extends Activity { private EditText tagName; private EditText tagDescription; private CheckBox isSilent; + private Bitmap setBitmap; boolean isNewTag = false; @@ -204,23 +205,44 @@ public class TagSettingsActivity extends Activity { else Toast.makeText(this, R.string.tag_list_saved, Toast.LENGTH_LONG).show(); - tagDataService.save(tagData); InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(tagName.getWindowToken(), 0); if (isNewTag) { - Intent intent = new Intent(this, TagViewActivity.class); - intent.putExtra(TagViewActivity.EXTRA_TAG_NAME, newName); - intent.putExtra(TagViewActivity.TOKEN_FILTER, TagFilterExposer.filterFromTagData(this, tagData)); - super.finish(); - startActivity(intent); - AndroidUtilities.callApiMethod(5, this, "overridePendingTransition", //$NON-NLS-1$ - new Class[] { Integer.TYPE, Integer.TYPE }, - R.anim.slide_left_in, R.anim.slide_left_out); - return; - } + Flags.set(Flags.ACTFM_SUPPRESS_SYNC); + tagDataService.save(tagData); + final String name = newName; + final Runnable loadTag = new Runnable() { + @Override + public void run() { + Intent intent = new Intent(TagSettingsActivity.this, TagViewActivity.class); + intent.putExtra(TagViewActivity.EXTRA_TAG_NAME, name); + intent.putExtra(TagViewActivity.TOKEN_FILTER, + TagFilterExposer.filterFromTagData(TagSettingsActivity.this, tagData)); + finish(); + startActivity(intent); + } + }; + + if(actFmPreferenceService.isLoggedIn()) { + new Thread(new Runnable() { + @Override + public void run() { + actFmSyncService.pushTagDataOnSave(tagData, tagData.getMergedValues()); + if(setBitmap != null && tagData.getValue(TagData.REMOTE_ID) > 0) + uploadTagPicture(setBitmap); + runOnUiThread(loadTag); + } + }).start(); + } else { + loadTag.run(); + } + return; + } else { + tagDataService.save(tagData); + } refreshSettingsPage(); finish(); @@ -234,13 +256,9 @@ public class TagSettingsActivity extends Activity { private void finishWithAnimation(boolean backAnimation) { super.finish(); if (backAnimation) { - AndroidUtilities.callApiMethod(5, this, "overridePendingTransition", //$NON-NLS-1$ - new Class[] { Integer.TYPE, Integer.TYPE }, - R.anim.slide_right_in, R.anim.slide_right_out); + overridePendingTransition(R.anim.slide_right_in, R.anim.slide_right_out); } else { - AndroidUtilities.callApiMethod(5, this, "overridePendingTransition", //$NON-NLS-1$ - new Class[] { Integer.TYPE, Integer.TYPE }, - R.anim.slide_left_in, R.anim.slide_left_out); + overridePendingTransition(R.anim.slide_left_in, R.anim.slide_left_out); } } @@ -323,7 +341,9 @@ public class TagSettingsActivity extends Activity { @Override public void handleCameraResult(Bitmap bitmap) { picture.setImageBitmap(bitmap); - uploadTagPicture(bitmap); + setBitmap = bitmap; + if(tagData.getValue(TagData.REMOTE_ID) > 0) + uploadTagPicture(bitmap); } }; if (ActFmCameraModule.activityResult(this, requestCode, resultCode, data, callback)) { From 14f8d81ae84e08aadfd6d0f65e3d629265181864 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Thu, 19 Jan 2012 01:43:27 -0800 Subject: [PATCH 6/7] Allow ability to show welcome activity from settings --- astrid/res/values/keys.xml | 1 + astrid/res/values/strings-welcome.xml | 6 ++++ astrid/res/xml/preferences.xml | 5 +-- .../astrid/activity/EditPreferences.java | 31 +++++++++++++------ .../astrid/service/UpgradeService.java | 18 ++++------- .../welcome/tutorial/ViewPagerAdapter.java | 30 +++++++++++++----- .../welcome/tutorial/WelcomeWalkthrough.java | 31 ++++++++++++------- 7 files changed, 79 insertions(+), 43 deletions(-) diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index c29987055..7ad0a63d2 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -328,6 +328,7 @@ showed_collaborators_help showed_when_shortcut showed_when_row + tutorial diff --git a/astrid/res/values/strings-welcome.xml b/astrid/res/values/strings-welcome.xml index 5fb8476d2..38c36c9eb 100644 --- a/astrid/res/values/strings-welcome.xml +++ b/astrid/res/values/strings-welcome.xml @@ -3,6 +3,8 @@ Accept EULA to get started! + Show Tutorial + Welcome to Astrid! Make lists Share lists @@ -11,6 +13,8 @@ Discover Connect now\nto get started! + That\'s it! + The perfect personal\nto-do list that works great\nwith friends Perfect for any list:\nto read, to watch, to buy,\nto visit, to do! Share lists\nwith friends, housemates,\nor your sweetheart! @@ -19,4 +23,6 @@ Additional features,\nproductivity tips, and\nsuggestions from friends Login + Tap Astrid to return. + \ No newline at end of file diff --git a/astrid/res/xml/preferences.xml b/astrid/res/xml/preferences.xml index 656fc2d26..03ff2e753 100644 --- a/astrid/res/xml/preferences.xml +++ b/astrid/res/xml/preferences.xml @@ -3,8 +3,9 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:title="@string/EPr_title"> - - + + + = V3_9_2 && from < V3_9_2_2) { - newVersionString(changeLog, "3.9.2.2", new String[] { - "Reduced APK size", - "Fixed bugs with Google Task sync", - }); - } - - if (from < V3_9_2) { - newVersionString(changeLog, "3.9.2 (01/13/12)", new String[] { - "Made selecting dates and times easier:", - "New tutorial walkthrough for new users", - "Stomped on a few bugs", + newVersionString(changeLog, "3.9.2.2 (1/19/12)", new String[] { + "Astrid now recognizes words like 'tomorrow', 'monday', '!!!' and '2 pm' to set date and importance", + "New tutorial walkthrough for new users. Access it from the settings menu!", + "Reduced APK size", + "Minor UI tweaks, bug fixes", "Feedback welcomed!" }); } @@ -192,7 +186,7 @@ public final class UpgradeService { if (from >= V3_9_1 && from < V3_9_1_1) { newVersionString(changeLog, "3.9.1.1 (01/06/12)", new String[] { "Fixed a few bugs:", - " Crash when selecting certain lists", + " Crash when selecting certain lists", " Some lists not displayed", " Wrong text color when assigning tasks in Night theme" }); diff --git a/astrid/src/com/todoroo/astrid/welcome/tutorial/ViewPagerAdapter.java b/astrid/src/com/todoroo/astrid/welcome/tutorial/ViewPagerAdapter.java index 2089ea5ab..6d6139543 100644 --- a/astrid/src/com/todoroo/astrid/welcome/tutorial/ViewPagerAdapter.java +++ b/astrid/src/com/todoroo/astrid/welcome/tutorial/ViewPagerAdapter.java @@ -13,6 +13,9 @@ import android.widget.ImageView; import android.widget.TextView; import com.timsu.astrid.R; +import com.todoroo.andlib.service.Autowired; +import com.todoroo.andlib.service.DependencyInjectionService; +import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.viewpagerindicator.TitleProvider; public class ViewPagerAdapter extends PagerAdapter implements TitleProvider @@ -60,10 +63,20 @@ public class ViewPagerAdapter extends PagerAdapter implements TitleProvider }; private final Context context; public WelcomeWalkthrough parent; + @Autowired ActFmPreferenceService actFmPreferenceService; - public ViewPagerAdapter( Context context ) + public ViewPagerAdapter( Context context, boolean manual) { this.context = context; + DependencyInjectionService.getInstance().inject(this); + + if(manual) { + layouts[layouts.length - 1] = R.layout.welcome_walkthrough_page; + title[title.length - 1] = R.string.welcome_title_7_return; + images[images.length - 1] = R.drawable.welcome_walkthrough_1; + body[body.length - 1] = R.string.welcome_body_7_return; + } + } @@ -81,14 +94,15 @@ public class ViewPagerAdapter extends PagerAdapter implements TitleProvider View pageView = inflater.inflate(layouts[position], null, true); pageView.setLayoutParams( new ViewGroup.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT)); - if (position != getCount()-1){ - ImageView imageView = (ImageView) pageView.findViewById(R.id.welcome_walkthrough_image); - imageView.setImageResource(images[position]); + if (pageView.findViewById(R.id.welcome_walkthrough_image) != null) { + ImageView imageView = (ImageView) pageView.findViewById(R.id.welcome_walkthrough_image); + imageView.setImageResource(images[position]); + + TextView titleView = (TextView) pageView.findViewById(R.id.welcome_walkthrough_title); + titleView.setText(title[position]); - TextView titleView = (TextView) pageView.findViewById(R.id.welcome_walkthrough_title); - titleView.setText(title[position]); - TextView bodyView = (TextView) pageView.findViewById(R.id.welcome_walkthrough_body); - bodyView.setText(body[position]); + TextView bodyView = (TextView) pageView.findViewById(R.id.welcome_walkthrough_body); + bodyView.setText(body[position]); } ((ViewPager)pager).addView( pageView, 0 ); diff --git a/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java b/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java index 169423aef..31737a1d8 100644 --- a/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java +++ b/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java @@ -31,12 +31,14 @@ public class WelcomeWalkthrough extends ActFmLoginActivity { public static final String KEY_SHOWED_WELCOME_LOGIN = "key_showed_welcome_login"; //$NON-NLS-1$ + public static final String TOKEN_MANUAL_SHOW = "manual"; //$NON-NLS-1$ + @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); - mAdapter = new ViewPagerAdapter(this); + mAdapter = new ViewPagerAdapter(this, getIntent().hasExtra(TOKEN_MANUAL_SHOW)); mAdapter.parent = this; mPager = (ViewPager)findViewById(R.id.pager); @@ -44,6 +46,7 @@ public class WelcomeWalkthrough extends ActFmLoginActivity { mIndicator = (CirclePageIndicator)findViewById(R.id.indicator); mIndicator.setViewPager(mPager); + } @Override protected int getContentViewResource() { @@ -68,10 +71,22 @@ public class WelcomeWalkthrough extends ActFmLoginActivity { protected void initializeUI() { if(mAdapter == null) return; - if(currentPage == mAdapter.getCount()-1){ - super.initializeUI(); - setupTermsOfService(); - setupLoginLater(); + if(currentPage == mAdapter.getCount()-1) { + if(findViewById(R.id.fb_login) != null) { + super.initializeUI(); + setupTermsOfService(); + setupLoginLater(); + } else { + OnClickListener done = new OnClickListener() { + @Override + public void onClick(View arg0) { + finish(); + } + }; + currentView.findViewById(R.id.welcome_walkthrough_title).setOnClickListener(done); + currentView.findViewById(R.id.welcome_walkthrough_image).setOnClickListener(done); + } + } } @@ -106,12 +121,6 @@ public class WelcomeWalkthrough extends ActFmLoginActivity { Button pwLogin = (Button) findViewById(R.id.pw_login); pwLogin.setOnClickListener(signUpListener); } - /* - protected void setupWalkthroughLogin() { - Button loginButton = (Button)currentView.findViewById(R.id.walkthrough_login); - loginButton.setOnClickListener(showWalkthroughLoginListener); - }*/ - protected void setupLoginLater() { TextView loginLater = (TextView)currentView.findViewById(R.id.login_later); From 06514f3a19b73356df0a2bc274749b8fbb59c84f Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Thu, 19 Jan 2012 11:16:07 -0800 Subject: [PATCH 7/7] Try/catch in update message dialog to fix crashes with trying to show with a non-running activity --- .../astrid/service/UpdateMessageService.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java b/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java index b3684b87b..cba067453 100644 --- a/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java +++ b/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java @@ -14,6 +14,7 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.text.TextUtils; +import android.view.WindowManager.BadTokenException; import com.timsu.astrid.R; import com.todoroo.andlib.data.Property.StringProperty; @@ -91,8 +92,20 @@ public class UpdateMessageService { activity.runOnUiThread(new Runnable() { @Override public void run() { - DialogUtilities.htmlDialog(activity, - html, R.string.UpS_updates_title); + try { + DialogUtilities.htmlDialog(activity, + html, R.string.UpS_updates_title); + } catch (BadTokenException bt) { + try { + Activity current = (Activity) ContextManager.getContext(); + DialogUtilities.htmlDialog(current, + html, R.string.UpS_updates_title); + } catch (ClassCastException c) { + // Oh well, context wasn't an activity + } catch (BadTokenException bt2) { + // Oh well, activity isn't running + } + } } }); }