From 9829186618999ab6ff84ca7344cd28423b165c2f Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 4 Jun 2016 14:04:21 +0200 Subject: [PATCH] open the app on widgets result or formula click --- .../simplemobiletools/calculator/MyWidgetProvider.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/com/simplemobiletools/calculator/MyWidgetProvider.java b/app/src/main/java/com/simplemobiletools/calculator/MyWidgetProvider.java index 762b658f..b00f06ab 100644 --- a/app/src/main/java/com/simplemobiletools/calculator/MyWidgetProvider.java +++ b/app/src/main/java/com/simplemobiletools/calculator/MyWidgetProvider.java @@ -48,6 +48,9 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calculator { setupIntent(Constants.CLEAR, R.id.btn_clear); setupIntent(Constants.RESET, R.id.btn_reset); + setupAppOpenIntent(R.id.formula); + setupAppOpenIntent(R.id.result); + updateWidget(); super.onUpdate(context, appWidgetManager, appWidgetIds); } @@ -58,6 +61,12 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calculator { remoteViews.setOnClickPendingIntent(id, pendingIntent); } + private void setupAppOpenIntent(int id) { + final Intent intent = new Intent(cxt, MainActivity.class); + final PendingIntent pendingIntent = PendingIntent.getActivity(cxt, 0, intent, 0); + remoteViews.setOnClickPendingIntent(id, pendingIntent); + } + private void initVariables(Context context) { cxt = context; updateWidgetIds();