From 2f46e3fcfc1dcd0d4c78bd22ce5404ddf455cb0c Mon Sep 17 00:00:00 2001 From: Bogdan Yevtushenko Date: Tue, 27 Aug 2019 15:00:42 +0300 Subject: [PATCH 01/28] #172. Redesign records list. --- app/build.gradle | 1 + .../fragment/AccountOperationsFragment.kt | 26 ++- .../activity/record/AddRecordActivity.java | 2 +- .../activity/record/MainActivity.kt | 36 +++- .../moneytracker/adapter/RecordAdapter.kt | 87 +++++----- .../controller/FormatController.java | 12 +- .../controller/PeriodController.java | 4 +- .../controller/data/RecordController.java | 2 +- .../controller/external/Head.java | 2 +- .../moneytracker/entity/RecordAdapterData.kt | 11 ++ .../moneytracker/entity/data/Record.java | 2 +- .../moneytracker/entity/data/Transfer.java | 2 +- .../moneytracker/repo/base/IRepo.java | 2 +- .../ui/presenter/ShortSummaryPresenter.java | 6 +- app/src/main/res/layout/view_header_date.xml | 25 +++ app/src/main/res/layout/view_record.xml | 49 ++---- .../main/res/layout/view_summary_records.xml | 161 ++++++++++-------- app/src/main/res/values/styles.xml | 7 + 18 files changed, 270 insertions(+), 167 deletions(-) create mode 100644 app/src/main/java/com/blogspot/e_kanivets/moneytracker/entity/RecordAdapterData.kt create mode 100644 app/src/main/res/layout/view_header_date.xml diff --git a/app/build.gradle b/app/build.gradle index b77ab6c..1a5b225 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -88,4 +88,5 @@ dependencies { annotationProcessor 'com.google.dagger:dagger-compiler:2.11' provided 'org.glassfish:javax.annotation:10.0-b28' compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'com.android.support:cardview-v7:27.1.1' } diff --git a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/account/edit/fragment/AccountOperationsFragment.kt b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/account/edit/fragment/AccountOperationsFragment.kt index 93d7726..d82f8ae 100644 --- a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/account/edit/fragment/AccountOperationsFragment.kt +++ b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/account/edit/fragment/AccountOperationsFragment.kt @@ -5,9 +5,13 @@ import android.view.View import com.blogspot.e_kanivets.moneytracker.R import com.blogspot.e_kanivets.moneytracker.activity.base.BaseFragment import com.blogspot.e_kanivets.moneytracker.adapter.RecordAdapter +import com.blogspot.e_kanivets.moneytracker.controller.FormatController import com.blogspot.e_kanivets.moneytracker.controller.data.AccountController import com.blogspot.e_kanivets.moneytracker.controller.data.RecordController import com.blogspot.e_kanivets.moneytracker.controller.data.TransferController +import com.blogspot.e_kanivets.moneytracker.entity.HeaderItem +import com.blogspot.e_kanivets.moneytracker.entity.RecordAdapterData +import com.blogspot.e_kanivets.moneytracker.entity.RecordItem import com.blogspot.e_kanivets.moneytracker.entity.data.Account import com.blogspot.e_kanivets.moneytracker.entity.data.Category import com.blogspot.e_kanivets.moneytracker.entity.data.Record @@ -23,6 +27,8 @@ class AccountOperationsFragment : BaseFragment() { internal lateinit var recordController: RecordController @Inject internal lateinit var transferController: TransferController + @Inject + internal lateinit var formatController: FormatController private lateinit var account: Account @@ -34,17 +40,30 @@ class AccountOperationsFragment : BaseFragment() { } override fun initViews(view: View) { - recyclerView.adapter = RecordAdapter(requireContext(), getRecords(), false, null) + recyclerView.adapter = RecordAdapter(requireContext(), getRecordAdapterDataList(), false, null) } - private fun getRecords(): List { + private fun getRecordAdapterDataList(): List { val accountRecords = recordController.getRecordsForAccount(account) val accountTransfers = transferController.getTransfersForAccount(account) accountRecords += obtainRecordsFromTransfers(accountTransfers) accountRecords.sortByDescending { it.time } - return accountRecords + val recordAdapterData: MutableList = mutableListOf() + + var lastDate = EMPTY_DATE + + for (record in accountRecords) { + if (formatController.formatDateToString(record.time) != lastDate) { + lastDate = formatController.formatDateToString(record.time) + recordAdapterData.add(HeaderItem(lastDate)) + } + + recordAdapterData.add(RecordItem(record)) + } + + return recordAdapterData } private fun obtainRecordsFromTransfers(transfers: List): List { @@ -73,6 +92,7 @@ class AccountOperationsFragment : BaseFragment() { companion object { private const val KEY_ACCOUNT = "key_account" + private const val EMPTY_DATE = "empty_date" fun newInstance(account: Account): AccountOperationsFragment { val fragment = AccountOperationsFragment() diff --git a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/record/AddRecordActivity.java b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/record/AddRecordActivity.java index 1e04b51..ff23db7 100644 --- a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/record/AddRecordActivity.java +++ b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/record/AddRecordActivity.java @@ -366,7 +366,7 @@ private boolean addRecord() { } private void updateDateAndTime() { - tvDate.setText(formatController.formatDate(timestamp)); + tvDate.setText(formatController.formatDateToNumber(timestamp)); tvTime.setText(formatController.formatTime(timestamp)); } diff --git a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/record/MainActivity.kt b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/record/MainActivity.kt index e93e158..dd6b19f 100644 --- a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/record/MainActivity.kt +++ b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/record/MainActivity.kt @@ -14,7 +14,10 @@ import com.blogspot.e_kanivets.moneytracker.controller.PreferenceController import com.blogspot.e_kanivets.moneytracker.controller.data.AccountController import com.blogspot.e_kanivets.moneytracker.controller.data.ExchangeRateController import com.blogspot.e_kanivets.moneytracker.controller.data.RecordController +import com.blogspot.e_kanivets.moneytracker.entity.RecordAdapterData +import com.blogspot.e_kanivets.moneytracker.entity.HeaderItem import com.blogspot.e_kanivets.moneytracker.entity.Period +import com.blogspot.e_kanivets.moneytracker.entity.RecordItem import com.blogspot.e_kanivets.moneytracker.entity.data.Record import com.blogspot.e_kanivets.moneytracker.report.ReportMaker import com.blogspot.e_kanivets.moneytracker.ui.AppRateDialog @@ -26,6 +29,7 @@ import javax.inject.Inject class MainActivity : BaseDrawerActivity() { private lateinit var recordList: List + private val recordAdapterDataList: MutableList = mutableListOf() private lateinit var period: Period private lateinit var recordAdapter: RecordAdapter @@ -91,8 +95,7 @@ class MainActivity : BaseDrawerActivity() { private fun editRecord(position: Int) { AnswersProxy.get().logButton("Edit Record") - // Minus one because of list view's header view - val record = recordList[position - 1] + val record = recordList[position - 1 - getCountHeadersItems(position - 1)] startAddRecordActivity(record, AddRecordActivity.Mode.MODE_EDIT, record.type) } @@ -134,17 +137,43 @@ class MainActivity : BaseDrawerActivity() { override fun update() { recordList = recordController.getRecordsForPeriod(period) recordList = recordList.reversed() + updateRecordAdapterDataList() val currency = currencyController.readDefaultCurrency() val reportMaker = ReportMaker(rateController) val report = reportMaker.getRecordReport(currency, period, recordList) - recordAdapter.setRecords(recordList, report, currency, reportMaker.currencyNeeded(currency, recordList)) + recordAdapter.setRecords(recordAdapterDataList, report, currency, reportMaker.currencyNeeded(currency, recordList)) fillDefaultAccount() } + private fun getCountHeadersItems(position: Int): Int { + var countHeadersItems = 0 + for (inOfData in 0 until position) { + if (recordAdapterDataList[inOfData] is HeaderItem) { + countHeadersItems++ + } + } + return countHeadersItems + } + + private fun updateRecordAdapterDataList() { + recordAdapterDataList.clear() + + var lastDate = EMPTY_DATE + for (record in recordList) { + if (formatController.formatDateToString(record.time) != lastDate) { + lastDate = formatController.formatDateToString(record.time) + recordAdapterDataList.add(HeaderItem(lastDate)) + } + + recordAdapterDataList.add(RecordItem(record)) + } + } + + private fun showAppRateDialog() { AnswersProxy.get().logEvent("Show App Rate Dialog") val dialog = AppRateDialog(this) @@ -170,6 +199,7 @@ class MainActivity : BaseDrawerActivity() { companion object { private const val REQUEST_ACTION_RECORD = 6 + private const val EMPTY_DATE = "empty_date" } } \ No newline at end of file diff --git a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/adapter/RecordAdapter.kt b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/adapter/RecordAdapter.kt index f07066d..41a8c08 100644 --- a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/adapter/RecordAdapter.kt +++ b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/adapter/RecordAdapter.kt @@ -11,10 +11,14 @@ import android.widget.TextView import com.blogspot.e_kanivets.moneytracker.MtApp import com.blogspot.e_kanivets.moneytracker.R import com.blogspot.e_kanivets.moneytracker.controller.FormatController -import com.blogspot.e_kanivets.moneytracker.entity.data.Record +import com.blogspot.e_kanivets.moneytracker.entity.RecordAdapterData +import com.blogspot.e_kanivets.moneytracker.entity.HeaderItem +import com.blogspot.e_kanivets.moneytracker.entity.RecordItem import com.blogspot.e_kanivets.moneytracker.report.record.IRecordReport import com.blogspot.e_kanivets.moneytracker.ui.presenter.ShortSummaryPresenter +import kotlinx.android.synthetic.main.view_header_date.view.* import kotlinx.android.synthetic.main.view_record.view.* +import kotlinx.android.synthetic.main.view_record.view.container import kotlinx.android.synthetic.main.view_summary_records.view.* import javax.inject.Inject @@ -30,16 +34,16 @@ class RecordAdapter : RecyclerView.Adapter { private var red: Int private var green: Int - private var records: List + private var items: List private var context: Context private var summaryPresenter: ShortSummaryPresenter - private var isHeaderViewNeeded: Boolean = false - private var headerViewHolder: HeaderViewHolder + private var isSummaryViewNeeded: Boolean = false + private var summaryViewHolder: SummaryViewHolder - constructor(context: Context, records: List, isHeaderViewNeeded: Boolean, itemClickListener: ((Int) -> Unit)?) { + constructor(context: Context, items: List, isSummaryViewNeeded: Boolean, itemClickListener: ((Int) -> Unit)?) { this.context = context - this.records = records + this.items = items MtApp.get().appComponent.inject(this) @@ -51,60 +55,64 @@ class RecordAdapter : RecyclerView.Adapter { summaryPresenter = ShortSummaryPresenter(context) this.itemClickListener = itemClickListener - this.isHeaderViewNeeded = isHeaderViewNeeded + this.isSummaryViewNeeded = isSummaryViewNeeded - headerViewHolder = HeaderViewHolder(LayoutInflater.from(context).inflate(R.layout.view_summary_records, null), itemClickListener) - summaryPresenter.create(true, headerViewHolder) + summaryViewHolder = SummaryViewHolder(LayoutInflater.from(context).inflate(R.layout.view_summary_records, null), itemClickListener) + summaryPresenter.create(true, summaryViewHolder) } - override fun getItemCount() = records.size + if (isHeaderViewNeeded) 1 else 0 + override fun getItemCount() = items.size + if (isSummaryViewNeeded) 1 else 0 - override fun getItemViewType(position: Int): Int = if (position == 0 && isHeaderViewNeeded) { + override fun getItemViewType(position: Int): Int = if (position == 0 && isSummaryViewNeeded) { + TYPE_SUMMARY + } else if (items[position - if (isSummaryViewNeeded) 1 else 0] is HeaderItem) { TYPE_HEADER } else { - TYPE_ITEM + TYPE_RECORD } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder = - if (viewType == TYPE_HEADER) { - headerViewHolder - } else { - ViewHolder(LayoutInflater.from(context).inflate(R.layout.view_record, parent, false), itemClickListener) + when (viewType) { + TYPE_RECORD -> RecordViewHolder(LayoutInflater.from(context).inflate(R.layout.view_record, parent, false), itemClickListener) + TYPE_HEADER -> HeaderViewHolder(LayoutInflater.from(context).inflate(R.layout.view_header_date, parent, false)) + else -> summaryViewHolder } override fun onBindViewHolder(rvViewHolder: RecyclerView.ViewHolder, position: Int) { - if (position == 0 && isHeaderViewNeeded) { + if (position == 0 && isSummaryViewNeeded) { //adapter already bound to view return } - val viewHolder = rvViewHolder as ViewHolder - val record: Record = records[position - if (isHeaderViewNeeded) 1 else 0] - viewHolder.container.setBackgroundColor(if (record.isIncome) whiteGreen else whiteRed) - viewHolder.tvPrice.setTextColor(if (record.isIncome) green else red) - - viewHolder.tvDateAndTime.text = formatController.formatDateAndTime(record.time) - val price = (if (record.isIncome) record.fullPrice else getNegative(record.fullPrice)) - viewHolder.tvPrice.text = formatController.formatSignedAmount(price) - viewHolder.tvTitle.text = record.title - viewHolder.tvCategory.text = record.category?.name - viewHolder.tvCurrency.text = record.currency + if (rvViewHolder is RecordViewHolder) { + val record = items[position - if (isSummaryViewNeeded) 1 else 0] as RecordItem + rvViewHolder.tvPrice.setTextColor(if (record.isIncome) green else red) + + val price = (if (record.isIncome) record.fullPrice else getNegative(record.fullPrice)) + rvViewHolder.tvPrice.text = formatController.formatSignedAmount(price) + rvViewHolder.tvTitle.text = record.title + rvViewHolder.tvCategory.text = record.categoryName + rvViewHolder.tvCurrency.text = record.currency + } else { + val headerViewHolder = rvViewHolder as HeaderViewHolder + val header = items[position - if (isSummaryViewNeeded) 1 else 0] as HeaderItem + headerViewHolder.tvDate.text = header.date + } } private fun getNegative(number: Double): Double { return -1 * number } - fun setRecords(recordsList: List, report: IRecordReport?, currency: String, ratesNeeded: List) { - records = recordsList + fun setRecords(itemsList: List, report: IRecordReport?, currency: String, ratesNeeded: List) { + items = itemsList summaryPresenter.update(report, currency, ratesNeeded) notifyDataSetChanged() } - class ViewHolder : RecyclerView.ViewHolder { + class RecordViewHolder : RecyclerView.ViewHolder { var container: LinearLayout - var tvDateAndTime: TextView var tvPrice: TextView var tvTitle: TextView var tvCategory: TextView @@ -112,7 +120,6 @@ class RecordAdapter : RecyclerView.Adapter { constructor(view: View, itemClickListener: ((Int) -> Unit)?) : super(view) { container = view.container - tvDateAndTime = view.tvDateAndTime tvPrice = view.tvPrice tvTitle = view.tvTitle tvCategory = view.tvCategory @@ -124,7 +131,11 @@ class RecordAdapter : RecyclerView.Adapter { } } - class HeaderViewHolder : RecyclerView.ViewHolder, ShortSummaryPresenter.SummaryViewInterface { + class HeaderViewHolder(view: View) : RecyclerView.ViewHolder(view) { + val tvDate: TextView = view.tvDate + } + + class SummaryViewHolder : RecyclerView.ViewHolder, ShortSummaryPresenter.SummaryViewInterface { private var tvPeriod: TextView private var tvTotalIncome: TextView @@ -145,15 +156,15 @@ class RecordAdapter : RecyclerView.Adapter { tvTotalExpense = view.tvTotalExpense tvTotal = view.tvTotal - view.setOnClickListener { + view.cvSummary.setOnClickListener { itemClickListener?.invoke(0) } } } companion object { - - private const val TYPE_HEADER = 0 - private const val TYPE_ITEM = 1 + private const val TYPE_SUMMARY = 0 + private const val TYPE_HEADER = 1 + private const val TYPE_RECORD = 2 } } diff --git a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/FormatController.java b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/FormatController.java index 33e73bf..5dc8cf7 100644 --- a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/FormatController.java +++ b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/FormatController.java @@ -20,7 +20,9 @@ public class FormatController { public static final String PRECISION_NONE = "precision_none"; @SuppressLint("SimpleDateFormat") - private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + private static final SimpleDateFormat dateInNumberFormat = new SimpleDateFormat("yyyy-MM-dd"); + @SuppressLint("SimpleDateFormat") + private static final SimpleDateFormat dateInStringFormat = new SimpleDateFormat("d MMMM yyyy"); @SuppressLint("SimpleDateFormat") private static final SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm"); @SuppressLint("SimpleDateFormat") @@ -72,8 +74,12 @@ public String formatExpense(double amount, String currency) { return (amount > 0 ? "+ " : "- ") + formatAmount(Math.abs(amount)) + " " + currency; } - public String formatDate(long timestamp) { - return dateFormat.format(new Date(timestamp)); + public String formatDateToNumber(long timestamp) { + return dateInNumberFormat.format(new Date(timestamp)); + } + + public String formatDateToString(long timestamp) { + return dateInStringFormat.format(new Date(timestamp)); } public String formatTime(long timestamp) { diff --git a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/PeriodController.java b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/PeriodController.java index ab947c7..4a286ec 100644 --- a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/PeriodController.java +++ b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/PeriodController.java @@ -133,7 +133,7 @@ public Period yearPeriod() { public Period allTimePeriod() { Calendar cal = Calendar.getInstance(); - // set start of time by Jesus + // set start of date by Jesus cal.set(Calendar.YEAR, 2000); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 1); @@ -141,7 +141,7 @@ public Period allTimePeriod() { Date first = cal.getTime(); - // set possible end of time + // set possible end of date cal.set(Calendar.YEAR, 3000); cal.set(Calendar.MONTH, Calendar.DECEMBER); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); diff --git a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/data/RecordController.java b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/data/RecordController.java index c15d524..8d3c0f2 100644 --- a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/data/RecordController.java +++ b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/data/RecordController.java @@ -92,7 +92,7 @@ record = validateRecord(record); @NonNull @Override public List readWithCondition(String condition, String[] args) { List recordList = super.readWithCondition(condition, args); - // Sort record list by time field from smallest to biggest + // Sort record list by date field from smallest to biggest Collections.sort(recordList, new Comparator() { @Override public int compare(Record lhs, Record rhs) { return lhs.getTime() < rhs.getTime() ? -1 : (lhs.getTime() == rhs.getTime() ? 0 : 1); diff --git a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/external/Head.java b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/external/Head.java index 396c9a3..8f00b77 100644 --- a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/external/Head.java +++ b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/external/Head.java @@ -7,7 +7,7 @@ * @author Evgenii Kanivets */ public interface Head { - String TIME = "time"; + String TIME = "date"; String TITLE = "title"; String CATEGORY = "category"; String PRICE = "price"; diff --git a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/entity/RecordAdapterData.kt b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/entity/RecordAdapterData.kt new file mode 100644 index 0000000..b397517 --- /dev/null +++ b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/entity/RecordAdapterData.kt @@ -0,0 +1,11 @@ +package com.blogspot.e_kanivets.moneytracker.entity + +import com.blogspot.e_kanivets.moneytracker.entity.data.Record + +sealed class RecordAdapterData + +data class HeaderItem(val date: String) : RecordAdapterData() + +data class RecordItem(val title: String, val categoryName: String, val fullPrice: Double, val currency: String, val isIncome: Boolean) : RecordAdapterData() { + constructor(record: Record) : this(record.title, record.category?.name?.toString().orEmpty(), record.fullPrice, record.currency, record.isIncome) +} \ No newline at end of file diff --git a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/entity/data/Record.java b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/entity/data/Record.java index 47e8d09..9eb7c3a 100644 --- a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/entity/data/Record.java +++ b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/entity/data/Record.java @@ -171,7 +171,7 @@ public String toString() { } sb.append(", "); - sb.append("time = ").append(time).append(", "); + sb.append("date = ").append(time).append(", "); sb.append("category = ").append(category).append(", "); sb.append("price = ").append(price).append(", "); sb.append("account = ").append(account).append(", "); diff --git a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/entity/data/Transfer.java b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/entity/data/Transfer.java index 305fa50..2ac54cc 100644 --- a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/entity/data/Transfer.java +++ b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/entity/data/Transfer.java @@ -126,7 +126,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Transfer {"); sb.append("id = ").append(id).append(", "); - sb.append("time = ").append(time).append(", "); + sb.append("date = ").append(time).append(", "); sb.append("fromAccountId = ").append(fromAccountId).append(", "); sb.append("toAccountId = ").append(toAccountId).append(", "); sb.append("fromAmount = ").append(fromAmount).append(", "); diff --git a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/repo/base/IRepo.java b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/repo/base/IRepo.java index 18e2740..d146343 100644 --- a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/repo/base/IRepo.java +++ b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/repo/base/IRepo.java @@ -60,7 +60,7 @@ public interface IRepo { * Reads all records from storage that matches given condition. The same as in standard Android * {@link SQLiteOpenHelper}. * - * @param condition is a string of selection. For example - "time BETWEEN ? AND ?". + * @param condition is a string of selection. For example - "date BETWEEN ? AND ?". * @param args is a string array with data to be inserted in condition string instead of '?'. * @return list of matched records. List can't be null, but may be zero sized. */ diff --git a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/ui/presenter/ShortSummaryPresenter.java b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/ui/presenter/ShortSummaryPresenter.java index 65e9893..49217fb 100644 --- a/app/src/main/java/com/blogspot/e_kanivets/moneytracker/ui/presenter/ShortSummaryPresenter.java +++ b/app/src/main/java/com/blogspot/e_kanivets/moneytracker/ui/presenter/ShortSummaryPresenter.java @@ -46,10 +46,12 @@ public ShortSummaryPresenter(Context context) { green = context.getResources().getColor(R.color.green); } - public View create(boolean shortSummary, RecordAdapter.HeaderViewHolder mainViewHolder) { + public View create(boolean shortSummary, RecordAdapter.SummaryViewHolder mainViewHolder) { view = layoutInflater.inflate(R.layout.view_summary_records, null); view.findViewById(R.id.iv_more).setVisibility(shortSummary ? View.VISIBLE : View.INVISIBLE); - + view.setEnabled(false); + view.findViewById(R.id.lvSummary).setClickable(false); + view.findViewById(R.id.cvSummary).setClickable(true); view.setTag(mainViewHolder != null ? mainViewHolder : new ViewHolder(view)); return view; diff --git a/app/src/main/res/layout/view_header_date.xml b/app/src/main/res/layout/view_header_date.xml new file mode 100644 index 0000000..03e2d13 --- /dev/null +++ b/app/src/main/res/layout/view_header_date.xml @@ -0,0 +1,25 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/view_record.xml b/app/src/main/res/layout/view_record.xml index f1f663c..f1b4afa 100644 --- a/app/src/main/res/layout/view_record.xml +++ b/app/src/main/res/layout/view_record.xml @@ -23,48 +23,23 @@ android:orientation="vertical"> + android:text="New Text" + android:theme="@style/Text_Body2" /> - - - - - - - + android:layout_gravity="center_vertical|top" + android:gravity="start" + android:paddingBottom="5dp" + android:text="New Text" + android:textAppearance="?android:attr/textAppearanceSmall" + android:theme="@style/Text_Caption" /> diff --git a/app/src/main/res/layout/view_summary_records.xml b/app/src/main/res/layout/view_summary_records.xml index a7ee8cb..751e706 100644 --- a/app/src/main/res/layout/view_summary_records.xml +++ b/app/src/main/res/layout/view_summary_records.xml @@ -1,97 +1,112 @@ - - + + + card_view:cardCornerRadius="5dp" + card_view:cardElevation="5dp" + card_view:cardUseCompatPadding="true"> - - + + + android:orientation="horizontal"> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index b0a43c7..d283a56 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -59,6 +59,13 @@ @color/text_black + +