Calculation fixable messages

This commit is contained in:
Sergey Solovyev 2012-11-17 23:53:56 +04:00
parent 1ab714b044
commit ef11120244
14 changed files with 192 additions and 59 deletions

View File

@ -20,6 +20,20 @@ public enum CalculatorFixableError {
public void fix() { public void fix() {
CalculatorLocatorImpl.getInstance().getPreferenceService().setAngleUnits(AngleUnit.rad); CalculatorLocatorImpl.getInstance().getPreferenceService().setAngleUnits(AngleUnit.rad);
} }
},
preferred_numeral_base() {
@Override
public void fix() {
CalculatorLocatorImpl.getInstance().getPreferenceService().setPreferredNumeralBase();
}
},
preferred_angle_units() {
@Override
public void fix() {
CalculatorLocatorImpl.getInstance().getPreferenceService().setPreferredAngleUnits();
}
}; };
@NotNull @NotNull

View File

@ -163,6 +163,8 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener {
@NotNull String expression, @NotNull String expression,
@Nullable MessageRegistry mr) { @Nullable MessageRegistry mr) {
CalculatorLocatorImpl.getInstance().getPreferenceService().checkPreferredPreferences(false);
PreparedExpression preparedExpression = null; PreparedExpression preparedExpression = null;
try { try {

View File

@ -1,6 +1,7 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import jscl.AngleUnit; import jscl.AngleUnit;
import jscl.NumeralBase;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@ -10,5 +11,11 @@ import org.jetbrains.annotations.NotNull;
*/ */
public interface CalculatorPreferenceService { public interface CalculatorPreferenceService {
void setPreferredAngleUnits();
void setAngleUnits(@NotNull AngleUnit angleUnit); void setAngleUnits(@NotNull AngleUnit angleUnit);
void setPreferredNumeralBase();
void setNumeralBase(@NotNull NumeralBase numeralBase);
void checkPreferredPreferences(boolean force);
} }

View File

@ -8,13 +8,15 @@
<TextView a:id="@+id/calculation_messages_text_view" <TextView a:id="@+id/calculation_messages_text_view"
a:layout_width="0dp" a:layout_width="0dp"
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:layout_weight="5"/> a:layout_weight="5"
a:layout_gravity="top|left"/>
<Button <Button
a:id="@+id/fix_button" a:id="@+id/fix_button"
a:layout_width="0dp" a:layout_width="0dp"
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:layout_weight="1" a:layout_weight="1"
a:layout_gravity="top|right"
a:text="@string/fix" /> a:text="@string/fix" />
</LinearLayout> </LinearLayout>

View File

@ -257,4 +257,12 @@
</string> </string>
<string name="fix">Fix</string> <string name="fix">Fix</string>
<string name="p_preferred_numeral_base_title">Preferred numeral base</string>
<string name="p_preferred_numeral_base_summary">Defines the preferred numeral base</string>
<string name="preferred_numeral_base_message">Preferred numeral base \'%1$s\' differs from current numeral base \'%2$s\'. Forgot to change back?</string>
<string name="p_preferred_angle_units_title">Preferred angle units</string>
<string name="p_preferred_angle_units_summary">Defines the preferred angle units</string>
<string name="preferred_angle_units_message">Preferred angle units \'%1$s\' differs from current angle units \'%2$s\'. Forgot to change back?</string>
</resources> </resources>

View File

@ -32,12 +32,26 @@
a:summary="@string/c_calc_grouping_separator_summary" a:summary="@string/c_calc_grouping_separator_summary"
a:entryValues="@array/p_grouping_separator_values"/> a:entryValues="@array/p_grouping_separator_values"/>
<ListPreference
a:key="preferred_angle_units"
a:title="@string/p_preferred_angle_units_title"
a:summary="@string/p_preferred_angle_units_summary"
a:entries="@array/p_angle_units_names"
a:entryValues="@array/p_angle_units" />
<ListPreference a:key="@string/p_calc_angle_units_key" <ListPreference a:key="@string/p_calc_angle_units_key"
a:title="@string/c_calc_angle_units" a:title="@string/c_calc_angle_units"
a:entries="@array/p_angle_units_names" a:entries="@array/p_angle_units_names"
a:summary="@string/c_angle_units_summary" a:summary="@string/c_angle_units_summary"
a:entryValues="@array/p_angle_units"/> a:entryValues="@array/p_angle_units"/>
<ListPreference
a:key="preferred_numeral_base"
a:title="@string/p_preferred_numeral_base_title"
a:summary="@string/p_preferred_numeral_base_summary"
a:entries="@array/p_numeral_bases_names"
a:entryValues="@array/p_numeral_bases" />
<ListPreference a:key="@string/p_calc_numeral_bases_key" <ListPreference a:key="@string/p_calc_numeral_bases_key"
a:title="@string/c_calc_numeral_bases" a:title="@string/c_calc_numeral_bases"
a:entries="@array/p_numeral_bases_names" a:entries="@array/p_numeral_bases_names"

View File

@ -4,11 +4,15 @@ import android.app.Application;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import jscl.AngleUnit; import jscl.AngleUnit;
import jscl.NumeralBase;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.msg.AndroidMessage; import org.solovyev.android.msg.AndroidMessage;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
import java.util.ArrayList;
import java.util.List;
/** /**
* User: serso * User: serso
* Date: 11/17/12 * Date: 11/17/12
@ -16,6 +20,9 @@ import org.solovyev.common.msg.MessageType;
*/ */
public class AndroidCalculatorPreferenceService implements CalculatorPreferenceService { public class AndroidCalculatorPreferenceService implements CalculatorPreferenceService {
// ont hour
private static final Long PREFERRED_PREFS_INTERVAL_TIME = 1000L * 60L * 60L;
@NotNull @NotNull
private final Application application; private final Application application;
@ -23,6 +30,46 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS
this.application = application; this.application = application;
} }
@Override
public void checkPreferredPreferences(boolean force) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application);
final Long currentTime = System.currentTimeMillis();
if ( force || isTimeForCheck(currentTime, preferences)) {
final NumeralBase preferredNumeralBase = CalculatorPreferences.Calculations.preferredNumeralBase.getPreference(preferences);
final NumeralBase numeralBase = AndroidCalculatorEngine.Preferences.numeralBase.getPreference(preferences);
final AngleUnit preferredAngleUnits = CalculatorPreferences.Calculations.preferredAngleUnits.getPreference(preferences);
final AngleUnit angleUnits = AndroidCalculatorEngine.Preferences.angleUnit.getPreference(preferences);
final List<CalculatorFixableMessage> messages = new ArrayList<CalculatorFixableMessage>(2);
if ( numeralBase != preferredNumeralBase ) {
messages.add(new CalculatorFixableMessage(application.getString(R.string.preferred_numeral_base_message, preferredNumeralBase.name(), numeralBase.name()), MessageType.warning, CalculatorFixableError.preferred_numeral_base));
}
if ( angleUnits != preferredAngleUnits ) {
messages.add(new CalculatorFixableMessage(application.getString(R.string.preferred_angle_units_message, preferredAngleUnits.name(), angleUnits.name()), MessageType.warning, CalculatorFixableError.preferred_angle_units));
}
CalculatorMessagesDialog.showDialog(messages, application);
CalculatorPreferences.Calculations.lastPreferredPreferencesCheck.putPreference(preferences, currentTime);
}
}
private boolean isTimeForCheck(@NotNull Long currentTime, @NotNull SharedPreferences preferences) {
final Long lastPreferredPreferencesCheckTime = CalculatorPreferences.Calculations.lastPreferredPreferencesCheck.getPreference(preferences);
return currentTime - lastPreferredPreferencesCheckTime > PREFERRED_PREFS_INTERVAL_TIME;
}
@Override
public void setPreferredAngleUnits() {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application);
setAngleUnits(CalculatorPreferences.Calculations.preferredAngleUnits.getPreference(preferences));
}
@Override @Override
public void setAngleUnits(@NotNull AngleUnit angleUnit) { public void setAngleUnits(@NotNull AngleUnit angleUnit) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application);
@ -30,4 +77,18 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS
CalculatorLocatorImpl.getInstance().getNotifier().showMessage(new AndroidMessage(R.string.c_angle_units_changed_to, MessageType.info, application, angleUnit.name())); CalculatorLocatorImpl.getInstance().getNotifier().showMessage(new AndroidMessage(R.string.c_angle_units_changed_to, MessageType.info, application, angleUnit.name()));
} }
@Override
public void setPreferredNumeralBase() {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application);
setNumeralBase(CalculatorPreferences.Calculations.preferredNumeralBase.getPreference(preferences));
}
@Override
public void setNumeralBase(@NotNull NumeralBase numeralBase) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application);
AndroidCalculatorEngine.Preferences.numeralBase.putPreference(preferences, numeralBase);
CalculatorLocatorImpl.getInstance().getNotifier().showMessage(new AndroidMessage(R.string.c_numeral_base_changed_to, MessageType.info, application, numeralBase.name()));
}
} }

View File

@ -163,7 +163,7 @@ public class CalculatorActivityLauncher {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if ( CalculatorPreferences.Calculations.showCalculationMessagesDialog.getPreference(prefs) ) { if ( CalculatorPreferences.Calculations.showCalculationMessagesDialog.getPreference(prefs) ) {
CalculatorMessagesDialog.showDialog(messages, context); CalculatorMessagesDialog.showDialogForMessages(messages, context);
} }
} }
} }

View File

@ -126,6 +126,8 @@ public class CalculatorApplication extends android.app.Application {
CalculatorLocatorImpl.getInstance().getLogger().debug(TAG, "Application started!"); CalculatorLocatorImpl.getInstance().getLogger().debug(TAG, "Application started!");
CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage(TAG, "Application started!"); CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage(TAG, "Application started!");
CalculatorLocatorImpl.getInstance().getPreferenceService().checkPreferredPreferences(true);
} }
private void setTheme(@NotNull SharedPreferences preferences) { private void setTheme(@NotNull SharedPreferences preferences) {

View File

@ -10,7 +10,6 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.RemoteViews; import android.widget.RemoteViews;
import android.widget.Toast;
import jscl.AngleUnit; import jscl.AngleUnit;
import jscl.NumeralBase; import jscl.NumeralBase;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -19,7 +18,6 @@ import org.solovyev.android.AndroidUtils;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.calculator.view.AngleUnitsButton; import org.solovyev.android.calculator.view.AngleUnitsButton;
import org.solovyev.android.calculator.view.NumeralBasesButton; import org.solovyev.android.calculator.view.NumeralBasesButton;
import org.solovyev.android.view.drag.DirectionDragButton;
import org.solovyev.android.view.drag.DragButton; import org.solovyev.android.view.drag.DragButton;
import org.solovyev.android.view.drag.DragDirection; import org.solovyev.android.view.drag.DragDirection;
import org.solovyev.android.view.drag.SimpleOnDragListener; import org.solovyev.android.view.drag.SimpleOnDragListener;
@ -217,9 +215,7 @@ public final class CalculatorButtons {
final NumeralBase oldNumeralBase = AndroidCalculatorEngine.Preferences.numeralBase.getPreference(preferences); final NumeralBase oldNumeralBase = AndroidCalculatorEngine.Preferences.numeralBase.getPreference(preferences);
if (oldNumeralBase != numeralBase) { if (oldNumeralBase != numeralBase) {
AndroidCalculatorEngine.Preferences.numeralBase.putPreference(preferences, numeralBase); CalculatorLocatorImpl.getInstance().getPreferenceService().setNumeralBase(numeralBase);
Toast.makeText(context, context.getString(R.string.c_numeral_base_changed_to, numeralBase.name()), Toast.LENGTH_LONG).show();
} }
result = true; result = true;

View File

@ -12,27 +12,27 @@ import org.solovyev.common.msg.MessageType;
* Date: 11/17/12 * Date: 11/17/12
* Time: 6:54 PM * Time: 6:54 PM
*/ */
public class CalculationMessage implements Parcelable { public class CalculatorFixableMessage implements Parcelable {
public static final Creator<CalculationMessage> CREATOR = new Creator<CalculationMessage>() { public static final Creator<CalculatorFixableMessage> CREATOR = new Creator<CalculatorFixableMessage>() {
@Override @Override
public CalculationMessage createFromParcel(@NotNull Parcel in) { public CalculatorFixableMessage createFromParcel(@NotNull Parcel in) {
return CalculationMessage.fromParcel(in); return CalculatorFixableMessage.fromParcel(in);
} }
@Override @Override
public CalculationMessage[] newArray(int size) { public CalculatorFixableMessage[] newArray(int size) {
return new CalculationMessage[size]; return new CalculatorFixableMessage[size];
} }
}; };
@NotNull @NotNull
private static CalculationMessage fromParcel(@NotNull Parcel in) { private static CalculatorFixableMessage fromParcel(@NotNull Parcel in) {
final String message = in.readString(); final String message = in.readString();
final MessageType messageType = (MessageType) in.readSerializable(); final MessageType messageType = (MessageType) in.readSerializable();
final CalculatorFixableError fixableError = (CalculatorFixableError) in.readSerializable(); final CalculatorFixableError fixableError = (CalculatorFixableError) in.readSerializable();
return new CalculationMessage(message, messageType, fixableError); return new CalculatorFixableMessage(message, messageType, fixableError);
} }
@NotNull @NotNull
@ -44,15 +44,15 @@ public class CalculationMessage implements Parcelable {
@Nullable @Nullable
private final CalculatorFixableError fixableError; private final CalculatorFixableError fixableError;
public CalculationMessage(@NotNull Message message) { public CalculatorFixableMessage(@NotNull Message message) {
this.message = message.getLocalizedMessage(); this.message = message.getLocalizedMessage();
this.messageType = message.getMessageType(); this.messageType = message.getMessageType();
this.fixableError = CalculatorFixableError.getErrorByMessageCode(message.getMessageCode()); this.fixableError = CalculatorFixableError.getErrorByMessageCode(message.getMessageCode());
} }
public CalculationMessage(@NotNull String message, public CalculatorFixableMessage(@NotNull String message,
@NotNull MessageType messageType, @NotNull MessageType messageType,
@Nullable CalculatorFixableError fixableError) { @Nullable CalculatorFixableError fixableError) {
this.message = message; this.message = message;
this.messageType = messageType; this.messageType = messageType;
this.fixableError = fixableError; this.fixableError = fixableError;

View File

@ -31,7 +31,7 @@ public class CalculatorMessagesDialog extends SherlockActivity {
private static final String INPUT = "input"; private static final String INPUT = "input";
@NotNull @NotNull
private Input input = new Input(Collections.<CalculationMessage>emptyList()); private Input input = new Input(Collections.<CalculatorFixableMessage>emptyList());
public CalculatorMessagesDialog() { public CalculatorMessagesDialog() {
} }
@ -40,7 +40,7 @@ public class CalculatorMessagesDialog extends SherlockActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.calculation_messages_dialog); setContentView(R.layout.calculator_messages_dialog);
final Intent intent = getIntent(); final Intent intent = getIntent();
if (intent != null) { if (intent != null) {
@ -77,9 +77,9 @@ public class CalculatorMessagesDialog extends SherlockActivity {
final LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final List<CalculationMessage> messages = input.getMessages(); final List<CalculatorFixableMessage> messages = input.getMessages();
for (final CalculationMessage message : messages) { for (final CalculatorFixableMessage message : messages) {
final View view = layoutInflater.inflate(R.layout.calculation_messages_dialog_message, null); final View view = layoutInflater.inflate(R.layout.calculator_messages_dialog_message, null);
final TextView calculationMessagesTextView = (TextView) view.findViewById(R.id.calculation_messages_text_view); final TextView calculationMessagesTextView = (TextView) view.findViewById(R.id.calculation_messages_text_view);
calculationMessagesTextView.setText(message.getMessage()); calculationMessagesTextView.setText(message.getMessage());
@ -91,26 +91,7 @@ public class CalculatorMessagesDialog extends SherlockActivity {
fixButton.setOnClickListener(null); fixButton.setOnClickListener(null);
} else { } else {
fixButton.setVisibility(View.VISIBLE); fixButton.setVisibility(View.VISIBLE);
fixButton.setOnClickListener(new View.OnClickListener() { fixButton.setOnClickListener(new FixErrorOnClickListener(messages, message));
@Override
public void onClick(View v) {
final List<CalculationMessage> filteredMessages = new ArrayList<CalculationMessage>(messages.size() - 1);
for (CalculationMessage calculationMessage : messages) {
if ( calculationMessage.getFixableError() == null || calculationMessage.getFixableError() != message.getFixableError() ) {
filteredMessages.add(message);
}
}
fixableError.fix();
if (!filteredMessages.isEmpty()) {
CalculatorMessagesDialog.this.input = new Input(filteredMessages);
onInputChanged();
} else {
CalculatorMessagesDialog.this.finish();
}
}
});
} }
viewGroup.addView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); viewGroup.addView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
@ -132,7 +113,7 @@ public class CalculatorMessagesDialog extends SherlockActivity {
********************************************************************** **********************************************************************
*/ */
public static void showDialog(@NotNull List<Message> messages, @NotNull Context context) { public static void showDialogForMessages(@NotNull List<Message> messages, @NotNull Context context) {
if (!messages.isEmpty()) { if (!messages.isEmpty()) {
final Intent intent = new Intent(context, CalculatorMessagesDialog.class); final Intent intent = new Intent(context, CalculatorMessagesDialog.class);
@ -143,6 +124,17 @@ public class CalculatorMessagesDialog extends SherlockActivity {
} }
} }
public static void showDialog(@NotNull List<CalculatorFixableMessage> messages, @NotNull Context context) {
if (!messages.isEmpty()) {
final Intent intent = new Intent(context, CalculatorMessagesDialog.class);
intent.putExtra(INPUT, new Input(messages));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
private static final class Input implements Parcelable { private static final class Input implements Parcelable {
public static final Creator<Input> CREATOR = new Creator<Input>() { public static final Creator<Input> CREATOR = new Creator<Input>() {
@ -159,21 +151,21 @@ public class CalculatorMessagesDialog extends SherlockActivity {
@NotNull @NotNull
private static Input fromParcel(@NotNull Parcel in) { private static Input fromParcel(@NotNull Parcel in) {
final List<CalculationMessage> messages = new ArrayList<CalculationMessage>(); final List<CalculatorFixableMessage> messages = new ArrayList<CalculatorFixableMessage>();
in.readTypedList(messages, CalculationMessage.CREATOR); in.readTypedList(messages, CalculatorFixableMessage.CREATOR);
return new Input(messages); return new Input(messages);
} }
@NotNull @NotNull
private List<CalculationMessage> messages = new ArrayList<CalculationMessage>(); private List<CalculatorFixableMessage> messages = new ArrayList<CalculatorFixableMessage>();
private Input(@NotNull List<CalculationMessage> messages) { private Input(@NotNull List<CalculatorFixableMessage> messages) {
this.messages = messages; this.messages = messages;
} }
@NotNull @NotNull
public List<CalculationMessage> getMessages() { public List<CalculatorFixableMessage> getMessages() {
return messages; return messages;
} }
@ -189,13 +181,49 @@ public class CalculatorMessagesDialog extends SherlockActivity {
@NotNull @NotNull
public static Input fromMessages(@NotNull List<Message> messages) { public static Input fromMessages(@NotNull List<Message> messages) {
final List<CalculationMessage> stringMessages = new ArrayList<CalculationMessage>(messages.size()); final List<CalculatorFixableMessage> stringMessages = new ArrayList<CalculatorFixableMessage>(messages.size());
for (Message message : messages) { for (Message message : messages) {
stringMessages.add(new CalculationMessage(message)); stringMessages.add(new CalculatorFixableMessage(message));
} }
return new Input(stringMessages); return new Input(stringMessages);
} }
} }
private class FixErrorOnClickListener implements View.OnClickListener {
@NotNull
private final List<CalculatorFixableMessage> messages;
@NotNull
private final CalculatorFixableMessage currentMessage;
public FixErrorOnClickListener(@NotNull List<CalculatorFixableMessage> messages,
@NotNull CalculatorFixableMessage message) {
this.messages = messages;
this.currentMessage = message;
}
@Override
public void onClick(View v) {
final List<CalculatorFixableMessage> filteredMessages = new ArrayList<CalculatorFixableMessage>(messages.size() - 1);
for (CalculatorFixableMessage message : messages) {
if ( message.getFixableError() == null ) {
filteredMessages.add(message);
} else if ( message.getFixableError() != currentMessage.getFixableError() ) {
filteredMessages.add(message);
}
}
currentMessage.getFixableError().fix();
if (!filteredMessages.isEmpty()) {
CalculatorMessagesDialog.this.input = new Input(filteredMessages);
onInputChanged();
} else {
CalculatorMessagesDialog.this.finish();
}
}
}
} }

View File

@ -8,10 +8,7 @@ import org.solovyev.android.AndroidUtils;
import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.calculator.plot.GraphLineColor; import org.solovyev.android.calculator.plot.GraphLineColor;
import org.solovyev.android.prefs.BooleanPreference; import org.solovyev.android.prefs.*;
import org.solovyev.android.prefs.IntegerPreference;
import org.solovyev.android.prefs.Preference;
import org.solovyev.android.prefs.StringPreference;
import org.solovyev.android.view.VibratorContainer; import org.solovyev.android.view.VibratorContainer;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
@ -36,8 +33,9 @@ public final class CalculatorPreferences {
public static final Preference<Boolean> calculateOnFly = new BooleanPreference("calculations_calculate_on_fly", true); public static final Preference<Boolean> calculateOnFly = new BooleanPreference("calculations_calculate_on_fly", true);
public static final Preference<Boolean> showCalculationMessagesDialog = new BooleanPreference("show_calculation_messages_dialog", true); public static final Preference<Boolean> showCalculationMessagesDialog = new BooleanPreference("show_calculation_messages_dialog", true);
public static final Preference<NumeralBase> preferredNumeralBase = StringPreference.newInstance("preferred_numeral_base", NumeralBase.dec, NumeralBase.class); public static final Preference<NumeralBase> preferredNumeralBase = StringPreference.newInstance("preferred_numeral_base", AndroidCalculatorEngine.Preferences.numeralBase.getDefaultValue(), NumeralBase.class);
public static final Preference<AngleUnit> preferredAngleUnit = StringPreference.newInstance("preferred_angle_units", AngleUnit.deg, AngleUnit.class); public static final Preference<AngleUnit> preferredAngleUnits = StringPreference.newInstance("preferred_angle_units", AndroidCalculatorEngine.Preferences.angleUnit.getDefaultValue(), AngleUnit.class);
public static final Preference<Long> lastPreferredPreferencesCheck = new LongPreference("preferred_preferences_check_time", 0L);
} }
@ -183,8 +181,9 @@ public final class CalculatorPreferences {
applyDefaultPreference(preferences, Graph.lineColorReal); applyDefaultPreference(preferences, Graph.lineColorReal);
applyDefaultPreference(preferences, History.showIntermediateCalculations); applyDefaultPreference(preferences, History.showIntermediateCalculations);
applyDefaultPreference(preferences, Calculations.calculateOnFly); applyDefaultPreference(preferences, Calculations.calculateOnFly);
applyDefaultPreference(preferences, Calculations.preferredAngleUnit); applyDefaultPreference(preferences, Calculations.preferredAngleUnits);
applyDefaultPreference(preferences, Calculations.preferredNumeralBase); applyDefaultPreference(preferences, Calculations.preferredNumeralBase);
applyDefaultPreference(preferences, Calculations.lastPreferredPreferencesCheck);
// renew value after each application start // renew value after each application start