mirror of
https://github.com/wismna/DoNext.git
synced 2025-10-03 15:40:14 -04:00
Task list edition working (creation, delete...)
Add New Task dialog (not working) Tabs synchronized with DB
This commit is contained in:
@@ -9,29 +9,29 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".activities.MainActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".SettingsActivity"
|
android:name=".activities.SettingsActivity"
|
||||||
android:label="@string/settings_activity_title"
|
android:label="@string/settings_activity_title"
|
||||||
android:parentActivityName=".MainActivity">
|
android:parentActivityName=".activities.MainActivity">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value=".MainActivity" />
|
android:value=".activities.MainActivity" />
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".TaskListActivity"
|
<activity
|
||||||
|
android:name=".activities.TaskListActivity"
|
||||||
android:label="@string/task_list_activity_title"
|
android:label="@string/task_list_activity_title"
|
||||||
android:parentActivityName=".MainActivity">
|
android:parentActivityName=".activities.MainActivity">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value=".MainActivity" />
|
android:value=".activities.MainActivity" />
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
@@ -1,74 +0,0 @@
|
|||||||
package com.wismna.geoffroy.donext;
|
|
||||||
|
|
||||||
import android.app.ListActivity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ListView;
|
|
||||||
|
|
||||||
public class TaskListActivity extends ListActivity {
|
|
||||||
private TasksDataAccess dataAccess;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_task_list);
|
|
||||||
|
|
||||||
ListView listView = (ListView) findViewById(android.R.id.list);
|
|
||||||
dataAccess = new TasksDataAccess(this);
|
|
||||||
dataAccess.open();
|
|
||||||
|
|
||||||
//List<TaskList> values = dataAccess.getAllTaskLists();
|
|
||||||
|
|
||||||
// use the SimpleCursorAdapter to show the
|
|
||||||
// elements in a ListView
|
|
||||||
/*ArrayAdapter<TaskList> adapter = new ArrayAdapter<TaskList>(this,
|
|
||||||
android.R.layout.simple_list_item_1, values);
|
|
||||||
setListAdapter(adapter);*/
|
|
||||||
|
|
||||||
TaskListCursorAdapter adapter = new TaskListCursorAdapter(
|
|
||||||
this, R.layout.item_task_list, dataAccess.getAllTaskListsCursor(), 0);
|
|
||||||
listView.setAdapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Will be called when the create Task List button is clicked
|
|
||||||
public void onCreateTaskList(View view) {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
//ArrayAdapter<TaskList> adapter = (ArrayAdapter<TaskList>) getListAdapter();
|
|
||||||
TaskListCursorAdapter adapter = (TaskListCursorAdapter) getListAdapter();
|
|
||||||
TaskList taskList;
|
|
||||||
|
|
||||||
EditText editText = (EditText) findViewById(R.id.new_task_list_name);
|
|
||||||
// save the new comment to the database
|
|
||||||
taskList = dataAccess.createTaskList(editText.getText().toString());
|
|
||||||
//adapter.add(taskList);
|
|
||||||
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onDeleteTaskList(View view) {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
//ArrayAdapter<TaskList> adapter = (ArrayAdapter<TaskList>) getListAdapter();
|
|
||||||
TaskListCursorAdapter adapter = (TaskListCursorAdapter) getListAdapter();
|
|
||||||
TaskList taskList;
|
|
||||||
|
|
||||||
if (adapter.getCount() > 0) {
|
|
||||||
taskList = (TaskList) getListAdapter().getItem(0);
|
|
||||||
dataAccess.deleteTaskList(taskList);
|
|
||||||
//adapter.remove(taskList);
|
|
||||||
}
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
dataAccess.open();
|
|
||||||
super.onResume();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
dataAccess.close();
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,4 +1,4 @@
|
|||||||
package com.wismna.geoffroy.donext;
|
package com.wismna.geoffroy.donext.activities;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -16,8 +16,12 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
/*import android.support.design.widget.FloatingActionButton;
|
import com.wismna.geoffroy.donext.R;
|
||||||
import android.support.design.widget.Snackbar;*/
|
import com.wismna.geoffroy.donext.dao.TaskList;
|
||||||
|
import com.wismna.geoffroy.donext.database.TasksDataAccess;
|
||||||
|
import com.wismna.geoffroy.donext.fragments.NewTaskFragment;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@@ -36,6 +40,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
*/
|
*/
|
||||||
private ViewPager mViewPager;
|
private ViewPager mViewPager;
|
||||||
|
|
||||||
|
private TasksDataAccess dataAccess;
|
||||||
|
private List<TaskList> taskLists;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -43,10 +50,18 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
// Create the adapter that will return a fragment for each of the three
|
// Create the adapter that will return a fragment for each of the three
|
||||||
// primary sections of the activity.
|
// primary sections of the activity.
|
||||||
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||||
|
|
||||||
|
// Access database to retrieve Tabs
|
||||||
|
dataAccess = new TasksDataAccess(this);
|
||||||
|
dataAccess.open();
|
||||||
|
|
||||||
|
taskLists = dataAccess.getAllTaskLists();
|
||||||
|
mSectionsPagerAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
// Set up the ViewPager with the sections adapter.
|
// Set up the ViewPager with the sections adapter.
|
||||||
mViewPager = (ViewPager) findViewById(R.id.container);
|
mViewPager = (ViewPager) findViewById(R.id.container);
|
||||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||||
@@ -54,15 +69,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
|
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
|
||||||
tabLayout.setupWithViewPager(mViewPager);
|
tabLayout.setupWithViewPager(mViewPager);
|
||||||
|
|
||||||
/*FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
|
||||||
fab.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
|
||||||
.setAction("Action", null).show();
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/** Called when the user clicks the Settings button */
|
/** Called when the user clicks the Settings button */
|
||||||
public void openSettings(MenuItem menuItem) {
|
public void openSettings(MenuItem menuItem) {
|
||||||
@@ -75,6 +81,13 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Called when the user clicks the New Task button */
|
||||||
|
public void openNewTaskDialog(MenuItem menuItem) {
|
||||||
|
android.app.FragmentManager manager = getFragmentManager();
|
||||||
|
NewTaskFragment newTaskFragment = new NewTaskFragment();
|
||||||
|
newTaskFragment.show(manager, "Create new task");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
@@ -151,22 +164,17 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
// Show 3 total pages.
|
if (taskLists != null) {
|
||||||
return 7;
|
// Show the task lists
|
||||||
|
return taskLists.size();
|
||||||
|
}
|
||||||
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getPageTitle(int position) {
|
public CharSequence getPageTitle(int position) {
|
||||||
/*switch (position) {
|
if (taskLists == null) return "N/A";
|
||||||
case 0:
|
return taskLists.get(position).getName();
|
||||||
return "SECTION 1";
|
|
||||||
case 1:
|
|
||||||
return "SECTION 2";
|
|
||||||
case 2:
|
|
||||||
return "SECTION 3";
|
|
||||||
}
|
|
||||||
return null;*/
|
|
||||||
return "List " + position;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,10 +1,12 @@
|
|||||||
package com.wismna.geoffroy.donext;
|
package com.wismna.geoffroy.donext.activities;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.wismna.geoffroy.donext.R;
|
||||||
|
|
||||||
public class SettingsActivity extends AppCompatActivity {
|
public class SettingsActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
@@ -0,0 +1,88 @@
|
|||||||
|
package com.wismna.geoffroy.donext.activities;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
|
import com.wismna.geoffroy.donext.R;
|
||||||
|
import com.wismna.geoffroy.donext.adapters.TaskListCursorAdapter;
|
||||||
|
import com.wismna.geoffroy.donext.database.TasksDataAccess;
|
||||||
|
|
||||||
|
public class TaskListActivity extends AppCompatActivity {
|
||||||
|
private TasksDataAccess dataAccess;
|
||||||
|
private TaskListCursorAdapter adapter;
|
||||||
|
private ListView listView;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_task_list);
|
||||||
|
|
||||||
|
listView = (ListView) findViewById(android.R.id.list);
|
||||||
|
dataAccess = new TasksDataAccess(this);
|
||||||
|
dataAccess.open();
|
||||||
|
|
||||||
|
adapter = new TaskListCursorAdapter(
|
||||||
|
this, R.layout.item_task_list, dataAccess.getAllTaskListsCursor(), 0);
|
||||||
|
listView.setAdapter(adapter);
|
||||||
|
|
||||||
|
updateCreateButtonEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Will be called when the create Task List button is clicked
|
||||||
|
public void onCreateTaskList(View view) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
EditText editText = (EditText) findViewById(R.id.new_task_list_name);
|
||||||
|
|
||||||
|
Cursor cursor = dataAccess.createTaskList(editText.getText().toString());
|
||||||
|
adapter.changeCursor(cursor);
|
||||||
|
editText.setText("");
|
||||||
|
updateCreateButtonEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDeleteTaskList(View view) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final int position = listView.getPositionForView((View) view.getParent());
|
||||||
|
Cursor cursor = dataAccess.deleteTaskList((Cursor) adapter.getItem(position));
|
||||||
|
adapter.changeCursor(cursor);
|
||||||
|
updateCreateButtonEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
dataAccess.open();
|
||||||
|
super.onResume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
dataAccess.close();
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCreateButtonEnabled() {
|
||||||
|
//Button createButton = (Button) findViewById(R.id.new_task_list_button);
|
||||||
|
//EditText editText = (EditText) findViewById(R.id.new_task_list_name);
|
||||||
|
RelativeLayout layout = (RelativeLayout) findViewById(R.id.new_task_list_layout);
|
||||||
|
int taskListCount = adapter.getCount();
|
||||||
|
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
String maxTaskListsString = sharedPref.getString("pref_conf_max_lists", "3");
|
||||||
|
int maxTaskLists = Integer.valueOf(maxTaskListsString);
|
||||||
|
//createButton.setEnabled(taskListCount < maxTaskLists);
|
||||||
|
//editText.setEnabled(taskListCount < maxTaskLists);
|
||||||
|
if (taskListCount >= maxTaskLists) layout.setVisibility(View.GONE);
|
||||||
|
else layout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
dataAccess.close();
|
||||||
|
}
|
||||||
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
package com.wismna.geoffroy.donext;
|
package com.wismna.geoffroy.donext.adapters;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
@@ -8,6 +8,9 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.ResourceCursorAdapter;
|
import android.widget.ResourceCursorAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.wismna.geoffroy.donext.R;
|
||||||
|
import com.wismna.geoffroy.donext.database.DatabaseHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geoffroy on 15-11-25.
|
* Created by geoffroy on 15-11-25.
|
||||||
*/
|
*/
|
||||||
@@ -38,4 +41,9 @@ public class TaskListCursorAdapter extends ResourceCursorAdapter {
|
|||||||
taskListCount.setText(String.valueOf(count));
|
taskListCount.setText(String.valueOf(count));
|
||||||
taskListName.setText(name);
|
taskListName.setText(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
return super.getView(position, convertView, parent);
|
||||||
|
}
|
||||||
}
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
package com.wismna.geoffroy.donext;
|
package com.wismna.geoffroy.donext.dao;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geoffroy on 15-11-25.
|
* Created by geoffroy on 15-11-25.
|
@@ -1,4 +1,4 @@
|
|||||||
package com.wismna.geoffroy.donext;
|
package com.wismna.geoffroy.donext.dao;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geoffroy on 15-11-25.
|
* Created by geoffroy on 15-11-25.
|
||||||
@@ -26,6 +26,6 @@ public class TaskList {
|
|||||||
// Will be used by the ArrayAdapter in the ListView
|
// Will be used by the ArrayAdapter in the ListView
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return String.valueOf(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
package com.wismna.geoffroy.donext;
|
package com.wismna.geoffroy.donext.database;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
@@ -1,4 +1,4 @@
|
|||||||
package com.wismna.geoffroy.donext;
|
package com.wismna.geoffroy.donext.database;
|
||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -6,6 +6,8 @@ import android.database.Cursor;
|
|||||||
import android.database.SQLException;
|
import android.database.SQLException;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
|
import com.wismna.geoffroy.donext.dao.TaskList;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -30,7 +32,7 @@ public class TasksDataAccess {
|
|||||||
dbHelper.close();
|
dbHelper.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TaskList createTaskList(String name) {
|
/*public TaskList createTaskList(String name) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(DatabaseHelper.TASKLIST_COLUMN_NAME, name);
|
values.put(DatabaseHelper.TASKLIST_COLUMN_NAME, name);
|
||||||
long insertId = database.insert(DatabaseHelper.TASKLIST_TABLE_NAME, null,
|
long insertId = database.insert(DatabaseHelper.TASKLIST_TABLE_NAME, null,
|
||||||
@@ -42,17 +44,33 @@ public class TasksDataAccess {
|
|||||||
TaskList newTaskList = cursorToTaskList(cursor);
|
TaskList newTaskList = cursorToTaskList(cursor);
|
||||||
cursor.close();
|
cursor.close();
|
||||||
return newTaskList;
|
return newTaskList;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public Cursor createTaskList(String name) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(DatabaseHelper.TASKLIST_COLUMN_NAME, name);
|
||||||
|
database.insert(DatabaseHelper.TASKLIST_TABLE_NAME, null, values);
|
||||||
|
return getAllTaskListsCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteTaskList(TaskList comment) {
|
/*public void deleteTaskList(TaskList comment) {
|
||||||
long id = comment.getId();
|
long id = comment.getId();
|
||||||
System.out.println("Comment deleted with id: " + id);
|
System.out.println("Comment deleted with id: " + id);
|
||||||
database.delete(DatabaseHelper.TASKLIST_TABLE_NAME, DatabaseHelper.COLUMN_ID
|
database.delete(DatabaseHelper.TASKLIST_TABLE_NAME, DatabaseHelper.COLUMN_ID
|
||||||
+ " = " + id, null);
|
+ " = " + id, null);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public Cursor deleteTaskList(Cursor taskListCursor) {
|
||||||
|
TaskList taskList = cursorToTaskList(taskListCursor);
|
||||||
|
long id = taskList.getId();
|
||||||
|
System.out.println("Comment deleted with id: " + id);
|
||||||
|
database.delete(DatabaseHelper.TASKLIST_TABLE_NAME, DatabaseHelper.COLUMN_ID
|
||||||
|
+ " = " + id, null);
|
||||||
|
return getAllTaskListsCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TaskList> getAllTaskLists() {
|
public List<TaskList> getAllTaskLists() {
|
||||||
List<TaskList> taskLists = new ArrayList<TaskList>();
|
List<TaskList> taskLists = new ArrayList<>();
|
||||||
|
|
||||||
Cursor cursor = getAllTaskListsCursor();
|
Cursor cursor = getAllTaskListsCursor();
|
||||||
|
|
@@ -0,0 +1,66 @@
|
|||||||
|
package com.wismna.geoffroy.donext.fragments;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.app.DialogFragment;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import com.wismna.geoffroy.donext.R;
|
||||||
|
import com.wismna.geoffroy.donext.dao.TaskList;
|
||||||
|
import com.wismna.geoffroy.donext.database.TasksDataAccess;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by geoffroy on 15-11-26.
|
||||||
|
*/
|
||||||
|
public class NewTaskFragment extends DialogFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
// Get the layout inflater
|
||||||
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
|
|
||||||
|
// Inflate and set the layout for the dialog
|
||||||
|
// Pass null as the parent view because its going in the dialog layout
|
||||||
|
builder.setView(inflater.inflate(R.layout.new_task, null))
|
||||||
|
// Add action buttons
|
||||||
|
.setPositiveButton(R.string.new_task_save, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
// TODO: create the task in DB
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.new_task_cancel, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
NewTaskFragment.this.getDialog().cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
|
// Access database to retrieve task lists
|
||||||
|
TasksDataAccess dataAccess = new TasksDataAccess(getActivity());
|
||||||
|
dataAccess.open();
|
||||||
|
|
||||||
|
// Populate spinner with task lists
|
||||||
|
Spinner spinner = (Spinner) view.findViewById(R.id.new_task_list);
|
||||||
|
// Create an ArrayAdapter using the string array and a default spinner layout
|
||||||
|
List<TaskList> taskLists = dataAccess.getAllTaskLists();
|
||||||
|
ArrayAdapter<TaskList> adapter = new ArrayAdapter<>(
|
||||||
|
getActivity(), android.R.layout.simple_spinner_item, taskLists);
|
||||||
|
// Specify the layout to use when the list of choices appears
|
||||||
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
spinner.setAdapter(adapter);
|
||||||
|
}
|
||||||
|
}
|
@@ -6,7 +6,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
tools:context="com.wismna.geoffroy.donext.MainActivity">
|
tools:context=".activities.MainActivity">
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout
|
<android.support.design.widget.AppBarLayout
|
||||||
android:id="@+id/appbar"
|
android:id="@+id/appbar"
|
||||||
@@ -21,9 +21,7 @@
|
|||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:background="?attr/colorPrimary"
|
android:background="?attr/colorPrimary"
|
||||||
app:layout_scrollFlags="scroll|enterAlways"
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay">
|
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||||
|
|
||||||
</android.support.v7.widget.Toolbar>
|
|
||||||
|
|
||||||
<android.support.design.widget.TabLayout
|
<android.support.design.widget.TabLayout
|
||||||
android:id="@+id/tabs"
|
android:id="@+id/tabs"
|
||||||
|
@@ -8,8 +8,9 @@
|
|||||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
android:paddingTop="@dimen/activity_vertical_margin"
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context="com.wismna.geoffroy.donext.TaskListActivity">
|
tools:context=".activities.TaskListActivity">
|
||||||
<LinearLayout
|
<RelativeLayout
|
||||||
|
android:id="@+id/new_task_list_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<EditText
|
<EditText
|
||||||
@@ -18,11 +19,13 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="@string/task_list_new_list_hint"/>
|
android:hint="@string/task_list_new_list_hint"/>
|
||||||
<Button
|
<Button
|
||||||
|
android:id="@+id/new_task_list_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
android:onClick="onCreateTaskList"
|
android:onClick="onCreateTaskList"
|
||||||
android:text="@string/task_list_new_list_create"/>
|
android:text="@string/task_list_new_list_create"/>
|
||||||
</LinearLayout>
|
</RelativeLayout>
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@android:id/list"
|
android:id="@android:id/list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@@ -6,11 +6,16 @@
|
|||||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
android:paddingTop="@dimen/activity_vertical_margin"
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
tools:context="com.wismna.geoffroy.donext.MainActivity$PlaceholderFragment">
|
tools:context=".activities.MainActivity$PlaceholderFragment">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/section_label"
|
android:id="@+id/section_label"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@android:id/list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
</ListView>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@@ -1,12 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||||
|
android:padding="6dip">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/task_list_count"
|
android:id="@+id/task_list_count"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
android:text="test"
|
android:text="test"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
||||||
<TextView
|
<TextView
|
||||||
@@ -14,11 +15,15 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_toRightOf="@id/task_list_count"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
android:text="Name"
|
android:text="Name"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
android:text="@string/task_list_delete"
|
android:text="@string/task_list_delete"
|
||||||
android:onClick="onDeleteTaskList" />
|
android:onClick="onDeleteTaskList" />
|
||||||
</LinearLayout>
|
</RelativeLayout>
|
65
DoNExt/app/src/main/res/layout/new_task.xml
Normal file
65
DoNExt/app/src/main/res/layout/new_task.xml
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".activities.MainActivity">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/new_task_list"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/new_task_list"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
</Spinner>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/new_task_name"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/new_task_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/new_task_description"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/new_task_description"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:lines="3"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/new_task_priority"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
<RadioGroup
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/new_task_priority_low"
|
||||||
|
android:text="@string/new_task_priority_low"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
</RadioButton>
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/new_task_priority_normal"
|
||||||
|
android:text="@string/new_task_priority_normal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:checked="true">
|
||||||
|
</RadioButton>
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/new_task_priority_high"
|
||||||
|
android:text="@string/new_task_priority_high"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
</RadioButton>
|
||||||
|
</RadioGroup>
|
||||||
|
</LinearLayout>
|
@@ -1,22 +1,28 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context="com.wismna.geoffroy.donext.MainActivity">
|
tools:context=".activities.MainActivity">
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_settings"
|
android:id="@+id/action_newTask"
|
||||||
android:orderInCategory="100"
|
android:orderInCategory="10"
|
||||||
android:title="@string/action_settings"
|
android:title="@string/action_new_task"
|
||||||
android:onClick="openSettings"
|
android:onClick="openNewTaskDialog"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_editTabs"
|
android:id="@+id/action_editTabs"
|
||||||
android:orderInCategory="60"
|
android:orderInCategory="20"
|
||||||
android:title="@string/action_editTabs"
|
android:title="@string/action_editTabs"
|
||||||
android:onClick="openTaskLists"
|
android:onClick="openTaskLists"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_settings"
|
||||||
|
android:orderInCategory="30"
|
||||||
|
android:title="@string/action_settings"
|
||||||
|
android:onClick="openSettings"
|
||||||
|
app:showAsAction="never" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_about"
|
android:id="@+id/action_about"
|
||||||
android:orderInCategory="50"
|
android:orderInCategory="40"
|
||||||
android:title="@string/action_about"
|
android:title="@string/action_about"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
<string name="action_newTab">New list</string>
|
<string name="action_newTab">New list</string>
|
||||||
<string name="action_editTabs">Edit lists</string>
|
<string name="action_editTabs">Edit lists</string>
|
||||||
<string name="action_about">About</string>
|
<string name="action_about">About</string>
|
||||||
|
<string name="action_new_task">New task</string>
|
||||||
<string name="section_format">Hello World from section: %1$d</string>
|
<string name="section_format">Hello World from section: %1$d</string>
|
||||||
<string name="settings_activity_title">Settings</string>
|
<string name="settings_activity_title">Settings</string>
|
||||||
<string name="task_list_activity_title">List edition</string>
|
<string name="task_list_activity_title">List edition</string>
|
||||||
@@ -14,6 +15,18 @@
|
|||||||
<string name="task_list_new_list_create">Create</string>
|
<string name="task_list_new_list_create">Create</string>
|
||||||
<string name="task_list_delete">Delete</string>
|
<string name="task_list_delete">Delete</string>
|
||||||
|
|
||||||
|
<!-- Strings related to new task dialog -->
|
||||||
|
<string name="new_task_list">List</string>
|
||||||
|
<string name="new_task_name">Name</string>
|
||||||
|
<string name="new_task_description">Description</string>
|
||||||
|
<string name="new_task_priority">Priority</string>
|
||||||
|
<string name="new_task_priority_low">Low</string>
|
||||||
|
<string name="new_task_priority_normal">Normal</string>
|
||||||
|
<string name="new_task_priority_high">High</string>
|
||||||
|
<string name="new_task_save">Save</string>
|
||||||
|
<string name="new_task_cancel">Cancel</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Strings related to Settings -->
|
<!-- Strings related to Settings -->
|
||||||
<string name="settings_confirm_donext">Confirm on DoNext?</string>
|
<string name="settings_confirm_donext">Confirm on DoNext?</string>
|
||||||
<string name="settings_confirm_markdone">Confirm on mark Done?</string>
|
<string name="settings_confirm_markdone">Confirm on mark Done?</string>
|
||||||
|
Reference in New Issue
Block a user