Added gtasks preferences, bug fixes to get detail exposer working

pull/14/head
Tim Su 14 years ago
parent d00a35bf58
commit 1d5e7ef477

@ -395,48 +395,76 @@
</intent-filter>
</receiver>
<!-- rmilk -->
<receiver android:name="org.weloveastrid.rmilk.MilkFilterExposer">
<intent-filter>
<action android:name="com.todoroo.astrid.REQUEST_FILTERS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name="org.weloveastrid.rmilk.MilkDetailExposer">
<intent-filter>
<action android:name="com.todoroo.astrid.REQUEST_DETAILS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<activity android:name="org.weloveastrid.rmilk.MilkLoginActivity" />
<activity android:name="org.weloveastrid.rmilk.MilkPreferences"
android:icon="@drawable/icon"
android:label="@string/rmilk_MPr_header">
<meta-data android:name="category"
android:resource="@string/SyP_label" />
<intent-filter>
<action android:name="com.todoroo.astrid.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<service android:name="org.weloveastrid.rmilk.MilkBackgroundService"/>
<receiver android:name="org.weloveastrid.rmilk.MilkStartupReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="com.todoroo.astrid.STARTUP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name="org.weloveastrid.rmilk.MilkSyncActionExposer">
<intent-filter>
<action android:name="com.todoroo.astrid.REQUEST_SYNC_ACTIONS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<!-- rmilk -->
<receiver android:name="org.weloveastrid.rmilk.MilkFilterExposer">
<intent-filter>
<action android:name="com.todoroo.astrid.REQUEST_FILTERS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name="org.weloveastrid.rmilk.MilkDetailExposer">
<intent-filter>
<action android:name="com.todoroo.astrid.REQUEST_DETAILS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<activity android:name="org.weloveastrid.rmilk.MilkLoginActivity" />
<activity android:name="org.weloveastrid.rmilk.MilkPreferences"
android:icon="@drawable/icon"
android:label="@string/rmilk_MPr_header">
<meta-data android:name="category"
android:resource="@string/SyP_label" />
<intent-filter>
<action android:name="com.todoroo.astrid.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<service android:name="org.weloveastrid.rmilk.MilkBackgroundService"/>
<receiver android:name="org.weloveastrid.rmilk.MilkStartupReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="com.todoroo.astrid.STARTUP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name="org.weloveastrid.rmilk.MilkSyncActionExposer">
<intent-filter>
<action android:name="com.todoroo.astrid.REQUEST_SYNC_ACTIONS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<!-- gtasks -->
<receiver android:name="com.todoroo.astrid.gtasks.GtasksFilterExposer">
<intent-filter>
<action android:name="com.todoroo.astrid.REQUEST_FILTERS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name="com.todoroo.astrid.gtasks.GtasksDetailExposer">
<intent-filter>
<action android:name="com.todoroo.astrid.REQUEST_DETAILS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<activity android:name="com.todoroo.astrid.gtasks.GtasksPreferences"
android:label="@string/gtasks_GPr_header">
<meta-data android:name="category"
android:resource="@string/SyP_label" />
<intent-filter>
<action android:name="com.todoroo.astrid.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name="com.todoroo.astrid.gtasks.GtasksSyncActionExposer">
<intent-filter>
<action android:name="com.todoroo.astrid.REQUEST_SYNC_ACTIONS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>

@ -5,7 +5,7 @@
<stringAttribute key="ch.zork.quicklaunch.icon" value="14.gif"/>
<intAttribute key="ch.zork.quicklaunch.index" value="0"/>
<stringAttribute key="ch.zork.quicklaunch.mode" value="run"/>
<intAttribute key="com.android.ide.eclipse.adt.action" value="1"/>
<intAttribute key="com.android.ide.eclipse.adt.action" value="0"/>
<stringAttribute key="com.android.ide.eclipse.adt.activity" value="com.todoroo.astrid.reminders.NotificationActivity"/>
<stringAttribute key="com.android.ide.eclipse.adt.commandline" value="-scale 0.7"/>
<intAttribute key="com.android.ide.eclipse.adt.delay" value="0"/>

@ -33,6 +33,7 @@ public class GtasksDetailExposer extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
ContextManager.setContext(context);
DependencyInjectionService.getInstance().inject(this);
// if we aren't logged in, don't expose features
if(!gtasksPreferenceService.isLoggedIn())
@ -59,17 +60,14 @@ public class GtasksDetailExposer extends BroadcastReceiver {
if(extended)
return null;
DependencyInjectionService.getInstance().inject(this);
Metadata metadata = gtasksMetadataService.getTaskMetadata(id);
if(metadata == null)
return null;
StringBuilder builder = new StringBuilder();
long listId = metadata.getValue(GtasksMetadata.LIST_ID);
String listId = metadata.getValue(GtasksMetadata.LIST_ID);
String listName = gtasksListService.getListName(listId);
// RTM list is out of date. don't display RTM stuff
if(listName == GtasksListService.LIST_NOT_FOUND)
return null;

@ -53,7 +53,7 @@ public class GtasksListService {
* @param listId
* @return NOT_FOUND if no list by this id exists, otherwise list name
*/
public String getListName(long listId) {
public String getListName(String listId) {
readLists();
for(StoreObject list : lists)
if(list.getValue(GtasksList.REMOTE_ID).equals(listId))
@ -63,6 +63,7 @@ public class GtasksListService {
@SuppressWarnings("nls")
public void updateLists(JSONArray newLists) throws JSONException {
readLists();
for(int i = 0; i < newLists.length(); i++) {
JSONObject remote = newLists.getJSONObject(i);

@ -2,6 +2,7 @@ package com.todoroo.astrid.gtasks;
import com.todoroo.andlib.data.Property.IntegerProperty;
import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.utility.Preferences;
@ -21,7 +22,7 @@ public class GtasksMetadata {
public static final LongProperty ID = new LongProperty(Metadata.TABLE,
Metadata.VALUE1.name);
public static final LongProperty LIST_ID = new LongProperty(Metadata.TABLE,
public static final StringProperty LIST_ID = new StringProperty(Metadata.TABLE,
Metadata.VALUE2.name);
public static final LongProperty OWNER_ID = new LongProperty(Metadata.TABLE,
@ -37,8 +38,7 @@ public class GtasksMetadata {
Metadata metadata = new Metadata();
metadata.setValue(Metadata.KEY, GtasksMetadata.METADATA_KEY);
metadata.setValue(ID, (long)VALUE_UNSET);
metadata.setValue(LIST_ID, Preferences.getLong(GtasksPreferenceService.PREF_DEFAULT_LIST,
VALUE_UNSET));
metadata.setValue(LIST_ID, Preferences.getStringValue(GtasksPreferenceService.PREF_DEFAULT_LIST));
metadata.setValue(OWNER_ID, (long)VALUE_UNSET);
metadata.setValue(INDENTATION, 0);
metadata.setValue(ORDERING, VALUE_UNSET);

@ -0,0 +1,45 @@
package com.todoroo.astrid.gtasks;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.astrid.sync.SyncProviderPreferences;
import com.todoroo.astrid.sync.SyncProviderUtilities;
/**
* Displays synchronization preferences and an action panel so users can
* initiate actions from the menu.
*
* @author Tim Su <tim@todoroo.com>
*
*/
public class GtasksPreferences extends SyncProviderPreferences {
@Autowired private GtasksPreferenceService gtasksPreferenceService;
public GtasksPreferences() {
super();
DependencyInjectionService.getInstance().inject(this);
}
@Override
public int getPreferenceResource() {
return R.xml.preferences_gtasks;
}
@Override
public void startSync() {
//
}
@Override
public void logOut() {
//
}
@Override
public SyncProviderUtilities getUtilities() {
return gtasksPreferenceService;
}
}

@ -0,0 +1,75 @@
/**
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.gtasks;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.SyncAction;
/**
* Exposes sync action
*
*/
public class GtasksSyncActionExposer extends BroadcastReceiver {
@Autowired private GtasksPreferenceService gtasksPreferenceService;
@Autowired private GtasksListService gtasksListService;
@Override
public void onReceive(Context context, Intent intent) {
ContextManager.setContext(context);
DependencyInjectionService.getInstance().inject(this);
if(intent.getBooleanExtra("setup", false)) {
gtasksPreferenceService.setToken("haha");
try {
JSONArray newLists = new JSONArray();
JSONObject list = new JSONObject();
list.put("id", "1");
list.put("title", "Tim's Tasks");
newLists.put(list);
list = new JSONObject();
list.put("id", "2");
list.put("title", "Travel");
newLists.put(list);
gtasksListService.updateLists(newLists);
} catch (JSONException e) {
throw new RuntimeException(e);
}
System.err.println("you've ben set up the bomb.");
return;
}
// if we aren't logged in, don't expose sync action
//if(!gtasksPreferenceService.isLoggedIn())
// return;
Intent syncIntent = new Intent(intent.getAction(), null,
context, GtasksSyncActionExposer.class);
syncIntent.putExtra("setup", true);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, syncIntent, 0);
SyncAction syncAction = new SyncAction(context.getString(R.string.gtasks_GPr_header),
pendingIntent);
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_SYNC_ACTIONS);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, GtasksPreferenceService.IDENTIFIER);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, syncAction);
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 555 B

After

Width:  |  Height:  |  Size: 544 B

@ -12,6 +12,7 @@
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:visibility="gone"
android:orientation="vertical">
<Button android:id="@+id/done"

@ -13,7 +13,7 @@
<!-- ============================================== GtasksPreferences == -->
<!-- GTasks Preferences Title -->
<string name="gtasks_MPr_header">Google Tasks</string>
<string name="gtasks_GPr_header">Google Tasks</string>
<!-- ================================================ Synchronization == -->

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/sync_SPr_group_status">
<Preference
android:layout="@layout/status_preference"
android:key="@string/sync_SPr_status_key"
android:textSize="24sp"
android:gravity="center"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/sync_SPr_group_options">
<ListPreference
android:key="@string/gtasks_GPr_interval_key"
android:entries="@array/sync_SPr_interval_entries"
android:entryValues="@array/sync_SPr_interval_values"
android:title="@string/sync_SPr_interval_title" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/sync_SPr_group_actions">
<Preference
android:key="@string/sync_SPr_sync_key"
android:title="@string/sync_SPr_sync" />
<Preference
android:key="@string/sync_SPr_forget_key"
android:title="@string/sync_SPr_forget"
android:summary="@string/sync_SPr_forget_description" />
</PreferenceCategory>
</PreferenceScreen>
Loading…
Cancel
Save