Permalink
Browse files

[+] Some very rudimentary gmail checking

[+] new icons from Asus and from GMail
  • Loading branch information...
1 parent 717a35a commit a16c04cb5cd54d0299d62626cc66b66aca6b0f8f @artiomchi committed Jun 20, 2011
View
@@ -2,6 +2,17 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.flexlabs.widgets.gmailmulti">
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="12" />
- <application android:icon="@drawable/icon" android:label="@string/app_name">
+ <application android:icon="@drawable/icon" android:label="@string/app_name" android:name=".GMailWizApplication">
+ <receiver android:name=".WidgetLite" android:label="@string/widgetLite">
+ <intent-filter>
+ <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
+ <action android:name="org.flexlabs.action.NEW_GMAIL" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.PROVIDER_CHANGED" />
+ <data android:scheme="content" android:host="gmail-ls" />
+ </intent-filter>
+ <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_lite_info" />
+ </receiver>
</application>
</manifest>
View
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
+ <component name="AntConfiguration">
+ <defaultAnt bundledAnt="true" />
+ </component>
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
@@ -24,6 +27,9 @@
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</component>
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
+ <component name="EntryPointsManager">
+ <entry_points version="2.0" />
+ </component>
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY" />
<option name="OPTION_SCOPE" value="protected" />
@@ -174,7 +180,7 @@
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="VcsDirectoryMappings">
- <mapping directory="" vcs="" />
+ <mapping directory="" vcs="Git" />
</component>
<component name="masterDetails">
<states>
@@ -11,9 +11,30 @@
public static final class attr {
}
public static final class drawable {
- public static final int icon=0x7f020000;
+ public static final int asus_ep_widget_mail_land=0x7f020000;
+ public static final int asus_ep_widget_mail_port=0x7f020001;
+ public static final int asus_ep_widget_thumbnail_mail=0x7f020002;
+ public static final int gmail=0x7f020003;
+ public static final int gmail_smaller=0x7f020004;
+ public static final int gmail_tiny=0x7f020005;
+ public static final int icon=0x7f020006;
+ }
+ public static final class id {
+ public static final int goto_inbox=0x7f060000;
+ public static final int mailCount=0x7f060001;
+ public static final int mailText=0x7f060002;
+ }
+ public static final class layout {
+ public static final int widget_lite=0x7f030000;
}
public static final class string {
- public static final int app_name=0x7f030000;
+ public static final int app_name=0x7f050000;
+ public static final int goto_inbox=0x7f050002;
+ public static final int mail_multiple=0x7f050004;
+ public static final int mail_single=0x7f050003;
+ public static final int widgetLite=0x7f050001;
+ }
+ public static final class xml {
+ public static final int widget_lite_info=0x7f040000;
}
}
View
BIN gmail.pdn
Binary file not shown.
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.
View
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.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent" android:layout_height="fill_parent"
+ android:orientation="horizontal" android:gravity="right">
+ <TextView android:id="@+id/goto_inbox"
+ android:text="@string/goto_inbox"
+ android:layout_height="wrap_content" android:layout_width="wrap_content" android:maxWidth="102dp"
+ android:layout_marginTop="15dp" android:gravity="center"
+ android:textSize="13sp" android:textColor="@android:color/white"
+ android:shadowColor="#ff000000" android:shadowDx="1.0" android:shadowDy="1.0" android:shadowRadius="1.5"
+ android:singleLine="true"
+ android:drawableTop="@drawable/gmail_smaller" android:drawablePadding="-9.0px" />
+ <TextView android:id="@+id/mailCount" android:nextFocusLeft="@id/goto_inbox"
+ android:text="0"
+ android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="-7dp"
+ android:textSize="60sp" android:textColor="@android:color/white"
+ android:shadowColor="#ff000000" android:shadowDx="1.0" android:shadowDy="1.0" android:shadowRadius="1.5"
+ android:singleLine="true" />
+ <TextView android:id="@+id/mailText" android:nextFocusLeft="@id/mailCount"
+ android:text="@string/mail_multiple"
+ android:layout_height="wrap_content" android:layout_width="wrap_content" android:maxWidth="120dp"
+ android:textSize="32sp" android:textColor="@android:color/white"
+ android:shadowColor="#ff000000" android:shadowDx="1.0" android:shadowDy="1.0" android:shadowRadius="1.5"
+ android:singleLine="true" />
+</LinearLayout>
View
@@ -1,3 +1,8 @@
<resources>
<string name="app_name">GMail Multi Widget</string>
+ <string name="widgetLite">GMail Lite</string>
+
+ <string name="goto_inbox">Go to inbox</string>
+ <string name="mail_single">mail</string>
+ <string name="mail_multiple">mails</string>
</resources>
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
+ android:initialLayout="@layout/widget_lite"
+ android:minWidth="146dp"
+ android:minHeight="72dp"
+ android:label="@string/widgetLite"
+ android:updatePeriodMillis="86400000"
+ android:resizeMode="horizontal|vertical" />
@@ -0,0 +1,11 @@
+package org.flexlabs.widgets.gmailmulti;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Artiom Chilaru
+ * Date: 19/06/11
+ * Time: 10:08
+ */
+public class Constants {
+ public static final String ACTION_WIDGET_UPDATE = "org.flexlabs.action.NEW_GMAIL";
+}
@@ -0,0 +1,54 @@
+package org.flexlabs.widgets.gmailmulti;
+
+import android.app.Application;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.graphics.Region;
+import android.os.PatternMatcher;
+import android.text.TextUtils;
+import android.util.Log;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Artiom Chilaru
+ * Date: 19/06/11
+ * Time: 10:11
+ */
+public class GMailWizApplication extends Application {
+ private static boolean isRegistered = false;
+ public static int mailCount = 0;
+
+ private static final BroadcastReceiver receiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mailCount = intent.getIntExtra("count", 0);
+ Log.d("FlexLabs", "Receiver intent: " + intent);
+ Log.d("FlexLabs", "Receiver bundle: " + TextUtils.join(", ", intent.getExtras().keySet()));
+ for (String key : intent.getExtras().keySet()) {
+ Log.d("FlexLabs", "Receiver key: " + key + " = " + intent.getExtras().get(key));
+ }
+
+ context.sendBroadcast(new Intent(Constants.ACTION_WIDGET_UPDATE));
+ }
+ };
+
+ public static void registerReceiver(Context context) {
+ if (!isRegistered) {
+ IntentFilter intentFilter = new IntentFilter(Intent.ACTION_PROVIDER_CHANGED);
+ intentFilter.addDataScheme("content");
+ intentFilter.addDataAuthority("gmail-ls", null);
+ //intentFilter.addDataPath("/unread/^i", PatternMatcher.PATTERN_SIMPLE_GLOB);
+ context.getApplicationContext().registerReceiver(receiver, intentFilter);
+ isRegistered = true;
+ }
+ }
+
+ public static void unregisterReceiver(Context context) {
+ if (isRegistered) {
+ context.getApplicationContext().unregisterReceiver(receiver);
+ isRegistered = false;
+ }
+ }
+}
@@ -0,0 +1,54 @@
+package org.flexlabs.widgets.gmailmulti;
+
+import android.appwidget.AppWidgetManager;
+import android.appwidget.AppWidgetProvider;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+import android.widget.RemoteViews;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Artiom Chilaru
+ * Date: 19/06/11
+ * Time: 10:08
+ */
+public class WidgetLite extends AppWidgetProvider {
+ private int gMailCount = 0;
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ super.onReceive(context, intent);
+
+ if (Intent.ACTION_PROVIDER_CHANGED.equals(intent.getAction())) {
+ if (intent.getDataString().contains("/unread/^iim") && intent.getBooleanExtra("getAttention", false)) {
+ gMailCount = intent.getIntExtra("count", 0);
+ updateWidget(context);
+ }
+ }
+ if (Constants.ACTION_WIDGET_UPDATE.equals(intent.getAction())) {
+ updateWidget(context);
+ }
+ }
+
+ private void updateWidget(Context context) {
+ AppWidgetManager widgetManager = AppWidgetManager.getInstance(context);
+ int[] appWidgetIds = widgetManager.getAppWidgetIds(new ComponentName(context, WidgetLite.class));
+ onUpdate(context, widgetManager, appWidgetIds);
+ }
+
+ @Override
+ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
+ //GMailWizApplication.registerReceiver(context);
+
+ Log.d("FlexLabs", "onUpdate mail count: " + GMailWizApplication.mailCount);
+ for (int widgetId : appWidgetIds) {
+ RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_lite);
+
+ views.setTextViewText(R.id.mailCount, String.valueOf(gMailCount));
+
+ appWidgetManager.updateAppWidget(widgetId, views);
+ }
+ }
+}

0 comments on commit a16c04c

Please sign in to comment.