Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
391fe95df9
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="75" android:versionName="1.2.37" package="org.solovyev.android.calculator">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="75" android:versionName="1.2.34" package="org.solovyev.android.calculator">
|
||||
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8"/>
|
||||
|
||||
<application android:debuggable="false" android:hardwareAccelerated="false" android:icon="@drawable/icon" android:label="@string/c_app_name" android:name=".CalculatorApplication">
|
||||
<application android:debuggable="true" android:hardwareAccelerated="false" android:icon="@drawable/icon" android:label="@string/c_app_name" android:name=".CalculatorApplication">
|
||||
|
||||
<activity android:label="@string/c_app_name" android:name=".CalculatorActivity" android:windowSoftInputMode="adjustPan">
|
||||
|
||||
|
@ -4,4 +4,7 @@
|
||||
|
||||
<string name="c_show_equals_button_title">Показывать клавишу равно</string>
|
||||
<string name="c_show_equals_button_summary">Если включено, то клавиша равно будет показана</string>
|
||||
|
||||
<string name="c_hide_numeral_base_digits_title">Не показывать цифры из других систем счисления</string>
|
||||
<string name="c_hide_numeral_base_digits_summary">Если включено, то цифры из других систем счисления будут спрятаны</string>
|
||||
</resources>
|
@ -4,4 +4,7 @@
|
||||
|
||||
<string name="c_show_equals_button_title">Показывать клавишу равно</string>
|
||||
<string name="c_show_equals_button_summary">Если включено, то клавиша равно будет показана</string>
|
||||
|
||||
<string name="c_hide_numeral_base_digits_title">Не показывать цифры из других систем счисления</string>
|
||||
<string name="c_hide_numeral_base_digits_summary">Если включено, то цифры из других систем счисления будут спрятаны</string>
|
||||
</resources>
|
@ -4,4 +4,7 @@
|
||||
|
||||
<string name="c_show_equals_button_title">Show equals button</string>
|
||||
<string name="c_show_equals_button_summary">If turned on equals button is shown</string>
|
||||
|
||||
<string name="c_hide_numeral_base_digits_title">Hide other numeral base digits</string>
|
||||
<string name="c_hide_numeral_base_digits_summary">If turned on other numeral base digits base will be hidden</string>
|
||||
</resources>
|
@ -148,6 +148,13 @@
|
||||
a:summary="@string/c_show_equals_button_summary"
|
||||
a:defaultValue="true"/>
|
||||
|
||||
<android.preference.CheckBoxPreference
|
||||
a:key="hideNumeralBaseDigits"
|
||||
a:title="@string/c_hide_numeral_base_digits_title"
|
||||
a:summary="@string/c_hide_numeral_base_digits_summary"
|
||||
a:defaultValue="true"/>
|
||||
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
<PreferenceScreen
|
||||
|
@ -0,0 +1,20 @@
|
||||
package org.solovyev.android;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.solovyev.android.calculator.*;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 4/23/12
|
||||
* Time: 1:56 PM
|
||||
*/
|
||||
public interface ActivityMenu {
|
||||
|
||||
public boolean onCreateOptionsMenu(@NotNull Activity activity, @NotNull Menu menu);
|
||||
|
||||
public boolean onOptionsItemSelected(@NotNull Activity activity, @NotNull MenuItem item);
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package org.solovyev.android;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.solovyev.android.menu.AMenuItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 4/23/12
|
||||
* Time: 1:57 PM
|
||||
*/
|
||||
public class LayoutActivityMenu implements ActivityMenu {
|
||||
|
||||
public final int menuLayoutId;
|
||||
|
||||
@NotNull
|
||||
private List<LayoutMenuItem> menuItems;
|
||||
|
||||
private LayoutActivityMenu(int menuLayoutId) {
|
||||
this.menuLayoutId = menuLayoutId;
|
||||
}
|
||||
|
||||
public static <E extends Enum & LayoutMenuItem> ActivityMenu newInstance(int menuLayoutId, @NotNull Class<E> enumMenuClass) {
|
||||
final LayoutActivityMenu result = new LayoutActivityMenu(menuLayoutId);
|
||||
|
||||
result.menuItems = new ArrayList<LayoutMenuItem>(enumMenuClass.getEnumConstants().length);
|
||||
|
||||
Collections.addAll(result.menuItems, enumMenuClass.getEnumConstants());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ActivityMenu newInstance(int menuLayoutId, @NotNull List<LayoutMenuItem> menuItems) {
|
||||
final LayoutActivityMenu result = new LayoutActivityMenu(menuLayoutId);
|
||||
|
||||
result.menuItems = menuItems;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(@NotNull Activity activity, @NotNull Menu menu) {
|
||||
final MenuInflater menuInflater = activity.getMenuInflater();
|
||||
menuInflater.inflate(menuLayoutId, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NotNull Activity activity, @NotNull MenuItem item) {
|
||||
for (LayoutMenuItem menuItem : menuItems) {
|
||||
if (menuItem.getItemId().equals(item.getItemId())) {
|
||||
menuItem.onClick(item, activity);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return activity.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public static interface LayoutMenuItem extends AMenuItem<MenuItem> {
|
||||
|
||||
@NotNull
|
||||
Integer getItemId();
|
||||
}
|
||||
}
|
@ -28,10 +28,7 @@ import net.robotmedia.billing.BillingController;
|
||||
import net.robotmedia.billing.IBillingObserver;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.AndroidUtils;
|
||||
import org.solovyev.android.FontSizeAdjuster;
|
||||
import org.solovyev.android.LocalBinder;
|
||||
import org.solovyev.android.ResourceCache;
|
||||
import org.solovyev.android.*;
|
||||
import org.solovyev.android.calculator.about.CalculatorReleaseNotesActivity;
|
||||
import org.solovyev.android.calculator.history.CalculatorHistory;
|
||||
import org.solovyev.android.calculator.history.CalculatorHistoryState;
|
||||
@ -48,6 +45,9 @@ import org.solovyev.common.utils.history.HistoryAction;
|
||||
|
||||
public class CalculatorActivity extends Activity implements FontSizeAdjuster, SharedPreferences.OnSharedPreferenceChangeListener, ServiceConnection {
|
||||
|
||||
@NotNull
|
||||
public static final String TAG = "Calculator++";
|
||||
|
||||
private static final int HVGA_WIDTH_PIXELS = 320;
|
||||
|
||||
@Nullable
|
||||
@ -78,6 +78,9 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
||||
@NotNull
|
||||
private NumeralBaseButtons numeralBaseButtons = new NumeralBaseButtons();
|
||||
|
||||
@NotNull
|
||||
private ActivityMenu menu = LayoutActivityMenu.newInstance(R.menu.main_menu, CalculatorMenu.class);
|
||||
|
||||
/**
|
||||
* Called when the activity is first created.
|
||||
*/
|
||||
@ -581,45 +584,12 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
final MenuInflater menuInflater = getMenuInflater();
|
||||
menuInflater.inflate(R.menu.main_menu, menu);
|
||||
return true;
|
||||
return this.menu.onCreateOptionsMenu(this, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean result;
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.main_menu_item_settings:
|
||||
CalculatorActivityLauncher.showSettings(this);
|
||||
result = true;
|
||||
break;
|
||||
case R.id.main_menu_item_history:
|
||||
CalculatorActivityLauncher.showHistory(this);
|
||||
result = true;
|
||||
break;
|
||||
case R.id.main_menu_item_about:
|
||||
CalculatorActivityLauncher.showAbout(this);
|
||||
result = true;
|
||||
break;
|
||||
case R.id.main_menu_item_help:
|
||||
CalculatorActivityLauncher.showHelp(this);
|
||||
result = true;
|
||||
break;
|
||||
case R.id.main_menu_conversion_tool:
|
||||
new NumeralBaseConverterDialog(null).show(this);
|
||||
result = true;
|
||||
break;
|
||||
case R.id.main_menu_item_exit:
|
||||
this.finish();
|
||||
result = true;
|
||||
break;
|
||||
default:
|
||||
result = super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
return result;
|
||||
return menu.onOptionsItemSelected(this, item);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,7 @@ import org.solovyev.android.calculator.model.CalculatorParseException;
|
||||
import org.solovyev.android.calculator.model.TextProcessor;
|
||||
import org.solovyev.android.calculator.view.NumeralBaseConverterDialog;
|
||||
import org.solovyev.android.calculator.view.TextHighlighter;
|
||||
import org.solovyev.android.menu.AMenuItem;
|
||||
import org.solovyev.android.menu.LabeledMenuItem;
|
||||
import org.solovyev.android.view.AutoResizeTextView;
|
||||
import org.solovyev.common.utils.CollectionsUtils;
|
||||
|
||||
@ -35,18 +35,18 @@ import java.util.Set;
|
||||
*/
|
||||
public class CalculatorDisplay extends AutoResizeTextView implements ICalculatorDisplay{
|
||||
|
||||
public static enum MenuItem implements AMenuItem<CalculatorDisplay> {
|
||||
public static enum MenuItem implements LabeledMenuItem<CalculatorDisplay> {
|
||||
|
||||
copy(R.string.c_copy) {
|
||||
@Override
|
||||
public void doAction(@NotNull CalculatorDisplay data, @NotNull Context context) {
|
||||
public void onClick(@NotNull CalculatorDisplay data, @NotNull Context context) {
|
||||
CalculatorModel.copyResult(context, data);
|
||||
}
|
||||
},
|
||||
|
||||
convert(R.string.c_convert) {
|
||||
@Override
|
||||
public void doAction(@NotNull CalculatorDisplay data, @NotNull Context context) {
|
||||
public void onClick(@NotNull CalculatorDisplay data, @NotNull Context context) {
|
||||
new NumeralBaseConverterDialog(data.getGenericResult().toString()).show(context);
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ public class CalculatorDisplay extends AutoResizeTextView implements ICalculator
|
||||
|
||||
plot(R.string.c_plot) {
|
||||
@Override
|
||||
public void doAction(@NotNull CalculatorDisplay data, @NotNull Context context) {
|
||||
public void onClick(@NotNull CalculatorDisplay data, @NotNull Context context) {
|
||||
final Generic generic = data.getGenericResult();
|
||||
assert generic != null;
|
||||
|
||||
|
@ -0,0 +1,75 @@
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.solovyev.android.LayoutActivityMenu;
|
||||
import org.solovyev.android.calculator.view.NumeralBaseConverterDialog;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 4/23/12
|
||||
* Time: 2:25 PM
|
||||
*/
|
||||
enum CalculatorMenu implements LayoutActivityMenu.LayoutMenuItem {
|
||||
|
||||
settings(R.id.main_menu_item_settings){
|
||||
@Override
|
||||
public void onClick(@NotNull MenuItem data, @NotNull Context context) {
|
||||
CalculatorActivityLauncher.showSettings(context);
|
||||
}
|
||||
},
|
||||
|
||||
history(R.id.main_menu_item_history) {
|
||||
@Override
|
||||
public void onClick(@NotNull MenuItem data, @NotNull Context context) {
|
||||
CalculatorActivityLauncher.showHistory(context);
|
||||
}
|
||||
},
|
||||
|
||||
about(R.id.main_menu_item_about) {
|
||||
@Override
|
||||
public void onClick(@NotNull MenuItem data, @NotNull Context context) {
|
||||
CalculatorActivityLauncher.showAbout(context);
|
||||
}
|
||||
},
|
||||
|
||||
help(R.id.main_menu_item_help) {
|
||||
@Override
|
||||
public void onClick(@NotNull MenuItem data, @NotNull Context context) {
|
||||
CalculatorActivityLauncher.showHelp(context);
|
||||
}
|
||||
},
|
||||
|
||||
conversion_tool( R.id.main_menu_conversion_tool) {
|
||||
@Override
|
||||
public void onClick(@NotNull MenuItem data, @NotNull Context context) {
|
||||
new NumeralBaseConverterDialog(null).show(context);
|
||||
}
|
||||
},
|
||||
|
||||
exit(R.id.main_menu_item_exit) {
|
||||
@Override
|
||||
public void onClick(@NotNull MenuItem data, @NotNull Context context) {
|
||||
if (context instanceof Activity) {
|
||||
((Activity) context).finish();
|
||||
} else {
|
||||
Log.e(CalculatorActivity.TAG, "Activity menu used with context");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final int menuItemId;
|
||||
|
||||
private CalculatorMenu (int menuItemId) {
|
||||
this.menuItemId = menuItemId;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Integer getItemId() {
|
||||
return menuItemId;
|
||||
}
|
||||
}
|
@ -36,6 +36,7 @@ public final class CalculatorPreferences {
|
||||
public static final Preference<Boolean> usePrevAsBack = new BooleanPreference("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> autoOrientation = new BooleanPreference("autoOrientation", true);
|
||||
public static final Preference<Boolean> hideNumeralBaseDigits = new BooleanPreference("hideNumeralBaseDigits", true);
|
||||
|
||||
public static enum Theme {
|
||||
|
||||
|
@ -13,7 +13,7 @@ import org.solovyev.android.calculator.model.CalculatorEngine;
|
||||
*/
|
||||
public class NumeralBaseButtons {
|
||||
|
||||
public synchronized void toggleNumericDigits(@NotNull Activity activity, @NotNull NumeralBase currentNumeralBase) {
|
||||
private synchronized void toggleNumericDigits(@NotNull Activity activity, @NotNull NumeralBase currentNumeralBase) {
|
||||
for (NumeralBase numeralBase : NumeralBase.values()) {
|
||||
if ( currentNumeralBase != numeralBase ) {
|
||||
AndroidNumeralBase.valueOf(numeralBase).toggleButtons(false, activity);
|
||||
@ -24,7 +24,12 @@ public class NumeralBaseButtons {
|
||||
}
|
||||
|
||||
public synchronized void toggleNumericDigits(@NotNull Activity activity, @NotNull SharedPreferences preferences) {
|
||||
if (CalculatorPreferences.Gui.hideNumeralBaseDigits.getPreference(preferences)) {
|
||||
final NumeralBase nb = CalculatorEngine.Preferences.numeralBase.getPreference(preferences);
|
||||
this.toggleNumericDigits(activity, nb);
|
||||
} else {
|
||||
// set HEX to show all digits
|
||||
AndroidNumeralBase.valueOf(NumeralBase.hex).toggleButtons(true, activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.menu.AMenuItem;
|
||||
import org.solovyev.android.menu.LabeledMenuItem;
|
||||
import org.solovyev.common.utils.StringUtils;
|
||||
|
||||
/**
|
||||
@ -27,11 +27,11 @@ import org.solovyev.common.utils.StringUtils;
|
||||
* Date: 12/18/11
|
||||
* Time: 3:09 PM
|
||||
*/
|
||||
public enum HistoryItemMenuItem implements AMenuItem<HistoryItemMenuData> {
|
||||
public enum HistoryItemMenuItem implements LabeledMenuItem<HistoryItemMenuData> {
|
||||
|
||||
use(R.string.c_use) {
|
||||
@Override
|
||||
public void doAction(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
||||
public void onClick(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
||||
if (context instanceof AbstractHistoryActivity) {
|
||||
AbstractHistoryActivity.useHistoryItem(data.getHistoryState(), (AbstractHistoryActivity) context);
|
||||
} else {
|
||||
@ -42,7 +42,7 @@ public enum HistoryItemMenuItem implements AMenuItem<HistoryItemMenuData> {
|
||||
|
||||
copy_expression(R.string.c_copy_expression) {
|
||||
@Override
|
||||
public void doAction(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
||||
public void onClick(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
||||
final CalculatorHistoryState calculatorHistoryState = data.getHistoryState();
|
||||
final String text = calculatorHistoryState.getEditorState().getText();
|
||||
if (!StringUtils.isEmpty(text)) {
|
||||
@ -55,7 +55,7 @@ public enum HistoryItemMenuItem implements AMenuItem<HistoryItemMenuData> {
|
||||
|
||||
copy_result(R.string.c_copy_result) {
|
||||
@Override
|
||||
public void doAction(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
||||
public void onClick(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
||||
final CalculatorHistoryState calculatorHistoryState = data.getHistoryState();
|
||||
final String text = calculatorHistoryState.getDisplayState().getEditorState().getText();
|
||||
if (!StringUtils.isEmpty(text)) {
|
||||
@ -68,7 +68,7 @@ public enum HistoryItemMenuItem implements AMenuItem<HistoryItemMenuData> {
|
||||
|
||||
save(R.string.c_save) {
|
||||
@Override
|
||||
public void doAction(@NotNull final HistoryItemMenuData data, @NotNull final Context context) {
|
||||
public void onClick(@NotNull final HistoryItemMenuData data, @NotNull final Context context) {
|
||||
final CalculatorHistoryState historyState = data.getHistoryState();
|
||||
if (!historyState.isSaved()) {
|
||||
createEditHistoryDialog(data, context, true);
|
||||
@ -80,7 +80,7 @@ public enum HistoryItemMenuItem implements AMenuItem<HistoryItemMenuData> {
|
||||
|
||||
edit(R.string.c_edit) {
|
||||
@Override
|
||||
public void doAction(@NotNull final HistoryItemMenuData data, @NotNull final Context context) {
|
||||
public void onClick(@NotNull final HistoryItemMenuData data, @NotNull final Context context) {
|
||||
final CalculatorHistoryState historyState = data.getHistoryState();
|
||||
if (historyState.isSaved()) {
|
||||
createEditHistoryDialog(data, context, false);
|
||||
@ -92,7 +92,7 @@ public enum HistoryItemMenuItem implements AMenuItem<HistoryItemMenuData> {
|
||||
|
||||
remove(R.string.c_remove) {
|
||||
@Override
|
||||
public void doAction(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
||||
public void onClick(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
||||
final CalculatorHistoryState historyState = data.getHistoryState();
|
||||
if (historyState.isSaved()) {
|
||||
data.getAdapter().remove(historyState);
|
||||
|
@ -24,6 +24,7 @@ import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.calculator.model.AndroidMathRegistry;
|
||||
import org.solovyev.android.menu.AMenuBuilder;
|
||||
import org.solovyev.android.menu.AMenuItem;
|
||||
import org.solovyev.android.menu.LabeledMenuItem;
|
||||
import org.solovyev.android.menu.MenuImpl;
|
||||
import org.solovyev.common.math.MathEntity;
|
||||
import org.solovyev.common.utils.EqualsTool;
|
||||
@ -117,10 +118,10 @@ public abstract class AbstractMathEntityListActivity<T extends MathEntity> exten
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
final T item = (T) parent.getItemAtPosition(position);
|
||||
|
||||
final List<AMenuItem<T>> menuItems = getMenuItemsOnLongClick(item);
|
||||
final List<LabeledMenuItem<T>> menuItems = getMenuItemsOnLongClick(item);
|
||||
|
||||
if (!menuItems.isEmpty()) {
|
||||
final AMenuBuilder<AMenuItem<T>, T> menuBuilder = AMenuBuilder.newInstance(AbstractMathEntityListActivity.this, MenuImpl.newInstance(menuItems));
|
||||
final AMenuBuilder<LabeledMenuItem<T>, T> menuBuilder = AMenuBuilder.newInstance(AbstractMathEntityListActivity.this, MenuImpl.newInstance(menuItems));
|
||||
menuBuilder.create(item).show();
|
||||
}
|
||||
|
||||
@ -138,7 +139,7 @@ public abstract class AbstractMathEntityListActivity<T extends MathEntity> exten
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected abstract List<AMenuItem<T>> getMenuItemsOnLongClick(@NotNull T item);
|
||||
protected abstract List<LabeledMenuItem<T>> getMenuItemsOnLongClick(@NotNull T item);
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
|
@ -16,6 +16,7 @@ import org.solovyev.android.calculator.CalculatorModel;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.calculator.model.CalculatorEngine;
|
||||
import org.solovyev.android.menu.AMenuItem;
|
||||
import org.solovyev.android.menu.LabeledMenuItem;
|
||||
import org.solovyev.common.utils.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -29,10 +30,10 @@ import java.util.List;
|
||||
*/
|
||||
public class CalculatorFunctionsActivity extends AbstractMathEntityListActivity<Function> {
|
||||
|
||||
private static enum LongClickMenuItem implements AMenuItem<Function>{
|
||||
private static enum LongClickMenuItem implements LabeledMenuItem<Function> {
|
||||
use(R.string.c_use) {
|
||||
@Override
|
||||
public void doAction(@NotNull Function data, @NotNull Context context) {
|
||||
public void onClick(@NotNull Function data, @NotNull Context context) {
|
||||
CalculatorModel.instance.processDigitButtonAction(data.getName(), false);
|
||||
if (context instanceof Activity) {
|
||||
((Activity) context).finish();
|
||||
@ -50,7 +51,7 @@ public class CalculatorFunctionsActivity extends AbstractMathEntityListActivity<
|
||||
|
||||
copy_description(R.string.c_copy_description) {
|
||||
@Override
|
||||
public void doAction(@NotNull Function data, @NotNull Context context) {
|
||||
public void onClick(@NotNull Function data, @NotNull Context context) {
|
||||
final String text = CalculatorEngine.instance.getFunctionsRegistry().getDescription(context, data.getName());
|
||||
if (!StringUtils.isEmpty(text)) {
|
||||
final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
|
||||
@ -107,8 +108,8 @@ public class CalculatorFunctionsActivity extends AbstractMathEntityListActivity<
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected List<AMenuItem<Function>> getMenuItemsOnLongClick(@NotNull Function item) {
|
||||
List<AMenuItem<Function>> result = new ArrayList<AMenuItem<Function>>(Arrays.asList(LongClickMenuItem.values()));
|
||||
protected List<LabeledMenuItem<Function>> getMenuItemsOnLongClick(@NotNull Function item) {
|
||||
List<LabeledMenuItem<Function>> result = new ArrayList<LabeledMenuItem<Function>>(Arrays.asList(LongClickMenuItem.values()));
|
||||
|
||||
if ( StringUtils.isEmpty(CalculatorEngine.instance.getFunctionsRegistry().getDescription(this, item.getName())) ) {
|
||||
result.remove(LongClickMenuItem.copy_description);
|
||||
|
@ -9,6 +9,7 @@ import org.solovyev.android.calculator.CalculatorModel;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.calculator.model.CalculatorEngine;
|
||||
import org.solovyev.android.menu.AMenuItem;
|
||||
import org.solovyev.android.menu.LabeledMenuItem;
|
||||
import org.solovyev.common.utils.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -23,11 +24,11 @@ import java.util.List;
|
||||
|
||||
public class CalculatorOperatorsActivity extends AbstractMathEntityListActivity<Operator> {
|
||||
|
||||
private static enum LongClickMenuItem implements AMenuItem<Operator> {
|
||||
private static enum LongClickMenuItem implements LabeledMenuItem<Operator> {
|
||||
|
||||
use(R.string.c_use) {
|
||||
@Override
|
||||
public void doAction(@NotNull Operator data, @NotNull Context context) {
|
||||
public void onClick(@NotNull Operator data, @NotNull Context context) {
|
||||
CalculatorModel.instance.processDigitButtonAction(data.getName(), false);
|
||||
if (context instanceof Activity) {
|
||||
((Activity) context).finish();
|
||||
@ -37,7 +38,7 @@ public class CalculatorOperatorsActivity extends AbstractMathEntityListActivity<
|
||||
|
||||
copy_description(R.string.c_copy_description) {
|
||||
@Override
|
||||
public void doAction(@NotNull Operator data, @NotNull Context context) {
|
||||
public void onClick(@NotNull Operator data, @NotNull Context context) {
|
||||
final String text = OperatorDescriptionGetter.instance.getDescription(context, data.getName());
|
||||
if (!StringUtils.isEmpty(text)) {
|
||||
final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
|
||||
@ -60,8 +61,8 @@ public class CalculatorOperatorsActivity extends AbstractMathEntityListActivity<
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected List<AMenuItem<Operator>> getMenuItemsOnLongClick(@NotNull Operator item) {
|
||||
final List<AMenuItem<Operator>> result = new ArrayList<AMenuItem<Operator>>(Arrays.asList(LongClickMenuItem.values()));
|
||||
protected List<LabeledMenuItem<Operator>> getMenuItemsOnLongClick(@NotNull Operator item) {
|
||||
final List<LabeledMenuItem<Operator>> result = new ArrayList<LabeledMenuItem<Operator>>(Arrays.asList(LongClickMenuItem.values()));
|
||||
|
||||
if ( StringUtils.isEmpty(OperatorDescriptionGetter.instance.getDescription(this, item.getName())) ) {
|
||||
result.remove(LongClickMenuItem.copy_description);
|
||||
|
@ -26,7 +26,7 @@ import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.calculator.math.MathType;
|
||||
import org.solovyev.android.calculator.model.CalculatorEngine;
|
||||
import org.solovyev.android.calculator.model.Var;
|
||||
import org.solovyev.android.menu.AMenuItem;
|
||||
import org.solovyev.android.menu.LabeledMenuItem;
|
||||
import org.solovyev.common.utils.CollectionsUtils;
|
||||
import org.solovyev.common.utils.Finder;
|
||||
import org.solovyev.common.utils.StringUtils;
|
||||
@ -42,10 +42,10 @@ import java.util.List;
|
||||
*/
|
||||
public class CalculatorVarsActivity extends AbstractMathEntityListActivity<IConstant> {
|
||||
|
||||
private static enum LongClickMenuItem implements AMenuItem<IConstant>{
|
||||
private static enum LongClickMenuItem implements LabeledMenuItem<IConstant>{
|
||||
use(R.string.c_use) {
|
||||
@Override
|
||||
public void doAction(@NotNull IConstant data, @NotNull Context context) {
|
||||
public void onClick(@NotNull IConstant data, @NotNull Context context) {
|
||||
CalculatorModel.instance.processDigitButtonAction(data.getName(), false);
|
||||
if (context instanceof Activity) {
|
||||
((Activity) context).finish();
|
||||
@ -55,7 +55,7 @@ public class CalculatorVarsActivity extends AbstractMathEntityListActivity<ICons
|
||||
|
||||
edit(R.string.c_edit) {
|
||||
@Override
|
||||
public void doAction(@NotNull IConstant data, @NotNull Context context) {
|
||||
public void onClick(@NotNull IConstant data, @NotNull Context context) {
|
||||
if (context instanceof AbstractMathEntityListActivity) {
|
||||
createEditVariableDialog((AbstractMathEntityListActivity<IConstant>)context, data, data.getName(), StringUtils.getNotEmpty(data.getValue(), ""), data.getDescription());
|
||||
}
|
||||
@ -64,7 +64,7 @@ public class CalculatorVarsActivity extends AbstractMathEntityListActivity<ICons
|
||||
|
||||
remove(R.string.c_remove) {
|
||||
@Override
|
||||
public void doAction(@NotNull IConstant data, @NotNull Context context) {
|
||||
public void onClick(@NotNull IConstant data, @NotNull Context context) {
|
||||
if (context instanceof AbstractMathEntityListActivity) {
|
||||
new MathEntityRemover<IConstant>(data, null, CalculatorEngine.instance.getVarsRegistry(), ((AbstractMathEntityListActivity<IConstant>) context)).showConfirmationDialog();
|
||||
}
|
||||
@ -73,7 +73,7 @@ public class CalculatorVarsActivity extends AbstractMathEntityListActivity<ICons
|
||||
|
||||
copy_value(R.string.c_copy_value) {
|
||||
@Override
|
||||
public void doAction(@NotNull IConstant data, @NotNull Context context) {
|
||||
public void onClick(@NotNull IConstant data, @NotNull Context context) {
|
||||
final String text = data.getValue();
|
||||
if (!StringUtils.isEmpty(text)) {
|
||||
final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
|
||||
@ -84,7 +84,7 @@ public class CalculatorVarsActivity extends AbstractMathEntityListActivity<ICons
|
||||
|
||||
copy_description(R.string.c_copy_description) {
|
||||
@Override
|
||||
public void doAction(@NotNull IConstant data, @NotNull Context context) {
|
||||
public void onClick(@NotNull IConstant data, @NotNull Context context) {
|
||||
final String text = CalculatorEngine.instance.getVarsRegistry().getDescription(context, data.getName());
|
||||
if (!StringUtils.isEmpty(text)) {
|
||||
final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
|
||||
@ -130,8 +130,8 @@ public class CalculatorVarsActivity extends AbstractMathEntityListActivity<ICons
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected List<AMenuItem<IConstant>> getMenuItemsOnLongClick(@NotNull IConstant item) {
|
||||
final List<AMenuItem<IConstant>> result = new ArrayList<AMenuItem<IConstant>>(Arrays.asList(LongClickMenuItem.values()));
|
||||
protected List<LabeledMenuItem<IConstant>> getMenuItemsOnLongClick(@NotNull IConstant item) {
|
||||
final List<LabeledMenuItem<IConstant>> result = new ArrayList<LabeledMenuItem<IConstant>>(Arrays.asList(LongClickMenuItem.values()));
|
||||
|
||||
if ( item.isSystem() ) {
|
||||
result.remove(LongClickMenuItem.edit);
|
||||
|
Loading…
Reference in New Issue
Block a user