Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan-evtushenko committed Sep 17, 2019
2 parents 17d8b1d + f256147 commit 3a88e13
Show file tree
Hide file tree
Showing 56 changed files with 1,270 additions and 1,274 deletions.
11 changes: 6 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ repositories {
}

android {
compileSdkVersion 27
compileSdkVersion 29
buildToolsVersion '27.0.3'
defaultConfig {
applicationId 'com.blogspot.e_kanivets.moneytracker'
minSdkVersion 17
targetSdkVersion 26
minSdkVersion 21
targetSdkVersion 29

versionCode 31
versionName '2.0.1'
versionCode 32
versionName '2.1.0'
}
signingConfigs {
releaseConfig {
Expand Down Expand Up @@ -99,4 +99,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'
}
19 changes: 9 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.blogspot.e_kanivets.moneytracker">

<!-- Used only for Dropbox backup -->
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".MtApp"
android:allowBackup="true"
Expand Down Expand Up @@ -32,7 +29,7 @@
android:name=".activity.record.AddRecordActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.Default"
android:windowSoftInputMode="stateVisible" />
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".activity.account.AddAccountActivity"
android:label="@string/title_add_account"
Expand Down Expand Up @@ -98,15 +95,19 @@
android:launchMode="singleTask"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<data android:scheme="db-5lqugcckdy9y6lj" />

<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.BROWSABLE" />

<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="db-5lqugcckdy9y6lj" />
</intent-filter>
</activity>

<meta-data
android:name="io.fabric.ApiKey"
android:value="955ae4864ae2a833aeda5b62631512524288adf8" />

<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.blogspot.e_kanivets.moneytracker"
Expand All @@ -117,10 +118,8 @@
android:resource="@xml/file_paths" />
</provider>

<meta-data
android:name="io.fabric.ApiKey"
android:value="955ae4864ae2a833aeda5b62631512524288adf8" />

</application>

<uses-permission android:name="android.permission.INTERNET" />

</manifest>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
package com.blogspot.e_kanivets.moneytracker.activity

import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import com.blogspot.e_kanivets.moneytracker.MtApp
import com.blogspot.e_kanivets.moneytracker.R
import com.blogspot.e_kanivets.moneytracker.activity.base.BaseBackActivity
import com.blogspot.e_kanivets.moneytracker.adapter.RecordReportAdapter
import com.blogspot.e_kanivets.moneytracker.controller.CurrencyController
import com.blogspot.e_kanivets.moneytracker.controller.FormatController
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.Period
import com.blogspot.e_kanivets.moneytracker.entity.RecordReportItem
import com.blogspot.e_kanivets.moneytracker.entity.data.Record
import com.blogspot.e_kanivets.moneytracker.report.ReportMaker
import com.blogspot.e_kanivets.moneytracker.report.record.IRecordReport
import com.blogspot.e_kanivets.moneytracker.ui.presenter.ShortSummaryPresenter
import kotlinx.android.synthetic.main.activity_report.*
import java.util.*
import javax.inject.Inject

class ReportActivity : BaseBackActivity() {

@Inject
lateinit var recordController: RecordController
@Inject
lateinit var rateController: ExchangeRateController
@Inject
lateinit var currencyController: CurrencyController

private var recordList: List<Record> = listOf()
private var period: Period? = null
private lateinit var adapter: RecordReportAdapter
private lateinit var recordReportConverter: RecordReportConverter

private lateinit var shortSummaryPresenter: ShortSummaryPresenter

override fun getContentViewId() = R.layout.activity_report

override fun initData(): Boolean {
super.initData()
appComponent.inject(this)

period = intent.getParcelableExtra(KEY_PERIOD)
if (period == null) return false

recordList = recordController.getRecordsForPeriod(period)
shortSummaryPresenter = ShortSummaryPresenter(this)
adapter = RecordReportAdapter(mutableListOf(), hashMapOf(), this)
recordReportConverter = RecordReportConverter()

return true
}

override fun initViews() {
super.initViews()

initSpinnerCurrency()

adapter.setSummaryView(shortSummaryPresenter.create(false, null))
recyclerView.adapter = adapter
}

private fun update(currency: String) {
val reportMaker = ReportMaker(rateController)
val report = reportMaker.getRecordReport(currency, period, recordList)

adapter.setData(recordReportConverter.getItemsFromReport(report), recordReportConverter.getDataFromReport(report))
shortSummaryPresenter.update(report, currency, reportMaker.currencyNeeded(currency, recordList))
}

private fun initSpinnerCurrency() {
val currencyList = currencyController.readAll()

spinnerCurrency.adapter = ArrayAdapter(this, R.layout.view_spinner_item, currencyList)
spinnerCurrency.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, p2: Int, p3: Long) =
update(spinnerCurrency.selectedItem.toString())

override fun onNothingSelected(p0: AdapterView<*>?) {}
}

val currency = currencyController.readDefaultCurrency()

spinnerCurrency.setSelection(currencyList.indexOf(currency))
}

class RecordReportConverter {

@Inject
lateinit var formatController: FormatController

init {
MtApp.get().appComponent.inject(this)
}

fun getItemsFromReport(report: IRecordReport?): MutableList<RecordReportItem> {
val items: MutableList<RecordReportItem> = mutableListOf()

if (report == null) return items

for (categoryRecord in report.summary) {
val parentRow = RecordReportItem.ParentRow(categoryRecord.title, formatController.formatSignedAmount(categoryRecord.amount), false)
items.add(parentRow)
}
return items
}

fun getDataFromReport(report: IRecordReport?): HashMap<RecordReportItem.ParentRow, List<RecordReportItem.ChildRow>> {
val data: HashMap<RecordReportItem.ParentRow, List<RecordReportItem.ChildRow>> = hashMapOf()

if (report == null) return data

for (categoryRecord in report.summary) {
val parentRow = RecordReportItem.ParentRow(categoryRecord.title, formatController.formatSignedAmount(categoryRecord.amount), false)
val childRows: MutableList<RecordReportItem.ChildRow> = mutableListOf()

for (summaryRecord in categoryRecord.summaryRecordList) {
val childRow = RecordReportItem.ChildRow(summaryRecord.title, formatController.formatSignedAmount(summaryRecord.amount))
childRows.add(childRow)
}

data[parentRow] = childRows
}
return data
}

}

companion object {

const val KEY_PERIOD = "key_period"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class SettingsActivity extends BaseBackActivity {
super.initViews();

// Display the fragment as the main content.
getFragmentManager().beginTransaction().replace(R.id.content, new SettingsFragment()).commit();
getFragmentManager().beginTransaction().replace(R.id.contentView, new SettingsFragment()).commit();
}

public static class SettingsFragment extends PreferenceFragment {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
break;

case REQUEST_TRANSFER:
update();
setResult(RESULT_OK);
break;

case REQUEST_EDIT_ACCOUNT:
update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public class AddAccountActivity extends BaseBackActivity {

private IValidator<Account> accountValidator;

@BindView(R.id.content)
@BindView(R.id.contentView)
View contentView;
@BindView(R.id.et_title)
@BindView(R.id.etTitle)
EditText etTitle;
@BindView(R.id.et_init_sum)
EditText etInitSum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class TransferActivity extends BaseBackActivity {

private List<Account> accountList;

@BindView(R.id.content)
@BindView(R.id.contentView)
View contentView;
@BindView(R.id.spinner_from)
AppCompatSpinner spinnerFrom;
Expand Down
Loading

0 comments on commit 3a88e13

Please sign in to comment.