From 2a4984f0ecd194dd66fa7bc4c2521af0cd32b440 Mon Sep 17 00:00:00 2001 From: Sergey Solovyev Date: Mon, 9 Jan 2012 19:11:40 +0400 Subject: [PATCH] android_calculator-46: Add 'Remove' to context menu for constants, functions etc --- .../math/edit/CalculatorVarsActivity.java | 10 +++++++ .../math/edit/MathEntityRemover.java | 26 +++++++++++-------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsActivity.java b/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsActivity.java index 8a0b7f8c..1832f96c 100644 --- a/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsActivity.java +++ b/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsActivity.java @@ -62,6 +62,15 @@ public class CalculatorVarsActivity extends AbstractMathEntityListActivity(data, null, CalculatorEngine.instance.getVarsRegistry(), ((AbstractMathEntityListActivity) context)).showConfirmationDialog(); + } + } + }, + copy_value(R.string.c_copy_value) { @Override public void doAction(@NotNull IConstant data, @NotNull Context context) { @@ -126,6 +135,7 @@ public class CalculatorVarsActivity extends AbstractMathEntityListActivity implements DialogInterface.OnClick @Override public void onClick(DialogInterface dialog, int which) { if (!confirmed) { - final TextView question = new TextView(activity); - question.setText(String.format(activity.getString(R.string.c_var_removal_confirmation_question), mathEntity.getName())); - question.setPadding(6, 6, 6, 6); - final AlertDialog.Builder builder = new AlertDialog.Builder(activity) - .setCancelable(true) - .setView(question) - .setTitle(R.string.c_var_removal_confirmation) - .setNegativeButton(R.string.c_no, callbackOnCancel) - .setPositiveButton(R.string.c_yes, new MathEntityRemover(mathEntity, callbackOnCancel, true, varsRegistry, activity)); - - builder.create().show(); + showConfirmationDialog(); } else { if (activity.isInCategory(mathEntity)) { activity.getAdapter().remove(mathEntity); @@ -81,4 +71,18 @@ class MathEntityRemover implements DialogInterface.OnClick } } } + + public void showConfirmationDialog() { + final TextView question = new TextView(activity); + question.setText(String.format(activity.getString(R.string.c_var_removal_confirmation_question), mathEntity.getName())); + question.setPadding(6, 6, 6, 6); + final AlertDialog.Builder builder = new AlertDialog.Builder(activity) + .setCancelable(true) + .setView(question) + .setTitle(R.string.c_var_removal_confirmation) + .setNegativeButton(R.string.c_no, callbackOnCancel) + .setPositiveButton(R.string.c_yes, new MathEntityRemover(mathEntity, callbackOnCancel, true, varsRegistry, activity)); + + builder.create().show(); + } }