Changed large layout screen partition from weight to percentageRelativeLayout to accomodate different behaviours in sdk version < 21

Due Date is now optional and has a check box
This commit is contained in:
bg45
2017-04-03 17:18:32 -04:00
parent f94089ed88
commit 954055cbe9
10 changed files with 58 additions and 31 deletions

View File

@@ -8,8 +8,8 @@ android {
applicationId "com.wismna.geoffroy.donext"
minSdkVersion 19
targetSdkVersion 25
versionCode 18
versionName "1.4.3"
versionCode 19
versionName "1.4.4"
}
buildTypes {
release {
@@ -21,11 +21,11 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'com.android.support:support-v4:25.3.0'
compile 'com.android.support:percent:25.3.0'
compile 'com.android.support:recyclerview-v7:25.3.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:percent:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.google.android.gms:play-services-ads:10.2.1'
compile 'net.danlew:android.joda:2.9.7'
testCompile 'junit:junit:4.12'

View File

@@ -51,7 +51,8 @@ public class TaskRecyclerViewAdapter extends RecyclerView.Adapter<TaskRecyclerVi
public void onBindViewHolder(final SimpleViewHolder holder, int position) {
holder.mItem = mValues.get(position);
holder.mIdView.setText(String.valueOf(holder.mItem.getId()));
if(holder.mItem.getDueDate().isBefore(LocalDate.now()))
LocalDate dueDate = holder.mItem.getDueDate();
if(dueDate != null && dueDate.isBefore(LocalDate.now()))
holder.mAlarmView.setImageResource(R.drawable.ic_access_alarm);
holder.mCycleView.setText(String.valueOf(holder.mItem.getCycle()));
holder.mTitleView.setText(holder.mItem.getName());

View File

@@ -96,7 +96,7 @@ public class Task {
this.dueDate = LocalDate.parse(dueDate);
}
catch (Exception e){
this.dueDate = LocalDate.now();
this.dueDate = null;
}
}

View File

@@ -51,13 +51,13 @@ public class TaskDataAccess implements AutoCloseable {
/** Adds or update a task in the database */
public Task createOrUpdateTask(long id, String name, String description, int priority,
long taskList, LocalDate date, boolean isTodayList) {
long taskList, String dueDate, boolean isTodayList) {
ContentValues values = new ContentValues();
values.put(DatabaseHelper.TASKS_COLUMN_NAME, name);
values.put(DatabaseHelper.TASKS_COLUMN_DESC, description);
values.put(DatabaseHelper.TASKS_COLUMN_PRIORITY, priority);
values.put(DatabaseHelper.TASKS_COLUMN_LIST, taskList);
values.put(DatabaseHelper.TASKS_COLUMN_DUEDATE, date.toString());
values.put(DatabaseHelper.TASKS_COLUMN_DUEDATE, dueDate);
values.put(DatabaseHelper.TASKS_COLUMN_TODAYDATE, isTodayList? LocalDate.now().toString() : "");
long insertId;
if (id == 0)

View File

@@ -6,6 +6,7 @@ import android.support.v4.app.DialogFragment;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.SeekBar;
@@ -95,8 +96,6 @@ public class TaskFormDialogFragment extends DynamicDialogFragment {
}
private void setTaskValues(View view) {
// Get date picker
final DatePicker dueDatePicker = (DatePicker) view.findViewById(R.id.new_task_due_date);
// Populate spinner with task lists
Spinner spinner = (Spinner) view.findViewById(R.id.new_task_list);
@@ -118,6 +117,17 @@ public class TaskFormDialogFragment extends DynamicDialogFragment {
checkBox.setVisibility(isTodayActive ? View.VISIBLE : View.GONE);
todayLabel.setVisibility(isTodayActive ? View.VISIBLE : View.GONE);
// Get date picker
final DatePicker dueDatePicker = (DatePicker) view.findViewById(R.id.new_task_due_date);
// Handle due date spinner depending on check box
CheckBox setDueDate = (CheckBox) view.findViewById(R.id.new_task_due_date_set);
setDueDate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
dueDatePicker.setVisibility(isChecked ? View.VISIBLE : View.GONE);
}
});
// Set other properties if they exist
if (task != null) {
@@ -130,7 +140,10 @@ public class TaskFormDialogFragment extends DynamicDialogFragment {
// Set Due Date
LocalDate dueDate = task.getDueDate();
if (dueDate != null) {
setDueDate.setChecked(true);
dueDatePicker.updateDate(dueDate.getYear(), dueDate.getMonthOfYear() - 1, dueDate.getDayOfMonth());
}
checkBox.setChecked(task.isToday());
}

View File

@@ -274,6 +274,7 @@ public class TasksFragment extends Fragment implements
EditText nameText = (EditText) dialogView.findViewById(R.id.new_task_name);
EditText descText = (EditText) dialogView.findViewById(R.id.new_task_description);
SeekBar seekBar = (SeekBar) dialogView.findViewById(R.id.new_task_priority);
CheckBox setDueDate = (CheckBox) dialogView.findViewById(R.id.new_task_due_date_set);
DatePicker dueDatePicker = (DatePicker) dialogView.findViewById(R.id.new_task_due_date);
TaskList taskList = (TaskList) listSpinner.getSelectedItem();
CheckBox todayList = (CheckBox) dialogView.findViewById(R.id.new_task_today);
@@ -285,7 +286,11 @@ public class TasksFragment extends Fragment implements
descText.getText().toString(),
seekBar.getProgress(),
taskList.getId(),
new LocalDate(dueDatePicker.getYear(), dueDatePicker.getMonth() + 1, dueDatePicker.getDayOfMonth()),
setDueDate.isChecked() ?
new LocalDate(dueDatePicker.getYear(),
dueDatePicker.getMonth() + 1,
dueDatePicker.getDayOfMonth()).toString()
: "",
isToday);
Bundle args = dialog.getArguments();

View File

@@ -25,24 +25,22 @@
android:onClick="onNewTaskClick"
android:src="@drawable/ic_add" />
<LinearLayout
android:layout_width="wrap_content"
<android.support.percent.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="horizontal">
android:layout_marginTop="?attr/actionBarSize">
<android.widget.ListView
android:id="@+id/list"
android:layout_width="0dp"
app:layout_widthPercent="20%"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:choiceMode="singleChoice"
android:listSelector="@drawable/tasklist_select"/>
<com.wismna.geoffroy.donext.widgets.NonSwipeableViewPager
android:id="@+id/container"
android:layout_width="0dp"
app:layout_widthPercent="80%"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:layout_toEndOf="@id/list"
android:background="@android:color/background_light"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
</android.support.percent.PercentRelativeLayout>
</android.support.design.widget.CoordinatorLayout>

View File

@@ -7,6 +7,7 @@
android:layout_marginTop="?attr/actionBarSize"
android:background="@android:color/background_light">
<RelativeLayout
android:id="@+id/new_task_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/text_margin"
@@ -62,6 +63,13 @@
android:layout_height="30dp"
android:layout_toEndOf="@id/new_task_priority_label"
android:layout_below="@id/new_task_description" />
<CheckBox
android:id="@+id/new_task_today"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
android:layout_below="@id/new_task_priority"
android:layout_alignParentEnd="true" />
<TextView
android:id="@+id/new_task_today_label"
android:text="@string/new_task_today"
@@ -69,26 +77,28 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:visibility="visible"
android:layout_below="@id/new_task_priority" />
<CheckBox
android:id="@+id/new_task_today"
android:id="@+id/new_task_due_date_set"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/new_task_today_label"
android:layout_below="@id/new_task_priority" />
android:layout_below="@id/new_task_today"
android:layout_alignParentEnd="true" />
<TextView
android:id="@+id/new_task_due_date_label"
android:text="@string/new_task_due_date"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="200dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginTop="8dp"
android:layout_below="@id/new_task_today" />
<DatePicker
android:id="@+id/new_task_due_date"
android:datePickerMode="spinner"
android:calendarViewShown="false"
android:spinnersShown="true"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/new_task_due_date_label" />

View File

@@ -49,7 +49,7 @@
<string name="settings_today_title">Vue Aujourd\'hui</string>
<string name="settings_today_enable">Activer la vue Aujourd\'hui?</string>
<string name="settings_today_desc">La vue Aujourd\'hui est une façon particulière d\'organiser vos tâches. Choisissez quelles tâches vous voulez faire dans la journée et elles apparaîtront dans cette vue. À la fin de la journée, cette vue est réinitialisée.</string>
<string name="new_task_due_date">Date de fin</string>
<string name="new_task_due_date">Mettre une date de fin?</string>
<string name="task_alarm">Task is past due date</string>
<string name="action_todayList">Vue Aujourd\'hui</string>
<string name="title_activity_today">Aujourd\'hui</string>

View File

@@ -26,7 +26,7 @@
<string name="new_task_name_error">Task name cannot be blank</string>
<string name="new_task_description_hint">Optional task description</string>
<string name="new_task_priority">Priority</string>
<string name="new_task_due_date">Due date</string>
<string name="new_task_due_date">Set a due date?</string>
<string name="new_task_save">Save</string>
<string name="new_task_cancel">Cancel</string>
<string name="new_task_delete">Delete</string>