Permalink
Browse files

Added a stub for Task Graph activity

  • Loading branch information...
alekz committed Sep 26, 2011
1 parent da3fb8c commit c53176479a8cb835f5b7251b3aa5dc05ac02efc6
View
@@ -16,6 +16,7 @@
<activity android:name=".TaskEdit"></activity>
<activity android:name=".ReportList"></activity>
<activity android:name=".ReportEdit"></activity>
+ <activity android:name=".TaskGraph"></activity>
</application>
-</manifest>
+</manifest>
@@ -32,50 +32,52 @@
public static final int report_list=0x7f030001;
public static final int report_row=0x7f030002;
public static final int task_edit=0x7f030003;
- public static final int task_list=0x7f030004;
- public static final int task_row=0x7f030005;
+ public static final int task_graph=0x7f030004;
+ public static final int task_list=0x7f030005;
+ public static final int task_row=0x7f030006;
}
public static final class string {
/** Global
*/
public static final int app_name=0x7f040000;
- public static final int button_cancel_edit_report=0x7f04001a;
- public static final int button_cancel_edit_task=0x7f04000d;
+ public static final int button_cancel_edit_report=0x7f04001b;
+ public static final int button_cancel_edit_task=0x7f04000e;
public static final int button_no=0x7f040002;
- public static final int button_save_report=0x7f040019;
- public static final int button_save_task=0x7f04000c;
+ public static final int button_save_report=0x7f04001a;
+ public static final int button_save_task=0x7f04000d;
public static final int button_yes=0x7f040001;
- public static final int menu_create_report=0x7f040013;
+ public static final int menu_create_report=0x7f040014;
public static final int menu_create_task=0x7f040004;
- public static final int menu_delete_report=0x7f040015;
+ public static final int menu_delete_report=0x7f040016;
public static final int menu_delete_task=0x7f040006;
- public static final int menu_edit_report=0x7f040014;
+ public static final int menu_edit_report=0x7f040015;
public static final int menu_edit_task=0x7f040005;
+ public static final int menu_view_task_graph=0x7f040008;
public static final int menu_view_task_reports=0x7f040007;
- public static final int message_confirm_delete_report=0x7f04001e;
- public static final int message_confirm_delete_task=0x7f040011;
+ public static final int message_confirm_delete_report=0x7f04001f;
+ public static final int message_confirm_delete_task=0x7f040012;
/** List of reports
*/
- public static final int message_no_reports=0x7f040012;
+ public static final int message_no_reports=0x7f040013;
/** List of tasks
*/
public static final int message_no_tasks=0x7f040003;
- public static final int message_report_created=0x7f04001b;
- public static final int message_report_deleted=0x7f04001d;
- public static final int message_report_updated=0x7f04001c;
- public static final int message_task_created=0x7f04000e;
- public static final int message_task_deleted=0x7f040010;
- public static final int message_task_updated=0x7f04000f;
- public static final int report_date=0x7f040017;
- public static final int report_value=0x7f040018;
- public static final int task_start_value=0x7f04000a;
- public static final int task_target_value=0x7f04000b;
- public static final int task_title=0x7f040009;
+ public static final int message_report_created=0x7f04001c;
+ public static final int message_report_deleted=0x7f04001e;
+ public static final int message_report_updated=0x7f04001d;
+ public static final int message_task_created=0x7f04000f;
+ public static final int message_task_deleted=0x7f040011;
+ public static final int message_task_updated=0x7f040010;
+ public static final int report_date=0x7f040018;
+ public static final int report_value=0x7f040019;
+ public static final int task_start_value=0x7f04000b;
+ public static final int task_target_value=0x7f04000c;
+ public static final int task_title=0x7f04000a;
/** Delete report
*/
- public static final int title_edit_report=0x7f040016;
+ public static final int title_edit_report=0x7f040017;
/** Edit task
*/
- public static final int title_edit_task=0x7f040008;
+ public static final int title_edit_task=0x7f040009;
}
}
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+</LinearLayout>
View
@@ -12,6 +12,7 @@
<string name="menu_edit_task">Edit Task</string>
<string name="menu_delete_task">Delete Task</string>
<string name="menu_view_task_reports">View Reports</string>
+ <string name="menu_view_task_graph">View Graph</string>
<!-- Edit task -->
<string name="title_edit_task">Edit Task</string>
@@ -24,13 +24,15 @@
private static final int ACTIVITY_CREATE_TASK = 0;
private static final int ACTIVITY_EDIT_TASK = 1;
private static final int ACTIVITY_VIEW_TASK_REPORTS = 2;
+ private static final int ACTIVITY_VIEW_TASK_GRAPH = 3;
private static final int DIALOG_CONFIRM_DELETE_TASK_ID = 1;
public static final int MENU_ID_CREATE_TASK = Menu.FIRST;
public static final int MENU_ID_EDIT_TASK = Menu.FIRST + 1;
public static final int MENU_ID_DELETE_TASK = Menu.FIRST + 2;
public static final int MENU_ID_VIEW_TASK_REPORTS = Menu.FIRST + 3;
+ public static final int MENU_ID_VIEW_TASK_GRAPH = Menu.FIRST + 4;
private GoalTrackerDbAdapter mDbHelper;
private Cursor mTasksCursor;
@@ -101,10 +103,11 @@ public void onCreateContextMenu(ContextMenu menu, View v,
menu.setHeaderTitle(title);
// Add menu items
- menu.add(0, MENU_ID_VIEW_TASK_REPORTS, 0,
+ menu.add(0, MENU_ID_VIEW_TASK_GRAPH, 0, R.string.menu_view_task_graph);
+ menu.add(0, MENU_ID_VIEW_TASK_REPORTS, 1,
R.string.menu_view_task_reports);
- menu.add(0, MENU_ID_EDIT_TASK, 1, R.string.menu_edit_task);
- menu.add(0, MENU_ID_DELETE_TASK, 2, R.string.menu_delete_task);
+ menu.add(0, MENU_ID_EDIT_TASK, 2, R.string.menu_edit_task);
+ menu.add(0, MENU_ID_DELETE_TASK, 3, R.string.menu_delete_task);
}
/**
@@ -120,6 +123,10 @@ public boolean onContextItemSelected(MenuItem item) {
switch (item.getItemId()) {
+ case MENU_ID_VIEW_TASK_GRAPH:
+ runViewTaskGraph(rowId);
+ return true;
+
case MENU_ID_VIEW_TASK_REPORTS:
runViewTaskReports(rowId);
return true;
@@ -143,7 +150,7 @@ public boolean onContextItemSelected(MenuItem item) {
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
- runViewTaskReports(id);
+ runViewTaskGraph(id);
}
/**
@@ -205,6 +212,17 @@ public void onClick(DialogInterface dialog,
return dialog;
}
+ /**
+ * Displays task's graph
+ *
+ * @param rowId
+ */
+ private void runViewTaskGraph(long rowId) {
+ Intent i = new Intent(this, TaskGraph.class);
+ i.putExtra(ReportPeer.KEY_TASK_ID, rowId);
+ startActivityForResult(i, ACTIVITY_VIEW_TASK_GRAPH);
+ }
+
/**
* Displays list of task reports
*
@@ -0,0 +1,57 @@
+package com.k10v.goaltracker;
+
+import android.app.Activity;
+import android.database.Cursor;
+import android.os.Bundle;
+import android.util.Log;
+
+public class TaskGraph extends Activity {
+
+ private static final String TAG = "TaskGraph";
+
+ private GoalTrackerDbAdapter mDbHelper;
+ private Cursor mReportsCursor;
+ private long mTaskId;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.task_graph);
+
+ // Prepare DB adapter
+ mDbHelper = new GoalTrackerDbAdapter(this);
+ mDbHelper.open();
+
+ // Retrieve task ID: first check if it's stored in saved state, if not
+ // then check Intent's extras. If ID is empty, it is an error.
+ if (savedInstanceState != null) {
+ mTaskId = (Long) savedInstanceState.getSerializable(
+ ReportPeer.KEY_TASK_ID);
+ } else {
+ Bundle extras = getIntent().getExtras();
+ if (extras != null) {
+ mTaskId = extras.getLong(ReportPeer.KEY_TASK_ID);
+ }
+ }
+ if (mTaskId == 0) {
+ // Error
+ Log.e(TAG, "Task ID is empty");
+ finish();
+ }
+
+ drawGraph();
+ }
+
+ /**
+ * Draw the graph.
+ */
+ private void drawGraph() {
+ mReportsCursor = mDbHelper.getReportPeer().
+ fetchReportsByTask(mTaskId, true);
+ startManagingCursor(mReportsCursor);
+
+ // TODO: ...
+ }
+}

0 comments on commit c531764

Please sign in to comment.