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

Commit

Permalink
Merge commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgenii Kanivets committed Sep 20, 2018
2 parents ec63763 + 6599787 commit 8c711f1
Show file tree
Hide file tree
Showing 45 changed files with 1,768 additions and 1,278 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ jdk: oraclejdk8
android:
components:
# The BuildTools version used by your project
- build-tools-26.0.2
- build-tools-27.0.3

# The SDK version used to compile your project
- android-21
- android-26
- android-27

# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- addon-google_apis-google-26
- addon-google_apis-google-27

# Specify at least one system image,
# if you need to run emulator(s) during your tests
Expand Down
22 changes: 13 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ buildscript {
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'

repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}

android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId 'com.blogspot.e_kanivets.moneytracker'
minSdkVersion 17
Expand Down Expand Up @@ -65,22 +68,23 @@ dependencies {
transitive = true
}

compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:support-v4:27.1.1'
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support:design:27.1.1'
compile 'com.jakewharton:butterknife:8.5.1' // View annotation bindings
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' // ButterKnife compiler
compile 'com.google.dagger:dagger:2.0.1' // Dependency injection tool
compile 'com.google.dagger:dagger:2.11' // Dependency injection tool
compile 'com.github.PhilJay:MPAndroidChart:v2.2.4' // Charts
compile 'com.jakewharton.timber:timber:4.1.2' // Advanced logging tool
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support.constraint:constraint-layout:1.1.3'
compile 'com.dropbox.core:dropbox-core-sdk:3.0.5' // Dropbox Core API

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.0.43-beta'
testCompile 'org.mockito:mockito-core:2.8.9'
androidTestCompile 'com.crittercism.dexmaker:dexmaker:1.4'
androidTestCompile 'com.crittercism.dexmaker:dexmaker-dx:1.4'
androidTestCompile 'com.crittercism.dexmaker:dexmaker-mockito:1.4'
annotationProcessor 'com.google.dagger:dagger-compiler:2.0.1'
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"
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
android:screenOrientation="portrait"
android:theme="@style/Theme.Default" />
<activity
android:name=".activity.account.EditAccountActivity"
android:name=".activity.account.edit.EditAccountActivity"
android:label="@string/title_activity_edit_account"
android:screenOrientation="portrait"
android:theme="@style/Theme.Default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,25 @@
import javax.inject.Inject;

public class SettingsActivity extends BaseBackActivity {
@SuppressWarnings("unused")
private static final String TAG = "SettingsActivity";
@SuppressWarnings("unused") private static final String TAG = "SettingsActivity";

@Override
protected int getContentViewId() {
@Override protected int getContentViewId() {
return R.layout.activity_settings;
}

@Override
protected void initViews() {
@Override protected void initViews() {
super.initViews();

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

public static class SettingsFragment extends PreferenceFragment {
@Inject
AccountController accountController;
@Inject
CurrencyController currencyController;
@Inject
PreferenceController preferenceController;

@Override
public void onCreate(Bundle savedInstanceState) {
@Inject AccountController accountController;
@Inject CurrencyController currencyController;
@Inject PreferenceController preferenceController;

@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

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

setupDefaultAccountPref();
setupDefaultCurrencyPref();
setupNonSubstitutionCurrencyPref();
setupDisplayPrecision();
setupAboutPref();
}

private void setupAboutPref() {
Preference preference = findPreference(getString(R.string.pref_about));
preference.setSummary(getString(R.string.about_summary, BuildConfig.VERSION_NAME,
Build.VERSION.RELEASE));
}

private void setupDefaultAccountPref() {
ListPreference defaultAccountPref = (ListPreference) findPreference(getString(R.string.pref_default_account));
ListPreference defaultAccountPref =
(ListPreference) findPreference(getString(R.string.pref_default_account));
defaultAccountPref.setOnPreferenceChangeListener(preferenceChangeListener);

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

@SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument")
private void setupDefaultCurrencyPref() {
ListPreference defaultCurrencyPref = (ListPreference) findPreference(getString(R.string.pref_default_currency));
@SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument") private void setupDefaultCurrencyPref() {
ListPreference defaultCurrencyPref =
(ListPreference) findPreference(getString(R.string.pref_default_currency));
defaultCurrencyPref.setOnPreferenceChangeListener(preferenceChangeListener);

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

@SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument")
private void setupDisplayPrecision() {
ListPreference displayPrecisionPref = (ListPreference) findPreference(getString(R.string.pref_display_precision));
@SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument") private void setupNonSubstitutionCurrencyPref() {
ListPreference nonSubstitutionCurrencyPref =
(ListPreference) findPreference(getString(R.string.pref_non_substitution_currency));
nonSubstitutionCurrencyPref.setOnPreferenceChangeListener(preferenceChangeListener);

List<String> currencyList = currencyController.readAll();
nonSubstitutionCurrencyPref.setEntries(currencyList.toArray(new String[0]));
nonSubstitutionCurrencyPref.setEntryValues(currencyList.toArray(new String[0]));

String nonSubstitutionCurrency = preferenceController.readNonSubstitutionCurrency();
nonSubstitutionCurrencyPref.setDefaultValue(nonSubstitutionCurrency);
nonSubstitutionCurrencyPref.setSummary(nonSubstitutionCurrency);
}

@SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument") private void setupDisplayPrecision() {
ListPreference displayPrecisionPref =
(ListPreference) findPreference(getString(R.string.pref_display_precision));
displayPrecisionPref.setOnPreferenceChangeListener(preferenceChangeListener);

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

private void setupAboutPref() {
Preference preference = findPreference(getString(R.string.pref_about));
preference.setSummary(getString(R.string.about_summary, BuildConfig.VERSION_NAME, Build.VERSION.RELEASE));
}

@SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument")
private String[] getEntries(List<Account> accountList) {
List<String> result = new ArrayList<>();
Expand All @@ -146,16 +152,15 @@ private String[] getEntryValues(List<Account> accountList) {
return result.toArray(new String[0]);
}

private Preference.OnPreferenceChangeListener preferenceChangeListener
= new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// Previously we could set summary to default value,
// but now it's needed to display selected entry
preference.setSummary("%s");
getActivity().setResult(RESULT_OK);
return true;
}
};
private Preference.OnPreferenceChangeListener preferenceChangeListener =
new Preference.OnPreferenceChangeListener() {
@Override public boolean onPreferenceChange(Preference preference, Object newValue) {
// Previously we could set summary to default value,
// but now it's needed to display selected entry
preference.setSummary("%s");
getActivity().setResult(RESULT_OK);
return true;
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import android.widget.ListView;

import com.blogspot.e_kanivets.moneytracker.R;
import com.blogspot.e_kanivets.moneytracker.activity.account.edit.EditAccountActivity;
import com.blogspot.e_kanivets.moneytracker.activity.base.BaseBackActivity;
import com.blogspot.e_kanivets.moneytracker.adapter.AccountAdapter;
import com.blogspot.e_kanivets.moneytracker.controller.data.AccountController;
import com.blogspot.e_kanivets.moneytracker.entity.data.Account;
import com.blogspot.e_kanivets.moneytracker.ui.presenter.AccountsSummaryPresenter;
import com.blogspot.e_kanivets.moneytracker.util.AnswersProxy;

Expand All @@ -20,36 +22,30 @@
import butterknife.OnItemClick;

public class AccountsActivity extends BaseBackActivity {
@SuppressWarnings("unused")
private static final String TAG = "AccountsActivity";
@SuppressWarnings("unused") private static final String TAG = "AccountsActivity";

private static final int REQUEST_ADD_ACCOUNT = 1;
private static final int REQUEST_TRANSFER = 2;
private static final int REQUEST_EDIT_ACCOUNT = 3;

@Inject
AccountController accountController;
@Inject AccountController accountController;

private AccountsSummaryPresenter summaryPresenter;

@BindView(R.id.list_view)
ListView listView;
@BindView(R.id.list_view) ListView listView;

@Override
protected int getContentViewId() {
@Override protected int getContentViewId() {
return R.layout.activity_accounts;
}

@Override
protected boolean initData() {
@Override protected boolean initData() {
boolean result = super.initData();
getAppComponent().inject(AccountsActivity.this);
summaryPresenter = new AccountsSummaryPresenter(AccountsActivity.this);
return result;
}

@Override
protected void initViews() {
@Override protected void initViews() {
super.initViews();

listView.addHeaderView(summaryPresenter.create());
Expand All @@ -58,14 +54,12 @@ protected void initViews() {
update();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
@Override public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_accounts, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
@Override public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_transfer:
makeTransfer();
Expand All @@ -76,28 +70,23 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
}

@OnItemClick(R.id.list_view)
public void onAccountClick(int position) {
Intent intent = new Intent(this, EditAccountActivity.class);
intent.putExtra(EditAccountActivity.KEY_ACCOUNT, accountController.readAll().get(position - 1));
startActivityForResult(intent, REQUEST_EDIT_ACCOUNT);
@OnItemClick(R.id.list_view) public void onAccountClick(int position) {
Account account = accountController.readAll().get(position - 1);
startActivityForResult(EditAccountActivity.Companion.newIntent(this, account), REQUEST_EDIT_ACCOUNT);
}

public void makeTransfer() {
AnswersProxy.get().logButton("Add Transfer");
startActivityForResult(new Intent(AccountsActivity.this, TransferActivity.class),
REQUEST_TRANSFER);
startActivityForResult(new Intent(AccountsActivity.this, TransferActivity.class), REQUEST_TRANSFER);
}

@OnClick(R.id.btn_add_account)
public void addAccount() {
@OnClick(R.id.btn_add_account) public void addAccount() {
AnswersProxy.get().logButton("Add Account");
Intent intent = new Intent(AccountsActivity.this, AddAccountActivity.class);
startActivityForResult(intent, REQUEST_ADD_ACCOUNT);
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (resultCode == AppCompatActivity.RESULT_OK) {
Expand Down
Loading

0 comments on commit 8c711f1

Please sign in to comment.