Skip to content

Commit

Permalink
Update version strings for v2.0.3 release
Browse files Browse the repository at this point in the history
Fix: unable to enter decimals in split editor
Fix: split type toggle not working in split editor
Remove transaction exported flag from XML
Add app/system version to UserVoice feedback
  • Loading branch information
codinguser committed Nov 21, 2015
1 parent ebf2e83 commit a3ad8c2
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 38 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Change Log
===============================================================================
Version 2.0.3 *(2015-11-21)*
----------------------------
* Fixed: Unable to enter decimal amounts in split editor
* Fixed: Split editor shows wrong imbalance when editing transaction
* Fixed: Auto-backups not correctly generated

Version 2.0.2 *(2015-11-20)*
----------------------------
* Fixed: Exporting to external service does not work in some devices
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ apply plugin: 'io.fabric'

def versionMajor = 2
def versionMinor = 0
def versionPatch = 2
def versionBuild = 2
def versionPatch = 3
def versionBuild = 0

def buildTime() {
def df = new SimpleDateFormat("yyyyMMdd HH:mm 'UTC'")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,6 @@ public void testDefaultTransactionType(){

onView(withId(R.id.fab_create_transaction)).perform(click());
onView(withId(R.id.input_transaction_type)).check(matches(allOf(isChecked(), withText(R.string.label_spend))));
Espresso.pressBack();
//now validate the other case

setDefaultTransactionType(TransactionType.DEBIT);

onView(withId(R.id.fab_create_transaction)).perform(click());
onView(withId(R.id.input_transaction_type)).check(matches(allOf(not(isChecked()), withText(R.string.label_receive))));
Espresso.pressBack();
}

private void setDefaultTransactionType(TransactionType type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
import android.os.Build;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.util.Log;
Expand All @@ -33,6 +34,7 @@
import com.uservoice.uservoicesdk.Config;
import com.uservoice.uservoicesdk.UserVoice;

import org.gnucash.android.BuildConfig;
import org.gnucash.android.R;
import org.gnucash.android.db.AccountsDbAdapter;
import org.gnucash.android.db.CommoditiesDbAdapter;
Expand Down Expand Up @@ -108,6 +110,9 @@ public void onCreate(){
Config config = new Config("gnucash.uservoice.com");
config.setTopicId(107400);
config.setForumId(320493);
config.putUserTrait("app_version_name", BuildConfig.VERSION_NAME);
config.putUserTrait("app_version_code", BuildConfig.VERSION_CODE);
config.putUserTrait("android_version", Build.VERSION.RELEASE);
// config.identifyUser("USER_ID", "User Name", "email@example.com");
UserVoice.init(config, this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,11 @@ private void exportTransactions(XmlSerializer xmlSerializer, boolean exportTempl
ArrayList<String> slotValue = new ArrayList<>();

String notes = cursor.getString(cursor.getColumnIndexOrThrow("trans_notes"));
boolean exported = cursor.getInt(cursor.getColumnIndexOrThrow("trans_exported")) == 1;
if (notes != null && notes.length() > 0) {
slotKey.add(GncXmlHelper.KEY_NOTES);
slotType.add(GncXmlHelper.ATTR_VALUE_STRING);
slotValue.add(notes);
}
if (!exported) {
slotKey.add(GncXmlHelper.KEY_EXPORTED);
slotType.add(GncXmlHelper.ATTR_VALUE_STRING);
slotValue.add("false");
}

String scheduledActionUID = cursor.getString(cursor.getColumnIndexOrThrow("trans_from_sched_action"));
if (scheduledActionUID != null && !scheduledActionUID.isEmpty()){
Expand Down Expand Up @@ -826,14 +820,14 @@ public String getExportMimeType(){
*/
public static boolean createBackup(){
try {
new File(BACKUP_FOLDER_PATH).mkdirs();
FileOutputStream fileOutputStream = new FileOutputStream(getBackupFilePath());
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(bufferedOutputStream);
OutputStreamWriter writer = new OutputStreamWriter(gzipOutputStream);

ExportParams params = new ExportParams(ExportFormat.XML);
new GncXmlExporter(params).generateExport(writer);
writer.close();
return true;
} catch (IOException | ExporterException e) {
Crashlytics.logException(e);
Expand All @@ -849,6 +843,7 @@ public static boolean createBackup(){
* @see #BACKUP_FOLDER_PATH
*/
private static String getBackupFilePath(){
new File(BACKUP_FOLDER_PATH).mkdirs();
return BACKUP_FOLDER_PATH + buildExportFilename(ExportFormat.XML) + ".zip";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ protected Boolean doInBackground(Uri... uris) {
GncXmlImporter.parse(accountInputStream);
} catch (Exception exception){
Log.e(ImportAsyncTask.class.getName(), "" + exception.getMessage());
Crashlytics.log("Could not open: " + uris[0].toString());
Crashlytics.logException(exception);
exception.printStackTrace();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,13 @@ public void onConfigurationChanged(Configuration newConfig) {

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (!mDrawerLayout.isDrawerOpen(mNavigationView))
mDrawerLayout.openDrawer(mNavigationView);
else
mDrawerLayout.closeDrawer(mNavigationView);
if (item.getItemId() == android.R.id.home){
if (!mDrawerLayout.isDrawerOpen(mNavigationView))
mDrawerLayout.openDrawer(mNavigationView);
else
mDrawerLayout.closeDrawer(mNavigationView);
return true;
}

return super.onOptionsItemSelected(item);
}
Expand All @@ -133,6 +136,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
* Handler for the navigation drawer items
* */
protected void onDrawerMenuItemClicked(int itemId) {

switch (itemId){
case R.id.nav_item_open: { //Open... files
AccountsActivity.startXmlFileChooser(this);
Expand All @@ -148,8 +152,13 @@ protected void onDrawerMenuItemClicked(int itemId) {
}
break;

case R.id.nav_item_reports:
startActivity(new Intent(this, ReportsActivity.class));
case R.id.nav_item_reports: {
if (!(this instanceof AccountsActivity) || !(this instanceof ReportsActivity))
this.finish();
Intent intent = new Intent(this, ReportsActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
}
break;

case R.id.nav_item_scheduled_actions: { //show scheduled transactions
Expand All @@ -159,9 +168,8 @@ protected void onDrawerMenuItemClicked(int itemId) {
}
break;

case R.id.nav_item_export:{
case R.id.nav_item_export:
AccountsActivity.openExportFragment(this);
}
break;

case R.id.nav_item_settings: //Settings activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
Expand All @@ -42,6 +43,11 @@
import android.widget.TextView;
import android.widget.Toast;

import com.crashlytics.android.Crashlytics;

import net.objecthunter.exp4j.Expression;
import net.objecthunter.exp4j.ExpressionBuilder;

import org.gnucash.android.R;
import org.gnucash.android.db.AccountsDbAdapter;
import org.gnucash.android.db.CommoditiesDbAdapter;
Expand Down Expand Up @@ -140,6 +146,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
if (!splitList.isEmpty()) {
//aha! there are some splits. Let's load those instead
loadSplitViews(splitList);
mImbalanceWatcher.afterTextChanged(null);
} else {
final String currencyCode = mAccountsDbAdapter.getAccountCurrencyCode(mAccountUID);
Split split = new Split(new Money(mBaseAmount.abs(), Commodity.getInstance(currencyCode)), mAccountUID);
Expand All @@ -149,9 +156,9 @@ public void onActivityCreated(Bundle savedInstanceState) {
View view = addSplitView(split);
view.findViewById(R.id.input_accounts_spinner).setEnabled(false);
view.findViewById(R.id.btn_remove_split).setVisibility(View.GONE);
TransactionsActivity.displayBalance(mImbalanceTextView, new Money(mBaseAmount.negate(), mCommodity));
}

TransactionsActivity.displayBalance(mImbalanceTextView, new Money(mBaseAmount.negate(), mCommodity));
}

@Override
Expand Down Expand Up @@ -287,14 +294,43 @@ public void onClick(View view) {
}

accountsSpinner.setOnItemSelectedListener(new SplitAccountListener(splitTypeSwitch, this));
splitTypeSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
splitTypeSwitch.addOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mImbalanceWatcher.afterTextChanged(null);
}
});
splitAmountEditText.addTextChangedListener(mImbalanceWatcher);
}

/**
* Returns the value of the amount in the splitAmountEditText field without setting the value to the view
* <p>If the expression in the view is currently incomplete or invalid, null is returned.
* This method is used primarily for computing the imbalance</p>
* @return Value in the split item amount field, or {@link BigDecimal#ZERO} if the expression is empty or invalid
*/
public BigDecimal getAmountValue(){
String amountString = splitAmountEditText.getCleanString();
if (amountString.isEmpty())
return BigDecimal.ZERO;

ExpressionBuilder expressionBuilder = new ExpressionBuilder(amountString);
Expression expression;

try {
expression = expressionBuilder.build();
} catch (RuntimeException e) {
return BigDecimal.ZERO;
}

if (expression != null && expression.validate().isValid()) {
return new BigDecimal(expression.evaluate());
} else {
Log.v(SplitEditorFragment.this.getClass().getSimpleName(),
"Incomplete expression for updating imbalance: " + expression);
return BigDecimal.ZERO;
}
}
}

/**
Expand Down Expand Up @@ -406,16 +442,12 @@ public void afterTextChanged(Editable editable) {

for (View splitItem : mSplitItemViewList) {
SplitViewHolder viewHolder = (SplitViewHolder) splitItem.getTag();
viewHolder.splitAmountEditText.removeTextChangedListener(this);
BigDecimal amount = viewHolder.splitAmountEditText.getValue();
if (amount != null) {
if (viewHolder.splitTypeSwitch.isChecked()) {
imbalance = imbalance.subtract(amount);
} else {
imbalance = imbalance.add(amount);
}
BigDecimal amount = viewHolder.getAmountValue().abs();
if (viewHolder.splitTypeSwitch.isChecked()) {
imbalance = imbalance.subtract(amount);
} else {
imbalance = imbalance.add(amount);
}
viewHolder.splitAmountEditText.addTextChangedListener(this);
}

TransactionsActivity.displayBalance(mImbalanceTextView, new Money(imbalance.negate(), mCommodity));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ private void initializeViewsWithTransaction(){
//when autocompleting, only change the amount if the user has not manually changed it already
mAmountEditText.setValue(mTransaction.getBalance(mAccountUID).asBigDecimal());
}
mCurrencyTextView.setText(mTransaction.getCurrency().getSymbol(Locale.getDefault()));
mCurrencyTextView.setText(mTransaction.getCurrency().getSymbol());
mNotesEditText.setText(mTransaction.getNote());
mDateTextView.setText(DATE_FORMATTER.format(mTransaction.getTimeMillis()));
mTimeTextView.setText(TIME_FORMATTER.format(mTransaction.getTimeMillis()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.gnucash.android.model.TransactionType;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
* A special type of {@link android.widget.ToggleButton} which displays the appropriate CREDIT/DEBIT labels for the
Expand All @@ -38,6 +40,8 @@
public class TransactionTypeSwitch extends SwitchCompat {
private AccountType mAccountType = AccountType.EXPENSE;

List<OnCheckedChangeListener> mOnCheckedChangeListeners = new ArrayList<>();

public TransactionTypeSwitch(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
Expand Down Expand Up @@ -113,6 +117,14 @@ public void setAmountFormattingListener(CalculatorEditText amoutView, TextView c
setOnCheckedChangeListener(new OnTypeChangedListener(amoutView, currencyTextView));
}

/**
* Add listeners to be notified when the checked status changes
* @param checkedChangeListener Checked change listener
*/
public void addOnCheckedChangeListener(OnCheckedChangeListener checkedChangeListener){
mOnCheckedChangeListeners.add(checkedChangeListener);
}

/**
* Toggles the button checked based on the movement caused by the transaction type for the specified account
* @param transactionType {@link org.gnucash.android.model.TransactionType} of the split
Expand All @@ -123,7 +135,7 @@ public void setChecked(TransactionType transactionType){

/**
* Returns the account type associated with this button
* @return
* @return Type of account
*/
public AccountType getAccountType(){
return mAccountType;
Expand Down Expand Up @@ -173,6 +185,10 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
}

}

for (OnCheckedChangeListener listener : mOnCheckedChangeListeners) {
listener.onCheckedChanged(compoundButton, isChecked);
}
}
}
}

0 comments on commit a3ad8c2

Please sign in to comment.