Permalink
Browse files

fix up the click to config

cargo-cult...
  • Loading branch information...
1 parent 39a4288 commit 94090a7aabd9ce04b23b67a16a080478c005d723 @gregkh committed Jun 10, 2010
Showing with 22 additions and 2 deletions.
  1. +1 −1 res/layout/config.xml
  2. +1 −0 res/values/strings.xml
  3. +3 −1 src/com/kroah/clock/Configure.java
  4. +17 −0 src/com/kroah/clock/MedAppWidget.java
View
@@ -7,7 +7,7 @@
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:text="@string/hello"
+ android:text="@string/configure"
/>
<Button
android:id="@+id/myButton"
View
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello"> This is a Widget, so there is nothing to do here</string>
+ <string name="configure">This is the configure screen</string>
<string name="app_name">World Clock</string>
<string name="app_descrip">A World Clock desktop widget</string>
<string name="ok">Ok</string>
@@ -17,7 +17,7 @@
public class Configure extends Activity {
public static final String MODULE = "GREGKHConfigureScreen";
- int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
+ public static int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
private Button okButton;
// Display a simple "About" dialog
@@ -82,10 +82,12 @@ public void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
Bundle extras = intent.getExtras();
if (extras != null) {
+ Log.d(MODULE, "onCreate:extras != null");
mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
}
// If they gave us an intent without the widget id, get out
if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
+ Log.d(MODULE, "onCreatea:mAppWidgetId == INVALID");
finish();
}
@@ -22,6 +22,19 @@ public void onUpdate(Context context,
appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, MedAppWidget.class));
}
+ // Tie clicking on the button to bring up our configure screen
+ RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
+ if (views == null)
+ Log.d(MODULE, "buildUpdate:views == null");
+ Intent intent = new Intent(context, Configure.class);
+ if (intent == null)
+ Log.d(MODULE, "buildUpdate:intent == null");
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, Configure.mAppWidgetId);
+ PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
+ if (pendingIntent == null)
+ Log.d(MODULE, "buildUpdate:pendingIntent == null");
+ views.setOnClickPendingIntent(R.id.time, pendingIntent);
+
// UpdateService.requestUpdate(appWidgetIds);
context.startService(new Intent(context, UpdateService.class));
Log.d(MODULE, "onUpdate:exit");
@@ -42,10 +55,14 @@ public static RemoteViews buildUpdate(Context context) {
Intent intent = new Intent(context, Configure.class);
if (intent == null)
Log.d(MODULE, "buildUpdate:intent == null");
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, Configure.mAppWidgetId);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
if (pendingIntent == null)
Log.d(MODULE, "buildUpdate:pendingIntent == null");
views.setOnClickPendingIntent(R.id.time, pendingIntent);
+
+// Intent result = new Intent();
+// result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
Log.d(MODULE, "buildUpdate:exit");
return views;

0 comments on commit 94090a7

Please sign in to comment.