version update

This commit is contained in:
Sergey Solovyev 2013-02-02 20:21:05 +04:00
parent cafa6b01ed
commit 8d84e24ca9
76 changed files with 282 additions and 874 deletions

View File

@ -1,21 +1,5 @@
package org.solovyev.android; package org.solovyev.android;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.os.Build;
import android.util.Log;
import android.view.MotionEvent;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/** /**
* User: Solovyev_S * User: Solovyev_S
* Date: 03.10.12 * Date: 03.10.12
@ -23,95 +7,8 @@ import java.io.IOException;
*/ */
public final class AndroidUtils2 { public final class AndroidUtils2 {
@NotNull
private static final boolean AT_LEAST_API_5 = Build.VERSION.SDK_INT >= 5;
private AndroidUtils2() { private AndroidUtils2() {
throw new AssertionError(); throw new AssertionError();
} }
public static void addFlags(@NotNull Intent intent, boolean detached, @NotNull Context context) {
int flags = 0;
if (!(context instanceof Activity)) {
flags = flags | Intent.FLAG_ACTIVITY_NEW_TASK;
}
if (detached) {
flags = flags | Intent.FLAG_ACTIVITY_NO_HISTORY;
}
intent.setFlags(flags);
}
public static void toggleComponent(@NotNull Context context,
@NotNull Class<? extends Context> componentClass,
boolean enable) {
final PackageManager pm = context.getPackageManager();
final int componentState;
if (enable) {
componentState = PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
} else {
componentState = PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
}
pm.setComponentEnabledSetting(new ComponentName(context, componentClass), componentState, PackageManager.DONT_KILL_APP);
}
public static boolean isComponentEnabled(@NotNull Context context,
@NotNull Class<? extends Context> componentClass) {
final PackageManager pm = context.getPackageManager();
int componentEnabledSetting = pm.getComponentEnabledSetting(new ComponentName(context, componentClass));
return componentEnabledSetting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED || componentEnabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
}
public static String saveBitmap(@NotNull Bitmap bitmap,
@NotNull String path,
@NotNull String fileName) {
final File filePath = new File(path);
filePath.mkdirs();
final File file = new File(path, fileName);
if (!file.exists()) {
final String name = file.getAbsolutePath();
FileOutputStream fos = null;
try {
fos = new FileOutputStream(name);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.flush();
} catch (FileNotFoundException e) {
Log.e("AndroidUtils", e.getMessage(), e);
} catch (IOException e) {
Log.e("AndroidUtils", e.getMessage(), e);
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
Log.e("AndroidUtils", e.getMessage(), e);
}
}
}
return name;
}
return null;
}
public static int getPointerCountFromMotionEvent(@NotNull MotionEvent event) {
return AT_LEAST_API_5 ? event.getPointerCount() : 1;
}
public static float getXFromMotionEvent(@NotNull MotionEvent event, int pointer) {
return AT_LEAST_API_5 ? event.getX(pointer) : 0;
}
public static float getYFromMotionEvent(@NotNull MotionEvent event, int pointer) {
return AT_LEAST_API_5 ? event.getY(pointer) : 0;
}
} }

View File

@ -1,69 +0,0 @@
package org.solovyev.android;
import android.app.Application;
import org.jetbrains.annotations.NotNull;
import org.solovyev.common.DelayedExecutor;
/**
* User: serso
* Date: 12/1/12
* Time: 3:58 PM
*/
public final class App {
/*
**********************************************************************
*
* STATIC
*
**********************************************************************
*/
@NotNull
public static final App instance = new App();
@NotNull
public static App getInstance() {
return instance;
}
/*
**********************************************************************
*
* FIELDS
*
**********************************************************************
*/
@NotNull
private volatile Application application;
@NotNull
private volatile DelayedExecutor uiThreadExecutor;
private volatile boolean initialized;
private App() {
}
public void init(@NotNull Application application) {
if (!initialized) {
this.application = application;
this.uiThreadExecutor = new UiThreadExecutor();
this.initialized = true;
}
}
@NotNull
public <A extends Application> A getApplication() {
return (A) application;
}
@NotNull
public DelayedExecutor getUiThreadExecutor() {
return uiThreadExecutor;
}
}

View File

@ -1,34 +0,0 @@
package org.solovyev.android;
import android.os.Handler;
import org.jetbrains.annotations.NotNull;
import org.solovyev.common.DelayedExecutor;
import java.util.concurrent.TimeUnit;
/**
* User: serso
* Date: 12/1/12
* Time: 4:11 PM
*/
public class UiThreadExecutor implements DelayedExecutor {
@NotNull
private final Handler uiHandler;
public UiThreadExecutor() {
assert AndroidUtils.isUiThread() : "Must be called on UI thread!";
this.uiHandler = new Handler();
}
@Override
public void execute(@NotNull Runnable command, long delay, @NotNull TimeUnit delayUnit) {
this.uiHandler.postDelayed(command, delayUnit.toMillis(delay));
}
@Override
public void execute(@NotNull Runnable command) {
this.uiHandler.post(command);
}
}

View File

@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.text.TextProcessor; import org.solovyev.android.calculator.text.TextProcessor;
import org.solovyev.android.calculator.view.TextHighlighter; import org.solovyev.android.calculator.view.TextHighlighter;
import org.solovyev.android.prefs.BooleanPreference; import org.solovyev.android.prefs.BooleanPreference;
import org.solovyev.common.collections.CollectionsUtils; import org.solovyev.common.collections.Collections;
/** /**
* User: serso * User: serso
@ -33,7 +33,7 @@ import org.solovyev.common.collections.CollectionsUtils;
public class AndroidCalculatorEditorView extends EditText implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEditorView { public class AndroidCalculatorEditorView extends EditText implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEditorView {
@NotNull @NotNull
private static final BooleanPreference colorDisplay = new BooleanPreference("org.solovyev.android.calculator.CalculatorModel_color_display", true); private static final BooleanPreference colorDisplay = BooleanPreference.of("org.solovyev.android.calculator.CalculatorModel_color_display", true);
private volatile boolean initialized = false; private volatile boolean initialized = false;
@ -74,7 +74,7 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe
// fix for missing cursor in android 3 and higher // fix for missing cursor in android 3 and higher
try { try {
// IDEA: return false always except if method was called from TextView.isCursorVisible() method // IDEA: return false always except if method was called from TextView.isCursorVisible() method
for (StackTraceElement stackTraceElement : CollectionsUtils.asList(Thread.currentThread().getStackTrace())) { for (StackTraceElement stackTraceElement : Collections.asList(Thread.currentThread().getStackTrace())) {
if ("isCursorVisible".equals(stackTraceElement.getMethodName())) { if ("isCursorVisible".equals(stackTraceElement.getMethodName())) {
return true; return true;
} }

View File

@ -15,7 +15,7 @@ import jscl.AngleUnit;
import jscl.NumeralBase; import jscl.NumeralBase;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils; import org.solovyev.android.AViews;
import org.solovyev.android.calculator.core.R; import org.solovyev.android.calculator.core.R;
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;
@ -43,7 +43,7 @@ public final class CalculatorButtons {
final float textSize = root.getContext().getResources().getDimension(R.dimen.cpp_keyboard_button_text_size_mobile); final float textSize = root.getContext().getResources().getDimension(R.dimen.cpp_keyboard_button_text_size_mobile);
AndroidUtils.processViewsOfType(root, DragButton.class, new AndroidUtils.ViewProcessor<DragButton>() { AViews.processViewsOfType(root, DragButton.class, new AViews.ViewProcessor<DragButton>() {
@Override @Override
public void process(@NotNull DragButton button) { public void process(@NotNull DragButton button) {
button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize); button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
@ -68,11 +68,11 @@ public final class CalculatorButtons {
@NotNull Activity activity) { @NotNull Activity activity) {
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences; preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences;
final boolean large = AndroidUtils.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, activity.getResources().getConfiguration()) && final boolean large = AViews.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, activity.getResources().getConfiguration()) &&
CalculatorPreferences.Gui.getLayout(preferences) != CalculatorPreferences.Gui.Layout.main_calculator_mobile; CalculatorPreferences.Gui.getLayout(preferences) != CalculatorPreferences.Gui.Layout.main_calculator_mobile;
if (!large) { if (!large) {
if (AndroidUtils.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT if (AViews.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT
|| !CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) { || !CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) {
final DragButton equalsButton = (DragButton)activity.findViewById(R.id.cpp_button_equals); final DragButton equalsButton = (DragButton)activity.findViewById(R.id.cpp_button_equals);

View File

@ -3,8 +3,8 @@ package org.solovyev.android.calculator;
import android.content.Context; import android.content.Context;
import android.view.View; import android.view.View;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.android.menu.AMenuBuilder; import org.solovyev.android.menu.ContextMenuBuilder;
import org.solovyev.android.menu.MenuImpl; import org.solovyev.android.menu.ListContextMenu;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -39,7 +39,7 @@ public class CalculatorDisplayOnClickListener implements View.OnClickListener {
} }
if (!filteredMenuItems.isEmpty()) { if (!filteredMenuItems.isEmpty()) {
AMenuBuilder.newInstance(context, MenuImpl.newInstance(filteredMenuItems)).create(displayViewState).show(); ContextMenuBuilder.newInstance(context, ListContextMenu.newInstance(filteredMenuItems)).create(displayViewState).show();
} }
} else { } else {

View File

@ -30,37 +30,37 @@ public final class CalculatorPreferences {
throw new AssertionError(); throw new AssertionError();
} }
public static final Preference<Integer> appVersion = new IntegerPreference("application.version", -1); public static final Preference<Integer> appVersion = IntegerPreference.of("application.version", -1);
public static final Preference<Integer> appOpenedCounter = new IntegerPreference("app_opened_counter", 0); public static final Preference<Integer> appOpenedCounter = IntegerPreference.of("app_opened_counter", 0);
public static class OnscreenCalculator { public static class OnscreenCalculator {
public static final Preference<Boolean> startOnBoot = new BooleanPreference("onscreen_start_on_boot", false); public static final Preference<Boolean> startOnBoot = BooleanPreference.of("onscreen_start_on_boot", false);
public static final Preference<Boolean> showAppIcon = new BooleanPreference("onscreen_show_app_icon", true); public static final Preference<Boolean> showAppIcon = BooleanPreference.of("onscreen_show_app_icon", true);
public static final Preference<Boolean> removeIconDialogShown = new BooleanPreference("onscreen_remove_icon_dialog_shown", false); public static final Preference<Boolean> removeIconDialogShown = BooleanPreference.of("onscreen_remove_icon_dialog_shown", false);
} }
public static class Calculations { public static class Calculations {
public static final Preference<Boolean> calculateOnFly = new BooleanPreference("calculations_calculate_on_fly", true); public static final Preference<Boolean> calculateOnFly = BooleanPreference.of("calculations_calculate_on_fly", true);
public static final Preference<Boolean> showCalculationMessagesDialog = new BooleanPreference("show_calculation_messages_dialog", true); public static final Preference<Boolean> showCalculationMessagesDialog = BooleanPreference.of("show_calculation_messages_dialog", true);
public static final Preference<NumeralBase> preferredNumeralBase = StringPreference.newInstance("preferred_numeral_base", AndroidCalculatorEngine.Preferences.numeralBase.getDefaultValue(), NumeralBase.class); public static final Preference<NumeralBase> preferredNumeralBase = StringPreference.ofEnum("preferred_numeral_base", AndroidCalculatorEngine.Preferences.numeralBase.getDefaultValue(), NumeralBase.class);
public static final Preference<AngleUnit> preferredAngleUnits = StringPreference.newInstance("preferred_angle_units", AndroidCalculatorEngine.Preferences.angleUnit.getDefaultValue(), AngleUnit.class); public static final Preference<AngleUnit> preferredAngleUnits = StringPreference.ofEnum("preferred_angle_units", AndroidCalculatorEngine.Preferences.angleUnit.getDefaultValue(), AngleUnit.class);
public static final Preference<Long> lastPreferredPreferencesCheck = new LongPreference("preferred_preferences_check_time", 0L); public static final Preference<Long> lastPreferredPreferencesCheck = LongPreference.of("preferred_preferences_check_time", 0L);
} }
public static class Gui { public static class Gui {
public static final Preference<Theme> theme = StringPreference.newInstance("org.solovyev.android.calculator.CalculatorActivity_calc_theme", Theme.metro_blue_theme, Theme.class); public static final Preference<Theme> theme = StringPreference.ofEnum("org.solovyev.android.calculator.CalculatorActivity_calc_theme", Theme.metro_blue_theme, Theme.class);
public static final Preference<Layout> layout = StringPreference.newInstance("org.solovyev.android.calculator.CalculatorActivity_calc_layout", Layout.main_calculator, Layout.class); public static final Preference<Layout> layout = StringPreference.ofEnum("org.solovyev.android.calculator.CalculatorActivity_calc_layout", Layout.main_calculator, Layout.class);
public static final Preference<Boolean> feedbackWindowShown = new BooleanPreference("feedback_window_shown", false); public static final Preference<Boolean> feedbackWindowShown = BooleanPreference.of("feedback_window_shown", false);
public static final Preference<Boolean> notesppAnnounceShown = new BooleanPreference("notespp_announce_shown", false); public static final Preference<Boolean> notesppAnnounceShown = BooleanPreference.of("notespp_announce_shown", false);
public static final Preference<Boolean> showReleaseNotes = new BooleanPreference("org.solovyev.android.calculator.CalculatorActivity_show_release_notes", true); public static final Preference<Boolean> showReleaseNotes = BooleanPreference.of("org.solovyev.android.calculator.CalculatorActivity_show_release_notes", true);
public static final Preference<Boolean> usePrevAsBack = new BooleanPreference("org.solovyev.android.calculator.CalculatorActivity_use_back_button_as_prev", false); public static final Preference<Boolean> usePrevAsBack = BooleanPreference.of("org.solovyev.android.calculator.CalculatorActivity_use_back_button_as_prev", false);
public static final Preference<Boolean> showEqualsButton = new BooleanPreference("showEqualsButton", true); public static final Preference<Boolean> showEqualsButton = BooleanPreference.of("showEqualsButton", true);
public static final Preference<Boolean> autoOrientation = new BooleanPreference("autoOrientation", true); public static final Preference<Boolean> autoOrientation = BooleanPreference.of("autoOrientation", true);
public static final Preference<Boolean> hideNumeralBaseDigits = new BooleanPreference("hideNumeralBaseDigits", true); public static final Preference<Boolean> hideNumeralBaseDigits = BooleanPreference.of("hideNumeralBaseDigits", true);
@NotNull @NotNull
public static Theme getTheme(@NotNull SharedPreferences preferences) { public static Theme getTheme(@NotNull SharedPreferences preferences) {
@ -131,11 +131,11 @@ public final class CalculatorPreferences {
} }
public static class Graph { public static class Graph {
public static final Preference<Boolean> plotImag = new BooleanPreference("graph_plot_imag", false); public static final Preference<Boolean> plotImag = BooleanPreference.of("graph_plot_imag", false);
} }
public static class History { public static class History {
public static final Preference<Boolean> showIntermediateCalculations = new BooleanPreference("history_show_intermediate_calculations", false); public static final Preference<Boolean> showIntermediateCalculations = BooleanPreference.of("history_show_intermediate_calculations", false);
} }
@ -210,9 +210,7 @@ public final class CalculatorPreferences {
} }
private static void applyDefaultPreference(@NotNull SharedPreferences preferences, @NotNull Preference<?> preference) { private static void applyDefaultPreference(@NotNull SharedPreferences preferences, @NotNull Preference<?> preference) {
if (!preference.isSet(preferences)) { preference.tryPutDefault(preferences);
preference.putDefault(preferences);
}
} }
} }

View File

@ -17,7 +17,7 @@ import com.actionbarsherlock.app.SherlockActivity;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.android.calculator.core.R; import org.solovyev.android.calculator.core.R;
import org.solovyev.common.msg.Message; import org.solovyev.common.msg.Message;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -101,7 +101,7 @@ public class FixableMessagesDialog extends SherlockActivity {
fixButton.setOnClickListener(new FixErrorOnClickListener(messages, message)); fixButton.setOnClickListener(new FixErrorOnClickListener(messages, message));
final CharSequence fixCaption = fixableError.getFixCaption(); final CharSequence fixCaption = fixableError.getFixCaption();
if (!StringUtils.isEmpty(fixCaption)) { if (!Strings.isEmpty(fixCaption)) {
fixButton.setText(fixCaption); fixButton.setText(fixCaption);
} }
} }

View File

@ -1,36 +0,0 @@
package org.solovyev.android.calculator;
import android.app.Activity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils;
/**
* User: serso
* Date: 1/19/13
* Time: 5:04 PM
*/
public final class Threads {
private Threads() {
throw new AssertionError();
}
public static void tryRunOnUiThread(@Nullable final Activity activity, @NotNull final Runnable runnable) {
if (activity != null && !activity.isFinishing()) {
if (AndroidUtils.isUiThread()) {
runnable.run();
} else {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
// some time may pass and activity might be closing
if (!activity.isFinishing()) {
runnable.run();
}
}
});
}
}
}
}

View File

@ -109,7 +109,7 @@ public class AndroidExternalListenersContainer implements CalculatorExternalList
Locator.getInstance().getNotifier().showDebugMessage(TAG, "Editor state changed: " + newEditorState.getText()); Locator.getInstance().getNotifier().showDebugMessage(TAG, "Editor state changed: " + newEditorState.getText());
onEditorStateChanged(App.getInstance().getApplication(), calculatorEventData, newEditorState); onEditorStateChanged(App.getApplication(), calculatorEventData, newEditorState);
break; break;
case display_state_changed: case display_state_changed:
@ -118,7 +118,7 @@ public class AndroidExternalListenersContainer implements CalculatorExternalList
Locator.getInstance().getNotifier().showDebugMessage(TAG, "Display state changed: " + newDisplayState.getText()); Locator.getInstance().getNotifier().showDebugMessage(TAG, "Display state changed: " + newDisplayState.getText());
onDisplayStateChanged(App.getInstance().getApplication(), calculatorEventData, newDisplayState); onDisplayStateChanged(App.getApplication(), calculatorEventData, newDisplayState);
break; break;
} }
} }

View File

@ -24,7 +24,7 @@ import org.solovyev.android.prefs.Preference;
import org.solovyev.android.prefs.StringPreference; import org.solovyev.android.prefs.StringPreference;
import org.solovyev.common.text.EnumMapper; import org.solovyev.common.text.EnumMapper;
import org.solovyev.common.text.NumberMapper; import org.solovyev.common.text.NumberMapper;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.util.ArrayList; import java.util.ArrayList;
@ -63,14 +63,14 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen
private static final String ANGLE_UNITS_DEFAULT = "deg"; private static final String ANGLE_UNITS_DEFAULT = "deg";
public static class Preferences { public static class Preferences {
public static final Preference<String> groupingSeparator = StringPreference.newInstance(GROUPING_SEPARATOR_P_KEY, JsclMathEngine.GROUPING_SEPARATOR_DEFAULT); public static final Preference<String> groupingSeparator = StringPreference.of(GROUPING_SEPARATOR_P_KEY, JsclMathEngine.GROUPING_SEPARATOR_DEFAULT);
public static final Preference<String> multiplicationSign = StringPreference.newInstance(MULTIPLICATION_SIGN_P_KEY, MULTIPLICATION_SIGN_DEFAULT); public static final Preference<String> multiplicationSign = StringPreference.of(MULTIPLICATION_SIGN_P_KEY, MULTIPLICATION_SIGN_DEFAULT);
public static final Preference<Integer> precision = StringPreference.newInstance(RESULT_PRECISION_P_KEY, RESULT_PRECISION_DEFAULT, NumberMapper.getMapper(Integer.class)); public static final Preference<Integer> precision = StringPreference.ofTypedValue(RESULT_PRECISION_P_KEY, RESULT_PRECISION_DEFAULT, NumberMapper.of(Integer.class));
public static final Preference<Boolean> roundResult = new BooleanPreference(ROUND_RESULT_P_KEY, ROUND_RESULT_DEFAULT); public static final Preference<Boolean> roundResult = BooleanPreference.of(ROUND_RESULT_P_KEY, ROUND_RESULT_DEFAULT);
public static final Preference<NumeralBase> numeralBase = StringPreference.newInstance(NUMERAL_BASES_P_KEY, NUMERAL_BASES_DEFAULT, EnumMapper.newInstance(NumeralBase.class)); public static final Preference<NumeralBase> numeralBase = StringPreference.ofTypedValue(NUMERAL_BASES_P_KEY, NUMERAL_BASES_DEFAULT, EnumMapper.of(NumeralBase.class));
public static final Preference<AngleUnit> angleUnit = StringPreference.newInstance(ANGLE_UNITS_P_KEY, ANGLE_UNITS_DEFAULT, EnumMapper.newInstance(AngleUnit.class)); public static final Preference<AngleUnit> angleUnit = StringPreference.ofTypedValue(ANGLE_UNITS_P_KEY, ANGLE_UNITS_DEFAULT, EnumMapper.of(AngleUnit.class));
public static final Preference<Boolean> scienceNotation = new BooleanPreference(SCIENCE_NOTATION_P_KEY, SCIENCE_NOTATION_DEFAULT); public static final Preference<Boolean> scienceNotation = BooleanPreference.of(SCIENCE_NOTATION_P_KEY, SCIENCE_NOTATION_DEFAULT);
public static final Preference<Integer> maxCalculationTime = StringPreference.newInstance(MAX_CALCULATION_TIME_P_KEY, MAX_CALCULATION_TIME_DEFAULT, NumberMapper.getMapper(Integer.class)); public static final Preference<Integer> maxCalculationTime = StringPreference.ofTypedValue(MAX_CALCULATION_TIME_P_KEY, MAX_CALCULATION_TIME_DEFAULT, NumberMapper.of(Integer.class));
private static final List<String> preferenceKeys = new ArrayList<String>(); private static final List<String> preferenceKeys = new ArrayList<String>();
@ -246,7 +246,7 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen
this.setTimeout(Preferences.maxCalculationTime.getPreference(preferences)); this.setTimeout(Preferences.maxCalculationTime.getPreference(preferences));
final String groupingSeparator = Preferences.groupingSeparator.getPreference(preferences); final String groupingSeparator = Preferences.groupingSeparator.getPreference(preferences);
if (StringUtils.isEmpty(groupingSeparator)) { if (Strings.isEmpty(groupingSeparator)) {
this.setUseGroupingSeparator(false); this.setUseGroupingSeparator(false);
} else { } else {
this.setUseGroupingSeparator(true); this.setUseGroupingSeparator(true);

View File

@ -89,7 +89,7 @@ public class AndroidMathEntityDao<T extends MathPersistenceEntity> implements Ma
public String getDescription(@NotNull String descriptionId) { public String getDescription(@NotNull String descriptionId) {
final Resources resources = context.getResources(); final Resources resources = context.getResources();
final int stringId = resources.getIdentifier(descriptionId, "string", App.getInstance().getApplication().getClass().getPackage().getName()); final int stringId = resources.getIdentifier(descriptionId, "string", App.getApplication().getClass().getPackage().getName());
try { try {
return resources.getString(stringId); return resources.getString(stringId);
} catch (Resources.NotFoundException e) { } catch (Resources.NotFoundException e) {

View File

@ -12,9 +12,9 @@ import org.solovyev.android.calculator.ToJsclTextProcessor;
import org.solovyev.android.calculator.core.R; import org.solovyev.android.calculator.core.R;
import org.solovyev.android.calculator.units.CalculatorNumeralBase; import org.solovyev.android.calculator.units.CalculatorNumeralBase;
import org.solovyev.common.MutableObject; import org.solovyev.common.MutableObject;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import org.solovyev.math.units.Unit; import org.solovyev.common.units.Unit;
import org.solovyev.math.units.UnitImpl; import org.solovyev.common.units.UnitImpl;
import java.util.Arrays; import java.util.Arrays;
@ -28,7 +28,7 @@ public class NumeralBaseConverterDialog {
@Nullable @Nullable
private String initialFromValue; private String initialFromValue;
public NumeralBaseConverterDialog(String initialFromValue) { public NumeralBaseConverterDialog(@Nullable String initialFromValue) {
this.initialFromValue = initialFromValue; this.initialFromValue = initialFromValue;
} }
@ -37,7 +37,7 @@ public class NumeralBaseConverterDialog {
b.setFromUnitTypes(Arrays.asList(CalculatorNumeralBase.values())); b.setFromUnitTypes(Arrays.asList(CalculatorNumeralBase.values()));
b.setToUnitTypes(Arrays.asList(CalculatorNumeralBase.values())); b.setToUnitTypes(Arrays.asList(CalculatorNumeralBase.values()));
if (!StringUtils.isEmpty(initialFromValue)) { if (!Strings.isEmpty(initialFromValue)) {
String value = initialFromValue; String value = initialFromValue;
try { try {
value = ToJsclTextProcessor.getInstance().process(value).getExpression(); value = ToJsclTextProcessor.getInstance().process(value).getExpression();

View File

@ -13,7 +13,7 @@ import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.core.R; import org.solovyev.android.calculator.core.R;
import org.solovyev.android.view.ViewBuilder; import org.solovyev.android.view.ViewBuilder;
import org.solovyev.android.view.ViewFromLayoutBuilder; import org.solovyev.android.view.ViewFromLayoutBuilder;
import org.solovyev.math.units.*; import org.solovyev.common.units.*;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -169,7 +169,7 @@ public class UnitConverterViewBuilder implements ViewBuilder<View> {
final String from = fromEditText.getText().toString(); final String from = fromEditText.getText().toString();
try { try {
toEditText.setText(ConversionUtils.doConversion(converter, from, getFromUnitType(main), getToUnitType(main))); toEditText.setText(Conversions.doConversion(converter, from, getFromUnitType(main), getToUnitType(main)));
} catch (ConversionException e) { } catch (ConversionException e) {
toEditText.setText(context.getString(R.string.c_error)); toEditText.setText(context.getString(R.string.c_error));
} }

View File

@ -11,7 +11,7 @@ import android.util.DisplayMetrics;
import android.view.WindowManager; import android.view.WindowManager;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils; import org.solovyev.android.AViews;
import org.solovyev.android.calculator.CalculatorDisplayViewState; import org.solovyev.android.calculator.CalculatorDisplayViewState;
import org.solovyev.android.calculator.CalculatorEditorViewState; import org.solovyev.android.calculator.CalculatorEditorViewState;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
@ -65,7 +65,7 @@ public class CalculatorOnscreenService extends Service implements ExternalCalcul
twoThirdWidth = Math.min(twoThirdWidth, twoThirdHeight); twoThirdWidth = Math.min(twoThirdWidth, twoThirdHeight);
twoThirdHeight = Math.max(twoThirdWidth, getHeight(twoThirdWidth)); twoThirdHeight = Math.max(twoThirdWidth, getHeight(twoThirdWidth));
final int baseWidth = AndroidUtils.toPixels(dm, 300); final int baseWidth = AViews.toPixels(dm, 300);
final int width0 = Math.min(twoThirdWidth, baseWidth); final int width0 = Math.min(twoThirdWidth, baseWidth);
final int height0 = Math.min(twoThirdHeight, getHeight(baseWidth)); final int height0 = Math.min(twoThirdHeight, getHeight(baseWidth));

View File

@ -6,12 +6,12 @@ import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.android.AndroidUtils2; import org.solovyev.android.AndroidUtils;
import org.solovyev.android.calculator.AbstractFixableError;
import org.solovyev.android.App; import org.solovyev.android.App;
import org.solovyev.android.calculator.AbstractFixableError;
import org.solovyev.android.calculator.CalculatorPreferences;
import org.solovyev.android.calculator.FixableMessage; import org.solovyev.android.calculator.FixableMessage;
import org.solovyev.android.calculator.FixableMessagesDialog; import org.solovyev.android.calculator.FixableMessagesDialog;
import org.solovyev.android.calculator.CalculatorPreferences;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
import java.util.Arrays; import java.util.Arrays;
@ -22,7 +22,7 @@ public class CalculatorOnscreenStartActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (AndroidUtils2.isComponentEnabled(this, CalculatorOnscreenStartActivity.class)) { if (AndroidUtils.isComponentEnabled(this, CalculatorOnscreenStartActivity.class)) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (!CalculatorPreferences.OnscreenCalculator.removeIconDialogShown.getPreference(prefs)) { if (!CalculatorPreferences.OnscreenCalculator.removeIconDialogShown.getPreference(prefs)) {
@ -44,7 +44,7 @@ public class CalculatorOnscreenStartActivity extends Activity {
@Override @Override
public void fix() { public void fix() {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(App.getInstance().getApplication()); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(App.getApplication());
CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(prefs, false); CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(prefs, false);
} }
} }

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="116" android:versionName="1.6.1" package="org.solovyev.android.calculator"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="117" android:versionName="1.6.2" package="org.solovyev.android.calculator">
<uses-permission android:name="android.permission.VIBRATE"/> <uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>

View File

@ -12,19 +12,19 @@ target=android-15
android.library.reference.1=../android-app-core android.library.reference.1=../android-app-core
android.library.reference.2=../android-app-widget android.library.reference.2=../android-app-widget
android.library.reference.3=../android-app-onscreen android.library.reference.3=../android-app-onscreen
android.library.reference.4=gen-external-apklibs/org.solovyev.android_android-common-all_1.0.6 android.library.reference.4=gen-external-apklibs/org.solovyev.android_android-common-all_1.0.7-SNAPSHOT
android.library.reference.5=gen-external-apklibs/org.solovyev.android_android-common-ads_1.0.6 android.library.reference.5=gen-external-apklibs/org.solovyev.android_android-common-ads_1.0.7-SNAPSHOT
android.library.reference.6=gen-external-apklibs/org.solovyev.android_android-common-core_1.0.6 android.library.reference.6=gen-external-apklibs/org.solovyev.android_android-common-core_1.0.7-SNAPSHOT
android.library.reference.7=gen-external-apklibs/org.solovyev.android_android-common-billing_1.0.6 android.library.reference.7=gen-external-apklibs/org.solovyev.android_android-common-billing_1.0.7-SNAPSHOT
android.library.reference.8=gen-external-apklibs/org.solovyev.android_android-common-db_1.0.6 android.library.reference.8=gen-external-apklibs/org.solovyev.android_android-common-db_1.0.7-SNAPSHOT
android.library.reference.9=gen-external-apklibs/org.solovyev.android_android-common-http_1.0.6 android.library.reference.9=gen-external-apklibs/org.solovyev.android_android-common-http_1.0.7-SNAPSHOT
android.library.reference.10=gen-external-apklibs/org.solovyev.android_android-common-list_1.0.6 android.library.reference.10=gen-external-apklibs/org.solovyev.android_android-common-list_1.0.7-SNAPSHOT
android.library.reference.11=gen-external-apklibs/org.solovyev.android_android-common-view_1.0.6 android.library.reference.11=gen-external-apklibs/org.solovyev.android_android-common-view_1.0.7-SNAPSHOT
android.library.reference.12=gen-external-apklibs/org.solovyev.android_android-common-preferences_1.0.6 android.library.reference.12=gen-external-apklibs/org.solovyev.android_android-common-preferences_1.0.7-SNAPSHOT
android.library.reference.13=gen-external-apklibs/org.solovyev.android_android-common-menu_1.0.6 android.library.reference.13=gen-external-apklibs/org.solovyev.android_android-common-menu_1.0.7-SNAPSHOT
android.library.reference.14=gen-external-apklibs/org.solovyev.android_android-common-other_1.0.6 android.library.reference.14=gen-external-apklibs/org.solovyev.android_android-common-other_1.0.7-SNAPSHOT
android.library.reference.15=gen-external-apklibs/org.solovyev.android_android-common-sherlock_1.0.6 android.library.reference.15=gen-external-apklibs/org.solovyev.android_android-common-sherlock_1.0.7-SNAPSHOT
android.library.reference.16=gen-external-apklibs/com.actionbarsherlock_actionbarsherlock_4.2.0 android.library.reference.16=gen-external-apklibs/com.actionbarsherlock_actionbarsherlock_4.2.0
android.library.reference.17=gen-external-apklibs/org.solovyev.android_android-common-keyboard_1.0.6 android.library.reference.17=gen-external-apklibs/org.solovyev.android_android-common-keyboard_1.0.7-SNAPSHOT

View File

@ -17,7 +17,8 @@ import org.solovyev.android.calculator.view.NumeralBasesButton;
import org.solovyev.android.calculator.view.OnDragListenerVibrator; import org.solovyev.android.calculator.view.OnDragListenerVibrator;
import org.solovyev.android.history.HistoryDragProcessor; import org.solovyev.android.history.HistoryDragProcessor;
import org.solovyev.android.view.drag.*; import org.solovyev.android.view.drag.*;
import org.solovyev.common.Announcer; import org.solovyev.common.listeners.JListeners;
import org.solovyev.common.listeners.Listeners;
import org.solovyev.common.math.Point2d; import org.solovyev.common.math.Point2d;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -42,7 +43,7 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
private Vibrator vibrator; private Vibrator vibrator;
@NotNull @NotNull
private final Announcer<DragPreferencesChangeListener> dpclRegister = new Announcer<DragPreferencesChangeListener>(DragPreferencesChangeListener.class); private final JListeners<DragPreferencesChangeListener> dpclRegister = Listeners.newHardRefListeners();
@NotNull @NotNull
private String logTag = "CalculatorActivity"; private String logTag = "CalculatorActivity";
@ -79,7 +80,7 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
} }
public void processButtons(@NotNull final Activity activity, @NotNull View root) { public void processButtons(@NotNull final Activity activity, @NotNull View root) {
dpclRegister.clear(); dpclRegister.removeAll();
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
final SimpleOnDragListener.Preferences dragPreferences = SimpleOnDragListener.getPreferences(preferences, activity); final SimpleOnDragListener.Preferences dragPreferences = SimpleOnDragListener.getPreferences(preferences, activity);
@ -239,7 +240,10 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) { public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
if (key != null && key.startsWith("org.solovyev.android.calculator.DragButtonCalibrationActivity")) { if (key != null && key.startsWith("org.solovyev.android.calculator.DragButtonCalibrationActivity")) {
dpclRegister.announce().onDragPreferencesChange(SimpleOnDragListener.getPreferences(preferences, CalculatorApplication.getInstance())); final SimpleOnDragListener.Preferences dragPreferences = SimpleOnDragListener.getPreferences(preferences, CalculatorApplication.getInstance());
for (DragPreferencesChangeListener dragPreferencesChangeListener : dpclRegister.getListeners()) {
dragPreferencesChangeListener.onDragPreferencesChange(dragPreferences);
}
} }
} }

View File

@ -5,7 +5,7 @@ import android.os.Handler;
import android.widget.Toast; import android.widget.Toast;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils; import org.solovyev.android.AThreads;
import org.solovyev.android.msg.AndroidMessage; import org.solovyev.android.msg.AndroidMessage;
import org.solovyev.common.msg.Message; import org.solovyev.common.msg.Message;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
@ -32,7 +32,7 @@ public class AndroidCalculatorNotifier implements CalculatorNotifier {
} }
public AndroidCalculatorNotifier(@NotNull Application application, boolean showDebugMessages) { public AndroidCalculatorNotifier(@NotNull Application application, boolean showDebugMessages) {
assert AndroidUtils.isUiThread(); assert AThreads.isUiThread();
this.application = application; this.application = application;
this.showDebugMessages = showDebugMessages; this.showDebugMessages = showDebugMessages;
@ -61,7 +61,7 @@ public class AndroidCalculatorNotifier implements CalculatorNotifier {
} }
private void showMessageInUiThread(@NotNull final String message) { private void showMessageInUiThread(@NotNull final String message) {
if (AndroidUtils.isUiThread()) { if (AThreads.isUiThread()) {
Toast.makeText(application, message, Toast.LENGTH_SHORT).show(); Toast.makeText(application, message, Toast.LENGTH_SHORT).show();
} else { } else {
uiHandler.post(new Runnable() { uiHandler.post(new Runnable() {

View File

@ -23,14 +23,16 @@ import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AActivities;
import org.solovyev.android.AThreads;
import org.solovyev.android.AndroidUtils; import org.solovyev.android.AndroidUtils;
import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment; import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment;
import org.solovyev.android.calculator.plot.CalculatorPlotActivity; import org.solovyev.android.calculator.plot.CalculatorPlotActivity;
import org.solovyev.android.fragments.FragmentUtils; import org.solovyev.android.fragments.FragmentUtils;
import org.solovyev.android.prefs.Preference; import org.solovyev.android.prefs.Preference;
import org.solovyev.common.equals.EqualsTool; import org.solovyev.common.Objects;
import org.solovyev.common.history.HistoryAction; import org.solovyev.common.history.HistoryAction;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
public class CalculatorActivity extends SherlockFragmentActivity implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEventListener { public class CalculatorActivity extends SherlockFragmentActivity implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEventListener {
@ -114,7 +116,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
if (!CalculatorApplication.isMonkeyRunner(context)) { if (!CalculatorApplication.isMonkeyRunner(context)) {
boolean dialogShown = false; boolean dialogShown = false;
if (EqualsTool.areEqual(savedVersion, CalculatorPreferences.appVersion.getDefaultValue())) { if (Objects.areEqual(savedVersion, CalculatorPreferences.appVersion.getDefaultValue())) {
// new start // new start
final AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(R.string.c_first_start_text); final AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(R.string.c_first_start_text);
builder.setPositiveButton(android.R.string.ok, null); builder.setPositiveButton(android.R.string.ok, null);
@ -126,7 +128,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
final boolean showReleaseNotes = CalculatorPreferences.Gui.showReleaseNotes.getPreference(preferences); final boolean showReleaseNotes = CalculatorPreferences.Gui.showReleaseNotes.getPreference(preferences);
if (showReleaseNotes) { if (showReleaseNotes) {
final String releaseNotes = CalculatorReleaseNotesFragment.getReleaseNotes(context, savedVersion + 1); final String releaseNotes = CalculatorReleaseNotesFragment.getReleaseNotes(context, savedVersion + 1);
if (!StringUtils.isEmpty(releaseNotes)) { if (!Strings.isEmpty(releaseNotes)) {
final AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(Html.fromHtml(releaseNotes)); final AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(Html.fromHtml(releaseNotes));
builder.setPositiveButton(android.R.string.ok, null); builder.setPositiveButton(android.R.string.ok, null);
builder.setTitle(R.string.c_release_notes); builder.setTitle(R.string.c_release_notes);
@ -199,7 +201,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final CalculatorPreferences.Gui.Layout newLayout = CalculatorPreferences.Gui.layout.getPreference(preferences); final CalculatorPreferences.Gui.Layout newLayout = CalculatorPreferences.Gui.layout.getPreference(preferences);
if ( newLayout != activityHelper.getLayout() ) { if ( newLayout != activityHelper.getLayout() ) {
AndroidUtils.restartActivity(this); AActivities.restartActivity(this);
} }
this.activityHelper.onResume(this); this.activityHelper.onResume(this);
@ -330,12 +332,12 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) { switch (calculatorEventType) {
case plot_graph: case plot_graph:
Threads.tryRunOnUiThread(this, new Runnable() { AThreads.tryRunOnUiThread(this, new Runnable() {
@Override @Override
public void run() { public void run() {
if ( isMultiPane() ) { if (isMultiPane()) {
final ActionBar.Tab selectedTab = getSupportActionBar().getSelectedTab(); final ActionBar.Tab selectedTab = getSupportActionBar().getSelectedTab();
if ( selectedTab != null && CalculatorFragmentType.plotter.getFragmentTag().equals(selectedTab.getTag()) ) { if (selectedTab != null && CalculatorFragmentType.plotter.getFragmentTag().equals(selectedTab.getTag())) {
// do nothing - fragment shown and already registered for plot updates // do nothing - fragment shown and already registered for plot updates
} else { } else {
// otherwise - open fragment // otherwise - open fragment

View File

@ -18,7 +18,8 @@ import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils; import org.solovyev.android.AActivities;
import org.solovyev.android.AViews;
import org.solovyev.android.sherlock.tabs.ActionBarFragmentTabListener; import org.solovyev.android.sherlock.tabs.ActionBarFragmentTabListener;
/** /**
@ -112,7 +113,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
final ActionBar actionBar = activity.getSupportActionBar(); final ActionBar actionBar = activity.getSupportActionBar();
if (activity instanceof CalculatorActivity) { if (activity instanceof CalculatorActivity) {
if (AndroidUtils.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT) { if (AViews.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT) {
actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowTitleEnabled(true);
} else { } else {
actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(false);
@ -144,7 +145,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
final CalculatorPreferences.Gui.Theme newTheme = CalculatorPreferences.Gui.theme.getPreference(preferences); final CalculatorPreferences.Gui.Theme newTheme = CalculatorPreferences.Gui.theme.getPreference(preferences);
if (!theme.equals(newTheme)) { if (!theme.equals(newTheme)) {
AndroidUtils.restartActivity(activity); AActivities.restartActivity(activity);
} }
} }
@ -281,13 +282,13 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
final StringBuilder helpText = new StringBuilder(); final StringBuilder helpText = new StringBuilder();
helpText.append("Size: "); helpText.append("Size: ");
if (AndroidUtils.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE, c)) { if (AViews.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE, c)) {
helpText.append("xlarge"); helpText.append("xlarge");
} else if (AndroidUtils.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, c)) { } else if (AViews.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, c)) {
helpText.append("large"); helpText.append("large");
} else if (AndroidUtils.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL, c)) { } else if (AViews.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL, c)) {
helpText.append("normal"); helpText.append("normal");
} else if (AndroidUtils.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_SMALL, c)) { } else if (AViews.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_SMALL, c)) {
helpText.append("small"); helpText.append("small");
} else { } else {
helpText.append("unknown"); helpText.append("unknown");

View File

@ -14,7 +14,7 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
import jscl.math.Generic; import jscl.math.Generic;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils2; import org.solovyev.android.AndroidUtils;
import org.solovyev.android.App; import org.solovyev.android.App;
import org.solovyev.android.calculator.about.CalculatorAboutActivity; import org.solovyev.android.calculator.about.CalculatorAboutActivity;
import org.solovyev.android.calculator.function.FunctionEditDialogFragment; import org.solovyev.android.calculator.function.FunctionEditDialogFragment;
@ -27,7 +27,7 @@ import org.solovyev.android.calculator.plot.CalculatorPlotter;
import org.solovyev.android.calculator.preferences.CalculatorPreferencesActivity; import org.solovyev.android.calculator.preferences.CalculatorPreferencesActivity;
import org.solovyev.common.msg.Message; import org.solovyev.common.msg.Message;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import java.util.List; import java.util.List;
@ -47,7 +47,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
public static void showHistory(@NotNull final Context context, boolean detached) { public static void showHistory(@NotNull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorHistoryActivity.class); final Intent intent = new Intent(context, CalculatorHistoryActivity.class);
AndroidUtils2.addFlags(intent, detached, context); AndroidUtils.addIntentFlags(intent, detached, context);
context.startActivity(intent); context.startActivity(intent);
} }
@ -60,7 +60,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
} }
public static void showSettings(@NotNull final Context context, boolean detached) { public static void showSettings(@NotNull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorPreferencesActivity.class); final Intent intent = new Intent(context, CalculatorPreferencesActivity.class);
AndroidUtils2.addFlags(intent, detached, context); AndroidUtils.addIntentFlags(intent, detached, context);
context.startActivity(intent); context.startActivity(intent);
} }
@ -74,7 +74,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
public static void showFunctions(@NotNull final Context context, boolean detached) { public static void showFunctions(@NotNull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorFunctionsActivity.class); final Intent intent = new Intent(context, CalculatorFunctionsActivity.class);
AndroidUtils2.addFlags(intent, detached, context); AndroidUtils.addIntentFlags(intent, detached, context);
context.startActivity(intent); context.startActivity(intent);
} }
@ -84,7 +84,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
public static void showOperators(@NotNull final Context context, boolean detached) { public static void showOperators(@NotNull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorOperatorsActivity.class); final Intent intent = new Intent(context, CalculatorOperatorsActivity.class);
AndroidUtils2.addFlags(intent, detached, context); AndroidUtils.addIntentFlags(intent, detached, context);
context.startActivity(intent); context.startActivity(intent);
} }
@ -94,14 +94,14 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
public static void showVars(@NotNull final Context context, boolean detached) { public static void showVars(@NotNull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorVarsActivity.class); final Intent intent = new Intent(context, CalculatorVarsActivity.class);
AndroidUtils2.addFlags(intent, detached, context); AndroidUtils.addIntentFlags(intent, detached, context);
context.startActivity(intent); context.startActivity(intent);
} }
public static void plotGraph(@NotNull final Context context){ public static void plotGraph(@NotNull final Context context){
final Intent intent = new Intent(); final Intent intent = new Intent();
intent.setClass(context, CalculatorPlotActivity.class); intent.setClass(context, CalculatorPlotActivity.class);
AndroidUtils2.addFlags(intent, false, context); AndroidUtils.addIntentFlags(intent, false, context);
context.startActivity(intent); context.startActivity(intent);
} }
@ -110,14 +110,14 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
final CalculatorDisplayViewState viewState = display.getViewState(); final CalculatorDisplayViewState viewState = display.getViewState();
if (viewState.isValid() ) { if (viewState.isValid() ) {
final String varValue = viewState.getText(); final String varValue = viewState.getText();
if (!StringUtils.isEmpty(varValue)) { if (!Strings.isEmpty(varValue)) {
if (CalculatorVarsFragment.isValidValue(varValue)) { if (CalculatorVarsFragment.isValidValue(varValue)) {
if (context instanceof SherlockFragmentActivity) { if (context instanceof SherlockFragmentActivity) {
VarEditDialogFragment.showDialog(VarEditDialogFragment.Input.newFromValue(varValue), ((SherlockFragmentActivity) context).getSupportFragmentManager()); VarEditDialogFragment.showDialog(VarEditDialogFragment.Input.newFromValue(varValue), ((SherlockFragmentActivity) context).getSupportFragmentManager());
} else { } else {
final Intent intent = new Intent(context, CalculatorVarsActivity.class); final Intent intent = new Intent(context, CalculatorVarsActivity.class);
intent.putExtra(CalculatorVarsFragment.CREATE_VAR_EXTRA_STRING, varValue); intent.putExtra(CalculatorVarsFragment.CREATE_VAR_EXTRA_STRING, varValue);
AndroidUtils2.addFlags(intent, false, context); AndroidUtils.addIntentFlags(intent, false, context);
context.startActivity(intent); context.startActivity(intent);
} }
} else { } else {
@ -137,7 +137,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
if (viewState.isValid() ) { if (viewState.isValid() ) {
final String functionValue = viewState.getText(); final String functionValue = viewState.getText();
if (!StringUtils.isEmpty(functionValue)) { if (!Strings.isEmpty(functionValue)) {
FunctionEditDialogFragment.showDialog(FunctionEditDialogFragment.Input.newFromDisplay(viewState), context); FunctionEditDialogFragment.showDialog(FunctionEditDialogFragment.Input.newFromDisplay(viewState), context);
@ -162,7 +162,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
if (viewState.isValid() ) { if (viewState.isValid() ) {
final String functionValue = viewState.getText(); final String functionValue = viewState.getText();
final Generic expression = viewState.getResult(); final Generic expression = viewState.getResult();
if (!StringUtils.isEmpty(functionValue) && expression != null) { if (!Strings.isEmpty(functionValue) && expression != null) {
if ( plotter.isPlotPossibleFor(expression) ) { if ( plotter.isPlotPossibleFor(expression) ) {
plotter.plot(expression); plotter.plot(expression);
} else { } else {
@ -184,7 +184,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
public static void likeButtonPressed(@NotNull final Context context) { public static void likeButtonPressed(@NotNull 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(CalculatorApplication.FACEBOOK_APP_URL));
AndroidUtils2.addFlags(intent, false, context); AndroidUtils.addIntentFlags(intent, false, context);
context.startActivity(intent); context.startActivity(intent);
} }
@ -204,22 +204,22 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
if ( source instanceof Context ) { if ( source instanceof Context ) {
context = ((Context) source); context = ((Context) source);
} else { } else {
context = App.getInstance().getApplication(); context = App.getApplication();
} }
switch (calculatorEventType){ switch (calculatorEventType){
case show_create_matrix_dialog: case show_create_matrix_dialog:
App.getInstance().getUiThreadExecutor().execute(new Runnable() { App.getUiThreadExecutor().execute(new Runnable() {
@Override @Override
public void run() { public void run() {
final Intent intent = new Intent(context, CalculatorMatrixActivity.class); final Intent intent = new Intent(context, CalculatorMatrixActivity.class);
AndroidUtils2.addFlags(intent, false, context); AndroidUtils.addIntentFlags(intent, false, context);
context.startActivity(intent); context.startActivity(intent);
} }
}); });
break; break;
case show_create_var_dialog: case show_create_var_dialog:
App.getInstance().getUiThreadExecutor().execute(new Runnable() { App.getUiThreadExecutor().execute(new Runnable() {
@Override @Override
public void run() { public void run() {
CalculatorActivityLauncher.tryCreateVar(context); CalculatorActivityLauncher.tryCreateVar(context);
@ -227,7 +227,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
}); });
break; break;
case show_create_function_dialog: case show_create_function_dialog:
App.getInstance().getUiThreadExecutor().execute(new Runnable() { App.getUiThreadExecutor().execute(new Runnable() {
@Override @Override
public void run() { public void run() {
CalculatorActivityLauncher.tryCreateFunction(context); CalculatorActivityLauncher.tryCreateFunction(context);
@ -237,7 +237,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
case show_evaluation_error: case show_evaluation_error:
final String errorMessage = (String) data; final String errorMessage = (String) data;
if (errorMessage != null) { if (errorMessage != null) {
App.getInstance().getUiThreadExecutor().execute(new Runnable() { App.getUiThreadExecutor().execute(new Runnable() {
@Override @Override
public void run() { public void run() {
showEvaluationError(context, errorMessage); showEvaluationError(context, errorMessage);
@ -248,7 +248,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
case show_message_dialog: case show_message_dialog:
final DialogData dialogData = (DialogData) data; final DialogData dialogData = (DialogData) data;
if (dialogData != null) { if (dialogData != null) {
App.getInstance().getUiThreadExecutor().execute(new Runnable() { App.getUiThreadExecutor().execute(new Runnable() {
@Override @Override
public void run() { public void run() {
CalculatorDialogActivity.showDialog(context, dialogData); CalculatorDialogActivity.showDialog(context, dialogData);

View File

@ -13,7 +13,7 @@ import org.acra.ACRA;
import org.acra.ReportingInteractionMode; import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes; import org.acra.annotation.ReportsCrashes;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.android.AndroidUtils2; import org.solovyev.android.AndroidUtils;
import org.solovyev.android.App; import org.solovyev.android.App;
import org.solovyev.android.ads.AdsController; import org.solovyev.android.ads.AdsController;
import org.solovyev.android.calculator.external.AndroidExternalListenersContainer; import org.solovyev.android.calculator.external.AndroidExternalListenersContainer;
@ -100,7 +100,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
public void onCreate() { public void onCreate() {
ACRA.init(this); ACRA.init(this);
App.getInstance().init(this); App.init(this);
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
CalculatorPreferences.setDefaultValues(preferences); CalculatorPreferences.setDefaultValues(preferences);
@ -221,7 +221,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (CalculatorPreferences.OnscreenCalculator.showAppIcon.getKey().equals(key)) { if (CalculatorPreferences.OnscreenCalculator.showAppIcon.getKey().equals(key)) {
boolean showAppIcon = CalculatorPreferences.OnscreenCalculator.showAppIcon.getPreference(prefs); boolean showAppIcon = CalculatorPreferences.OnscreenCalculator.showAppIcon.getPreference(prefs);
AndroidUtils2.toggleComponent(this, CalculatorOnscreenStartActivity.class, showAppIcon); AndroidUtils.toggleComponent(this, CalculatorOnscreenStartActivity.class, showAppIcon);
Locator.getInstance().getNotifier().showMessage(R.string.cpp_this_change_may_require_reboot, MessageType.info); Locator.getInstance().getNotifier().showMessage(R.string.cpp_this_change_may_require_reboot, MessageType.info);
} }
} }

View File

@ -11,10 +11,10 @@ import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils2; import org.solovyev.android.AndroidUtils;
import org.solovyev.android.fragments.FragmentUtils; import org.solovyev.android.fragments.FragmentUtils;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
/** /**
* User: serso * User: serso
@ -33,7 +33,7 @@ public class CalculatorDialogActivity extends SherlockFragmentActivity {
final Intent intent = new Intent(); final Intent intent = new Intent();
intent.setClass(context, CalculatorDialogActivity.class); intent.setClass(context, CalculatorDialogActivity.class);
intent.putExtra(DIALOG_DATA_EXTRA, ParcelableDialogData.wrap(dialogData)); intent.putExtra(DIALOG_DATA_EXTRA, ParcelableDialogData.wrap(dialogData));
AndroidUtils2.addFlags(intent, false, context); AndroidUtils.addIntentFlags(intent, false, context);
context.startActivity(intent); context.startActivity(intent);
} }
@ -49,7 +49,7 @@ public class CalculatorDialogActivity extends SherlockFragmentActivity {
setContentView(R.layout.cpp_dialog); setContentView(R.layout.cpp_dialog);
final String title = dialogData.getTitle(); final String title = dialogData.getTitle();
if (!StringUtils.isEmpty(title)) { if (!Strings.isEmpty(title)) {
setTitle(title); setTitle(title);
} }

View File

@ -27,7 +27,7 @@ public class CalculatorEditorFragment extends SherlockFragment {
private CalculatorFragmentHelper fragmentHelper; private CalculatorFragmentHelper fragmentHelper;
@NotNull @NotNull
private ActivityMenu<Menu, MenuItem> menu = ListActivityMenu.fromList(CalculatorMenu.class, SherlockMenuHelper.getInstance()); private ActivityMenu<Menu, MenuItem> menu = ListActivityMenu.fromEnum(CalculatorMenu.class, SherlockMenuHelper.getInstance());
public CalculatorEditorFragment() { public CalculatorEditorFragment() {
} }

View File

@ -18,7 +18,7 @@ import org.solovyev.android.calculator.CalculatorApplication;
import org.solovyev.android.calculator.CalculatorFragment; import org.solovyev.android.calculator.CalculatorFragment;
import org.solovyev.android.calculator.CalculatorFragmentType; import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
/** /**
* User: serso * User: serso
@ -58,7 +58,7 @@ public class CalculatorReleaseNotesFragment extends CalculatorFragment {
boolean first = true; boolean first = true;
for ( int i = version; i >= minVersion; i-- ) { for ( int i = version; i >= minVersion; i-- ) {
String releaseNotesForVersion = textHelper.getText("c_release_notes_for_" + i); String releaseNotesForVersion = textHelper.getText("c_release_notes_for_" + i);
if (!StringUtils.isEmpty(releaseNotesForVersion)){ if (!Strings.isEmpty(releaseNotesForVersion)){
assert releaseNotesForVersion != null; assert releaseNotesForVersion != null;
if ( !first ) { if ( !first ) {
result.append("<br/><br/>"); result.append("<br/><br/>");

View File

@ -14,7 +14,7 @@ import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.math.edit.VarEditorSaver; import org.solovyev.android.calculator.math.edit.VarEditorSaver;
import org.solovyev.android.calculator.model.AFunction; import org.solovyev.android.calculator.model.AFunction;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -79,7 +79,7 @@ public class FunctionEditorSaver implements View.OnClickListener {
if (canBeSaved) { if (canBeSaved) {
if (validateParameters(parameterNames)) { if (validateParameters(parameterNames)) {
if (!StringUtils.isEmpty(content)) { if (!Strings.isEmpty(content)) {
builder.setParameterNames(parameterNames); builder.setParameterNames(parameterNames);
builder.setName(name); builder.setName(name);
builder.setDescription(description); builder.setDescription(description);

View File

@ -26,15 +26,14 @@ import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.jscl.JsclOperation; import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.android.menu.*; import org.solovyev.android.menu.*;
import org.solovyev.android.sherlock.menu.SherlockMenuHelper; import org.solovyev.android.sherlock.menu.SherlockMenuHelper;
import org.solovyev.common.collections.CollectionsUtils; import org.solovyev.common.JPredicate;
import org.solovyev.common.collections.Collections;
import org.solovyev.common.equals.Equalizer; import org.solovyev.common.equals.Equalizer;
import org.solovyev.common.filter.Filter; import org.solovyev.common.filter.Filter;
import org.solovyev.common.filter.FilterRule;
import org.solovyev.common.filter.FilterRulesChain; import org.solovyev.common.filter.FilterRulesChain;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -145,7 +144,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
final HistoryItemMenuData data = new HistoryItemMenuData(historyState, adapter); final HistoryItemMenuData data = new HistoryItemMenuData(historyState, adapter);
final List<HistoryItemMenuItem> menuItems = CollectionsUtils.asList(HistoryItemMenuItem.values()); final List<HistoryItemMenuItem> menuItems = Collections.asList(HistoryItemMenuItem.values());
if (historyState.isSaved()) { if (historyState.isSaved()) {
menuItems.remove(HistoryItemMenuItem.save); menuItems.remove(HistoryItemMenuItem.save);
@ -157,11 +156,11 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
menuItems.remove(HistoryItemMenuItem.edit); menuItems.remove(HistoryItemMenuItem.edit);
} }
if (historyState.getDisplayState().isValid() && StringUtils.isEmpty(historyState.getDisplayState().getEditorState().getText())) { if (historyState.getDisplayState().isValid() && Strings.isEmpty(historyState.getDisplayState().getEditorState().getText())) {
menuItems.remove(HistoryItemMenuItem.copy_result); menuItems.remove(HistoryItemMenuItem.copy_result);
} }
final AMenuBuilder<HistoryItemMenuItem, HistoryItemMenuData> menuBuilder = AMenuBuilder.newInstance(context, MenuImpl.newInstance(menuItems)); final ContextMenuBuilder<HistoryItemMenuItem, HistoryItemMenuData> menuBuilder = ContextMenuBuilder.newInstance(context, ListContextMenu.newInstance(menuItems));
menuBuilder.create(data).show(); menuBuilder.create(data).show();
return true; return true;
@ -219,7 +218,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
boolean result = false; boolean result = false;
try { try {
historyState.setSaved(true); historyState.setSaved(true);
if ( CollectionsUtils.contains(historyState, Locator.getInstance().getHistory().getSavedHistory(), new Equalizer<CalculatorHistoryState>() { if ( Collections.contains(historyState, Locator.getInstance().getHistory().getSavedHistory(), new Equalizer<CalculatorHistoryState>() {
@Override @Override
public boolean equals(@Nullable CalculatorHistoryState first, @Nullable CalculatorHistoryState second) { public boolean equals(@Nullable CalculatorHistoryState first, @Nullable CalculatorHistoryState second) {
return first != null && second != null && return first != null && second != null &&
@ -244,13 +243,13 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
private List<CalculatorHistoryState> getHistoryList() { private List<CalculatorHistoryState> getHistoryList() {
final List<CalculatorHistoryState> calculatorHistoryStates = getHistoryItems(); final List<CalculatorHistoryState> calculatorHistoryStates = getHistoryItems();
Collections.sort(calculatorHistoryStates, COMPARATOR); java.util.Collections.sort(calculatorHistoryStates, COMPARATOR);
final FilterRulesChain<CalculatorHistoryState> filterRulesChain = new FilterRulesChain<CalculatorHistoryState>(); final FilterRulesChain<CalculatorHistoryState> filterRulesChain = new FilterRulesChain<CalculatorHistoryState>();
filterRulesChain.addFilterRule(new FilterRule<CalculatorHistoryState>() { filterRulesChain.addFilterRule(new JPredicate<CalculatorHistoryState>() {
@Override @Override
public boolean isFiltered(CalculatorHistoryState object) { public boolean apply(CalculatorHistoryState object) {
return object == null || StringUtils.isEmpty(object.getEditorState().getText()); return object == null || Strings.isEmpty(object.getEditorState().getText());
} }
}); });

View File

@ -13,7 +13,7 @@ import android.widget.ArrayAdapter;
import android.widget.TextView; import android.widget.TextView;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@ -45,7 +45,7 @@ public class HistoryArrayAdapter extends ArrayAdapter<CalculatorHistoryState> {
final TextView commentView = (TextView) result.findViewById(R.id.history_item_comment); final TextView commentView = (TextView) result.findViewById(R.id.history_item_comment);
if (commentView != null) { if (commentView != null) {
final String comment = state.getComment(); final String comment = state.getComment();
if (!StringUtils.isEmpty(comment)) { if (!Strings.isEmpty(comment)) {
commentView.setText(comment); commentView.setText(comment);
} else { } else {
commentView.setText(""); commentView.setText("");

View File

@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import org.solovyev.android.menu.LabeledMenuItem; import org.solovyev.android.menu.LabeledMenuItem;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
/** /**
* User: serso * User: serso
@ -41,7 +41,7 @@ public enum HistoryItemMenuItem implements LabeledMenuItem<HistoryItemMenuData>
public void onClick(@NotNull HistoryItemMenuData data, @NotNull Context context) { public void onClick(@NotNull HistoryItemMenuData data, @NotNull Context context) {
final CalculatorHistoryState calculatorHistoryState = data.getHistoryState(); final CalculatorHistoryState calculatorHistoryState = data.getHistoryState();
final String text = calculatorHistoryState.getEditorState().getText(); final String text = calculatorHistoryState.getEditorState().getText();
if (!StringUtils.isEmpty(text)) { if (!Strings.isEmpty(text)) {
final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE); final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
clipboard.setText(text); clipboard.setText(text);
Toast.makeText(context, context.getText(R.string.c_expression_copied), Toast.LENGTH_SHORT).show(); Toast.makeText(context, context.getText(R.string.c_expression_copied), Toast.LENGTH_SHORT).show();
@ -54,7 +54,7 @@ public enum HistoryItemMenuItem implements LabeledMenuItem<HistoryItemMenuData>
public void onClick(@NotNull HistoryItemMenuData data, @NotNull Context context) { public void onClick(@NotNull HistoryItemMenuData data, @NotNull Context context) {
final CalculatorHistoryState calculatorHistoryState = data.getHistoryState(); final CalculatorHistoryState calculatorHistoryState = data.getHistoryState();
final String text = calculatorHistoryState.getDisplayState().getEditorState().getText(); final String text = calculatorHistoryState.getDisplayState().getEditorState().getText();
if (!StringUtils.isEmpty(text)) { if (!Strings.isEmpty(text)) {
final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE); final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
clipboard.setText(text); clipboard.setText(text);
Toast.makeText(context, context.getText(R.string.c_result_copied), Toast.LENGTH_SHORT).show(); Toast.makeText(context, context.getText(R.string.c_result_copied), Toast.LENGTH_SHORT).show();

View File

@ -20,15 +20,15 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.CalculatorFragmentType; import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.menu.AMenuBuilder;
import org.solovyev.android.menu.AMenuItem; import org.solovyev.android.menu.AMenuItem;
import org.solovyev.android.menu.ContextMenuBuilder;
import org.solovyev.android.menu.LabeledMenuItem; import org.solovyev.android.menu.LabeledMenuItem;
import org.solovyev.android.menu.MenuImpl; import org.solovyev.android.menu.ListContextMenu;
import org.solovyev.common.equals.EqualsTool; import org.solovyev.common.JPredicate;
import org.solovyev.common.Objects;
import org.solovyev.common.filter.Filter; import org.solovyev.common.filter.Filter;
import org.solovyev.common.filter.FilterRule;
import org.solovyev.common.math.MathEntity; import org.solovyev.common.math.MathEntity;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
@ -51,7 +51,7 @@ 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"; 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(StringUtils.toObject("1234567890abcdefghijklmnopqrstuvwxyzйцукенгшщзхъфывапролджэячсмитьбюё_".toCharArray())); protected final static List<Character> acceptableChars = Arrays.asList(Strings.toObject("1234567890abcdefghijklmnopqrstuvwxyzйцукенгшщзхъфывапролджэячсмитьбюё_".toCharArray()));
/* /*
@ -124,7 +124,7 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
final List<LabeledMenuItem<T>> menuItems = getMenuItemsOnLongClick(item); final List<LabeledMenuItem<T>> menuItems = getMenuItemsOnLongClick(item);
if (!menuItems.isEmpty()) { if (!menuItems.isEmpty()) {
final AMenuBuilder<LabeledMenuItem<T>, T> menuBuilder = AMenuBuilder.newInstance(AbstractMathEntityListFragment.this.getActivity(), MenuImpl.newInstance(menuItems)); final ContextMenuBuilder<LabeledMenuItem<T>, T> menuBuilder = ContextMenuBuilder.newInstance(AbstractMathEntityListFragment.this.getActivity(), ListContextMenu.newInstance(menuItems));
menuBuilder.create(item).show(); menuBuilder.create(item).show();
} }
@ -169,9 +169,9 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
private List<T> getMathEntitiesByCategory() { private List<T> getMathEntitiesByCategory() {
final List<T> result = getMathEntities(); final List<T> result = getMathEntities();
new Filter<T>(new FilterRule<T>() { new Filter<T>(new JPredicate<T>() {
@Override @Override
public boolean isFiltered(T t) { public boolean apply(T t) {
return !isInCategory(t); return !isInCategory(t);
} }
}).filter(result.iterator()); }).filter(result.iterator());
@ -180,7 +180,7 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
} }
protected boolean isInCategory(@Nullable T t) { protected boolean isInCategory(@Nullable T t) {
return t != null && (category == null || EqualsTool.areEqual(getMathEntityCategory(t), category)); return t != null && (category == null || Objects.areEqual(getMathEntityCategory(t), category));
} }
@NotNull @NotNull
@ -246,7 +246,7 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
final String mathEntityDescription = descriptionGetter.getDescription(getContext(), mathEntity.getName()); final String mathEntityDescription = descriptionGetter.getDescription(getContext(), mathEntity.getName());
final TextView description = (TextView) result.findViewById(R.id.math_entity_description); final TextView description = (TextView) result.findViewById(R.id.math_entity_description);
if (!StringUtils.isEmpty(mathEntityDescription)) { if (!Strings.isEmpty(mathEntityDescription)) {
description.setVisibility(View.VISIBLE); description.setVisibility(View.VISIBLE);
description.setText(mathEntityDescription); description.setText(mathEntityDescription);
} else { } else {

View File

@ -24,7 +24,7 @@ import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.function.FunctionEditDialogFragment; import org.solovyev.android.calculator.function.FunctionEditDialogFragment;
import org.solovyev.android.menu.AMenuItem; import org.solovyev.android.menu.AMenuItem;
import org.solovyev.android.menu.LabeledMenuItem; import org.solovyev.android.menu.LabeledMenuItem;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -73,7 +73,7 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment<
List<LabeledMenuItem<Function>> result = new ArrayList<LabeledMenuItem<Function>>(Arrays.asList(LongClickMenuItem.values())); List<LabeledMenuItem<Function>> result = new ArrayList<LabeledMenuItem<Function>>(Arrays.asList(LongClickMenuItem.values()));
final CalculatorMathRegistry<Function> functionsRegistry = Locator.getInstance().getEngine().getFunctionsRegistry(); final CalculatorMathRegistry<Function> functionsRegistry = Locator.getInstance().getEngine().getFunctionsRegistry();
if ( StringUtils.isEmpty(functionsRegistry.getDescription(item.getName())) ) { if ( Strings.isEmpty(functionsRegistry.getDescription(item.getName())) ) {
result.remove(LongClickMenuItem.copy_description); result.remove(LongClickMenuItem.copy_description);
} }
@ -247,7 +247,7 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment<
@Override @Override
public void onClick(@NotNull Function function, @NotNull Context context) { public void onClick(@NotNull Function function, @NotNull Context context) {
final String text = Locator.getInstance().getEngine().getFunctionsRegistry().getDescription(function.getName()); final String text = Locator.getInstance().getEngine().getFunctionsRegistry().getDescription(function.getName());
if (!StringUtils.isEmpty(text)) { if (!Strings.isEmpty(text)) {
final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE); final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
clipboard.setText(text); clipboard.setText(text);
} }

View File

@ -11,7 +11,7 @@ import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.CalculatorFragmentType; import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.menu.AMenuItem; import org.solovyev.android.menu.AMenuItem;
import org.solovyev.android.menu.LabeledMenuItem; import org.solovyev.android.menu.LabeledMenuItem;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -39,7 +39,7 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment<
protected List<LabeledMenuItem<Operator>> getMenuItemsOnLongClick(@NotNull Operator item) { protected List<LabeledMenuItem<Operator>> getMenuItemsOnLongClick(@NotNull Operator item) {
final List<LabeledMenuItem<Operator>> result = new ArrayList<LabeledMenuItem<Operator>>(Arrays.asList(LongClickMenuItem.values())); final List<LabeledMenuItem<Operator>> result = new ArrayList<LabeledMenuItem<Operator>>(Arrays.asList(LongClickMenuItem.values()));
if ( StringUtils.isEmpty(OperatorDescriptionGetter.instance.getDescription(this.getActivity(), item.getName())) ) { if ( Strings.isEmpty(OperatorDescriptionGetter.instance.getDescription(this.getActivity(), item.getName())) ) {
result.remove(LongClickMenuItem.copy_description); result.remove(LongClickMenuItem.copy_description);
} }
@ -81,7 +81,7 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment<
@Override @Override
public String getDescription(@NotNull Context context, @NotNull String mathEntityName) { public String getDescription(@NotNull Context context, @NotNull String mathEntityName) {
String result = Locator.getInstance().getEngine().getOperatorsRegistry().getDescription(mathEntityName); String result = Locator.getInstance().getEngine().getOperatorsRegistry().getDescription(mathEntityName);
if (StringUtils.isEmpty(result)) { if (Strings.isEmpty(result)) {
result = Locator.getInstance().getEngine().getPostfixFunctionsRegistry().getDescription(mathEntityName); result = Locator.getInstance().getEngine().getPostfixFunctionsRegistry().getDescription(mathEntityName);
} }
@ -110,7 +110,7 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment<
@Override @Override
public void onClick(@NotNull Operator data, @NotNull Context context) { public void onClick(@NotNull Operator data, @NotNull Context context) {
final String text = OperatorDescriptionGetter.instance.getDescription(context, data.getName()); final String text = OperatorDescriptionGetter.instance.getDescription(context, data.getName());
if (!StringUtils.isEmpty(text)) { if (!Strings.isEmpty(text)) {
final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE); final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
clipboard.setText(text); clipboard.setText(text);
} }

View File

@ -22,8 +22,8 @@ import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.menu.AMenuItem; import org.solovyev.android.menu.AMenuItem;
import org.solovyev.android.menu.LabeledMenuItem; import org.solovyev.android.menu.LabeledMenuItem;
import org.solovyev.common.JPredicate; import org.solovyev.common.JPredicate;
import org.solovyev.common.collections.CollectionsUtils; import org.solovyev.common.collections.Collections;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -49,7 +49,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
final Bundle bundle = getArguments(); final Bundle bundle = getArguments();
if (bundle != null) { if (bundle != null) {
final String varValue = bundle.getString(CREATE_VAR_EXTRA_STRING); final String varValue = bundle.getString(CREATE_VAR_EXTRA_STRING);
if (!StringUtils.isEmpty(varValue)) { if (!Strings.isEmpty(varValue)) {
VarEditDialogFragment.showDialog(VarEditDialogFragment.Input.newFromValue(varValue), this.getActivity().getSupportFragmentManager()); VarEditDialogFragment.showDialog(VarEditDialogFragment.Input.newFromValue(varValue), this.getActivity().getSupportFragmentManager());
// in order to stop intent for other tabs // in order to stop intent for other tabs
@ -75,11 +75,11 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
result.remove(LongClickMenuItem.remove); result.remove(LongClickMenuItem.remove);
} }
if (StringUtils.isEmpty(Locator.getInstance().getEngine().getVarsRegistry().getDescription(item.getName()))) { if (Strings.isEmpty(Locator.getInstance().getEngine().getVarsRegistry().getDescription(item.getName()))) {
result.remove(LongClickMenuItem.copy_description); result.remove(LongClickMenuItem.copy_description);
} }
if (StringUtils.isEmpty(item.getValue())) { if (Strings.isEmpty(item.getValue())) {
result.remove(LongClickMenuItem.copy_value); result.remove(LongClickMenuItem.copy_value);
} }
@ -102,10 +102,10 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
protected List<IConstant> getMathEntities() { protected List<IConstant> getMathEntities() {
final List<IConstant> result = new ArrayList<IConstant>(Locator.getInstance().getEngine().getVarsRegistry().getEntities()); final List<IConstant> result = new ArrayList<IConstant>(Locator.getInstance().getEngine().getVarsRegistry().getEntities());
CollectionsUtils.removeAll(result, new JPredicate<IConstant>() { Collections.removeAll(result, new JPredicate<IConstant>() {
@Override @Override
public boolean apply(@Nullable IConstant var) { public boolean apply(@Nullable IConstant var) {
return var != null && CollectionsUtils.contains(var.getName(), MathType.INFINITY_JSCL, MathType.NAN); return var != null && Collections.contains(var.getName(), MathType.INFINITY_JSCL, MathType.NAN);
} }
}); });
@ -249,7 +249,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
@Override @Override
public void onClick(@NotNull IConstant data, @NotNull Context context) { public void onClick(@NotNull IConstant data, @NotNull Context context) {
final String text = data.getValue(); final String text = data.getValue();
if (!StringUtils.isEmpty(text)) { if (!Strings.isEmpty(text)) {
assert text != null; assert text != null;
Locator.getInstance().getClipboard().setText(text); Locator.getInstance().getClipboard().setText(text);
} }
@ -260,7 +260,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
@Override @Override
public void onClick(@NotNull IConstant data, @NotNull Context context) { public void onClick(@NotNull IConstant data, @NotNull Context context) {
final String text = Locator.getInstance().getEngine().getVarsRegistry().getDescription(data.getName()); final String text = Locator.getInstance().getEngine().getVarsRegistry().getDescription(data.getName());
if (!StringUtils.isEmpty(text)) { if (!Strings.isEmpty(text)) {
assert text != null; assert text != null;
Locator.getInstance().getClipboard().setText(text); Locator.getInstance().getClipboard().setText(text);
} }

View File

@ -22,7 +22,7 @@ import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.calculator.model.MathEntityBuilder; import org.solovyev.android.calculator.model.MathEntityBuilder;
import org.solovyev.common.math.MathEntity; import org.solovyev.common.math.MathEntity;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
/** /**
* User: serso * User: serso
@ -87,7 +87,7 @@ public class VarEditorSaver<T extends MathEntity> implements View.OnClickListene
if (mathType.getMathType() == MathType.text || mathType.getMathType() == MathType.constant) { if (mathType.getMathType() == MathType.text || mathType.getMathType() == MathType.constant) {
if (StringUtils.isEmpty(value)) { if (Strings.isEmpty(value)) {
// value is empty => undefined variable // value is empty => undefined variable
varBuilder.setName(name); varBuilder.setName(name);
varBuilder.setDescription(description); varBuilder.setDescription(description);
@ -126,7 +126,7 @@ public class VarEditorSaver<T extends MathEntity> implements View.OnClickListene
public static boolean isValidName(@Nullable String name) { public static boolean isValidName(@Nullable String name) {
boolean result = false; boolean result = false;
if (!StringUtils.isEmpty(name)) { if (!Strings.isEmpty(name)) {
try { try {
assert name != null; assert name != null;
Identifier.parser.parse(Parser.Parameters.newInstance(name, new MutableInt(0), Locator.getInstance().getEngine().getMathEngine0()), null); Identifier.parser.parse(Parser.Parameters.newInstance(name, new MutableInt(0), Locator.getInstance().getEngine().getMathEngine0()), null);

View File

@ -16,7 +16,8 @@ import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils2; import org.solovyev.android.AThreads;
import org.solovyev.android.AndroidUtils;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.menu.AMenuItem; import org.solovyev.android.menu.AMenuItem;
@ -152,7 +153,7 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
} }
private void updateChart(@NotNull final PlotData plotData, @Nullable final SherlockFragmentActivity activity) { private void updateChart(@NotNull final PlotData plotData, @Nullable final SherlockFragmentActivity activity) {
Threads.tryRunOnUiThread(activity, new Runnable() { AThreads.tryRunOnUiThread(activity, new Runnable() {
@Override @Override
public void run() { public void run() {
createChart(plotData); createChart(plotData);
@ -308,7 +309,7 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
final File externalFilesDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES); final File externalFilesDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
if (externalFilesDir != null) { if (externalFilesDir != null) {
final String path = externalFilesDir.getPath(); final String path = externalFilesDir.getPath();
AndroidUtils2.saveBitmap(screenshot, path, screenShotFileName); AndroidUtils.saveBitmap(screenshot, path, screenShotFileName);
Locator.getInstance().getNotifier().showMessage(R.string.cpp_plot_screenshot_saved, MessageType.info, path + "/" + screenShotFileName); Locator.getInstance().getNotifier().showMessage(R.string.cpp_plot_screenshot_saved, MessageType.info, path + "/" + screenShotFileName);
} else { } else {
Locator.getInstance().getNotifier().showMessage(R.string.cpp_plot_unable_to_save_screenshot, MessageType.error); Locator.getInstance().getNotifier().showMessage(R.string.cpp_plot_unable_to_save_screenshot, MessageType.error);

View File

@ -5,7 +5,7 @@ package org.solovyev.android.calculator.plot;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.VelocityTracker; import android.view.VelocityTracker;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.android.AndroidUtils2; import org.solovyev.android.AViews;
class TouchHandler { class TouchHandler {
@ -43,7 +43,7 @@ class TouchHandler {
float x = event.getX(); float x = event.getX();
float y = event.getY(); float y = event.getY();
int pointerCount = AndroidUtils2.getPointerCountFromMotionEvent(event); int pointerCount = AViews.getPointerCountFromMotionEvent(event);
switch (action) { switch (action) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
@ -63,7 +63,7 @@ class TouchHandler {
velocityTracker.addMovement(event); velocityTracker.addMovement(event);
listener.onTouchMove(x, y); listener.onTouchMove(x, y);
} else if (pointerCount == 2) { } else if (pointerCount == 2) {
listener.onTouchZoomMove(x, y, AndroidUtils2.getXFromMotionEvent(event, 1), AndroidUtils2.getYFromMotionEvent(event, 1)); listener.onTouchZoomMove(x, y, AViews.getXFromMotionEvent(event, 1), AViews.getYFromMotionEvent(event, 1));
} }
break; break;
@ -75,7 +75,7 @@ class TouchHandler {
case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_POINTER_DOWN:
if (pointerCount == 2) { if (pointerCount == 2) {
listener.onTouchZoomDown(x, y, AndroidUtils2.getXFromMotionEvent(event, 1), AndroidUtils2.getYFromMotionEvent(event, 1)); listener.onTouchZoomDown(x, y, AViews.getXFromMotionEvent(event, 1), AViews.getYFromMotionEvent(event, 1));
} }
break; break;

View File

@ -21,7 +21,7 @@ import net.robotmedia.billing.ResponseCode;
import net.robotmedia.billing.helper.AbstractBillingObserver; import net.robotmedia.billing.helper.AbstractBillingObserver;
import net.robotmedia.billing.model.Transaction; import net.robotmedia.billing.model.Transaction;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.android.AndroidUtils; import org.solovyev.android.AActivities;
import org.solovyev.android.App; import org.solovyev.android.App;
import org.solovyev.android.ads.AdsController; import org.solovyev.android.ads.AdsController;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
@ -156,7 +156,7 @@ public class CalculatorPreferencesActivity extends SherlockPreferenceActivity im
case PURCHASED: case PURCHASED:
adFreePreference.setEnabled(false); adFreePreference.setEnabled(false);
// restart activity to disable ads // restart activity to disable ads
AndroidUtils.restartActivity(this); AActivities.restartActivity(this);
break; break;
case CANCELLED: case CANCELLED:
adFreePreference.setEnabled(true); adFreePreference.setEnabled(true);
@ -177,7 +177,7 @@ public class CalculatorPreferencesActivity extends SherlockPreferenceActivity im
if (response == ResponseCode.RESULT_OK) { if (response == ResponseCode.RESULT_OK) {
adFreePreference.setEnabled(false); adFreePreference.setEnabled(false);
final Message message = new AndroidMessage(R.string.cpp_purchase_thank_you_text, MessageType.info, App.getInstance().getApplication()); final Message message = new AndroidMessage(R.string.cpp_purchase_thank_you_text, MessageType.info, App.getApplication());
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_message_dialog, MessageDialogData.newInstance(message, null)); Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_message_dialog, MessageDialogData.newInstance(message, null));
} }
} }

View File

@ -8,7 +8,7 @@ import android.support.v4.app.FragmentTransaction;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.common.collections.CollectionsUtils; import org.solovyev.common.collections.Collections;
import java.util.List; import java.util.List;
@ -51,7 +51,7 @@ public class FragmentUtils {
} }
public static void removeFragments(@NotNull SherlockFragmentActivity activity, @NotNull String... fragmentTags) { public static void removeFragments(@NotNull SherlockFragmentActivity activity, @NotNull String... fragmentTags) {
removeFragments(activity, CollectionsUtils.asList(fragmentTags)); removeFragments(activity, Collections.asList(fragmentTags));
} }
public static void removeFragments(@NotNull SherlockFragmentActivity activity, @NotNull List<String> fragmentTags) { public static void removeFragments(@NotNull SherlockFragmentActivity activity, @NotNull List<String> fragmentTags) {
@ -61,7 +61,7 @@ public class FragmentUtils {
} }
public static void detachFragments(@NotNull SherlockFragmentActivity activity, @NotNull String... fragmentTags) { public static void detachFragments(@NotNull SherlockFragmentActivity activity, @NotNull String... fragmentTags) {
detachFragments(activity, CollectionsUtils.asList(fragmentTags)); detachFragments(activity, Collections.asList(fragmentTags));
} }
public static void detachFragments(@NotNull SherlockFragmentActivity activity, @NotNull List<String> fragmentTags) { public static void detachFragments(@NotNull SherlockFragmentActivity activity, @NotNull List<String> fragmentTags) {

View File

@ -4,8 +4,8 @@ import junit.framework.Assert;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.junit.Test; import org.junit.Test;
import org.solovyev.android.calculator.units.CalculatorNumeralBase; import org.solovyev.android.calculator.units.CalculatorNumeralBase;
import org.solovyev.math.units.Unit; import org.solovyev.common.units.Unit;
import org.solovyev.math.units.UnitConverter; import org.solovyev.common.units.UnitConverter;
import java.util.Date; import java.util.Date;
import java.util.Random; import java.util.Random;

View File

@ -53,7 +53,7 @@ public class AndroidCalculatorEditorViewTest {
for ( int j = 0; j < count; j++ ) { for ( int j = 0; j < count; j++ ) {
try { try {
int textLength = random.nextInt(maxTextLength); int textLength = random.nextInt(maxTextLength);
Locator.getInstance().getEditor().insert(StringUtils.generateRandomString(textLength), textLength); Locator.getInstance().getEditor().insert(Strings.generateRandomString(textLength), textLength);
} catch (Throwable e) { } catch (Throwable e) {
System.out.println(e); System.out.println(e);
error.set(true); error.set(true);

View File

@ -14,7 +14,7 @@ import org.solovyev.android.calculator.CalculatorEditorViewState;
import org.solovyev.android.calculator.CalculatorEditorViewStateImpl; import org.solovyev.android.calculator.CalculatorEditorViewStateImpl;
import org.solovyev.android.calculator.jscl.JsclOperation; import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.common.equals.CollectionEqualizer; import org.solovyev.common.equals.CollectionEqualizer;
import org.solovyev.common.equals.EqualsTool; import org.solovyev.common.Objects;
import org.solovyev.common.history.HistoryHelper; import org.solovyev.common.history.HistoryHelper;
import org.solovyev.common.history.SimpleHistoryHelper; import org.solovyev.common.history.SimpleHistoryHelper;
@ -122,7 +122,7 @@ public class HistoryUtilsTest {
public void testToXml() throws Exception { public void testToXml() throws Exception {
final Date date = new Date(100000000); final Date date = new Date(100000000);
HistoryHelper<CalculatorHistoryState> history = new SimpleHistoryHelper<CalculatorHistoryState>(); HistoryHelper<CalculatorHistoryState> history = SimpleHistoryHelper.newInstance();
CalculatorDisplayViewState calculatorDisplay = CalculatorDisplayViewStateImpl.newErrorState(JsclOperation.simplify, "Error"); CalculatorDisplayViewState calculatorDisplay = CalculatorDisplayViewStateImpl.newErrorState(JsclOperation.simplify, "Error");
@ -170,7 +170,7 @@ public class HistoryUtilsTest {
Assert.assertEquals(toXml2, xml); Assert.assertEquals(toXml2, xml);
final List<CalculatorHistoryState> fromXml = new ArrayList<CalculatorHistoryState>(); final List<CalculatorHistoryState> fromXml = new ArrayList<CalculatorHistoryState>();
final HistoryHelper<CalculatorHistoryState> historyFromXml = new SimpleHistoryHelper<CalculatorHistoryState>(); final HistoryHelper<CalculatorHistoryState> historyFromXml = SimpleHistoryHelper.newInstance();
HistoryUtils.fromXml(xml, fromXml); HistoryUtils.fromXml(xml, fromXml);
for (CalculatorHistoryState historyState : fromXml) { for (CalculatorHistoryState historyState : fromXml) {
historyFromXml.addState(historyState); historyFromXml.addState(historyState);
@ -186,6 +186,6 @@ public class HistoryUtilsTest {
historyState.setId(0); historyState.setId(0);
historyState.setSaved(true); historyState.setSaved(true);
} }
Assert.assertTrue(EqualsTool.areEqual(history.getStates(), historyFromXml.getStates(), new CollectionEqualizer<CalculatorHistoryState>(null))); Assert.assertTrue(Objects.areEqual(history.getStates(), historyFromXml.getStates(), new CollectionEqualizer<CalculatorHistoryState>(null)));
} }
} }

View File

@ -1,22 +0,0 @@
package org.solovyev.common;
import junit.framework.Assert;
import org.junit.Test;
import org.solovyev.common.interval.IntervalImpl;
import org.solovyev.common.text.NumberIntervalMapper;
/**
* User: serso
* Date: 9/23/11
* Time: 2:54 PM
*/
public class FloatIntervalMapperTest {
@Test
public void testParse() throws Exception {
final NumberIntervalMapper<Float> mapper = new NumberIntervalMapper<Float>(Float.class);
Assert.assertEquals(IntervalImpl.newClosed(1.2f, 12.2f), mapper.parseValue("1.2;12.2"));
Assert.assertEquals(IntervalImpl.newPoint(0f), mapper.parseValue("0;0"));
}
}

View File

@ -1,34 +0,0 @@
package org.solovyev.common.math;
import org.junit.Assert;
import org.junit.Test;
/**
* User: serso
* Date: 9/20/11
* Time: 5:51 PM
*/
public class DiscreteNormalizerTest {
@Test
public void testNormalize() throws Exception {
DiscreteNormalizer dn = new DiscreteNormalizer(0, 10, 1d);
Assert.assertTrue(MathUtils.equals(0, dn.normalize(0.5), 2));
Assert.assertTrue(MathUtils.equals(0, dn.normalize(0.99), 2));
Assert.assertTrue(MathUtils.equals(0.1, dn.normalize(1), 2));
Assert.assertTrue(MathUtils.equals(0.1, dn.normalize(1.01), 2));
Assert.assertTrue(MathUtils.equals(1, dn.normalize(10), 2));
Assert.assertTrue(MathUtils.equals(0.9, dn.normalize(9.99), 2));
}
@Test
public void testDenormalize() throws Exception {
DiscreteNormalizer dn = new DiscreteNormalizer(0, 10, 1d);
Assert.assertTrue(MathUtils.equals(0, dn.normalize(dn.denormalize(0)), 2));
Assert.assertTrue(MathUtils.equals(0.1, dn.normalize(dn.denormalize(0.1)), 2));
Assert.assertTrue(MathUtils.equals(1, dn.normalize(dn.denormalize(1)), 2));
Assert.assertTrue(MathUtils.equals(0.9, dn.normalize(dn.denormalize(0.9)), 2));
}
}

View File

@ -10,7 +10,7 @@ import jscl.NumeralBase;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.math.MathType;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
/** /**
* User: serso * User: serso
@ -48,7 +48,7 @@ public abstract class AbstractNumberBuilder {
} }
private boolean spaceBefore(@NotNull MathType.Result mathTypeResult) { private boolean spaceBefore(@NotNull MathType.Result mathTypeResult) {
return numberBuilder == null && StringUtils.isEmpty(mathTypeResult.getMatch().trim()); return numberBuilder == null && Strings.isEmpty(mathTypeResult.getMatch().trim());
} }
private boolean numeralBaseInTheStart(@NotNull MathType mathType) { private boolean numeralBaseInTheStart(@NotNull MathType mathType) {

View File

@ -4,7 +4,7 @@ import jscl.math.Generic;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.jscl.JsclOperation; import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
/** /**
* User: serso * User: serso
@ -89,7 +89,7 @@ public class CalculatorDisplayViewStateImpl implements CalculatorDisplayViewStat
@NotNull @NotNull
@Override @Override
public String getText() { public String getText() {
return StringUtils.getNotEmpty(isValid() ? stringResult : errorMessage, ""); return Strings.getNotEmpty(isValid() ? stringResult : errorMessage, "");
} }
@Override @Override

View File

@ -5,7 +5,7 @@ import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.history.CalculatorHistoryState; import org.solovyev.android.calculator.history.CalculatorHistoryState;
import org.solovyev.android.calculator.history.EditorHistoryState; import org.solovyev.android.calculator.history.EditorHistoryState;
import org.solovyev.common.gui.CursorControl; import org.solovyev.common.gui.CursorControl;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
/** /**
* User: Solovyev_S * User: Solovyev_S
@ -93,7 +93,7 @@ public class CalculatorEditorImpl implements CalculatorEditor {
case use_history_state: case use_history_state:
final CalculatorHistoryState calculatorHistoryState = (CalculatorHistoryState)data; final CalculatorHistoryState calculatorHistoryState = (CalculatorHistoryState)data;
final EditorHistoryState editorState = calculatorHistoryState.getEditorState(); final EditorHistoryState editorState = calculatorHistoryState.getEditorState();
this.setText(StringUtils.getNotEmpty(editorState.getText(), ""), editorState.getCursorPosition()); this.setText(Strings.getNotEmpty(editorState.getText(), ""), editorState.getCursorPosition());
break; break;
} }
} }

View File

@ -4,7 +4,7 @@ import jscl.AngleUnit;
import jscl.text.msg.Messages; import jscl.text.msg.Messages;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.common.collections.CollectionsUtils; import org.solovyev.common.collections.Collections;
import java.util.List; import java.util.List;
@ -40,7 +40,7 @@ public enum CalculatorFixableError implements FixableError {
private final List<String> messageCodes; private final List<String> messageCodes;
CalculatorFixableError(@Nullable String... messageCodes) { CalculatorFixableError(@Nullable String... messageCodes) {
this.messageCodes = CollectionsUtils.asList(messageCodes); this.messageCodes = Collections.asList(messageCodes);
} }
@Nullable @Nullable

View File

@ -18,7 +18,7 @@ import org.solovyev.android.calculator.model.Functions;
import org.solovyev.android.calculator.model.MathEntityBuilder; import org.solovyev.android.calculator.model.MathEntityBuilder;
import org.solovyev.common.JBuilder; import org.solovyev.common.JBuilder;
import org.solovyev.common.math.MathRegistry; import org.solovyev.common.math.MathRegistry;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -101,7 +101,7 @@ public class CalculatorFunctionsMathRegistry extends AbstractCalculatorMathRegis
result = ((CustomFunction) function).getDescription(); result = ((CustomFunction) function).getDescription();
} }
if (StringUtils.isEmpty(result) ) { if (Strings.isEmpty(result) ) {
result = super.getDescription(functionName); result = super.getDescription(functionName);
} }

View File

@ -21,9 +21,9 @@ import org.solovyev.common.msg.ListMessageRegistry;
import org.solovyev.common.msg.Message; import org.solovyev.common.msg.Message;
import org.solovyev.common.msg.MessageRegistry; import org.solovyev.common.msg.MessageRegistry;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import org.solovyev.math.units.ConversionException; import org.solovyev.common.units.ConversionException;
import org.solovyev.math.units.ConversionUtils; import org.solovyev.common.units.Conversions;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -209,7 +209,7 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener {
expression = expression.trim(); expression = expression.trim();
if (StringUtils.isEmpty(expression)) { if (Strings.isEmpty(expression)) {
fireCalculatorEvent(newCalculationEventData(operation, expression, sequenceId), CalculatorEventType.calculation_result, CalculatorOutputImpl.newEmptyOutput(operation)); fireCalculatorEvent(newCalculationEventData(operation, expression, sequenceId), CalculatorEventType.calculation_result, CalculatorOutputImpl.newEmptyOutput(operation));
} else { } else {
preparedExpression = prepareExpression(expression); preparedExpression = prepareExpression(expression);
@ -367,7 +367,7 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener {
if (from != to) { if (from != to) {
String fromString = generic.toString(); String fromString = generic.toString();
if (!StringUtils.isEmpty(fromString)) { if (!Strings.isEmpty(fromString)) {
try { try {
fromString = ToJsclTextProcessor.getInstance().process(fromString).getExpression(); fromString = ToJsclTextProcessor.getInstance().process(fromString).getExpression();
} catch (CalculatorParseException e) { } catch (CalculatorParseException e) {
@ -375,7 +375,8 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener {
} }
} }
result = ConversionUtils.doConversion(CalculatorNumeralBase.getConverter(), fromString, CalculatorNumeralBase.valueOf(from), CalculatorNumeralBase.valueOf(to));
result = Conversions.doConversion(CalculatorNumeralBase.getConverter(), fromString, CalculatorNumeralBase.valueOf(from), CalculatorNumeralBase.valueOf(to));
} else { } else {
result = generic.toString(); result = generic.toString();
} }
@ -531,7 +532,7 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener {
final CalculatorDisplayViewState newState = displayChangeEventData.getNewValue(); final CalculatorDisplayViewState newState = displayChangeEventData.getNewValue();
if (newState.isValid()) { if (newState.isValid()) {
final String result = newState.getStringResult(); final String result = newState.getStringResult();
if ( !StringUtils.isEmpty(result) ) { if ( !Strings.isEmpty(result) ) {
final CalculatorMathRegistry<IConstant> varsRegistry = Locator.getInstance().getEngine().getVarsRegistry(); final CalculatorMathRegistry<IConstant> varsRegistry = Locator.getInstance().getEngine().getVarsRegistry();
final IConstant ansVar = varsRegistry.get(CalculatorVarsRegistry.ANS); final IConstant ansVar = varsRegistry.get(CalculatorVarsRegistry.ANS);

View File

@ -3,7 +3,7 @@ package org.solovyev.android.calculator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.math.MathType;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
/** /**
* User: serso * User: serso
@ -22,7 +22,7 @@ public class CalculatorKeyboardImpl implements CalculatorKeyboard {
@Override @Override
public void buttonPressed(@Nullable final String text) { public void buttonPressed(@Nullable final String text) {
if (!StringUtils.isEmpty(text)) { if (!Strings.isEmpty(text)) {
assert text != null; assert text != null;
// process special buttons // process special buttons
@ -105,7 +105,7 @@ public class CalculatorKeyboardImpl implements CalculatorKeyboard {
final CalculatorDisplayViewState displayViewState = Locator.getInstance().getDisplay().getViewState(); final CalculatorDisplayViewState displayViewState = Locator.getInstance().getDisplay().getViewState();
if (displayViewState.isValid()) { if (displayViewState.isValid()) {
final CharSequence text = displayViewState.getText(); final CharSequence text = displayViewState.getText();
if (!StringUtils.isEmpty(text)) { if (!Strings.isEmpty(text)) {
Locator.getInstance().getClipboard().setText(text); Locator.getInstance().getClipboard().setText(text);
Locator.getInstance().getNotifier().showMessage(CalculatorMessage.newInfoMessage(CalculatorMessages.result_copied)); Locator.getInstance().getNotifier().showMessage(CalculatorMessage.newInfoMessage(CalculatorMessages.result_copied));
} }

View File

@ -5,10 +5,9 @@ import jscl.math.function.Comparison;
import jscl.math.function.Function; import jscl.math.function.Function;
import jscl.math.function.Trigonometric; import jscl.math.function.Trigonometric;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.common.collections.CollectionsUtils; import org.solovyev.common.collections.Collections;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -75,9 +74,9 @@ public enum FunctionCategory {
@NotNull @NotNull
public static List<FunctionCategory> getCategoriesByTabOrder() { public static List<FunctionCategory> getCategoriesByTabOrder() {
final List<FunctionCategory> result = CollectionsUtils.asList(FunctionCategory.values()); final List<FunctionCategory> result = Collections.asList(FunctionCategory.values());
Collections.sort(result, new Comparator<FunctionCategory>() { java.util.Collections.sort(result, new Comparator<FunctionCategory>() {
@Override @Override
public int compare(FunctionCategory category, FunctionCategory category1) { public int compare(FunctionCategory category, FunctionCategory category1) {
return category.tabOrder - category1.tabOrder; return category.tabOrder - category1.tabOrder;

View File

@ -2,9 +2,11 @@ package org.solovyev.android.calculator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.common.utils.ListListenersContainer; import org.solovyev.common.listeners.JListeners;
import org.solovyev.common.listeners.Listeners;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.List; import java.util.List;
/** /**
@ -18,7 +20,7 @@ public class ListCalculatorEventContainer implements CalculatorEventContainer {
private static final String TAG = "CalculatorEventData"; private static final String TAG = "CalculatorEventData";
@NotNull @NotNull
private final ListListenersContainer<CalculatorEventListener> listeners = new ListListenersContainer<CalculatorEventListener>(); private final JListeners<CalculatorEventListener> listeners = Listeners.newWeakRefListeners();
@Override @Override
public void addCalculatorEventListener(@NotNull CalculatorEventListener calculatorEventListener) { public void addCalculatorEventListener(@NotNull CalculatorEventListener calculatorEventListener) {
@ -37,7 +39,7 @@ public class ListCalculatorEventContainer implements CalculatorEventContainer {
@Override @Override
public void fireCalculatorEvents(@NotNull List<CalculatorEvent> calculatorEvents) { public void fireCalculatorEvents(@NotNull List<CalculatorEvent> calculatorEvents) {
final List<CalculatorEventListener> listeners = this.listeners.getListeners(); final Collection<CalculatorEventListener> listeners = this.listeners.getListeners();
//final CalculatorLogger logger = Locator.getInstance().getLogger(); //final CalculatorLogger logger = Locator.getInstance().getLogger();

View File

@ -2,9 +2,8 @@ package org.solovyev.android.calculator;
import jscl.math.operator.*; import jscl.math.operator.*;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.common.collections.CollectionsUtils; import org.solovyev.common.collections.Collections;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -61,9 +60,9 @@ public enum OperatorCategory {
@NotNull @NotNull
public static List<OperatorCategory> getCategoriesByTabOrder() { public static List<OperatorCategory> getCategoriesByTabOrder() {
final List<OperatorCategory> result = CollectionsUtils.asList(OperatorCategory.values()); final List<OperatorCategory> result = Collections.asList(OperatorCategory.values());
Collections.sort(result, new Comparator<OperatorCategory>() { java.util.Collections.sort(result, new Comparator<OperatorCategory>() {
@Override @Override
public int compare(OperatorCategory category, OperatorCategory category1) { public int compare(OperatorCategory category, OperatorCategory category1) {
return category.tabOrder - category1.tabOrder; return category.tabOrder - category1.tabOrder;

View File

@ -11,9 +11,9 @@ import jscl.math.function.IConstant;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.calculator.text.TextProcessor; import org.solovyev.android.calculator.text.TextProcessor;
import org.solovyev.common.StartsWithFinder; import org.solovyev.common.collections.Collections;
import org.solovyev.common.collections.CollectionsUtils;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
import org.solovyev.common.search.StartsWithFinder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -47,7 +47,7 @@ public class ToJsclTextProcessor implements TextProcessor<PreparedExpression, St
@NotNull @NotNull
private static StringBuilder processExpression(@NotNull String s) throws CalculatorParseException { private static StringBuilder processExpression(@NotNull String s) throws CalculatorParseException {
final StartsWithFinder startsWithFinder = new StartsWithFinder(s, 0); final StartsWithFinder startsWithFinder = StartsWithFinder.newInstance(s);
final StringBuilder result = new StringBuilder(); final StringBuilder result = new StringBuilder();
MathType.Result mathTypeResult = null; MathType.Result mathTypeResult = null;
@ -75,7 +75,7 @@ public class ToJsclTextProcessor implements TextProcessor<PreparedExpression, St
if (mathTypeBefore != null && if (mathTypeBefore != null &&
(mathTypeBefore.getMathType() == MathType.function || mathTypeBefore.getMathType() == MathType.operator) && (mathTypeBefore.getMathType() == MathType.function || mathTypeBefore.getMathType() == MathType.operator) &&
CollectionsUtils.find(MathType.openGroupSymbols, startsWithFinder) != null) { Collections.find(MathType.openGroupSymbols, startsWithFinder) != null) {
final String functionName = mathTypeBefore.getMatch(); final String functionName = mathTypeBefore.getMatch();
final Function function = Locator.getInstance().getEngine().getFunctionsRegistry().get(functionName); final Function function = Locator.getInstance().getEngine().getFunctionsRegistry().get(functionName);
if ( function == null || function.getMinParameters() > 0 ) { if ( function == null || function.getMinParameters() > 0 ) {
@ -96,18 +96,18 @@ public class ToJsclTextProcessor implements TextProcessor<PreparedExpression, St
depth++; depth++;
} }
final StartsWithFinder startsWithFinder = new StartsWithFinder(s, 0); final StartsWithFinder startsWithFinder = StartsWithFinder.newInstance(s);
final StringBuilder result = new StringBuilder(); final StringBuilder result = new StringBuilder();
for (int i = 0; i < s.length(); i++) { for (int i = 0; i < s.length(); i++) {
startsWithFinder.setI(i); startsWithFinder.setI(i);
int offset = 0; int offset = 0;
String functionName = CollectionsUtils.find(MathType.function.getTokens(), startsWithFinder); String functionName = Collections.find(MathType.function.getTokens(), startsWithFinder);
if (functionName == null) { if (functionName == null) {
String operatorName = CollectionsUtils.find(MathType.operator.getTokens(), startsWithFinder); String operatorName = Collections.find(MathType.operator.getTokens(), startsWithFinder);
if (operatorName == null) { if (operatorName == null) {
String varName = CollectionsUtils.find(Locator.getInstance().getEngine().getVarsRegistry().getNames(), startsWithFinder); String varName = Collections.find(Locator.getInstance().getEngine().getVarsRegistry().getNames(), startsWithFinder);
if (varName != null) { if (varName != null) {
final IConstant var = Locator.getInstance().getEngine().getVarsRegistry().get(varName); final IConstant var = Locator.getInstance().getEngine().getVarsRegistry().get(varName);
if (var != null) { if (var != null) {

View File

@ -2,9 +2,8 @@ package org.solovyev.android.calculator;
import jscl.math.function.IConstant; import jscl.math.function.IConstant;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.common.collections.CollectionsUtils; import org.solovyev.common.collections.Collections;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -39,9 +38,9 @@ public enum VarCategory {
@NotNull @NotNull
public static List<VarCategory> getCategoriesByTabOrder() { public static List<VarCategory> getCategoriesByTabOrder() {
final List<VarCategory> result = CollectionsUtils.asList(VarCategory.values()); final List<VarCategory> result = Collections.asList(VarCategory.values());
Collections.sort(result, new Comparator<VarCategory>() { java.util.Collections.sort(result, new Comparator<VarCategory>() {
@Override @Override
public int compare(VarCategory category, VarCategory category1) { public int compare(VarCategory category, VarCategory category1) {
return category.tabOrder - category1.tabOrder; return category.tabOrder - category1.tabOrder;

View File

@ -15,7 +15,7 @@ import org.solovyev.android.calculator.CalculatorDisplay;
import org.solovyev.android.calculator.CalculatorDisplayViewState; import org.solovyev.android.calculator.CalculatorDisplayViewState;
import org.solovyev.android.calculator.CalculatorDisplayViewStateImpl; import org.solovyev.android.calculator.CalculatorDisplayViewStateImpl;
import org.solovyev.android.calculator.jscl.JsclOperation; import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
/** /**
* User: serso * User: serso
@ -65,9 +65,9 @@ public class CalculatorDisplayHistoryState implements Cloneable {
public void setValuesFromHistory(@NotNull CalculatorDisplay display) { public void setValuesFromHistory(@NotNull CalculatorDisplay display) {
if ( this.isValid() ) { if ( this.isValid() ) {
display.setViewState(CalculatorDisplayViewStateImpl.newValidState(this.getJsclOperation(), this.getGenericResult(), StringUtils.getNotEmpty(this.getEditorState().getText(), ""), this.getEditorState().getCursorPosition())); display.setViewState(CalculatorDisplayViewStateImpl.newValidState(this.getJsclOperation(), this.getGenericResult(), Strings.getNotEmpty(this.getEditorState().getText(), ""), this.getEditorState().getCursorPosition()));
} else { } else {
display.setViewState(CalculatorDisplayViewStateImpl.newErrorState(this.getJsclOperation(), StringUtils.getNotEmpty(this.getErrorMessage(), ""))); display.setViewState(CalculatorDisplayViewStateImpl.newErrorState(this.getJsclOperation(), Strings.getNotEmpty(this.getErrorMessage(), "")));
} }
} }

View File

@ -3,7 +3,6 @@ package org.solovyev.android.calculator.history;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.common.collections.CollectionsUtils;
import org.solovyev.common.history.HistoryAction; import org.solovyev.common.history.HistoryAction;
import org.solovyev.common.history.HistoryHelper; import org.solovyev.common.history.HistoryHelper;
import org.solovyev.common.history.SimpleHistoryHelper; import org.solovyev.common.history.SimpleHistoryHelper;
@ -26,7 +25,7 @@ public class CalculatorHistoryImpl implements CalculatorHistory {
private final AtomicInteger counter = new AtomicInteger(0); private final AtomicInteger counter = new AtomicInteger(0);
@NotNull @NotNull
private final HistoryHelper<CalculatorHistoryState> history = new SimpleHistoryHelper<CalculatorHistoryState>(); private final HistoryHelper<CalculatorHistoryState> history = SimpleHistoryHelper.newInstance();
@NotNull @NotNull
private final List<CalculatorHistoryState> savedHistory = new ArrayList<CalculatorHistoryState>(); private final List<CalculatorHistoryState> savedHistory = new ArrayList<CalculatorHistoryState>();
@ -123,7 +122,7 @@ public class CalculatorHistoryImpl implements CalculatorHistory {
final List<CalculatorHistoryState> result = new LinkedList<CalculatorHistoryState>(); final List<CalculatorHistoryState> result = new LinkedList<CalculatorHistoryState>();
CalculatorHistoryState laterState = null; CalculatorHistoryState laterState = null;
for (CalculatorHistoryState state : CollectionsUtils.reversed(states)) { for (CalculatorHistoryState state : org.solovyev.common.collections.Collections.reversed(states)) {
if ( laterState != null ) { if ( laterState != null ) {
final String laterEditorText = laterState.getEditorState().getText(); final String laterEditorText = laterState.getEditorState().getText();
final String editorText = state.getEditorState().getText(); final String editorText = state.getEditorState().getText();

View File

@ -12,7 +12,7 @@ import org.simpleframework.xml.Root;
import org.solovyev.android.calculator.CalculatorDisplayViewState; import org.solovyev.android.calculator.CalculatorDisplayViewState;
import org.solovyev.android.calculator.CalculatorEditor; import org.solovyev.android.calculator.CalculatorEditor;
import org.solovyev.android.calculator.CalculatorEditorViewState; import org.solovyev.android.calculator.CalculatorEditorViewState;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
@Root @Root
public class EditorHistoryState implements Cloneable{ public class EditorHistoryState implements Cloneable{
@ -49,7 +49,7 @@ public class EditorHistoryState implements Cloneable{
} }
public void setValuesFromHistory(@NotNull CalculatorEditor editor) { public void setValuesFromHistory(@NotNull CalculatorEditor editor) {
editor.setText(StringUtils.getNotEmpty(this.getText(), "")); editor.setText(Strings.getNotEmpty(this.getText(), ""));
editor.setSelection(this.getCursorPosition()); editor.setSelection(this.getCursorPosition());
} }

View File

@ -13,7 +13,7 @@ import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.CalculatorParseException; import org.solovyev.android.calculator.CalculatorParseException;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
import org.solovyev.common.JPredicate; import org.solovyev.common.JPredicate;
import org.solovyev.common.collections.CollectionsUtils; import org.solovyev.common.collections.Collections;
import java.util.*; import java.util.*;
@ -190,7 +190,7 @@ public enum MathType {
boolean needMultiplicationSignAfter, boolean needMultiplicationSignAfter,
@NotNull MathGroupType groupType, @NotNull MathGroupType groupType,
@NotNull String... tokens) { @NotNull String... tokens) {
this(priority, needMultiplicationSignBefore, needMultiplicationSignAfter, groupType, CollectionsUtils.asList(tokens)); this(priority, needMultiplicationSignBefore, needMultiplicationSignAfter, groupType, Collections.asList(tokens));
} }
MathType(@NotNull Integer priority, MathType(@NotNull Integer priority,
@ -202,7 +202,7 @@ public enum MathType {
this.needMultiplicationSignBefore = needMultiplicationSignBefore; this.needMultiplicationSignBefore = needMultiplicationSignBefore;
this.needMultiplicationSignAfter = needMultiplicationSignAfter; this.needMultiplicationSignAfter = needMultiplicationSignAfter;
this.groupType = groupType; this.groupType = groupType;
this.tokens = Collections.unmodifiableList(tokens); this.tokens = java.util.Collections.unmodifiableList(tokens);
} }
@NotNull @NotNull
@ -219,7 +219,7 @@ public enum MathType {
final MathType mathType = getType(s.toString(), result).getMathType(); final MathType mathType = getType(s.toString(), result).getMathType();
if (CollectionsUtils.contains(mathType, digit, dot, grouping_separator, power_10)) { if (Collections.contains(mathType, digit, dot, grouping_separator, power_10)) {
// continue // continue
} else if (mathType == close_group_symbol) { } else if (mathType == close_group_symbol) {
numberOfOpenGroups++; numberOfOpenGroups++;
@ -246,7 +246,7 @@ public enum MathType {
if (i > 0) { if (i > 0) {
final EndsWithFinder endsWithFinder = new EndsWithFinder(s); final EndsWithFinder endsWithFinder = new EndsWithFinder(s);
endsWithFinder.setI(i + 1); endsWithFinder.setI(i + 1);
if (!CollectionsUtils.contains(function.getTokens(), FilterType.included, endsWithFinder)) { if (!Collections.contains(function.getTokens(), FilterType.included, endsWithFinder)) {
MathType type = getType(s.toString(), i).getMathType(); MathType type = getType(s.toString(), i).getMathType();
if (type != constant) { if (type != constant) {
return true; return true;
@ -350,7 +350,7 @@ public enum MathType {
final StartsWithFinder startsWithFinder = new StartsWithFinder(text, i); final StartsWithFinder startsWithFinder = new StartsWithFinder(text, i);
for (MathType mathType : getMathTypesByPriority()) { for (MathType mathType : getMathTypesByPriority()) {
final String s = CollectionsUtils.find(mathType.getTokens(), startsWithFinder); final String s = Collections.find(mathType.getTokens(), startsWithFinder);
if (s != null) { if (s != null) {
if ( s.length() == 1 ) { if ( s.length() == 1 ) {
if (hexMode || JsclMathEngine.getInstance().getNumeralBase() == NumeralBase.hex) { if (hexMode || JsclMathEngine.getInstance().getNumeralBase() == NumeralBase.hex) {
@ -373,14 +373,14 @@ public enum MathType {
@NotNull @NotNull
private static List<MathType> getMathTypesByPriority() { private static List<MathType> getMathTypesByPriority() {
if (mathTypesByPriority == null) { if (mathTypesByPriority == null) {
final List<MathType> result = CollectionsUtils.asList(MathType.values()); final List<MathType> result = Collections.asList(MathType.values());
Collections.sort(result, new Comparator<MathType>() { java.util.Collections.sort(result, new Comparator<MathType>() {
@Override @Override
public int compare(MathType l, MathType r) { public int compare(MathType l, MathType r) {
return l.priority.compareTo(r.priority); return l.priority.compareTo(r.priority);
} }
}); });
mathTypesByPriority = result; mathTypesByPriority = result;
} }

View File

@ -19,7 +19,7 @@ import org.solovyev.android.calculator.MathPersistenceEntity;
import org.solovyev.common.math.MathEntity; import org.solovyev.common.math.MathEntity;
import org.solovyev.common.msg.Message; import org.solovyev.common.msg.Message;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
@ -109,7 +109,7 @@ public class AFunction implements IFunction, MathPersistenceEntity, Serializable
@NotNull IFunction source) { @NotNull IFunction source) {
target.name = source.getName(); target.name = source.getName();
target.content = source.getContent(); target.content = source.getContent();
target.description = StringUtils.getNotEmpty(source.getDescription(), ""); target.description = Strings.getNotEmpty(source.getDescription(), "");
target.system = source.isSystem(); target.system = source.isSystem();
if (source.isIdDefined()) { if (source.isIdDefined()) {
target.id = source.getId(); target.id = source.getId();
@ -285,7 +285,7 @@ public class AFunction implements IFunction, MathPersistenceEntity, Serializable
throw new CreationException(e); throw new CreationException(e);
} }
result.system = system; result.system = system;
result.description = StringUtils.getNotEmpty(description, ""); result.description = Strings.getNotEmpty(description, "");
result.parameterNames = new ArrayList<String>(parameterNames); result.parameterNames = new ArrayList<String>(parameterNames);
return result; return result;

View File

@ -17,7 +17,7 @@ import org.simpleframework.xml.Transient;
import org.solovyev.android.calculator.MathPersistenceEntity; import org.solovyev.android.calculator.MathPersistenceEntity;
import org.solovyev.common.JBuilder; import org.solovyev.common.JBuilder;
import org.solovyev.common.math.MathEntity; import org.solovyev.common.math.MathEntity;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
/** /**
* User: serso * User: serso
@ -226,7 +226,7 @@ public class Var implements IConstant, MathPersistenceEntity {
@Override @Override
public boolean isDefined() { public boolean isDefined() {
return !StringUtils.isEmpty(value); return !Strings.isEmpty(value);
} }
@Override @Override

View File

@ -4,7 +4,7 @@ import jscl.math.Generic;
import jscl.math.function.Constant; import jscl.math.function.Constant;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
public class XyFunction implements FunctionEvaluator { public class XyFunction implements FunctionEvaluator {
@ -71,7 +71,7 @@ public class XyFunction implements FunctionEvaluator {
this.arity--; this.arity--;
} }
this.id = this.expressionString + "_" + StringUtils.getNotEmpty(this.xVariableName, "") + "_" + StringUtils.getNotEmpty(this.yVariableName, ""); this.id = this.expressionString + "_" + Strings.getNotEmpty(this.xVariableName, "") + "_" + Strings.getNotEmpty(this.yVariableName, "");
} }

View File

@ -2,10 +2,10 @@ package org.solovyev.android.calculator.units;
import jscl.NumeralBase; import jscl.NumeralBase;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.math.units.Unit; import org.solovyev.common.units.Unit;
import org.solovyev.math.units.UnitConverter; import org.solovyev.common.units.UnitConverter;
import org.solovyev.math.units.UnitImpl; import org.solovyev.common.units.UnitImpl;
import org.solovyev.math.units.UnitType; import org.solovyev.common.units.UnitType;
import java.math.BigInteger; import java.math.BigInteger;

View File

@ -1,16 +0,0 @@
package org.solovyev.common;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
/**
* User: serso
* Date: 12/1/12
* Time: 4:10 PM
*/
public interface DelayedExecutor extends Executor {
void execute(@NotNull Runnable command, long delay, @NotNull TimeUnit delayUnit);
}

View File

@ -1,35 +0,0 @@
package org.solovyev.common;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.common.text.CollectionTransformations;
import org.solovyev.common.text.Mapper;
import java.util.List;
public class ListMapper<T> implements Mapper<List<T>> {
@NotNull
private final Mapper<T> nestedMapper;
private ListMapper(@NotNull Mapper<T> nestedMapper) {
this.nestedMapper = nestedMapper;
}
@NotNull
private static <T> Mapper<List<T>> newInstance(@NotNull Mapper<T> nestedMapper) {
return new ListMapper<T>(nestedMapper);
}
@Nullable
@Override
public String formatValue(@Nullable List<T> value) throws IllegalArgumentException {
return CollectionTransformations.formatValue(value, ";", nestedMapper);
}
@Nullable
@Override
public List<T> parseValue(@Nullable String value) throws IllegalArgumentException {
return CollectionTransformations.split(value, ";", nestedMapper);
}
}

View File

@ -1,77 +0,0 @@
package org.solovyev.common.utils;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* User: Solovyev_S
* Date: 20.09.12
* Time: 16:43
*/
// todo serso: move to common
public class ListListenersContainer<T> {
@NotNull
private final List<WeakReference<T>> listeners = new ArrayList<WeakReference<T>>();
public void addListener(@NotNull final T listener) {
synchronized (listeners) {
boolean contains = Iterables.any(listeners, new WeakReferencePredicate<T>(listener));
if (!contains) {
listeners.add(new WeakReference<T>(listener));
}
}
}
public void removeListener(@NotNull T listener) {
synchronized (listeners) {
Iterables.removeIf(listeners, new WeakReferencePredicate<T>(listener));
}
}
@NotNull
public List<T> getListeners() {
final List<T> localListeners;
synchronized (listeners) {
localListeners = new ArrayList<T>(listeners.size());
// copy listeners and remove garbage collected references
for ( Iterator<WeakReference<T>> it = listeners.iterator(); it.hasNext(); ) {
final WeakReference<T> r = it.next();
final T t = r.get();
if ( t == null ) {
it.remove();
} else {
localListeners.add(t);
}
}
}
return localListeners;
}
private static class WeakReferencePredicate<T> implements Predicate<WeakReference<T>> {
@NotNull
private final T t;
public WeakReferencePredicate(T t) {
this.t = t;
}
@Override
public boolean apply(@Nullable WeakReference<T> r) {
final T t = r != null ? r.get() : null;
return this.t.equals(t);
}
}
}

View File

@ -1,15 +0,0 @@
package org.solovyev.math.units;
/**
* User: Solovyev_S
* Date: 24.09.12
* Time: 16:01
*/
public final class ConversionException extends Exception {
public ConversionException() {
}
public ConversionException(Throwable throwable) {
super(throwable);
}
}

View File

@ -1,38 +0,0 @@
package org.solovyev.math.units;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.common.text.StringUtils;
/**
* User: Solovyev_S
* Date: 24.09.12
* Time: 16:01
*/
public class ConversionUtils {
@NotNull
public static String doConversion(@NotNull UnitConverter<String> converter,
@Nullable String from,
@NotNull UnitType<String> fromUnitType,
@NotNull UnitType<String> toUnitType) throws ConversionException {
final String result;
if (StringUtils.isEmpty(from)) {
result = "";
} else {
String to = null;
try {
if (converter.isSupported(fromUnitType, toUnitType)) {
to = converter.convert(UnitImpl.newInstance(from, fromUnitType), toUnitType).getValue();
}
} catch (RuntimeException e) {
throw new ConversionException(e);
}
result = to;
}
return result;
}
}

View File

@ -1,17 +0,0 @@
package org.solovyev.math.units;
import org.jetbrains.annotations.NotNull;
/**
* User: serso
* Date: 4/21/12
* Time: 7:54 PM
*/
public interface Unit<V> {
@NotNull
V getValue();
@NotNull
UnitType<V> getUnitType();
}

View File

@ -1,42 +0,0 @@
package org.solovyev.math.units;
import org.jetbrains.annotations.NotNull;
/**
* User: serso
* Date: 4/21/12
* Time: 7:53 PM
*/
public interface UnitConverter<T> {
boolean isSupported(@NotNull UnitType<?> from, @NotNull UnitType<T> to);
@NotNull
Unit<T> convert(@NotNull Unit<?> from, @NotNull UnitType<T> toType);
public static class Dummy implements UnitConverter<Object> {
@NotNull
private static final Dummy instance = new Dummy();
@NotNull
public static <T> UnitConverter<T> getInstance() {
return (UnitConverter<T>)instance;
}
private Dummy() {
}
@Override
public boolean isSupported(@NotNull UnitType<?> from, @NotNull UnitType<Object> to) {
return false;
}
@NotNull
@Override
public Unit<Object> convert(@NotNull Unit<?> from, @NotNull UnitType<Object> toType) {
throw new IllegalArgumentException();
}
}
}

View File

@ -1,42 +0,0 @@
package org.solovyev.math.units;
import org.jetbrains.annotations.NotNull;
/**
* User: serso
* Date: 4/21/12
* Time: 8:01 PM
*/
public class UnitImpl<V> implements Unit<V> {
@NotNull
private V value;
@NotNull
private UnitType<V> unitType;
private UnitImpl() {
}
@NotNull
public static <V> Unit<V> newInstance(@NotNull V value, @NotNull UnitType<V> unitType) {
final UnitImpl<V> result = new UnitImpl<V>();
result.value = value;
result.unitType = unitType;
return result;
}
@NotNull
@Override
public V getValue() {
return this.value;
}
@NotNull
@Override
public UnitType<V> getUnitType() {
return unitType;
}
}

View File

@ -1,16 +0,0 @@
package org.solovyev.math.units;
import org.jetbrains.annotations.NotNull;
/**
* User: serso
* Date: 4/21/12
* Time: 7:55 PM
*/
public interface UnitType<V> {
@NotNull
Class<V> getUnitValueClass();
boolean equals(@NotNull Object o);
}

View File

@ -13,7 +13,7 @@ import org.simpleframework.xml.core.Persister;
import org.solovyev.android.calculator.CalculatorTestUtils; import org.solovyev.android.calculator.CalculatorTestUtils;
import org.solovyev.common.equals.CollectionEqualizer; import org.solovyev.common.equals.CollectionEqualizer;
import org.solovyev.common.equals.EqualsUtils; import org.solovyev.common.equals.EqualsUtils;
import org.solovyev.common.text.StringUtils; import org.solovyev.common.text.Strings;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.*; import java.util.*;
@ -122,7 +122,7 @@ public class FunctionsTest {
for ( int i = 0; i < 1000; i++ ) { for ( int i = 0; i < 1000; i++ ) {
final String content = generator.generate(); final String content = generator.generate();
final String paramsString = StringUtils.generateRandomString(random.nextInt(10)); final String paramsString = Strings.generateRandomString(random.nextInt(10));
final List<String> parameterNames = new ArrayList<String>(); final List<String> parameterNames = new ArrayList<String>();
for (int j = 0; j < paramsString.length(); j++) { for (int j = 0; j < paramsString.length(); j++) {
parameterNames.add(String.valueOf(paramsString.charAt(j))); parameterNames.add(String.valueOf(paramsString.charAt(j)));
@ -131,7 +131,7 @@ public class FunctionsTest {
final AFunction.Builder builder = new AFunction.Builder("test_" + i, content, parameterNames); final AFunction.Builder builder = new AFunction.Builder("test_" + i, content, parameterNames);
if ( random.nextBoolean() ) { if ( random.nextBoolean() ) {
builder.setDescription(StringUtils.generateRandomString(random.nextInt(100))); builder.setDescription(Strings.generateRandomString(random.nextInt(100)));
} }
builder.setSystem(random.nextBoolean()); builder.setSystem(random.nextBoolean());

View File

@ -33,8 +33,8 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<android.common.version>1.0.6</android.common.version> <android.common.version>1.0.7-SNAPSHOT</android.common.version>
<common.version>1.0.3</common.version> <common.version>1.0.4-SNAPSHOT</common.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>