mirror of https://github.com/tasks/tasks
Added gtasks preferences, bug fixes to get detail exposer working
parent
d00a35bf58
commit
1d5e7ef477
@ -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 |
@ -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…
Reference in New Issue