modelClass) {
24 | //noinspection unchecked
25 | return (T) new AddTaskViewModel(mDb, mTaskId);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/todolist/AppExecutors.java:
--------------------------------------------------------------------------------
1 | package com.example.android.todolist;
2 |
3 | /*
4 | * Copyright (C) 2017 The Android Open Source Project
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | import android.os.Handler;
20 | import android.os.Looper;
21 | import android.support.annotation.NonNull;
22 |
23 | import java.util.concurrent.Executor;
24 | import java.util.concurrent.Executors;
25 |
26 | /**
27 | * Global executor pools for the whole application.
28 | *
29 | * Grouping tasks like this avoids the effects of task starvation (e.g. disk reads don't wait behind
30 | * webservice requests).
31 | */
32 | public class AppExecutors {
33 |
34 | // For Singleton instantiation
35 | private static final Object LOCK = new Object();
36 | private static AppExecutors sInstance;
37 | private final Executor diskIO;
38 | private final Executor mainThread;
39 | private final Executor networkIO;
40 |
41 | private AppExecutors(Executor diskIO, Executor networkIO, Executor mainThread) {
42 | this.diskIO = diskIO;
43 | this.networkIO = networkIO;
44 | this.mainThread = mainThread;
45 | }
46 |
47 | public static AppExecutors getInstance() {
48 | if (sInstance == null) {
49 | synchronized (LOCK) {
50 | sInstance = new AppExecutors(Executors.newSingleThreadExecutor(),
51 | Executors.newFixedThreadPool(3),
52 | new MainThreadExecutor());
53 | }
54 | }
55 | return sInstance;
56 | }
57 |
58 | public Executor diskIO() {
59 | return diskIO;
60 | }
61 |
62 | public Executor mainThread() {
63 | return mainThread;
64 | }
65 |
66 | public Executor networkIO() {
67 | return networkIO;
68 | }
69 |
70 | private static class MainThreadExecutor implements Executor {
71 | private Handler mainThreadHandler = new Handler(Looper.getMainLooper());
72 |
73 | @Override
74 | public void execute(@NonNull Runnable command) {
75 | mainThreadHandler.post(command);
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/todolist/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.todolist;
18 |
19 | import android.arch.lifecycle.Observer;
20 | import android.arch.lifecycle.ViewModelProviders;
21 | import android.content.Intent;
22 | import android.os.Bundle;
23 | import android.support.annotation.Nullable;
24 | import android.support.design.widget.FloatingActionButton;
25 | import android.support.v7.app.AppCompatActivity;
26 | import android.support.v7.widget.DividerItemDecoration;
27 | import android.support.v7.widget.LinearLayoutManager;
28 | import android.support.v7.widget.RecyclerView;
29 | import android.support.v7.widget.helper.ItemTouchHelper;
30 | import android.util.Log;
31 | import android.view.View;
32 |
33 | import com.example.android.todolist.database.AppDatabase;
34 | import com.example.android.todolist.database.TaskEntry;
35 |
36 | import java.util.List;
37 |
38 | import static android.support.v7.widget.DividerItemDecoration.VERTICAL;
39 |
40 |
41 | public class MainActivity extends AppCompatActivity implements TaskAdapter.ItemClickListener {
42 |
43 | // Constant for logging
44 | private static final String TAG = MainActivity.class.getSimpleName();
45 | // Member variables for the adapter and RecyclerView
46 | private RecyclerView mRecyclerView;
47 | private TaskAdapter mAdapter;
48 |
49 | private AppDatabase mDb;
50 |
51 | @Override
52 | protected void onCreate(Bundle savedInstanceState) {
53 | super.onCreate(savedInstanceState);
54 | setContentView(R.layout.activity_main);
55 |
56 | // Set the RecyclerView to its corresponding view
57 | mRecyclerView = findViewById(R.id.recyclerViewTasks);
58 |
59 | // Set the layout for the RecyclerView to be a linear layout, which measures and
60 | // positions items within a RecyclerView into a linear list
61 | mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
62 |
63 | // Initialize the adapter and attach it to the RecyclerView
64 | mAdapter = new TaskAdapter(this, this);
65 | mRecyclerView.setAdapter(mAdapter);
66 |
67 | DividerItemDecoration decoration = new DividerItemDecoration(getApplicationContext(), VERTICAL);
68 | mRecyclerView.addItemDecoration(decoration);
69 |
70 | /*
71 | Add a touch helper to the RecyclerView to recognize when a user swipes to delete an item.
72 | An ItemTouchHelper enables touch behavior (like swipe and move) on each ViewHolder,
73 | and uses callbacks to signal when a user is performing these actions.
74 | */
75 | new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
76 | @Override
77 | public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
78 | return false;
79 | }
80 |
81 | // Called when a user swipes left or right on a ViewHolder
82 | @Override
83 | public void onSwiped(final RecyclerView.ViewHolder viewHolder, int swipeDir) {
84 | // Here is where you'll implement swipe to delete
85 | AppExecutors.getInstance().diskIO().execute(new Runnable() {
86 | @Override
87 | public void run() {
88 | int position = viewHolder.getAdapterPosition();
89 | List tasks = mAdapter.getTasks();
90 | mDb.taskDao().deleteTask(tasks.get(position));
91 | }
92 | });
93 | }
94 | }).attachToRecyclerView(mRecyclerView);
95 |
96 | /*
97 | Set the Floating Action Button (FAB) to its corresponding View.
98 | Attach an OnClickListener to it, so that when it's clicked, a new intent will be created
99 | to launch the AddTaskActivity.
100 | */
101 | FloatingActionButton fabButton = findViewById(R.id.fab);
102 |
103 | fabButton.setOnClickListener(new View.OnClickListener() {
104 | @Override
105 | public void onClick(View view) {
106 | // Create a new intent to start an AddTaskActivity
107 | Intent addTaskIntent = new Intent(MainActivity.this, AddTaskActivity.class);
108 | startActivity(addTaskIntent);
109 | }
110 | });
111 |
112 | mDb = AppDatabase.getInstance(getApplicationContext());
113 | setupViewModel();
114 | }
115 |
116 | private void setupViewModel() {
117 | MainViewModel viewModel = ViewModelProviders.of(this).get(MainViewModel.class);
118 | viewModel.getTasks().observe(this, new Observer>() {
119 | @Override
120 | public void onChanged(@Nullable List taskEntries) {
121 | Log.d(TAG, "Updating list of tasks from LiveData in ViewModel");
122 | mAdapter.setTasks(taskEntries);
123 | }
124 | });
125 | }
126 |
127 | @Override
128 | public void onItemClickListener(int itemId) {
129 | // Launch AddTaskActivity adding the itemId as an extra in the intent
130 | Intent intent = new Intent(MainActivity.this, AddTaskActivity.class);
131 | intent.putExtra(AddTaskActivity.EXTRA_TASK_ID, itemId);
132 | startActivity(intent);
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/todolist/MainViewModel.java:
--------------------------------------------------------------------------------
1 | package com.example.android.todolist;
2 |
3 | import android.app.Application;
4 | import android.arch.lifecycle.AndroidViewModel;
5 | import android.arch.lifecycle.LiveData;
6 | import android.util.Log;
7 |
8 | import com.example.android.todolist.database.AppDatabase;
9 | import com.example.android.todolist.database.TaskEntry;
10 |
11 | import java.util.List;
12 |
13 | public class MainViewModel extends AndroidViewModel {
14 |
15 | // Constant for logging
16 | private static final String TAG = MainViewModel.class.getSimpleName();
17 |
18 | private LiveData> tasks;
19 |
20 | public MainViewModel(Application application) {
21 | super(application);
22 | AppDatabase database = AppDatabase.getInstance(this.getApplication());
23 | Log.d(TAG, "Actively retrieving the tasks from the DataBase");
24 | tasks = database.taskDao().loadAllTasks();
25 | }
26 |
27 | public LiveData> getTasks() {
28 | return tasks;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/todolist/TaskAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.todolist;
18 |
19 | import android.content.Context;
20 | import android.graphics.drawable.GradientDrawable;
21 | import android.support.v4.content.ContextCompat;
22 | import android.support.v7.widget.RecyclerView;
23 | import android.view.LayoutInflater;
24 | import android.view.View;
25 | import android.view.ViewGroup;
26 | import android.widget.TextView;
27 |
28 | import com.example.android.todolist.database.TaskEntry;
29 |
30 | import java.text.SimpleDateFormat;
31 | import java.util.List;
32 | import java.util.Locale;
33 |
34 | /**
35 | * This TaskAdapter creates and binds ViewHolders, that hold the description and priority of a task,
36 | * to a RecyclerView to efficiently display data.
37 | */
38 | public class TaskAdapter extends RecyclerView.Adapter {
39 |
40 | // Constant for date format
41 | private static final String DATE_FORMAT = "dd/MM/yyy";
42 |
43 | // Member variable to handle item clicks
44 | final private ItemClickListener mItemClickListener;
45 | // Class variables for the List that holds task data and the Context
46 | private List mTaskEntries;
47 | private Context mContext;
48 | // Date formatter
49 | private SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
50 |
51 | /**
52 | * Constructor for the TaskAdapter that initializes the Context.
53 | *
54 | * @param context the current Context
55 | * @param listener the ItemClickListener
56 | */
57 | public TaskAdapter(Context context, ItemClickListener listener) {
58 | mContext = context;
59 | mItemClickListener = listener;
60 | }
61 |
62 | /**
63 | * Called when ViewHolders are created to fill a RecyclerView.
64 | *
65 | * @return A new TaskViewHolder that holds the view for each task
66 | */
67 | @Override
68 | public TaskViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
69 | // Inflate the task_layout to a view
70 | View view = LayoutInflater.from(mContext)
71 | .inflate(R.layout.task_layout, parent, false);
72 |
73 | return new TaskViewHolder(view);
74 | }
75 |
76 | /**
77 | * Called by the RecyclerView to display data at a specified position in the Cursor.
78 | *
79 | * @param holder The ViewHolder to bind Cursor data to
80 | * @param position The position of the data in the Cursor
81 | */
82 | @Override
83 | public void onBindViewHolder(TaskViewHolder holder, int position) {
84 | // Determine the values of the wanted data
85 | TaskEntry taskEntry = mTaskEntries.get(position);
86 | String description = taskEntry.getDescription();
87 | int priority = taskEntry.getPriority();
88 | String updatedAt = dateFormat.format(taskEntry.getUpdatedAt());
89 |
90 | //Set values
91 | holder.taskDescriptionView.setText(description);
92 | holder.updatedAtView.setText(updatedAt);
93 |
94 | // Programmatically set the text and color for the priority TextView
95 | String priorityString = "" + priority; // converts int to String
96 | holder.priorityView.setText(priorityString);
97 |
98 | GradientDrawable priorityCircle = (GradientDrawable) holder.priorityView.getBackground();
99 | // Get the appropriate background color based on the priority
100 | int priorityColor = getPriorityColor(priority);
101 | priorityCircle.setColor(priorityColor);
102 | }
103 |
104 | /*
105 | Helper method for selecting the correct priority circle color.
106 | P1 = red, P2 = orange, P3 = yellow
107 | */
108 | private int getPriorityColor(int priority) {
109 | int priorityColor = 0;
110 |
111 | switch (priority) {
112 | case 1:
113 | priorityColor = ContextCompat.getColor(mContext, R.color.materialRed);
114 | break;
115 | case 2:
116 | priorityColor = ContextCompat.getColor(mContext, R.color.materialOrange);
117 | break;
118 | case 3:
119 | priorityColor = ContextCompat.getColor(mContext, R.color.materialYellow);
120 | break;
121 | default:
122 | break;
123 | }
124 | return priorityColor;
125 | }
126 |
127 | /**
128 | * Returns the number of items to display.
129 | */
130 | @Override
131 | public int getItemCount() {
132 | if (mTaskEntries == null) {
133 | return 0;
134 | }
135 | return mTaskEntries.size();
136 | }
137 |
138 | public List getTasks() {
139 | return mTaskEntries;
140 | }
141 |
142 | /**
143 | * When data changes, this method updates the list of taskEntries
144 | * and notifies the adapter to use the new values on it
145 | */
146 | public void setTasks(List taskEntries) {
147 | mTaskEntries = taskEntries;
148 | notifyDataSetChanged();
149 | }
150 |
151 | public interface ItemClickListener {
152 | void onItemClickListener(int itemId);
153 | }
154 |
155 | // Inner class for creating ViewHolders
156 | class TaskViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
157 |
158 | // Class variables for the task description and priority TextViews
159 | TextView taskDescriptionView;
160 | TextView updatedAtView;
161 | TextView priorityView;
162 |
163 | /**
164 | * Constructor for the TaskViewHolders.
165 | *
166 | * @param itemView The view inflated in onCreateViewHolder
167 | */
168 | public TaskViewHolder(View itemView) {
169 | super(itemView);
170 |
171 | taskDescriptionView = itemView.findViewById(R.id.taskDescription);
172 | updatedAtView = itemView.findViewById(R.id.taskUpdatedAt);
173 | priorityView = itemView.findViewById(R.id.priorityTextView);
174 | itemView.setOnClickListener(this);
175 | }
176 |
177 | @Override
178 | public void onClick(View view) {
179 | int elementId = mTaskEntries.get(getAdapterPosition()).getId();
180 | mItemClickListener.onItemClickListener(elementId);
181 | }
182 | }
183 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/todolist/database/AppDatabase.java:
--------------------------------------------------------------------------------
1 | package com.example.android.todolist.database;
2 |
3 | import android.arch.persistence.room.Database;
4 | import android.arch.persistence.room.Room;
5 | import android.arch.persistence.room.RoomDatabase;
6 | import android.arch.persistence.room.TypeConverters;
7 | import android.content.Context;
8 | import android.util.Log;
9 |
10 | @Database(entities = {TaskEntry.class}, version = 1, exportSchema = false)
11 | @TypeConverters(DateConverter.class)
12 | public abstract class AppDatabase extends RoomDatabase {
13 |
14 | private static final String LOG_TAG = AppDatabase.class.getSimpleName();
15 | private static final Object LOCK = new Object();
16 | private static final String DATABASE_NAME = "todolist";
17 | private static AppDatabase sInstance;
18 |
19 | public static AppDatabase getInstance(Context context) {
20 | if (sInstance == null) {
21 | synchronized (LOCK) {
22 | Log.d(LOG_TAG, "Creating new database instance");
23 | sInstance = Room.databaseBuilder(context.getApplicationContext(),
24 | AppDatabase.class, AppDatabase.DATABASE_NAME)
25 | .build();
26 | }
27 | }
28 | Log.d(LOG_TAG, "Getting the database instance");
29 | return sInstance;
30 | }
31 |
32 | public abstract TaskDao taskDao();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/todolist/database/DateConverter.java:
--------------------------------------------------------------------------------
1 | package com.example.android.todolist.database;
2 |
3 | import android.arch.persistence.room.TypeConverter;
4 |
5 | import java.util.Date;
6 |
7 | public class DateConverter {
8 | @TypeConverter
9 | public static Date toDate(Long timestamp) {
10 | return timestamp == null ? null : new Date(timestamp);
11 | }
12 |
13 | @TypeConverter
14 | public static Long toTimestamp(Date date) {
15 | return date == null ? null : date.getTime();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/todolist/database/TaskDao.java:
--------------------------------------------------------------------------------
1 | package com.example.android.todolist.database;
2 |
3 | import android.arch.lifecycle.LiveData;
4 | import android.arch.persistence.room.Dao;
5 | import android.arch.persistence.room.Delete;
6 | import android.arch.persistence.room.Insert;
7 | import android.arch.persistence.room.OnConflictStrategy;
8 | import android.arch.persistence.room.Query;
9 | import android.arch.persistence.room.Update;
10 |
11 | import java.util.List;
12 |
13 | @Dao
14 | public interface TaskDao {
15 |
16 | @Query("SELECT * FROM task ORDER BY priority")
17 | LiveData> loadAllTasks();
18 |
19 | @Insert
20 | void insertTask(TaskEntry taskEntry);
21 |
22 | @Update(onConflict = OnConflictStrategy.REPLACE)
23 | void updateTask(TaskEntry taskEntry);
24 |
25 | @Delete
26 | void deleteTask(TaskEntry taskEntry);
27 |
28 | @Query("SELECT * FROM task WHERE id = :id")
29 | LiveData loadTaskById(int id);
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/todolist/database/TaskEntry.java:
--------------------------------------------------------------------------------
1 | package com.example.android.todolist.database;
2 |
3 | import android.arch.persistence.room.ColumnInfo;
4 | import android.arch.persistence.room.Entity;
5 | import android.arch.persistence.room.Ignore;
6 | import android.arch.persistence.room.PrimaryKey;
7 |
8 | import java.util.Date;
9 |
10 | @Entity(tableName = "task")
11 | public class TaskEntry {
12 |
13 | @PrimaryKey(autoGenerate = true)
14 | private int id;
15 | private String description;
16 | private int priority;
17 | @ColumnInfo(name = "updated_at")
18 | private Date updatedAt;
19 |
20 | @Ignore
21 | public TaskEntry(String description, int priority, Date updatedAt) {
22 | this.description = description;
23 | this.priority = priority;
24 | this.updatedAt = updatedAt;
25 | }
26 |
27 | public TaskEntry(int id, String description, int priority, Date updatedAt) {
28 | this.id = id;
29 | this.description = description;
30 | this.priority = priority;
31 | this.updatedAt = updatedAt;
32 | }
33 |
34 | public int getId() {
35 | return id;
36 | }
37 |
38 | public void setId(int id) {
39 | this.id = id;
40 | }
41 |
42 | public String getDescription() {
43 | return description;
44 | }
45 |
46 | public void setDescription(String description) {
47 | this.description = description;
48 | }
49 |
50 | public int getPriority() {
51 | return priority;
52 | }
53 |
54 | public void setPriority(int priority) {
55 | this.priority = priority;
56 | }
57 |
58 | public Date getUpdatedAt() {
59 | return updatedAt;
60 | }
61 |
62 | public void setUpdatedAt(Date updatedAt) {
63 | this.updatedAt = updatedAt;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/priority_circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_add_task.xml:
--------------------------------------------------------------------------------
1 |
5 |
15 |
16 |
17 |
24 |
25 |
26 |
35 |
36 |
37 |
45 |
46 |
55 |
56 |
64 |
65 |
73 |
74 |
75 |
76 |
77 |
86 |
87 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
11 |
12 |
18 |
19 |
20 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/task_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
18 |
19 |
20 |
27 |
28 |
29 |
36 |
37 |
38 |
39 |
40 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/android-architecture-components_toy_app/aaa06aea7ad8b219e6941da04cf8d244b51e2fd0/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/android-architecture-components_toy_app/aaa06aea7ad8b219e6941da04cf8d244b51e2fd0/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/android-architecture-components_toy_app/aaa06aea7ad8b219e6941da04cf8d244b51e2fd0/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/android-architecture-components_toy_app/aaa06aea7ad8b219e6941da04cf8d244b51e2fd0/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/android-architecture-components_toy_app/aaa06aea7ad8b219e6941da04cf8d244b51e2fd0/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #3F51B5
5 | #303F9F
6 | #C5CAE9
7 | #303F9F
8 |
9 |
10 | #E74C3C
11 | #E67E22
12 | #F1C40F
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | To-Do List
3 | All Tasks
4 | Add a New Task
5 |
6 |
7 | 1
8 | 2
9 | 3
10 |
11 |
12 |
13 | Describe your taskEntry…
14 | Priority
15 |
16 | High
17 | Medium
18 | Low
19 |
20 | Add
21 | Update
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | google()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.0.1'
10 |
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | String osName = System.getProperty("os.name").toLowerCase()
18 | if (osName.contains("windows")) {
19 | buildDir = "C:/tmp/${rootProject.name}/${project.name}"
20 | }
21 | repositories {
22 | jcenter()
23 | google()
24 | }
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/android-architecture-components_toy_app/aaa06aea7ad8b219e6941da04cf8d244b51e2fd0/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Dec 28 17:22:38 GMT 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn ( ) {
37 | echo "$*"
38 | }
39 |
40 | die ( ) {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save ( ) {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------