From 4b5864e9ab26ab5ed7bf59f631f1221ceb025a43 Mon Sep 17 00:00:00 2001 From: physphil Date: Sun, 17 Jun 2018 14:59:12 -0400 Subject: [PATCH 1/7] Version bump --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3bf0d93..687d4ba 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.physphil.android.remindme" minSdkVersion 21 targetSdkVersion 27 - versionCode 9000 - versionName "0.9" + versionCode 9020 + versionName "0.9.2" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { From 7058163d2af9f688ad489d32597eb50fd3cae82f Mon Sep 17 00:00:00 2001 From: Phil Shadlyn Date: Sun, 19 Aug 2018 11:51:20 -0400 Subject: [PATCH 2/7] WIP - create view for ReminderEntryField --- .../remindme/reminders/ReminderActivity.kt | 33 ++++----- .../reminders/list/ReminderListAdapter.kt | 4 +- .../android/remindme/ui/ProgressSpinner.kt | 2 +- .../android/remindme/ui/ReminderEntryField.kt | 59 ++++++++++++++++ app/src/main/res/layout/activity_reminder.xml | 67 +++++-------------- ...list.xml => view_header_reminder_list.xml} | 0 ..._spinner.xml => view_progress_spinner.xml} | 0 .../main/res/layout/view_reminder_entry.xml | 37 ++++++++++ ...er_list.xml => view_row_reminder_list.xml} | 0 app/src/main/res/values/attrs.xml | 5 ++ app/src/main/res/values/dimen.xml | 2 +- app/src/main/res/values/styles.xml | 1 - 12 files changed, 137 insertions(+), 73 deletions(-) create mode 100644 app/src/main/java/com/physphil/android/remindme/ui/ReminderEntryField.kt rename app/src/main/res/layout/{header_reminder_list.xml => view_header_reminder_list.xml} (100%) rename app/src/main/res/layout/{progress_spinner.xml => view_progress_spinner.xml} (100%) create mode 100644 app/src/main/res/layout/view_reminder_entry.xml rename app/src/main/res/layout/{row_reminder_list.xml => view_row_reminder_list.xml} (100%) diff --git a/app/src/main/java/com/physphil/android/remindme/reminders/ReminderActivity.kt b/app/src/main/java/com/physphil/android/remindme/reminders/ReminderActivity.kt index e1623d7..1c2790f 100644 --- a/app/src/main/java/com/physphil/android/remindme/reminders/ReminderActivity.kt +++ b/app/src/main/java/com/physphil/android/remindme/reminders/ReminderActivity.kt @@ -12,7 +12,6 @@ import android.view.Menu import android.view.MenuItem import android.widget.Button import android.widget.DatePicker -import android.widget.EditText import android.widget.TextView import android.widget.TimePicker import butterknife.BindView @@ -24,6 +23,7 @@ import com.physphil.android.remindme.R import com.physphil.android.remindme.RemindMeApplication import com.physphil.android.remindme.models.Recurrence import com.physphil.android.remindme.reminders.list.DeleteReminderDialogFragment +import com.physphil.android.remindme.ui.ReminderEntryField import com.physphil.android.remindme.util.getDisplayDate import com.physphil.android.remindme.util.getDisplayTime import io.reactivex.android.schedulers.AndroidSchedulers @@ -40,11 +40,11 @@ class ReminderActivity : BaseActivity(), TimePickerDialog.OnTimeSetListener, DatePickerDialog.OnDateSetListener, RecurrencePickerDialog.OnRecurrenceSetListener, DeleteReminderDialogFragment.Listener { - @BindView(R.id.reminder_title_text) - lateinit var titleText: EditText + @BindView(R.id.reminder_title_title) + lateinit var title: ReminderEntryField - @BindView(R.id.reminder_body_text) - lateinit var bodyText: EditText + @BindView(R.id.reminder_body) + lateinit var body: ReminderEntryField @BindView(R.id.reminder_time_btn) lateinit var timeText: Button @@ -86,9 +86,9 @@ class ReminderActivity : BaseActivity(), TimePickerDialog.OnTimeSetListener, .subscribe({ // on success. Save Reminder in viewmodel and update UI viewModel.reminder = it - titleText.setText(it.title, TextView.BufferType.EDITABLE) - titleText.setSelection(it.title.length) - bodyText.setText(it.body, TextView.BufferType.EDITABLE) + title.text.setText(it.title, TextView.BufferType.EDITABLE) + title.text.setSelection(it.title.length) + body.text.setText(it.body, TextView.BufferType.EDITABLE) timeText.text = it.getDisplayTime(this) dateText.text = it.getDisplayDate(this) repeatText.setText(it.recurrence.displayString) @@ -108,15 +108,16 @@ class ReminderActivity : BaseActivity(), TimePickerDialog.OnTimeSetListener, viewModel.closeActivityEvent.observe(this, Observer { finish() }) } - @OnTextChanged(R.id.reminder_title_text) - fun onTitleChanged(text: CharSequence) { - viewModel.updateTitle(text.toString()) - } + //todo - Move all these listeners to class of resepctive views +// @OnTextChanged(R.id.reminder_title_text) +// fun onTitleChanged(text: CharSequence) { +// viewModel.updateTitle(text.toString()) +// } - @OnTextChanged(R.id.reminder_body_text) - fun onBodyChanged(text: CharSequence) { - viewModel.updateBody(text.toString()) - } +// @OnTextChanged(R.id.reminder_body_text) +// fun onBodyChanged(text: CharSequence) { +// viewModel.updateBody(text.toString()) +// } @OnClick(R.id.reminder_time_btn, R.id.reminder_time_icon) fun onTimeClicked() { diff --git a/app/src/main/java/com/physphil/android/remindme/reminders/list/ReminderListAdapter.kt b/app/src/main/java/com/physphil/android/remindme/reminders/list/ReminderListAdapter.kt index 844e7cb..9ad3296 100644 --- a/app/src/main/java/com/physphil/android/remindme/reminders/list/ReminderListAdapter.kt +++ b/app/src/main/java/com/physphil/android/remindme/reminders/list/ReminderListAdapter.kt @@ -76,11 +76,11 @@ class ReminderListAdapter : RecyclerView.Adapter override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { return if (viewType == VIEW_TYPE_HEADER) { - val view = LayoutInflater.from(parent.context).inflate(R.layout.header_reminder_list, parent, false) + val view = LayoutInflater.from(parent.context).inflate(R.layout.view_header_reminder_list, parent, false) HeaderViewHolder(view) } else { - val view = LayoutInflater.from(parent.context).inflate(R.layout.row_reminder_list, parent, false) + val view = LayoutInflater.from(parent.context).inflate(R.layout.view_row_reminder_list, parent, false) ReminderViewHolder(view) } } diff --git a/app/src/main/java/com/physphil/android/remindme/ui/ProgressSpinner.kt b/app/src/main/java/com/physphil/android/remindme/ui/ProgressSpinner.kt index ad0616c..0b584e6 100644 --- a/app/src/main/java/com/physphil/android/remindme/ui/ProgressSpinner.kt +++ b/app/src/main/java/com/physphil/android/remindme/ui/ProgressSpinner.kt @@ -17,7 +17,7 @@ class ProgressSpinner : ConstraintLayout { constructor(context: Context) : this(context, null) constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0) constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - val view = inflate(context, R.layout.progress_spinner, this) + val view = inflate(context, R.layout.view_progress_spinner, this) ButterKnife.bind(this, view) attrs?.let { diff --git a/app/src/main/java/com/physphil/android/remindme/ui/ReminderEntryField.kt b/app/src/main/java/com/physphil/android/remindme/ui/ReminderEntryField.kt new file mode 100644 index 0000000..820327e --- /dev/null +++ b/app/src/main/java/com/physphil/android/remindme/ui/ReminderEntryField.kt @@ -0,0 +1,59 @@ +package com.physphil.android.remindme.ui + +import android.content.Context +import android.support.annotation.DrawableRes +import android.support.annotation.StringRes +import android.support.constraint.ConstraintLayout +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.EditText +import android.widget.ImageView +import android.widget.TextView +import butterknife.BindView +import butterknife.ButterKnife +import com.physphil.android.remindme.R + +/** + * Copyright (c) 2018 Phil Shadlyn + */ +class ReminderEntryField @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) + : ConstraintLayout(context, attrs, defStyleAttr) { + + @BindView(R.id.reminder_entry_title) + lateinit var title: TextView + + @BindView(R.id.reminder_entry_field) + lateinit var text: EditText + + @BindView(R.id.reminder_entry_icon) + lateinit var icon: ImageView + + init { + val view = LayoutInflater.from(context).inflate(R.layout.view_reminder_entry, this) + ButterKnife.bind(this, view) + + attrs?.let { + val ta = context.obtainStyledAttributes(attrs, R.styleable.ReminderEntryField) + val title = ta.getResourceId(R.styleable.ReminderEntryField_field_title, 0) + val icon = ta.getResourceId(R.styleable.ReminderEntryField_field_icon, 0) + + if (title > 0) { + setTitle(title) + } + + if (icon > 0) { + setIcon(icon) + } + + ta.recycle() + } + } + + fun setTitle(@StringRes title: Int) { + this.title.setText(title) + } + + fun setIcon(@DrawableRes icon: Int) { + this.icon.setImageResource(icon) + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_reminder.xml b/app/src/main/res/layout/activity_reminder.xml index 167cb75..3be93a3 100644 --- a/app/src/main/res/layout/activity_reminder.xml +++ b/app/src/main/res/layout/activity_reminder.xml @@ -11,64 +11,27 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - - - - - - + android:layout_marginTop="@dimen/global_margin_xlarge" + app:field_icon="@drawable/ic_notifications_24dp" + app:field_title="@string/reminder_title_title" + app:layout_constraintTop_toTopOf="parent"/> - - - + android:layout_marginTop="@dimen/global_margin_xlarge" + app:field_icon="@drawable/ic_view_headline_24dp" + app:field_title="@string/reminder_body_title" + app:layout_constraintTop_toBottomOf="@id/reminder_title_title"/>