diff --git a/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/CalculatorImpl.java b/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/CalculatorImpl.java index 693e2e3a..05fb06db 100644 --- a/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/CalculatorImpl.java +++ b/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/CalculatorImpl.java @@ -156,7 +156,7 @@ public class CalculatorImpl { baseValue = Double.parseDouble(newValue); } - public void handleLongClear() { + public void handleReset() { resetValues(); } diff --git a/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/Constants.java b/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/Constants.java index 96d74b98..b2fae490 100644 --- a/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/Constants.java +++ b/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/Constants.java @@ -12,6 +12,7 @@ public class Constants { public static final String ROOT = "root"; public static final String DECIMAL = "decimal"; public static final String CLEAR = "clear"; + public static final String RESET = "reset"; public static final String ZERO = "zero"; public static final String ONE = "one"; diff --git a/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/MainActivity.java b/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/MainActivity.java index 84f12dc2..30769938 100644 --- a/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/MainActivity.java +++ b/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/MainActivity.java @@ -65,7 +65,7 @@ public class MainActivity extends AppCompatActivity implements Calculator { @OnLongClick(R.id.btn_clear) public boolean clearLongClicked() { - calc.handleLongClear(); + calc.handleReset(); return true; } diff --git a/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/MyWidgetProvider.java b/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/MyWidgetProvider.java index 8d7357e2..40d98c9a 100644 --- a/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/MyWidgetProvider.java +++ b/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/MyWidgetProvider.java @@ -5,6 +5,7 @@ import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; import android.content.Context; import android.content.Intent; +import android.view.View; import android.widget.RemoteViews; public class MyWidgetProvider extends AppWidgetProvider implements Calculator { @@ -19,6 +20,7 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calculator { public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { widgetManager = appWidgetManager; remoteViews = new RemoteViews(context.getPackageName(), R.layout.activity_main); + remoteViews.setViewVisibility(R.id.btn_reset, View.VISIBLE); calc = new CalculatorImpl(this); widgetIds = appWidgetIds; cxt = context; @@ -45,6 +47,7 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calculator { setupIntent(Constants.POWER, R.id.btn_power); setupIntent(Constants.ROOT, R.id.btn_root); setupIntent(Constants.CLEAR, R.id.btn_clear); + setupIntent(Constants.RESET, R.id.btn_reset); appWidgetManager.updateAppWidget(appWidgetIds, remoteViews); } @@ -98,6 +101,9 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calculator { case Constants.CLEAR: calc.handleClear(); break; + case Constants.RESET: + calc.handleReset(); + break; case Constants.PLUS: case Constants.MINUS: case Constants.MULTIPLY: diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 06a5ff5b..ad1c91ec 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -64,6 +64,15 @@ android:layout_height="match_parent" android:layout_weight="1" android:text="C"/> + +