Skip to content

Commit

Permalink
Added source code from Session 1
Browse files Browse the repository at this point in the history
  • Loading branch information
sudar committed Feb 17, 2010
1 parent 69c4e56 commit 1660b6d
Show file tree
Hide file tree
Showing 37 changed files with 411 additions and 0 deletions.
7 changes: 7 additions & 0 deletions TaskManager/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="bin"/>
</classpath>
33 changes: 33 additions & 0 deletions TaskManager/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>TaskManager</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
20 changes: 20 additions & 0 deletions TaskManager/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sudarmuthu.android.taskmanager"
android:versionCode="1"
android:versionName="1.0">
<application android:name=".TaskManagerApplication" android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".ViewTasksActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AddTaskActivity"
android:label="@string/app_name"
/>
</application>
<uses-sdk android:minSdkVersion="4" />

</manifest>
Binary file added TaskManager/bin/TaskManager.apk
Binary file not shown.
Binary file added TaskManager/bin/classes.dex
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added TaskManager/bin/resources.ap_
Binary file not shown.
13 changes: 13 additions & 0 deletions TaskManager/default.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=Google Inc.:Google APIs:4
# Indicates whether an apk should be generated for each density.
split.density=false
37 changes: 37 additions & 0 deletions TaskManager/gen/com/sudarmuthu/android/taskmanager/R.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/

package com.sudarmuthu.android.taskmanager;

public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int add_button=0x7f050002;
public static final int cancel_button=0x7f050003;
public static final int task_list=0x7f050004;
public static final int task_name=0x7f050001;
public static final int tasks_title=0x7f050000;
}
public static final class layout {
public static final int add_tasks=0x7f030000;
public static final int main=0x7f030001;
}
public static final class string {
public static final int add_task=0x7f040002;
public static final int app_name=0x7f040000;
public static final int cancel=0x7f040004;
public static final int cancel_task=0x7f040003;
public static final int discard=0x7f040007;
public static final int tasks=0x7f040001;
public static final int unsaved_changes_message=0x7f040006;
public static final int unsaved_changes_title=0x7f040005;
}
}
Binary file added TaskManager/res/drawable-hdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TaskManager/res/drawable-ldpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TaskManager/res/drawable-mdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions TaskManager/res/layout/add_tasks.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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"
>

<TextView
android:id="@+id/tasks_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text ="@string/add_task"
/>

<EditText
android:id="@+id/task_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"


/>
<Button
android:id="@+id/add_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text ="@string/add_task"

/>

<Button
android:id="@+id/cancel_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text ="@string/cancel_task"

/>
</LinearLayout>
27 changes: 27 additions & 0 deletions TaskManager/res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/tasks_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/tasks"
/>
<Button
android:id="@+id/add_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/add_task"
android:layout_alignParentBottom="true"
/>
<TextView
android:id="@+id/task_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tasks_title"
android:layout_above="@id/add_button"
/>
</RelativeLayout>
11 changes: 11 additions & 0 deletions TaskManager/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TaskManager</string>
<string name="tasks">Tasks</string>
<string name="add_task">Add Task</string>
<string name="cancel_task">Cancel Tasks</string>
<string name="cancel">Cancel</string>
<string name="unsaved_changes_title">Unsaved changes</string>
<string name="unsaved_changes_message">You have a task which is not saved</string>
<string name="discard">Discard</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.sudarmuthu.android.taskmanager;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.sudarmuthu.android.taskmanager.tasks.Task;

public class AddTaskActivity extends TaskMangerActivity {

private EditText taskNameEditText;
private Button addButton;
private Button cancelButton;
protected boolean changesPending;
private AlertDialog unsavedChangesDialog;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add_tasks);
setUpViews();
}

private void setUpViews() {
taskNameEditText = (EditText)findViewById(R.id.task_name);
addButton = (Button)findViewById(R.id.add_button);
cancelButton = (Button)findViewById(R.id.cancel_button);

addButton.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
addTask();
}
});

cancelButton.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
cancel();
}
});

taskNameEditText.addTextChangedListener(new TextWatcher() {

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
changesPending = true;
}

@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {

}

@Override
public void afterTextChanged(Editable s) {

}
});
}

protected void cancel() {
if (changesPending) {
unsavedChangesDialog = new AlertDialog.Builder(this)
.setTitle(R.string.unsaved_changes_title)
.setMessage(R.string.unsaved_changes_message)
.setPositiveButton(R.string.add_task, new AlertDialog.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
addTask();
}
})
.setNeutralButton(R.string.discard, new AlertDialog.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
}

})
.setNegativeButton(android.R.string.cancel, new AlertDialog.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
unsavedChangesDialog.cancel();
}

})
.create();
unsavedChangesDialog.show();
} else {
finish();
}
}

protected void addTask() {
String taskName = taskNameEditText.getText().toString();
Task t = new Task(taskName);
getTaskManagerApplication().addTask(t);
finish();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.sudarmuthu.android.taskmanager;

import java.util.ArrayList;

import android.app.Application;

import com.sudarmuthu.android.taskmanager.tasks.Task;

public class TaskManagerApplication extends Application {

private ArrayList<Task> currentTasks;

@Override
public void onCreate() {
super.onCreate();
if (null == currentTasks) {
currentTasks = new ArrayList<Task>();
}
}

public void setCurrentTasks(ArrayList<Task> currentTasks) {
this.currentTasks = currentTasks;
}

public ArrayList<Task> getCurrentTasks() {
return currentTasks;
}

public void addTask(Task t) {
assert(null != t);
if (null == currentTasks) {
currentTasks = new ArrayList<Task>();
}
currentTasks.add(t);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.sudarmuthu.android.taskmanager;

import android.app.Activity;

public class TaskMangerActivity extends Activity {
protected TaskManagerApplication getTaskManagerApplication() {
TaskManagerApplication tma = (TaskManagerApplication)getApplication();
return tma;
}
}
Loading

0 comments on commit 1660b6d

Please sign in to comment.