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

Commit 6599787

Browse files
author
Evgenii Kanivets
authored
Merge pull request #161 from evgenii-kanivets/dev
v2.0.0: Account updates.
2 parents 60bf1b9 + 6e9450a commit 6599787

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1769
-1279
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ jdk: oraclejdk8
33
android:
44
components:
55
# The BuildTools version used by your project
6-
- build-tools-26.0.2
6+
- build-tools-27.0.3
77

88
# The SDK version used to compile your project
99
- android-21
10-
- android-26
10+
- android-27
1111

1212
# Additional components
1313
- extra-google-google_play_services
1414
- extra-google-m2repository
1515
- extra-android-m2repository
16-
- addon-google_apis-google-26
16+
- addon-google_apis-google-27
1717

1818
# Specify at least one system image,
1919
# if you need to run emulator(s) during your tests

app/build.gradle

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@ buildscript {
88
}
99
}
1010
apply plugin: 'com.android.application'
11+
apply plugin: 'kotlin-android'
12+
apply plugin: 'kotlin-android-extensions'
1113
apply plugin: 'io.fabric'
1214

1315
repositories {
1416
maven { url 'https://maven.fabric.io/public' }
17+
mavenCentral()
1518
}
1619

1720
android {
18-
compileSdkVersion 26
19-
buildToolsVersion '26.0.2'
21+
compileSdkVersion 27
22+
buildToolsVersion '27.0.3'
2023
defaultConfig {
2124
applicationId 'com.blogspot.e_kanivets.moneytracker'
2225
minSdkVersion 17
23-
targetSdkVersion 26
26+
targetSdkVersion 27
2427
versionCode 23
2528
versionName '1.8.7'
2629
}
@@ -65,22 +68,23 @@ dependencies {
6568
transitive = true
6669
}
6770

68-
compile 'com.android.support:support-v4:26.1.0'
69-
compile 'com.android.support:appcompat-v7:26.1.0'
70-
compile 'com.android.support:design:26.1.0'
71+
compile 'com.android.support:support-v4:27.1.1'
72+
compile 'com.android.support:appcompat-v7:27.1.1'
73+
compile 'com.android.support:design:27.1.1'
7174
compile 'com.jakewharton:butterknife:8.5.1' // View annotation bindings
7275
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' // ButterKnife compiler
73-
compile 'com.google.dagger:dagger:2.0.1' // Dependency injection tool
76+
compile 'com.google.dagger:dagger:2.11' // Dependency injection tool
7477
compile 'com.github.PhilJay:MPAndroidChart:v2.2.4' // Charts
7578
compile 'com.jakewharton.timber:timber:4.1.2' // Advanced logging tool
76-
compile 'com.android.support.constraint:constraint-layout:1.0.2'
79+
compile 'com.android.support.constraint:constraint-layout:1.1.3'
7780
compile 'com.dropbox.core:dropbox-core-sdk:3.0.5' // Dropbox Core API
7881

7982
testCompile 'junit:junit:4.12'
80-
testCompile 'org.mockito:mockito-core:2.0.43-beta'
83+
testCompile 'org.mockito:mockito-core:2.8.9'
8184
androidTestCompile 'com.crittercism.dexmaker:dexmaker:1.4'
8285
androidTestCompile 'com.crittercism.dexmaker:dexmaker-dx:1.4'
8386
androidTestCompile 'com.crittercism.dexmaker:dexmaker-mockito:1.4'
84-
annotationProcessor 'com.google.dagger:dagger-compiler:2.0.1'
87+
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
8588
provided 'org.glassfish:javax.annotation:10.0-b28'
89+
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
8690
}

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
android:screenOrientation="portrait"
8888
android:theme="@style/Theme.Default" />
8989
<activity
90-
android:name=".activity.account.EditAccountActivity"
90+
android:name=".activity.account.edit.EditAccountActivity"
9191
android:label="@string/title_activity_edit_account"
9292
android:screenOrientation="portrait"
9393
android:theme="@style/Theme.Default"

app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/SettingsActivity.java

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,25 @@
2222
import javax.inject.Inject;
2323

2424
public class SettingsActivity extends BaseBackActivity {
25-
@SuppressWarnings("unused")
26-
private static final String TAG = "SettingsActivity";
25+
@SuppressWarnings("unused") private static final String TAG = "SettingsActivity";
2726

28-
@Override
29-
protected int getContentViewId() {
27+
@Override protected int getContentViewId() {
3028
return R.layout.activity_settings;
3129
}
3230

33-
@Override
34-
protected void initViews() {
31+
@Override protected void initViews() {
3532
super.initViews();
3633

3734
// Display the fragment as the main content.
38-
getFragmentManager().beginTransaction()
39-
.replace(R.id.content, new SettingsFragment())
40-
.commit();
35+
getFragmentManager().beginTransaction().replace(R.id.content, new SettingsFragment()).commit();
4136
}
4237

4338
public static class SettingsFragment extends PreferenceFragment {
44-
@Inject
45-
AccountController accountController;
46-
@Inject
47-
CurrencyController currencyController;
48-
@Inject
49-
PreferenceController preferenceController;
50-
51-
@Override
52-
public void onCreate(Bundle savedInstanceState) {
39+
@Inject AccountController accountController;
40+
@Inject CurrencyController currencyController;
41+
@Inject PreferenceController preferenceController;
42+
43+
@Override public void onCreate(Bundle savedInstanceState) {
5344
super.onCreate(savedInstanceState);
5445

5546
MtApp.get().getAppComponent().inject(SettingsFragment.this);
@@ -59,18 +50,14 @@ public void onCreate(Bundle savedInstanceState) {
5950

6051
setupDefaultAccountPref();
6152
setupDefaultCurrencyPref();
53+
setupNonSubstitutionCurrencyPref();
6254
setupDisplayPrecision();
6355
setupAboutPref();
6456
}
6557

66-
private void setupAboutPref() {
67-
Preference preference = findPreference(getString(R.string.pref_about));
68-
preference.setSummary(getString(R.string.about_summary, BuildConfig.VERSION_NAME,
69-
Build.VERSION.RELEASE));
70-
}
71-
7258
private void setupDefaultAccountPref() {
73-
ListPreference defaultAccountPref = (ListPreference) findPreference(getString(R.string.pref_default_account));
59+
ListPreference defaultAccountPref =
60+
(ListPreference) findPreference(getString(R.string.pref_default_account));
7461
defaultAccountPref.setOnPreferenceChangeListener(preferenceChangeListener);
7562

7663
List<Account> accountList = accountController.readActiveAccounts();
@@ -87,9 +74,9 @@ private void setupDefaultAccountPref() {
8774
}
8875
}
8976

90-
@SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument")
91-
private void setupDefaultCurrencyPref() {
92-
ListPreference defaultCurrencyPref = (ListPreference) findPreference(getString(R.string.pref_default_currency));
77+
@SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument") private void setupDefaultCurrencyPref() {
78+
ListPreference defaultCurrencyPref =
79+
(ListPreference) findPreference(getString(R.string.pref_default_currency));
9380
defaultCurrencyPref.setOnPreferenceChangeListener(preferenceChangeListener);
9481

9582
List<String> currencyList = currencyController.readAll();
@@ -101,9 +88,23 @@ private void setupDefaultCurrencyPref() {
10188
defaultCurrencyPref.setSummary(defaultCurrency);
10289
}
10390

104-
@SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument")
105-
private void setupDisplayPrecision() {
106-
ListPreference displayPrecisionPref = (ListPreference) findPreference(getString(R.string.pref_display_precision));
91+
@SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument") private void setupNonSubstitutionCurrencyPref() {
92+
ListPreference nonSubstitutionCurrencyPref =
93+
(ListPreference) findPreference(getString(R.string.pref_non_substitution_currency));
94+
nonSubstitutionCurrencyPref.setOnPreferenceChangeListener(preferenceChangeListener);
95+
96+
List<String> currencyList = currencyController.readAll();
97+
nonSubstitutionCurrencyPref.setEntries(currencyList.toArray(new String[0]));
98+
nonSubstitutionCurrencyPref.setEntryValues(currencyList.toArray(new String[0]));
99+
100+
String nonSubstitutionCurrency = preferenceController.readNonSubstitutionCurrency();
101+
nonSubstitutionCurrencyPref.setDefaultValue(nonSubstitutionCurrency);
102+
nonSubstitutionCurrencyPref.setSummary(nonSubstitutionCurrency);
103+
}
104+
105+
@SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument") private void setupDisplayPrecision() {
106+
ListPreference displayPrecisionPref =
107+
(ListPreference) findPreference(getString(R.string.pref_display_precision));
107108
displayPrecisionPref.setOnPreferenceChangeListener(preferenceChangeListener);
108109

109110
List<String> precisionListValues = new ArrayList<>();
@@ -124,6 +125,11 @@ private void setupDisplayPrecision() {
124125
}
125126
}
126127

128+
private void setupAboutPref() {
129+
Preference preference = findPreference(getString(R.string.pref_about));
130+
preference.setSummary(getString(R.string.about_summary, BuildConfig.VERSION_NAME, Build.VERSION.RELEASE));
131+
}
132+
127133
@SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument")
128134
private String[] getEntries(List<Account> accountList) {
129135
List<String> result = new ArrayList<>();
@@ -146,16 +152,15 @@ private String[] getEntryValues(List<Account> accountList) {
146152
return result.toArray(new String[0]);
147153
}
148154

149-
private Preference.OnPreferenceChangeListener preferenceChangeListener
150-
= new Preference.OnPreferenceChangeListener() {
151-
@Override
152-
public boolean onPreferenceChange(Preference preference, Object newValue) {
153-
// Previously we could set summary to default value,
154-
// but now it's needed to display selected entry
155-
preference.setSummary("%s");
156-
getActivity().setResult(RESULT_OK);
157-
return true;
158-
}
159-
};
155+
private Preference.OnPreferenceChangeListener preferenceChangeListener =
156+
new Preference.OnPreferenceChangeListener() {
157+
@Override public boolean onPreferenceChange(Preference preference, Object newValue) {
158+
// Previously we could set summary to default value,
159+
// but now it's needed to display selected entry
160+
preference.setSummary("%s");
161+
getActivity().setResult(RESULT_OK);
162+
return true;
163+
}
164+
};
160165
}
161166
}

app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/account/AccountsActivity.java

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
import android.widget.ListView;
88

99
import com.blogspot.e_kanivets.moneytracker.R;
10+
import com.blogspot.e_kanivets.moneytracker.activity.account.edit.EditAccountActivity;
1011
import com.blogspot.e_kanivets.moneytracker.activity.base.BaseBackActivity;
1112
import com.blogspot.e_kanivets.moneytracker.adapter.AccountAdapter;
1213
import com.blogspot.e_kanivets.moneytracker.controller.data.AccountController;
14+
import com.blogspot.e_kanivets.moneytracker.entity.data.Account;
1315
import com.blogspot.e_kanivets.moneytracker.ui.presenter.AccountsSummaryPresenter;
1416
import com.blogspot.e_kanivets.moneytracker.util.AnswersProxy;
1517

@@ -20,36 +22,30 @@
2022
import butterknife.OnItemClick;
2123

2224
public class AccountsActivity extends BaseBackActivity {
23-
@SuppressWarnings("unused")
24-
private static final String TAG = "AccountsActivity";
25+
@SuppressWarnings("unused") private static final String TAG = "AccountsActivity";
2526

2627
private static final int REQUEST_ADD_ACCOUNT = 1;
2728
private static final int REQUEST_TRANSFER = 2;
2829
private static final int REQUEST_EDIT_ACCOUNT = 3;
2930

30-
@Inject
31-
AccountController accountController;
31+
@Inject AccountController accountController;
3232

3333
private AccountsSummaryPresenter summaryPresenter;
3434

35-
@BindView(R.id.list_view)
36-
ListView listView;
35+
@BindView(R.id.list_view) ListView listView;
3736

38-
@Override
39-
protected int getContentViewId() {
37+
@Override protected int getContentViewId() {
4038
return R.layout.activity_accounts;
4139
}
4240

43-
@Override
44-
protected boolean initData() {
41+
@Override protected boolean initData() {
4542
boolean result = super.initData();
4643
getAppComponent().inject(AccountsActivity.this);
4744
summaryPresenter = new AccountsSummaryPresenter(AccountsActivity.this);
4845
return result;
4946
}
5047

51-
@Override
52-
protected void initViews() {
48+
@Override protected void initViews() {
5349
super.initViews();
5450

5551
listView.addHeaderView(summaryPresenter.create());
@@ -58,14 +54,12 @@ protected void initViews() {
5854
update();
5955
}
6056

61-
@Override
62-
public boolean onCreateOptionsMenu(Menu menu) {
57+
@Override public boolean onCreateOptionsMenu(Menu menu) {
6358
getMenuInflater().inflate(R.menu.menu_accounts, menu);
6459
return true;
6560
}
6661

67-
@Override
68-
public boolean onOptionsItemSelected(MenuItem item) {
62+
@Override public boolean onOptionsItemSelected(MenuItem item) {
6963
switch (item.getItemId()) {
7064
case R.id.action_transfer:
7165
makeTransfer();
@@ -76,28 +70,23 @@ public boolean onOptionsItemSelected(MenuItem item) {
7670
}
7771
}
7872

79-
@OnItemClick(R.id.list_view)
80-
public void onAccountClick(int position) {
81-
Intent intent = new Intent(this, EditAccountActivity.class);
82-
intent.putExtra(EditAccountActivity.KEY_ACCOUNT, accountController.readAll().get(position - 1));
83-
startActivityForResult(intent, REQUEST_EDIT_ACCOUNT);
73+
@OnItemClick(R.id.list_view) public void onAccountClick(int position) {
74+
Account account = accountController.readAll().get(position - 1);
75+
startActivityForResult(EditAccountActivity.Companion.newIntent(this, account), REQUEST_EDIT_ACCOUNT);
8476
}
8577

8678
public void makeTransfer() {
8779
AnswersProxy.get().logButton("Add Transfer");
88-
startActivityForResult(new Intent(AccountsActivity.this, TransferActivity.class),
89-
REQUEST_TRANSFER);
80+
startActivityForResult(new Intent(AccountsActivity.this, TransferActivity.class), REQUEST_TRANSFER);
9081
}
9182

92-
@OnClick(R.id.btn_add_account)
93-
public void addAccount() {
83+
@OnClick(R.id.btn_add_account) public void addAccount() {
9484
AnswersProxy.get().logButton("Add Account");
9585
Intent intent = new Intent(AccountsActivity.this, AddAccountActivity.class);
9686
startActivityForResult(intent, REQUEST_ADD_ACCOUNT);
9787
}
9888

99-
@Override
100-
public void onActivityResult(int requestCode, int resultCode, Intent data) {
89+
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) {
10190
super.onActivityResult(requestCode, resultCode, data);
10291

10392
if (resultCode == AppCompatActivity.RESULT_OK) {

0 commit comments

Comments
 (0)