package co.smartreceipts.android.fragments.preferences;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;

import java.text.DecimalFormat;

import co.smartreceipts.android.R;
import wb.android.preferences.FloatSummaryEditTextPreference;

public class DefaultDistanceRatePreference extends FloatSummaryEditTextPreference {

	public DefaultDistanceRatePreference(Context context) {
		super(context);
	}

	public DefaultDistanceRatePreference(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public DefaultDistanceRatePreference(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	@Override
	public CharSequence getSummary() {
		if (TextUtils.isEmpty(getText())) { //Add a zero check
			return getContext().getString(R.string.pref_distance_rate_summaryOff);
		}
		else {
			try {
				float value = Float.parseFloat(getText());
				if (value <= 0) {
                    return getContext().getString(R.string.pref_distance_rate_summaryOff);
				}
				DecimalFormat decimalFormat = new DecimalFormat();
				decimalFormat.setMaximumFractionDigits(2);
				decimalFormat.setMinimumFractionDigits(2);
				decimalFormat.setGroupingUsed(false);
				return getContext().getString(R.string.pref_distance_rate_summaryOn, decimalFormat.format(value));
			} catch (NumberFormatException e) {
				return getContext().getString(R.string.pref_distance_rate_summaryOff);
			}
		}
	}
}

@@ -364,16 +364,69 @@
 ence %7B%0A%0A
+    private static final int DECIMAL_PRECISION = 5;%0A%0A
 %09public 
@@ -1188,33 +1188,49 @@
 mFractionDigits(
-2
+DECIMAL_PRECISION
 );%0A%09%09%09%09decimalFo
@@ -1263,9 +1263,25 @@
 its(
-2
+DECIMAL_PRECISION
 );%0A%09

Updated the decimal precision to for distance rate