Implemented password-based login and sign up to Astrid.com
@ -1,52 +0,0 @@
|
|||||||
/**
|
|
||||||
* See the file "LICENSE" for the full license governing this code.
|
|
||||||
*/
|
|
||||||
package com.todoroo.astrid.actfm;
|
|
||||||
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
|
|
||||||
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
|
|
||||||
import com.todoroo.astrid.api.AstridApiConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exposes Task Detail for notes
|
|
||||||
*
|
|
||||||
* @author Tim Su <tim@todoroo.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class TagDataDetailExposer extends BroadcastReceiver {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
long taskId = intent.getLongExtra(AstridApiConstants.EXTRAS_TASK_ID, -1);
|
|
||||||
if(taskId == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
String taskDetail = getTaskDetails(taskId);
|
|
||||||
if(taskDetail == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// transmit
|
|
||||||
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_DETAILS);
|
|
||||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, taskDetail);
|
|
||||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON,
|
|
||||||
ActFmPreferenceService.IDENTIFIER);
|
|
||||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
|
|
||||||
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTaskDetails(long id) {
|
|
||||||
/*Task task = PluginServices.getTaskService().fetchById(id, Task.PROJECT_ID);
|
|
||||||
if(task == null)
|
|
||||||
return null;
|
|
||||||
TagData tagData = PluginServices.getTagDataService().fetchById(task.getValue(Task.PROJECT_ID), TagData.TITLE);
|
|
||||||
if(tagData == null)*/
|
|
||||||
return null;
|
|
||||||
|
|
||||||
// return "<img src='silk_group'/> " + tagData.getValue(TagData.TITLE); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,229 +0,0 @@
|
|||||||
/**
|
|
||||||
* See the file "LICENSE" for the full license governing this code.
|
|
||||||
*/
|
|
||||||
package com.todoroo.astrid.actfm;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
import android.app.ListActivity;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import com.timsu.astrid.R;
|
|
||||||
import com.todoroo.andlib.data.TodorooCursor;
|
|
||||||
import com.todoroo.andlib.service.Autowired;
|
|
||||||
import com.todoroo.andlib.service.DependencyInjectionService;
|
|
||||||
import com.todoroo.andlib.service.ExceptionService;
|
|
||||||
import com.todoroo.andlib.sql.QueryTemplate;
|
|
||||||
import com.todoroo.andlib.utility.DialogUtilities;
|
|
||||||
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
|
|
||||||
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
|
|
||||||
import com.todoroo.astrid.activity.TaskListActivity;
|
|
||||||
import com.todoroo.astrid.adapter.TagDataAdapter;
|
|
||||||
import com.todoroo.astrid.dao.TagDataDao.TagDataCriteria;
|
|
||||||
import com.todoroo.astrid.data.TagData;
|
|
||||||
import com.todoroo.astrid.service.AstridDependencyInjector;
|
|
||||||
import com.todoroo.astrid.service.TagDataService;
|
|
||||||
import com.todoroo.astrid.service.StatisticsService;
|
|
||||||
import com.todoroo.astrid.service.ThemeService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Activity that displays a user's task lists and allows users
|
|
||||||
* to filter their task list.
|
|
||||||
*
|
|
||||||
* @author Tim Su <tim@todoroo.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class TagDataListActivity extends ListActivity implements OnItemClickListener {
|
|
||||||
|
|
||||||
// --- constants
|
|
||||||
|
|
||||||
private static final int REQUEST_LOG_IN = 1;
|
|
||||||
private static final int REQUEST_SHOW_GOAL = 2;
|
|
||||||
|
|
||||||
private static final int MENU_REFRESH_ID = Menu.FIRST + 0;
|
|
||||||
|
|
||||||
// --- instance variables
|
|
||||||
|
|
||||||
@Autowired ExceptionService exceptionService;
|
|
||||||
@Autowired TagDataService tagDataService;
|
|
||||||
@Autowired ActFmPreferenceService actFmPreferenceService;
|
|
||||||
@Autowired ActFmSyncService actFmSyncService;
|
|
||||||
|
|
||||||
protected TagDataAdapter adapter = null;
|
|
||||||
protected AtomicReference<String> queryTemplate = new AtomicReference<String>();
|
|
||||||
|
|
||||||
/* ======================================================================
|
|
||||||
* ======================================================= initialization
|
|
||||||
* ====================================================================== */
|
|
||||||
|
|
||||||
static {
|
|
||||||
AstridDependencyInjector.initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called when loading up the activity */
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
DependencyInjectionService.getInstance().inject(this);
|
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
setContentView(R.layout.tagData_list_activity);
|
|
||||||
ThemeService.applyTheme(this);
|
|
||||||
|
|
||||||
if(!actFmPreferenceService.isLoggedIn()) {
|
|
||||||
Intent login = new Intent(this, ActFmLoginActivity.class);
|
|
||||||
login.putExtra(ActFmLoginActivity.EXTRA_DO_NOT_SYNC, true);
|
|
||||||
startActivityForResult(login, REQUEST_LOG_IN);
|
|
||||||
}
|
|
||||||
|
|
||||||
initializeUIComponents();
|
|
||||||
setUpList();
|
|
||||||
refreshList(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("nls")
|
|
||||||
private void initializeUIComponents() {
|
|
||||||
((ImageButton) findViewById(R.id.extendedAddButton)).setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
DialogUtilities.okDialog(TagDataListActivity.this, "unsupported", null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
((ImageButton) findViewById(R.id.extendedAddButton)).setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
DialogUtilities.okDialog(TagDataListActivity.this, "unsupported", null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
((ImageView) findViewById(R.id.goals)).setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
Intent intent = new Intent(TagDataListActivity.this, TaskListActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create options menu (displayed when user presses menu key)
|
|
||||||
*
|
|
||||||
* @return true if menu should be displayed
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
|
||||||
if(menu.size() > 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
MenuItem item;
|
|
||||||
|
|
||||||
item = menu.add(Menu.NONE, MENU_REFRESH_ID, Menu.NONE,
|
|
||||||
R.string.PLA_menu_refresh);
|
|
||||||
item.setIcon(R.drawable.ic_menu_refresh);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================================================================
|
|
||||||
* ============================================================ lifecycle
|
|
||||||
* ====================================================================== */
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
StatisticsService.sessionStart(this);
|
|
||||||
StatisticsService.reportEvent("goal-list"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop() {
|
|
||||||
super.onStop();
|
|
||||||
StatisticsService.sessionStop(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
if(requestCode == REQUEST_LOG_IN) {
|
|
||||||
if(resultCode == RESULT_CANCELED)
|
|
||||||
finish();
|
|
||||||
else
|
|
||||||
refreshList(true);
|
|
||||||
} else
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================================================================
|
|
||||||
* ====================================================== populating list
|
|
||||||
* ====================================================================== */
|
|
||||||
|
|
||||||
/** Sets up the coach list adapter */
|
|
||||||
protected void setUpList() {
|
|
||||||
queryTemplate.set(new QueryTemplate().where(TagDataCriteria.isTeam()).toString());
|
|
||||||
TodorooCursor<TagData> currentCursor = tagDataService.fetchFiltered(queryTemplate.get(),
|
|
||||||
null, TagData.PROPERTIES);
|
|
||||||
startManagingCursor(currentCursor);
|
|
||||||
|
|
||||||
adapter = new TagDataAdapter(this, R.layout.tagData_adapter_row,
|
|
||||||
currentCursor, queryTemplate, false, null);
|
|
||||||
setListAdapter(adapter);
|
|
||||||
|
|
||||||
getListView().setOnItemClickListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** refresh the list with latest data from the web */
|
|
||||||
private void refreshList(boolean manual) {
|
|
||||||
actFmSyncService.fetchTagDataDashboard(manual, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Cursor cursor = adapter.getCursor();
|
|
||||||
cursor.requery();
|
|
||||||
startManagingCursor(cursor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================================================================
|
|
||||||
* ============================================================== actions
|
|
||||||
* ====================================================================== */
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
|
||||||
Intent intent = new Intent(this, TagDataViewActivity.class);
|
|
||||||
intent.putExtra(TagDataViewActivity.EXTRA_PROJECT_ID, id);
|
|
||||||
startActivityForResult(intent, REQUEST_SHOW_GOAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemSelected(int featureId, final MenuItem item) {
|
|
||||||
|
|
||||||
// handle my own menus
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case MENU_REFRESH_ID: {
|
|
||||||
refreshList(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
package com.todoroo.astrid.actfm;
|
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
|
|
||||||
import com.timsu.astrid.R;
|
|
||||||
import com.todoroo.andlib.service.ContextManager;
|
|
||||||
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
|
|
||||||
import com.todoroo.astrid.api.AstridApiConstants;
|
|
||||||
import com.todoroo.astrid.api.TaskAction;
|
|
||||||
import com.todoroo.astrid.core.PluginServices;
|
|
||||||
import com.todoroo.astrid.data.TagData;
|
|
||||||
|
|
||||||
public class ShowTagDataExposer extends BroadcastReceiver {
|
|
||||||
|
|
||||||
private static final String FILTER_ACTION = "com.todoroo.astrid.SHOW_PROJECT"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
ContextManager.setContext(context);
|
|
||||||
long taskId = intent.getLongExtra(AstridApiConstants.EXTRAS_TASK_ID, -1);
|
|
||||||
if(taskId == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
TagData tagData = PluginServices.getTagDataService().getTagData(taskId,
|
|
||||||
TagData.ID, TagData.TITLE);
|
|
||||||
if(tagData == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(AstridApiConstants.BROADCAST_REQUEST_ACTIONS.equals(intent.getAction())) {
|
|
||||||
final String label = tagData.getValue(TagData.TITLE);
|
|
||||||
final Drawable drawable = context.getResources().getDrawable(R.drawable.tango_users);
|
|
||||||
Intent newIntent = new Intent(FILTER_ACTION);
|
|
||||||
newIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
|
|
||||||
Bitmap icon = ((BitmapDrawable)drawable).getBitmap();
|
|
||||||
TaskAction action = new TaskAction(label,
|
|
||||||
PendingIntent.getBroadcast(context, (int)taskId, newIntent, 0), icon);
|
|
||||||
|
|
||||||
// transmit
|
|
||||||
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_ACTIONS);
|
|
||||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, ActFmPreferenceService.IDENTIFIER);
|
|
||||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, action);
|
|
||||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
|
|
||||||
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
|
|
||||||
} else if(FILTER_ACTION.equals(intent.getAction())) {
|
|
||||||
Intent launchIntent = new Intent(context, TagDataViewActivity.class);
|
|
||||||
launchIntent.putExtra(TagDataViewActivity.EXTRA_PROJECT_ID, tagData.getId());
|
|
||||||
ContextManager.getContext().startActivity(launchIntent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package com.todoroo.astrid.actfm;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Metadata entry for a task shared with astrid.com
|
|
||||||
*
|
|
||||||
* @author Tim Su <tim@todoroo.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class TaskFields {
|
|
||||||
|
|
||||||
/** metadata key */
|
|
||||||
public static final String METADATA_KEY = "actfm"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
/** remote id*/
|
|
||||||
public static final LongProperty REMOTE_ID = new LongProperty(Metadata.TABLE, Metadata.VALUE2.name);
|
|
||||||
|
|
||||||
/** goal id */
|
|
||||||
public static final LongProperty GOAL_ID = new LongProperty(Metadata.TABLE, Metadata.VALUE2.name);
|
|
||||||
|
|
||||||
/** user id */
|
|
||||||
public static final LongProperty USER_ID = new LongProperty(Metadata.TABLE, Metadata.VALUE3.name);
|
|
||||||
|
|
||||||
/** user */
|
|
||||||
public static final StringProperty USER = Metadata.VALUE4;
|
|
||||||
|
|
||||||
/** comment count */
|
|
||||||
public static final IntegerProperty COMMENT_COUNT = new IntegerProperty(Metadata.TABLE,
|
|
||||||
Metadata.VALUE4.name);
|
|
||||||
|
|
||||||
}
|
|
After Width: | Height: | Size: 888 B |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 502 B |
@ -1,25 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<item android:state_pressed="false" android:state_focused="false" android:drawable="@drawable/sharing_button_normal" />
|
|
||||||
<item android:state_pressed="true" android:state_focused="false" android:drawable="@drawable/sharing_button_pressed" />
|
|
||||||
|
|
||||||
<item android:state_pressed="false" android:state_focused="true" android:drawable="@drawable/sharing_button_focused" />
|
|
||||||
<item android:state_pressed="true" android:state_focused="true" android:drawable="@drawable/sharing_button_pressed" />
|
|
||||||
|
|
||||||
</selector>
|
|
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.6 KiB |