Merge branch 'master' into dev
Conflicts: android-app-core/res/values-de/text_vars.xml android-app-core/res/values-es/text_about.xml android-app-core/res/values-es/text_functions.xml android-app-core/res/values-es/text_operators.xml android-app-core/res/values-es/text_strings.xml android-app-core/res/values-es/text_vars.xml android-app-core/res/values-it/text_about.xml android-app-core/res/values-it/text_functions.xml android-app-core/res/values-it/text_operators.xml android-app-core/res/values-it/text_strings.xml android-app-core/res/values-it/text_vars.xml android-app-core/res/values-pl/text_about.xml android-app-core/res/values-pl/text_operators.xml android-app-core/res/values-pl/text_preferences.xml android-app-core/res/values-pl/text_strings.xml android-app-core/res/values-pl/text_vars.xml android-app-core/res/values-ru/text_about.xml android-app-core/res/values-uk/text_about.xml android-app-core/res/values-uk/text_functions.xml android-app-core/res/values-uk/text_operators.xml android-app-core/res/values-uk/text_preferences.xml android-app-core/res/values-uk/text_strings.xml android-app-core/res/values-uk/text_vars.xml android-app-core/res/values-zh-rtw/text_about.xml android-app-core/res/values-zh-rtw/text_functions.xml android-app-core/res/values-zh-rtw/text_operators.xml android-app-core/res/values-zh-rtw/text_preferences.xml android-app-core/res/values-zh-rtw/text_strings.xml android-app-core/res/values-zh-rtw/text_vars.xml android-app/project.properties pom.xml
This commit is contained in:
@@ -52,6 +52,8 @@ import java.util.List;
|
||||
|
||||
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.simple;
|
||||
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.simple_mobile;
|
||||
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.angleUnit;
|
||||
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.numeralBase;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
@@ -75,6 +77,12 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
|
||||
@Nonnull
|
||||
private String logTag = "CalculatorActivity";
|
||||
|
||||
@Nullable
|
||||
private AngleUnitsButton angleUnitsButton;
|
||||
|
||||
@Nullable
|
||||
private NumeralBasesButton clearButton;
|
||||
|
||||
protected AbstractCalculatorHelper() {
|
||||
}
|
||||
|
||||
@@ -151,12 +159,12 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
|
||||
equalsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new EqualsDragProcessor(), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final AngleUnitsButton angleUnitsButton = (AngleUnitsButton) getButton(root, R.id.cpp_button_6);
|
||||
angleUnitsButton = getButton(root, R.id.cpp_button_6);
|
||||
if (angleUnitsButton != null) {
|
||||
angleUnitsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.AngleUnitsChanger(activity), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final NumeralBasesButton clearButton = (NumeralBasesButton) getButton(root, R.id.cpp_button_clear);
|
||||
clearButton = getButton(root, R.id.cpp_button_clear);
|
||||
if (clearButton != null) {
|
||||
clearButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.NumeralBasesChanger(activity), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
@@ -266,12 +274,22 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||
if (key != null && key.startsWith("org.solovyev.android.calculator.DragButtonCalibrationActivity")) {
|
||||
if (key.startsWith("org.solovyev.android.calculator.DragButtonCalibrationActivity")) {
|
||||
final SimpleOnDragListener.Preferences dragPreferences = SimpleOnDragListener.getPreferences(preferences, CalculatorApplication.getInstance());
|
||||
for (DragPreferencesChangeListener dragPreferencesChangeListener : dpclRegister.getListeners()) {
|
||||
dragPreferencesChangeListener.onDragPreferencesChange(dragPreferences);
|
||||
}
|
||||
}
|
||||
|
||||
if (angleUnit.isSameKey(key) || numeralBase.isSameKey(key)) {
|
||||
if (angleUnitsButton != null) {
|
||||
angleUnitsButton.setAngleUnit(angleUnit.getPreference(preferences));
|
||||
}
|
||||
|
||||
if (clearButton != null) {
|
||||
clearButton.setNumeralBase(numeralBase.getPreference(preferences));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy(@Nonnull Activity activity) {
|
||||
|
@@ -205,7 +205,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
|
||||
}
|
||||
|
||||
public static void likeButtonPressed(@Nonnull final Context context) {
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(CalculatorApplication.FACEBOOK_APP_URL));
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(context.getString(R.string.cpp_share_link)));
|
||||
Android.addIntentFlags(intent, false, context);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
@@ -72,7 +72,6 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
||||
*/
|
||||
|
||||
private static final String TAG = "Calculator++ Application";
|
||||
public static final String FACEBOOK_APP_URL = "http://www.facebook.com/calculatorpp";
|
||||
|
||||
public static final String AD_FREE_PRODUCT_ID = "ad_free";
|
||||
public static final String AD_FREE_P_KEY = "org.solovyev.android.calculator_ad_free";
|
||||
@@ -243,6 +242,11 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static SharedPreferences getPreferences() {
|
||||
return PreferenceManager.getDefaultSharedPreferences(getInstance());
|
||||
}
|
||||
|
||||
public static boolean isMonkeyRunner(@Nonnull Context context) {
|
||||
// NOTE: this code is only for monkeyrunner
|
||||
return context.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD) == PackageManager.PERMISSION_GRANTED;
|
||||
|
@@ -36,6 +36,14 @@ import javax.annotation.Nullable;
|
||||
|
||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||
|
||||
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.hideNumeralBaseDigits;
|
||||
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.showEqualsButton;
|
||||
import static org.solovyev.android.calculator.NumeralBaseButtons.toggleNumericDigits;
|
||||
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences;
|
||||
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.angleUnit;
|
||||
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.multiplicationSign;
|
||||
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.numeralBase;
|
||||
|
||||
/**
|
||||
* User: Solovyev_S
|
||||
* Date: 25.09.12
|
||||
@@ -108,21 +116,6 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar
|
||||
|
||||
}
|
||||
|
||||
/* private static void setMarginsForView(@Nullable View view, int marginLeft, int marginBottom, @Nonnull Context context) {
|
||||
// IMPORTANT: this is workaround for probably android bug
|
||||
// currently margin values set in styles are not applied for some reasons to the views (using include tag) => set them manually
|
||||
|
||||
if (view != null) {
|
||||
final DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
||||
if (view.getLayoutParams() instanceof LinearLayout.LayoutParams) {
|
||||
final LinearLayout.LayoutParams oldParams = (LinearLayout.LayoutParams) view.getLayoutParams();
|
||||
final LinearLayout.LayoutParams newParams = new LinearLayout.LayoutParams(oldParams.width, oldParams.height, oldParams.weight);
|
||||
newParams.setMargins(AndroidUtils.toPixels(dm, marginLeft), 0, 0, AndroidUtils.toPixels(dm, marginBottom));
|
||||
view.setLayoutParams(newParams);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
@@ -130,25 +123,15 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||
if (AndroidCalculatorEngine.Preferences.numeralBase.getKey().equals(key) ||
|
||||
CalculatorPreferences.Gui.hideNumeralBaseDigits.getKey().equals(key)) {
|
||||
NumeralBaseButtons.toggleNumericDigits(this.getActivity(), preferences);
|
||||
if (numeralBase.isSameKey(key) || hideNumeralBaseDigits.isSameKey(key)) {
|
||||
toggleNumericDigits(this.getActivity(), preferences);
|
||||
}
|
||||
|
||||
if (AndroidCalculatorEngine.Preferences.angleUnit.getKey().equals(key) ||
|
||||
AndroidCalculatorEngine.Preferences.numeralBase.getKey().equals(key)) {
|
||||
View view = getView();
|
||||
if (view != null) {
|
||||
// we should update state of angle units/numeral base button => we can achieve it by invalidating the whole view
|
||||
view.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
if (CalculatorPreferences.Gui.showEqualsButton.getKey().equals(key)) {
|
||||
if (showEqualsButton.isSameKey(key)) {
|
||||
CalculatorButtons.toggleEqualsButton(preferences, this.getActivity());
|
||||
}
|
||||
|
||||
if (AndroidCalculatorEngine.Preferences.multiplicationSign.getKey().equals(key)) {
|
||||
if (multiplicationSign.isSameKey(key)) {
|
||||
CalculatorButtons.initMultiplicationButton(getView());
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,10 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||
|
||||
import static jscl.NumeralBase.hex;
|
||||
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.hideNumeralBaseDigits;
|
||||
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.numeralBase;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 4/20/12
|
||||
@@ -48,12 +52,12 @@ public class NumeralBaseButtons {
|
||||
}
|
||||
|
||||
public static void toggleNumericDigits(@Nonnull Activity activity, @Nonnull SharedPreferences preferences) {
|
||||
if (CalculatorPreferences.Gui.hideNumeralBaseDigits.getPreference(preferences)) {
|
||||
final NumeralBase nb = AndroidCalculatorEngine.Preferences.numeralBase.getPreference(preferences);
|
||||
if (hideNumeralBaseDigits.getPreference(preferences)) {
|
||||
final NumeralBase nb = numeralBase.getPreference(preferences);
|
||||
toggleNumericDigits(activity, nb);
|
||||
} else {
|
||||
// set HEX to show all digits
|
||||
AndroidNumeralBase.valueOf(NumeralBase.hex).toggleButtons(true, activity);
|
||||
AndroidNumeralBase.valueOf(hex).toggleButtons(true, activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -26,11 +26,13 @@ import android.os.Bundle;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.solovyev.android.calculator.CalculatorFragment;
|
||||
import org.solovyev.android.calculator.CalculatorFragmentType;
|
||||
import org.solovyev.android.calculator.R;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static org.solovyev.common.text.Strings.isEmpty;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 12/24/11
|
||||
@@ -46,7 +48,14 @@ public class CalculatorAboutFragment extends CalculatorFragment {
|
||||
public void onViewCreated(View root, Bundle savedInstanceState) {
|
||||
super.onViewCreated(root, savedInstanceState);
|
||||
|
||||
final TextView about = (TextView) root.findViewById(R.id.aboutTextView);
|
||||
about.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
final TextView aboutTextView = (TextView) root.findViewById(R.id.cpp_about_textview);
|
||||
aboutTextView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
final TextView translatorsTextTextView = (TextView) root.findViewById(R.id.cpp_about_translators_text);
|
||||
final TextView translatorsTextView = (TextView) root.findViewById(R.id.cpp_about_translators);
|
||||
if(isEmpty(translatorsTextView.getText())) {
|
||||
translatorsTextTextView.setVisibility(GONE);
|
||||
translatorsTextView.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -28,16 +28,16 @@ import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.solovyev.android.Android;
|
||||
import org.solovyev.android.calculator.CalculatorApplication;
|
||||
import org.solovyev.android.calculator.CalculatorFragment;
|
||||
import org.solovyev.android.calculator.CalculatorFragmentType;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.common.text.Strings;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static org.solovyev.android.Android.getAppVersionCode;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 12/25/11
|
||||
@@ -69,13 +69,14 @@ public class CalculatorReleaseNotesFragment extends CalculatorFragment {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
|
||||
final String releaseNotesForTitle = context.getString(R.string.c_release_notes_for_title);
|
||||
final int version = Android.getAppVersionCode(context);
|
||||
final int currentVersionCode = getAppVersionCode(context);
|
||||
|
||||
final TextHelper textHelper = new TextHelper(context.getResources(), CalculatorApplication.class.getPackage().getName());
|
||||
|
||||
boolean first = true;
|
||||
for (int i = version; i >= minVersion; i--) {
|
||||
String releaseNotesForVersion = textHelper.getText("c_release_notes_for_" + i);
|
||||
for (int versionCode = currentVersionCode; versionCode >= minVersion; versionCode--) {
|
||||
final String versionName = getVersionName(textHelper, versionCode);
|
||||
String releaseNotesForVersion = textHelper.getText(makeReleaseNotesResourceId(versionCode));
|
||||
if (!Strings.isEmpty(releaseNotesForVersion)) {
|
||||
assert releaseNotesForVersion != null;
|
||||
if (!first) {
|
||||
@@ -84,11 +85,29 @@ public class CalculatorReleaseNotesFragment extends CalculatorFragment {
|
||||
first = false;
|
||||
}
|
||||
releaseNotesForVersion = releaseNotesForVersion.replace("\n", "<br/>");
|
||||
result.append("<b>").append(releaseNotesForTitle).append(i).append("</b><br/><br/>");
|
||||
result.append("<b>").append(releaseNotesForTitle).append(versionName).append("</b><br/><br/>");
|
||||
result.append(releaseNotesForVersion);
|
||||
}
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private static String getVersionName(@Nonnull TextHelper textHelper, int versionCode) {
|
||||
final String versionName = textHelper.getText(makeVersionResourceId(versionCode));
|
||||
if (versionName != null) {
|
||||
return versionName;
|
||||
} else {
|
||||
return String.valueOf(versionCode);
|
||||
}
|
||||
}
|
||||
|
||||
private static String makeReleaseNotesResourceId(int versionCode) {
|
||||
return "c_release_notes_for_" + versionCode;
|
||||
}
|
||||
|
||||
private static String makeVersionResourceId(int versionCode) {
|
||||
return "c_release_notes_for_" + versionCode + "_version";
|
||||
}
|
||||
}
|
||||
|
@@ -80,8 +80,6 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
|
||||
|
||||
public static final String MATH_ENTITY_CATEGORY_EXTRA_STRING = "org.solovyev.android.calculator.CalculatorVarsActivity_math_entity_category";
|
||||
|
||||
protected final static List<Character> acceptableChars = Arrays.asList(Strings.toObjects("1234567890abcdefghijklmnopqrstuvwxyzйцукенгшщзхъфывапролджэячсмитьбюё_".toCharArray()));
|
||||
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
package org.solovyev.android.calculator.math.edit;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
@@ -30,17 +31,24 @@ import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
import jscl.math.function.IConstant;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.solovyev.android.Views;
|
||||
import org.solovyev.android.calculator.*;
|
||||
import org.solovyev.android.calculator.model.Var;
|
||||
import org.solovyev.android.sherlock.AndroidSherlockUtils;
|
||||
import org.solovyev.common.text.Strings;
|
||||
|
||||
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE;
|
||||
|
||||
/**
|
||||
* User: Solovyev_S
|
||||
@@ -49,6 +57,8 @@ import org.solovyev.android.sherlock.AndroidSherlockUtils;
|
||||
*/
|
||||
public class VarEditDialogFragment extends DialogFragment implements CalculatorEventListener {
|
||||
|
||||
private final static List<Character> acceptableChars = Arrays.asList(Strings.toObjects("1234567890abcdefghijklmnopqrstuvwxyzйцукенгшщзхъфывапролджэячсмитьбюёαβγδεζηθικλμνξοπρστυφχψω_".toCharArray()));
|
||||
|
||||
@Nonnull
|
||||
private final Input input;
|
||||
|
||||
@@ -101,7 +111,7 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE
|
||||
public void afterTextChanged(Editable s) {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
if (!AbstractMathEntityListFragment.acceptableChars.contains(c)) {
|
||||
if (!acceptableChars.contains(c)) {
|
||||
s.delete(i, i + 1);
|
||||
Toast.makeText(getActivity(), String.format(errorMsg, c), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
@@ -109,9 +119,12 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE
|
||||
}
|
||||
});
|
||||
|
||||
processGreekButtons(root, editName, R.id.var_edit_greek_buttons_1);
|
||||
processGreekButtons(root, editName, R.id.var_edit_greek_buttons_2);
|
||||
|
||||
// show soft keyboard automatically
|
||||
editName.requestFocus();
|
||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
getDialog().getWindow().setSoftInputMode(SOFT_INPUT_STATE_VISIBLE);
|
||||
|
||||
final EditText editValue = (EditText) root.findViewById(R.id.var_edit_value);
|
||||
editValue.setText(input.getValue());
|
||||
@@ -149,6 +162,21 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE
|
||||
}
|
||||
}
|
||||
|
||||
private void processGreekButtons(@Nonnull View root, @Nonnull final EditText editName, int greekButtonsViewId) {
|
||||
final ViewGroup greekButtons = (ViewGroup) root.findViewById(greekButtonsViewId);
|
||||
Views.processViewsOfType(greekButtons, Button.class, new Views.ViewProcessor<Button>() {
|
||||
@Override
|
||||
public void process(@Nonnull final Button greekButton) {
|
||||
greekButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
editName.append(greekButton.getText());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
|
||||
switch (calculatorEventType) {
|
||||
|
@@ -24,17 +24,14 @@ package org.solovyev.android.calculator.matrix;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.solovyev.android.calculator.CalculatorFragment;
|
||||
import org.solovyev.android.calculator.CalculatorFragmentType;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.view.IntegerRange;
|
||||
import org.solovyev.android.view.Picker;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* User: Solovyev_S
|
||||
@@ -91,11 +88,11 @@ public class CalculatorMatrixEditFragment extends CalculatorFragment implements
|
||||
final Picker<Integer> matrixColsCountPicker = (Picker<Integer>) root.findViewById(R.id.matrix_cols_count_picker);
|
||||
initPicker(matrixColsCountPicker);
|
||||
|
||||
Matrix matrix = null;
|
||||
MatrixUi matrix = null;
|
||||
if (in != null) {
|
||||
final Object matrixObject = in.getSerializable(MATRIX);
|
||||
if (matrixObject instanceof Matrix) {
|
||||
matrix = (Matrix) matrixObject;
|
||||
if (matrixObject instanceof MatrixUi) {
|
||||
matrix = (MatrixUi) matrixObject;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +100,7 @@ public class CalculatorMatrixEditFragment extends CalculatorFragment implements
|
||||
if (matrix == null) {
|
||||
matrixView.setMatrixDimensions(DEFAULT_ROWS, DEFAULT_COLS);
|
||||
} else {
|
||||
matrixView.setMatrix(matrix.bakingArray);
|
||||
matrixView.setMatrix(matrix.getBakingArray());
|
||||
}
|
||||
matrixRowsCountPicker.setCurrent(matrixView.getRows());
|
||||
matrixColsCountPicker.setCurrent(matrixView.getCols());
|
||||
@@ -113,7 +110,7 @@ public class CalculatorMatrixEditFragment extends CalculatorFragment implements
|
||||
public void onSaveInstanceState(@Nonnull Bundle out) {
|
||||
super.onSaveInstanceState(out);
|
||||
|
||||
out.putSerializable(MATRIX, new Matrix(getMatrixView(getView()).toMatrix()));
|
||||
out.putSerializable(MATRIX, new MatrixUi(getMatrixView(getView()).toMatrix()));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -146,16 +143,4 @@ public class CalculatorMatrixEditFragment extends CalculatorFragment implements
|
||||
getMatrixView(getView()).setMatrixRows(newRows);
|
||||
}
|
||||
|
||||
public static class Matrix implements Serializable {
|
||||
|
||||
@Nonnull
|
||||
private String[][] bakingArray;
|
||||
|
||||
public Matrix() {
|
||||
}
|
||||
|
||||
public Matrix(@Nonnull String[][] bakingArray) {
|
||||
this.bakingArray = bakingArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,27 @@
|
||||
package org.solovyev.android.calculator.matrix;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 7/11/13
|
||||
* Time: 4:54 PM
|
||||
*/
|
||||
class MatrixUi implements Serializable {
|
||||
|
||||
@Nonnull
|
||||
private String[][] bakingArray;
|
||||
|
||||
public MatrixUi() {
|
||||
}
|
||||
|
||||
public MatrixUi(@Nonnull String[][] bakingArray) {
|
||||
this.bakingArray = bakingArray;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
String[][] getBakingArray() {
|
||||
return bakingArray;
|
||||
}
|
||||
}
|
@@ -118,8 +118,8 @@ public class MatrixView extends TableLayout {
|
||||
throw new IllegalArgumentException("Number of columns must be more than 1: " + newCols);
|
||||
}
|
||||
|
||||
boolean rowsChanged = this.rows != newRows;
|
||||
boolean colsChanged = this.cols != newCols;
|
||||
final boolean rowsChanged = this.rows != newRows;
|
||||
final boolean colsChanged = this.cols != newCols;
|
||||
|
||||
if (rowsChanged || colsChanged) {
|
||||
if (!initialized) {
|
||||
|
@@ -31,29 +31,27 @@ import android.preference.Preference;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockPreferenceActivity;
|
||||
|
||||
import net.robotmedia.billing.BillingController;
|
||||
import net.robotmedia.billing.IBillingObserver;
|
||||
import net.robotmedia.billing.ResponseCode;
|
||||
import net.robotmedia.billing.helper.AbstractBillingObserver;
|
||||
import net.robotmedia.billing.model.Transaction;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.solovyev.android.Activities;
|
||||
import org.solovyev.android.App;
|
||||
import org.solovyev.android.ads.AdsController;
|
||||
import org.solovyev.android.calculator.*;
|
||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||
import org.solovyev.android.calculator.wizard.CalculatorWizardActivity;
|
||||
import org.solovyev.android.calculator.wizard.Wizards;
|
||||
import org.solovyev.android.msg.AndroidMessage;
|
||||
import org.solovyev.android.view.VibratorContainer;
|
||||
import org.solovyev.common.msg.Message;
|
||||
import org.solovyev.common.msg.MessageType;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static org.solovyev.android.calculator.wizard.CalculatorWizardActivity.startWizard;
|
||||
import static org.solovyev.android.calculator.wizard.Wizards.DEFAULT_WIZARD_FLOW;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 7/16/11
|
||||
@@ -81,7 +79,7 @@ public class CalculatorPreferencesActivity extends SherlockPreferenceActivity im
|
||||
restartWizardPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
CalculatorWizardActivity.startWizard(Wizards.DEFAULT_WIZARD_FLOW, CalculatorPreferencesActivity.this);
|
||||
startWizard(DEFAULT_WIZARD_FLOW, CalculatorPreferencesActivity.this);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 serso aka se.solovyev
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Contact details
|
||||
*
|
||||
* Email: se.solovyev@gmail.com
|
||||
* Site: http://se.solovyev.org
|
||||
*/
|
||||
|
||||
package org.solovyev.android.calculator.wizard;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.solovyev.android.calculator.wizard.WizardStep.last;
|
||||
import static org.solovyev.android.calculator.wizard.Wizards.DEFAULT_WIZARD_FLOW;
|
||||
import static org.solovyev.android.calculator.wizard.Wizards.FIRST_TIME_WIZARD;
|
||||
import static org.solovyev.android.calculator.wizard.WizardStep.welcome;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 6/16/13
|
||||
* Time: 9:25 PM
|
||||
*/
|
||||
final class AppWizardFlow implements WizardFlow {
|
||||
|
||||
@Nonnull
|
||||
private final ListWizardFlow listWizardFlow;
|
||||
|
||||
private AppWizardFlow(@Nonnull String name, @Nonnull List<WizardStep> wizardSteps) {
|
||||
this.listWizardFlow = new ListWizardFlow(name, wizardSteps);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
static AppWizardFlow newDefaultWizardFlow() {
|
||||
final List<WizardStep> wizardSteps = new ArrayList<WizardStep>();
|
||||
for (WizardStep wizardStep : WizardStep.values()) {
|
||||
if (wizardStep != welcome && wizardStep != last && wizardStep.isVisible()) {
|
||||
wizardSteps.add(wizardStep);
|
||||
}
|
||||
}
|
||||
return new AppWizardFlow(DEFAULT_WIZARD_FLOW, wizardSteps);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
static AppWizardFlow newFirstTimeWizardFlow() {
|
||||
final List<WizardStep> wizardSteps = new ArrayList<WizardStep>();
|
||||
for (WizardStep wizardStep : WizardStep.values()) {
|
||||
if (wizardStep.isVisible()) {
|
||||
wizardSteps.add(wizardStep);
|
||||
}
|
||||
}
|
||||
return new AppWizardFlow(FIRST_TIME_WIZARD, wizardSteps);
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return listWizardFlow.getName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public WizardStep getStep(@Nonnull String name) {
|
||||
return listWizardFlow.getStep(name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public WizardStep getNextStep(@Nonnull WizardStep step) {
|
||||
return listWizardFlow.getNextStep(step);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public WizardStep getPrevStep(@Nonnull WizardStep step) {
|
||||
return listWizardFlow.getPrevStep(step);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public WizardStep getFirstStep() {
|
||||
return listWizardFlow.getFirstStep();
|
||||
}
|
||||
}
|
@@ -29,7 +29,6 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.view.drag.DirectionDragButton;
|
||||
import org.solovyev.android.view.drag.DragButton;
|
||||
@@ -39,9 +38,10 @@ import org.solovyev.common.math.Point2d;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
|
||||
public class DragButtonWizardStep extends Fragment {
|
||||
|
||||
/*
|
||||
@@ -68,15 +68,14 @@ public class DragButtonWizardStep extends Fragment {
|
||||
@Nullable
|
||||
private TextView actionTextView;
|
||||
|
||||
@Nonnull
|
||||
private TextView descriptionTextView;
|
||||
|
||||
private DragButtonAction action = DragButtonAction.center;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
action = (DragButtonAction) savedInstanceState.getSerializable(ACTION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,8 +91,11 @@ public class DragButtonWizardStep extends Fragment {
|
||||
dragButton.setOnClickListener(new DragButtonOnClickListener());
|
||||
dragButton.setOnDragListener(new SimpleOnDragListener(new DragButtonProcessor(), SimpleOnDragListener.getDefaultPreferences(getActivity())));
|
||||
actionTextView = (TextView) root.findViewById(R.id.wizard_dragbutton_action_textview);
|
||||
descriptionTextView = (TextView) root.findViewById(R.id.wizard_dragbutton_description_textview);
|
||||
|
||||
actionTextView.setText(action.actionTextResId);
|
||||
if (savedInstanceState != null) {
|
||||
setAction((DragButtonAction) savedInstanceState.getSerializable(ACTION));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -173,6 +175,14 @@ public class DragButtonWizardStep extends Fragment {
|
||||
if (actionTextView != null) {
|
||||
actionTextView.setText(this.action.actionTextResId);
|
||||
}
|
||||
|
||||
boolean firstChange = false;
|
||||
if (action != DragButtonAction.center) {
|
||||
firstChange = true;
|
||||
}
|
||||
if (firstChange) {
|
||||
descriptionTextView.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,20 +1,13 @@
|
||||
package org.solovyev.android.calculator.wizard;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import net.robotmedia.billing.BillingController;
|
||||
|
||||
import org.solovyev.android.ads.AdsController;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.calculator.preferences.CalculatorPurchaseDialogActivity;
|
||||
|
||||
|
@@ -22,21 +22,18 @@
|
||||
|
||||
package org.solovyev.android.calculator.wizard;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import org.solovyev.android.App;
|
||||
import org.solovyev.android.Views;
|
||||
import org.solovyev.android.calculator.CalculatorApplication;
|
||||
import org.solovyev.android.calculator.CalculatorPreferences;
|
||||
import org.solovyev.android.calculator.R;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.solovyev.android.calculator.CalculatorApplication.getPreferences;
|
||||
import static org.solovyev.android.calculator.wizard.ChooseLayoutWizardStep.LAYOUT;
|
||||
import static org.solovyev.android.calculator.wizard.ChooseModeWizardStep.MODE;
|
||||
import static org.solovyev.android.calculator.wizard.OnScreenCalculatorWizardStep.ONSCREEN_CALCULATOR_ENABLED;
|
||||
@@ -55,10 +52,8 @@ enum WizardStep {
|
||||
boolean onNext(@Nonnull Fragment f) {
|
||||
final ChooseLayoutWizardStep fragment = (ChooseLayoutWizardStep) f;
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(f.getActivity());
|
||||
|
||||
final CalculatorLayout layout = fragment.getSelectedLayout();
|
||||
layout.apply(preferences);
|
||||
layout.apply(getPreferences());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -66,10 +61,8 @@ enum WizardStep {
|
||||
@Nullable
|
||||
@Override
|
||||
Bundle getFragmentArgs() {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(CalculatorApplication.getInstance());
|
||||
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(LAYOUT, CalculatorLayout.fromGuiLayout(CalculatorPreferences.Gui.layout.getPreference(preferences)));
|
||||
bundle.putSerializable(LAYOUT, CalculatorLayout.fromGuiLayout(CalculatorPreferences.Gui.layout.getPreference(getPreferences())));
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@@ -84,10 +77,8 @@ enum WizardStep {
|
||||
boolean onNext(@Nonnull Fragment f) {
|
||||
final ChooseModeWizardStep fragment = (ChooseModeWizardStep) f;
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(f.getActivity());
|
||||
|
||||
final CalculatorMode mode = fragment.getSelectedMode();
|
||||
mode.apply(preferences);
|
||||
mode.apply(getPreferences());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -95,10 +86,8 @@ enum WizardStep {
|
||||
@Nullable
|
||||
@Override
|
||||
Bundle getFragmentArgs() {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(CalculatorApplication.getInstance());
|
||||
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(MODE, CalculatorMode.fromGuiLayout(CalculatorPreferences.Gui.layout.getPreference(preferences)));
|
||||
bundle.putSerializable(MODE, CalculatorMode.fromGuiLayout(CalculatorPreferences.Gui.layout.getPreference(getPreferences())));
|
||||
return bundle;
|
||||
}
|
||||
},
|
||||
@@ -108,9 +97,7 @@ enum WizardStep {
|
||||
boolean onNext(@Nonnull Fragment f) {
|
||||
final OnScreenCalculatorWizardStep fragment = (OnScreenCalculatorWizardStep) f;
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(f.getActivity());
|
||||
|
||||
CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(preferences, fragment.isOnscreenCalculatorEnabled());
|
||||
CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), fragment.isOnscreenCalculatorEnabled());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -118,10 +105,8 @@ enum WizardStep {
|
||||
@Nullable
|
||||
@Override
|
||||
Bundle getFragmentArgs() {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(CalculatorApplication.getInstance());
|
||||
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(ONSCREEN_CALCULATOR_ENABLED, CalculatorPreferences.OnscreenCalculator.showAppIcon.getPreference(preferences));
|
||||
bundle.putSerializable(ONSCREEN_CALCULATOR_ENABLED, CalculatorPreferences.OnscreenCalculator.showAppIcon.getPreference(getPreferences()));
|
||||
return bundle;
|
||||
}
|
||||
},
|
||||
@@ -136,8 +121,6 @@ enum WizardStep {
|
||||
private final int titleResId;
|
||||
private final int nextButtonTitleResId;
|
||||
|
||||
|
||||
|
||||
WizardStep(@Nonnull Class<? extends Fragment> fragmentClass, int titleResId) {
|
||||
this(fragmentClass, titleResId, R.string.cpp_wizard_next);
|
||||
}
|
||||
|
@@ -30,8 +30,11 @@ import org.solovyev.android.calculator.CalculatorApplication;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.solovyev.android.calculator.wizard.AppWizardFlow.newDefaultWizardFlow;
|
||||
import static org.solovyev.android.calculator.wizard.AppWizardFlow.newFirstTimeWizardFlow;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.solovyev.android.calculator.wizard.WizardStep.last;
|
||||
import static org.solovyev.android.calculator.wizard.WizardStep.welcome;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
@@ -114,4 +117,26 @@ public final class Wizards {
|
||||
private static String makeLastStepPreferenceKey(@Nonnull String flowName) {
|
||||
return FLOW + ":" + flowName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
static WizardFlow newDefaultWizardFlow() {
|
||||
final List<WizardStep> wizardSteps = new ArrayList<WizardStep>();
|
||||
for (WizardStep wizardStep : WizardStep.values()) {
|
||||
if (wizardStep != welcome && wizardStep != last && wizardStep.isVisible()) {
|
||||
wizardSteps.add(wizardStep);
|
||||
}
|
||||
}
|
||||
return new ListWizardFlow(DEFAULT_WIZARD_FLOW, wizardSteps);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
static WizardFlow newFirstTimeWizardFlow() {
|
||||
final List<WizardStep> wizardSteps = new ArrayList<WizardStep>();
|
||||
for (WizardStep wizardStep : WizardStep.values()) {
|
||||
if (wizardStep.isVisible()) {
|
||||
wizardSteps.add(wizardStep);
|
||||
}
|
||||
}
|
||||
return new ListWizardFlow(FIRST_TIME_WIZARD, wizardSteps);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user