diff options
Diffstat (limited to 'app/src')
8 files changed, 193 insertions, 58 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java index 5d8ba1608..8c8a9d334 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java @@ -201,8 +201,12 @@ public class SyncManager { } public void updateCard(Card card) { + Date now = new Date(); + //TODO: Tell the server doAsync(()->{ + card.setLastModifiedLocal(now); + card.setLastModified(now); dataBaseAdapter.updateCard(card); }); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java index 2ef8436e0..038385d51 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java @@ -268,46 +268,36 @@ public class DataBaseAdapter { public LiveData<FullStack> getStack(long accountId, long localStackId) { return db.getStackDao().getFullStack(accountId, localStackId); } - public long createStack(long accountId, Stack stack) { stack.setAccountId(accountId); return db.getStackDao().insert(stack); - } - public void deleteStack(Stack stack) { db.getStackDao().delete(stack); } - public void updateStack(Stack stack) { db.getStackDao().update(stack); - } - public LiveData<FullCard> getCardByLocalId(long accountId, long localCardId) { - return db.getCardDao().getFullCardByLocalId(accountId, localCardId); + LiveData<FullCard> fullCardsForStack = db.getCardDao().getFullCardByLocalId(accountId, localCardId); + readRelationsForCard(fullCardsForStack.getValue()); + return fullCardsForStack; } - public long createCard(long accountId, Card card) { card.setAccountId(accountId); return db.getCardDao().insert(card); - } - public void deleteCard(Card card) { db.getCardDao().delete(card); } - public void updateCard(Card card) { db.getCardDao().update(card); } - - } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardDetailsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardDetailsFragment.java index eb3968138..557b87207 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardDetailsFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardDetailsFragment.java @@ -1,5 +1,9 @@ package it.niedermann.nextcloud.deck.ui.card; +import android.app.DatePickerDialog; +import android.app.TimePickerDialog; +import android.content.Context; +import android.content.DialogInterface; import android.content.res.ColorStateList; import android.graphics.Color; import android.os.Bundle; @@ -11,7 +15,19 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.DatePicker; import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.TimePicker; + +import java.text.DateFormat; +import java.text.FieldPosition; +import java.text.ParsePosition; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; import butterknife.BindView; import butterknife.ButterKnife; @@ -26,16 +42,24 @@ import it.niedermann.nextcloud.deck.persistence.sync.SyncManager; import static it.niedermann.nextcloud.deck.ui.card.CardAdapter.BUNDLE_KEY_ACCOUNT_ID; import static it.niedermann.nextcloud.deck.ui.card.CardAdapter.BUNDLE_KEY_LOCAL_ID; -public class CardDetailsFragment extends Fragment { +public class CardDetailsFragment extends Fragment implements DatePickerDialog.OnDateSetListener, + TimePickerDialog.OnTimeSetListener { private static final String TAG = CardDetailsFragment.class.getCanonicalName(); - FullCard card; - SyncManager syncManager; - + private FullCard card; + private SyncManager syncManager; + private DateFormat dateFormat; + private DateFormat dueTime = new SimpleDateFormat("HH:mm", Locale.ROOT); private Unbinder unbinder; - @BindView(R.id.dueDate) - EditText dueDate; + @BindView(R.id.dueDateDate) + TextView dueDate; + + @BindView(R.id.dueDateTime) + TextView dueDateTime; + + @BindView(R.id.clearDueDate) + ImageView clearDueDate; @BindView(R.id.labelsGroup) ChipGroup labelsGroup; @@ -61,6 +85,8 @@ public class CardDetailsFragment extends Fragment { View view = inflater.inflate(R.layout.fragment_card_edit_tab_details, container, false); unbinder = ButterKnife.bind(this, view); + dateFormat = android.text.format.DateFormat.getDateFormat(getActivity()); + //dueTime = android.text.format.DateFormat.getTimeFormat(getActivity()); Bundle args = getArguments(); if (args != null) { @@ -81,39 +107,84 @@ public class CardDetailsFragment extends Fragment { // TODO read/set available card details data this.card = card; if (this.card != null) { + // due date if (this.card.getCard().getDueDate() != null) { - dueDate.setText( - SupportUtil.getRelativeDateTimeString( - getActivity(), - this.card.getCard().getDueDate().getTime()) - ); + dueDate.setText(dateFormat.format(this.card.getCard().getDueDate())); + dueDateTime.setText(dueTime.format(this.card.getCard().getDueDate())); + } else { + dueDate.setText(null); + dueDateTime.setText(null); } - } - labelsGroup.removeAllViews(); - if (this.card.getLabels() != null && this.card.getLabels().size() > 0) { - Chip chip; - for (Label label : this.card.getLabels()) { - chip = new Chip(getActivity()); - chip.setText(label.getTitle()); - chip.setCloseIconResource(R.drawable.ic_close_circle_grey600); - - try { - int labelColor = Color.parseColor("#" + label.getColor()); - ColorStateList c = ColorStateList.valueOf(labelColor); - chip.setChipBackgroundColor(c); - chip.setTextColor(ColorUtil.getForegroundColorForBackgroundColor(labelColor)); - } catch (IllegalArgumentException e) { - Log.e(TAG, "error parsing label color", e); + // labels + labelsGroup.removeAllViews(); + if (this.card.getLabels() != null && this.card.getLabels().size() > 0) { + Chip chip; + for (Label label : this.card.getLabels()) { + chip = new Chip(getActivity()); + chip.setText(label.getTitle()); + chip.setCloseIconResource(R.drawable.ic_close_circle_grey600); + + try { + int labelColor = Color.parseColor("#" + label.getColor()); + ColorStateList c = ColorStateList.valueOf(labelColor); + chip.setChipBackgroundColor(c); + chip.setTextColor(ColorUtil.getForegroundColorForBackgroundColor(labelColor)); + } catch (IllegalArgumentException e) { + Log.e(TAG, "error parsing label color", e); + } + + labelsGroup.addView(chip); } + labelsGroup.setVisibility(View.VISIBLE); + } else { + labelsGroup.setVisibility(View.GONE); + } - labelsGroup.addView(chip); + // description + if (this.card.getCard().getDescription() != null) { + description.setText(this.card.getCard().getDescription()); } - labelsGroup.setVisibility(View.VISIBLE); - } else { - labelsGroup.setVisibility(View.GONE); } }); + + dueDate.setOnClickListener(v -> { + int year; + int month; + int day; + + Calendar cal = Calendar.getInstance(); + if (card.getCard().getDueDate() != null) { + cal.setTime(card.getCard().getDueDate()); + year = cal.get(Calendar.YEAR); + month = cal.get(Calendar.MONTH); + day = cal.get(Calendar.DAY_OF_MONTH); + } else { + year = cal.get(Calendar.YEAR); + month = cal.get(Calendar.MONTH); + day = cal.get(Calendar.DAY_OF_MONTH); + } + DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), this, year, month, day); + datePickerDialog.show(); + }); + + dueDateTime.setOnClickListener(v -> { + int hourOfDay = 0; + int minutes = 0; + + if (card.getCard().getDueDate() != null) { + hourOfDay = card.getCard().getDueDate().getHours(); + minutes = card.getCard().getDueDate().getMinutes(); + } + TimePickerDialog timePickerDialog = new TimePickerDialog( + getActivity(), this, hourOfDay, minutes, true); + timePickerDialog.show(); + }); + + clearDueDate.setOnClickListener(v -> { + this.card.getCard().setDueDate(null); + syncManager.updateCard(this.card.getCard()); + }); } @Override @@ -121,4 +192,33 @@ public class CardDetailsFragment extends Fragment { super.onDestroy(); unbinder.unbind(); } + + @Override + public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) { + + Calendar c = Calendar.getInstance(); + int hourOfDay; + int minute; + + if (dueDateTime.getText() != null && dueDateTime.length()>0) { + hourOfDay = this.card.getCard().getDueDate().getHours(); + minute = this.card.getCard().getDueDate().getMinutes(); + } else { + hourOfDay = 0; + minute = 0; + } + + c.set(year, month, dayOfMonth, hourOfDay, minute); + this.card.getCard().setDueDate(c.getTime()); + dueDate.setText(dateFormat.format(c.getTime())); + syncManager.updateCard(this.card.getCard()); + } + + @Override + public void onTimeSet(TimePicker view, int hourOfDay, int minute) { + this.card.getCard().getDueDate().setHours(hourOfDay); + this.card.getCard().getDueDate().setMinutes(minute); + dueDateTime.setText(dueTime.format(this.card.getCard().getDueDate().getTime())); + syncManager.updateCard(this.card.getCard()); + } } diff --git a/app/src/main/res/drawable/ic_activity_light_grey.xml b/app/src/main/res/drawable/ic_activity_light_grey.xml new file mode 100644 index 000000000..c40d9d080 --- /dev/null +++ b/app/src/main/res/drawable/ic_activity_light_grey.xml @@ -0,0 +1,6 @@ +<vector android:alpha="0.5" android:height="72dp" + android:viewportHeight="32" android:viewportWidth="32" + android:width="72dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#FF969696" + android:pathData="M16,1.9492 L6,18.8102H17L16,30.0508 26,13.1898H15Z"/> +</vector> diff --git a/app/src/main/res/layout/activity_edit.xml b/app/src/main/res/layout/activity_edit.xml index 37948821e..0a1afb66a 100644 --- a/app/src/main/res/layout/activity_edit.xml +++ b/app/src/main/res/layout/activity_edit.xml @@ -4,8 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" - android:padding="16dp"> + android:orientation="vertical"> <EditText android:id="@+id/title" @@ -13,6 +12,8 @@ android:layout_height="wrap_content" android:hint="@string/label_title" android:importantForAutofill="no" + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" android:inputType="textPersonName" /> <TextView @@ -20,8 +21,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" - android:layout_marginLeft="3dp" - android:layout_marginRight="3dp" + android:layout_marginLeft="19dp" + android:layout_marginRight="19dp" tools:text="Modified: 12 days ago Created: 12 days ago"/> <android.support.design.widget.TabLayout diff --git a/app/src/main/res/layout/fragment_card_edit_tab_activity.xml b/app/src/main/res/layout/fragment_card_edit_tab_activity.xml index 7db769592..c0974eaa9 100644 --- a/app/src/main/res/layout/fragment_card_edit_tab_activity.xml +++ b/app/src/main/res/layout/fragment_card_edit_tab_activity.xml @@ -9,7 +9,7 @@ <ImageView android:id="@+id/empty_list_icon" - app:srcCompat="@drawable/ic_folder_grey600_24dp" + app:srcCompat="@drawable/ic_activity_light_grey" android:layout_width="72dp" android:layout_height="72dp" android:contentDescription="@null" /> @@ -24,7 +24,7 @@ android:maxLines="2" android:paddingTop="16dp" android:paddingBottom="16dp" - android:text="Activity" + android:text="@string/activity" android:textSize="26sp" /> <TextView diff --git a/app/src/main/res/layout/fragment_card_edit_tab_details.xml b/app/src/main/res/layout/fragment_card_edit_tab_details.xml index 703fe352e..10bb11adf 100644 --- a/app/src/main/res/layout/fragment_card_edit_tab_details.xml +++ b/app/src/main/res/layout/fragment_card_edit_tab_details.xml @@ -1,9 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginTop="16dp" + android:padding="16dp" android:orientation="vertical"> <LinearLayout @@ -69,12 +70,42 @@ app:srcCompat="@drawable/calendar_blank_grey600_24dp" /> <EditText - android:id="@+id/dueDate" - android:layout_width="match_parent" + android:id="@+id/dueDateDate" + android:layout_width="116dp" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:drawablePadding="4dp" + android:enabled="true" + android:focusable="false" + android:hint="@string/hint_due_date_date" + android:maxLines="1" + android:padding="4dp" + android:textAlignment="center" + tools:text="01/07/2020" /> + + <EditText + android:id="@+id/dueDateTime" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:ems="10" - android:importantForAutofill="no" - android:inputType="datetime" /> + android:layout_marginTop="8dp" + android:drawablePadding="4dp" + android:enabled="true" + android:focusable="false" + android:hint="@string/hint_due_date_time" + android:maxLines="1" + android:minLines="0" + android:padding="4dp" + android:textAlignment="center" + tools:text="11:45" /> + + <ImageView + android:id="@+id/clearDueDate" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:paddingLeft="4dp" + android:paddingTop="6dp" + android:paddingRight="4dp" + app:srcCompat="@drawable/ic_close_circle_grey600" /> </LinearLayout> <LinearLayout @@ -102,4 +133,4 @@ android:scrollbars="vertical" /> </LinearLayout> -</LinearLayout>
\ No newline at end of file +</LinearLayout> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8a20d4ce6..0dd8038c4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -53,6 +53,9 @@ <string name="label_labels">Labels</string> <string name="label_description">Description</string> <string name="simple_people">People</string> - + <string name="hint_due_date_date">Click to set</string> + <string name="hint_due_date_time" translatable="false">00:00</string> <string name="modified_created_time">Modified: %1$s Created: %2$s</string> + + <string name="activity">Activity</string> </resources> |