forked from sudar/android-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
411 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Binary file not shown.
Binary file added
BIN
+875 Bytes
TaskManager/bin/com/sudarmuthu/android/taskmanager/AddTaskActivity$1.class
Binary file not shown.
Binary file added
BIN
+874 Bytes
TaskManager/bin/com/sudarmuthu/android/taskmanager/AddTaskActivity$2.class
Binary file not shown.
Binary file added
BIN
+1.15 KB
TaskManager/bin/com/sudarmuthu/android/taskmanager/AddTaskActivity$3.class
Binary file not shown.
Binary file added
BIN
+955 Bytes
TaskManager/bin/com/sudarmuthu/android/taskmanager/AddTaskActivity$4.class
Binary file not shown.
Binary file added
BIN
+954 Bytes
TaskManager/bin/com/sudarmuthu/android/taskmanager/AddTaskActivity$5.class
Binary file not shown.
Binary file added
BIN
+1.05 KB
TaskManager/bin/com/sudarmuthu/android/taskmanager/AddTaskActivity$6.class
Binary file not shown.
Binary file added
BIN
+3.44 KB
TaskManager/bin/com/sudarmuthu/android/taskmanager/AddTaskActivity.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+448 Bytes
TaskManager/bin/com/sudarmuthu/android/taskmanager/R$drawable.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.6 KB
TaskManager/bin/com/sudarmuthu/android/taskmanager/TaskManagerApplication.class
Binary file not shown.
Binary file added
BIN
+713 Bytes
TaskManager/bin/com/sudarmuthu/android/taskmanager/TaskMangerActivity.class
Binary file not shown.
Binary file added
BIN
+1.1 KB
TaskManager/bin/com/sudarmuthu/android/taskmanager/ViewTasksActivity$1.class
Binary file not shown.
Binary file added
BIN
+2.57 KB
TaskManager/bin/com/sudarmuthu/android/taskmanager/ViewTasksActivity.class
Binary file not shown.
Binary file added
BIN
+675 Bytes
TaskManager/bin/com/sudarmuthu/android/taskmanager/tasks/Task.class
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
106 changes: 106 additions & 0 deletions
106
TaskManager/src/com/sudarmuthu/android/taskmanager/AddTaskActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
TaskManager/src/com/sudarmuthu/android/taskmanager/TaskManagerApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
TaskManager/src/com/sudarmuthu/android/taskmanager/TaskMangerActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.