Permalink
Browse files

got basics of the widget framework up and working.

Yeah, it's a static string, but hey, it works!
  • Loading branch information...
1 parent e752ab5 commit 6cbed61ac4af083468a00ced92caab9819df19ea @gregkh committed Jun 9, 2010
View
@@ -3,7 +3,20 @@
package="com.kroah.clock"
android:versionCode="1"
android:versionName="001">
- <application android:icon="@drawable/icon" android:label="@string/app_name">
+ <application android:icon="@drawable/icon" android:label="@string/app_name" android:description="@string/app_descrip">
+
+ <receiver android:name=".MedAppWidget">
+ <intent-filter>
+ <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
+ </intent-filter>
+ <meta-data android:name="android.appwidget.provider"
+ android:resource="@xml/widget_med"/>
+ </receiver>
+ <activity android:name=".Configure">
+ <intent-filter>
+ <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
+ </intent-filter>
+ </activity>
<activity android:name=".Clock"
android:label="@string/app_name">
<intent-filter>
@@ -13,7 +26,8 @@
</activity>
</application>
-
+
+ <uses-permission android:name="android.permission.INTERNET"/>
<!--<uses-permission android:name="android.permission.BATTERY_STATS"/> -->
<!--<uses-permission android:name="android.permission_group.STORAGE"/> -->
View
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
@@ -10,30 +10,53 @@
public final class R {
public static final class attr {
}
+ public static final class color {
+ public static final int black=0x7f050000;
+ public static final int semi_black=0x7f050003;
+ public static final int semi_white=0x7f050002;
+ public static final int white=0x7f050001;
+ }
public static final class drawable {
public static final int icon=0x7f020000;
public static final int menu_about=0x7f020001;
public static final int menu_add=0x7f020002;
public static final int menu_close=0x7f020003;
public static final int menu_preferences=0x7f020004;
+ public static final int widget_bg=0x7f020005;
+ public static final int widget_bg_normal=0x7f020006;
+ public static final int widget_bg_pressed=0x7f020007;
+ public static final int widget_bg_selected=0x7f020008;
}
public static final class id {
- public static final int delete_contact=0x7f060002;
- public static final int edit_contact=0x7f060001;
- public static final int exit=0x7f060003;
- public static final int myListView=0x7f060000;
+ public static final int delete_contact=0x7f090004;
+ public static final int edit_contact=0x7f090003;
+ public static final int exit=0x7f090005;
+ public static final int loading=0x7f090002;
+ public static final int myListView=0x7f090000;
+ public static final int widget=0x7f090001;
}
public static final class layout {
public static final int main=0x7f030000;
+ public static final int widget_loading=0x7f030001;
}
public static final class menu {
- public static final int menu=0x7f050000;
+ public static final int menu=0x7f080000;
}
public static final class string {
- public static final int about=0x7f040003;
- public static final int about_title=0x7f040004;
- public static final int app_name=0x7f040001;
- public static final int hello=0x7f040000;
- public static final int ok=0x7f040002;
+ public static final int about=0x7f060004;
+ public static final int about_title=0x7f060005;
+ public static final int app_descrip=0x7f060002;
+ public static final int app_name=0x7f060001;
+ public static final int hello=0x7f060000;
+ public static final int ok=0x7f060003;
+ public static final int widget_loading=0x7f060006;
+ }
+ public static final class style {
+ public static final int Text=0x7f070001;
+ public static final int Text_Loading=0x7f070002;
+ public static final int WidgetBackground=0x7f070000;
+ }
+ public static final class xml {
+ public static final int widget_med=0x7f040000;
}
}
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_window_focused="false" android:drawable="@drawable/widget_bg_normal" />
+ <item android:state_pressed="true" android:drawable="@drawable/widget_bg_pressed" />
+ <item android:state_focused="true" android:drawable="@drawable/widget_bg_selected" />
+ <item android:drawable="@drawable/widget_bg_normal" />
+</selector>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/widget"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:focusable="true"
+ style="@style/WidgetBackground">
+
+ <TextView
+ android:id="@+id/loading"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:includeFontPadding="false"
+ android:gravity="center_horizontal"
+ android:text="@string/widget_loading"
+ android:padding="4dip"
+ style="@style/Text.Loading" />
+
+</LinearLayout>
+
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="black">#f000</color>
+ <color name="white">#ffff</color>
+ <color name="semi_white">#f888</color>
+ <color name="semi_black">#f666</color>
+</resources>
@@ -2,8 +2,10 @@
<resources>
<string name="hello">List of watched timezones here?</string>
<string name="app_name">World Clock</string>
+ <string name="app_descrip">A World Clock desktop widget</string>
<string name="ok">Ok</string>
<string name="about">This is a tiny widget to figure out what the time is in different parts of the world.</string>
<string name="about_title">About World Clock</string>
+ <string name="widget_loading">loading...</string>
</resources>
View
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<resources>
+
+ <style name="WidgetBackground">
+ <item name="android:background">@drawable/widget_bg</item>
+ </style>
+
+ <style name="Text">
+ </style>
+
+ <style name="Text.Loading">
+ <item name="android:textSize">10sp</item>
+ <item name="android:textColor">@color/semi_white</item>
+ </style>
+
+</resources>
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
+ android:minWidth="72dip"
+ android:minHeight="72dip"
+ android:updatePeriodMillis="0"
+ android:initialLayout="@layout/widget_loading"
+ android:configure="com.kroah.clock.Configure" />
Binary file not shown.
@@ -16,7 +16,6 @@
public class Clock extends Activity {
-
// Display a simple "About" dialog
final void about() {
AlertDialog.Builder ad = new AlertDialog.Builder(Clock.this);
@@ -36,12 +35,12 @@ public void onCancel(DialogInterface Dialog) {
});
ad.show();
}
-
+
static final private int MENU_ADD = 0;
static final private int MENU_SETTINGS = 1;
static final private int MENU_ABOUT = 2;
static final private int MENU_EXIT = 3;
-
+
/* Creates the menu items */
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, MENU_ADD, 0, "Add").setIcon(R.drawable.menu_add);
@@ -53,50 +52,50 @@ public boolean onCreateOptionsMenu(Menu menu) {
/* Handles item selections */
public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case MENU_ADD:
- timezone_list.add(0, "timezone foo");
- timezone_adapter.notifyDataSetChanged();
- return true;
- case MENU_SETTINGS:
- //settings();
- return true;
- case MENU_ABOUT:
- about();
- return true;
- case MENU_EXIT:
- finish();
- return true;
- }
- return false;
+ switch (item.getItemId()) {
+ case MENU_ADD:
+ timezone_list.add(0, "timezone foo");
+ timezone_adapter.notifyDataSetChanged();
+ return true;
+ case MENU_SETTINGS:
+ //settings();
+ return true;
+ case MENU_ABOUT:
+ about();
+ return true;
+ case MENU_EXIT:
+ finish();
+ return true;
+ }
+ return false;
}
-
- private ArrayList<String> timezone_list;
- private ArrayAdapter<String> timezone_adapter;
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- ListView myListView = (ListView)findViewById(R.id.myListView);
-
- timezone_list = new ArrayList<String>();
- timezone_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, timezone_list);
- myListView.setAdapter(timezone_adapter);
+ private ArrayList<String> timezone_list;
+ private ArrayAdapter<String> timezone_adapter;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
- timezone_list.add(0, "timezone 1");
- timezone_list.add(0, "timezone 2");
- timezone_list.add(0, "timezone 3");
- timezone_list.add(0, "timezone 4");
- timezone_list.add(0, "timezone 5");
- timezone_list.add(0, "timezone 6");
- timezone_list.add(0, "timezone 7");
- timezone_list.add(0, "timezone 8");
- timezone_list.add(0, "timezone 9");
- timezone_list.add(0, "timezone10");
- timezone_list.add(0, "timezone22");
- timezone_adapter.notifyDataSetChanged();
- }
-}
+ ListView myListView = (ListView)findViewById(R.id.myListView);
+
+ timezone_list = new ArrayList<String>();
+ timezone_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, timezone_list);
+ myListView.setAdapter(timezone_adapter);
+
+ timezone_list.add(0, "timezone 1");
+ timezone_list.add(0, "timezone 2");
+ timezone_list.add(0, "timezone 3");
+ timezone_list.add(0, "timezone 4");
+ timezone_list.add(0, "timezone 5");
+ timezone_list.add(0, "timezone 6");
+ timezone_list.add(0, "timezone 7");
+ timezone_list.add(0, "timezone 8");
+ timezone_list.add(0, "timezone 9");
+ timezone_list.add(0, "timezone10");
+ timezone_list.add(0, "timezone22");
+ timezone_adapter.notifyDataSetChanged();
+ }
+}
Oops, something went wrong.

0 comments on commit 6cbed61

Please sign in to comment.