package co.sfng.calendarwidget;

import android.app.Activity;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;


public class AppWidgetConfigureActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Initialize SharedPreferences with default values if it hasn't already.
        PreferenceManager.setDefaultValues(getApplicationContext(), R.xml.preferences, false);

        setContentView(R.layout.appwidget_settings);
        findViewById(R.id.ok_button).setOnClickListener(mOnClickListener);
    }

    private OnClickListener mOnClickListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            // Obtain all app widget IDs.
            Context context = getApplicationContext();
            AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
            ComponentName cn = new ComponentName(context, CalendarWidgetProvider.class);
            int[] appWidgetIds = appWidgetManager.getAppWidgetIds(cn);

            if (appWidgetIds != null && appWidgetIds.length != 0) {
                // Broadcast update action to all running app widgets.
                Intent intent = new Intent(context, CalendarWidgetProvider.class);
                intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
                intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
                context.sendBroadcast(intent);
            }

            finish();
        }
    };

}

@@ -825,24 +825,128 @@
 er);%0A    %7D%0A%0A
+%0A    @Override%0A    protected void onPause() %7B%0A        super.onPause();%0A        refreshWidgets();%0A    %7D%0A%0A
     private 
@@ -1056,32 +1056,134 @@
 k(View v) %7B%0A    
+        refreshWidgets();%0A            finish();%0A        %7D%0A    %7D;%0A%0A    private void refreshWidgets() %7B%0A
         // Obtai
@@ -1212,20 +1212,16 @@
         
-    
 Context 
@@ -1251,28 +1251,24 @@
 nContext();%0A
-    
         AppW
@@ -1346,20 +1346,16 @@
         
-   
- 
 Componen
@@ -1431,20 +1431,16 @@
         
-    
 int%5B%5D ap
@@ -1499,20 +1499,16 @@
         
- 
-   
 if (appW
@@ -1567,20 +1567,16 @@
         
-  
-  
 // Broad
@@ -1622,20 +1622,16 @@
 idgets.%0A
-    
         
@@ -1709,28 +1709,24 @@
             
-    
 intent.setAc
@@ -1781,28 +1781,24 @@
             
- 
-   
 intent.putEx
@@ -1866,20 +1866,16 @@
         
-    
 context.
@@ -1901,45 +1901,8 @@
 t);%0A
-            %7D%0A%0A            finish();%0A
     
@@ -1912,13 +1912,12 @@
  %7D%0A    %7D
-;
 %0A%0A%7D%0A

Refresh widgets when the app is onPause.