am df8f383e: (-s ours) Import revised translations. DO NOT MERGE
* commit 'df8f383efa27ceec34e219316684e9f5f4914b33':
Import revised translations. DO NOT MERGE
diff --git a/res/drawable-hdpi/droidman_closed.png b/res/drawable-hdpi/droidman_closed.png
index 26ac62e..22997b1 100644
--- a/res/drawable-hdpi/droidman_closed.png
+++ b/res/drawable-hdpi/droidman_closed.png
Binary files differ
diff --git a/res/drawable-hdpi/droidman_down_closed.png b/res/drawable-hdpi/droidman_down_closed.png
index 81e22e1..d7d73be 100644
--- a/res/drawable-hdpi/droidman_down_closed.png
+++ b/res/drawable-hdpi/droidman_down_closed.png
Binary files differ
diff --git a/res/drawable-hdpi/icon.png b/res/drawable-hdpi/icon.png
index b98e31f..667f6b3 100644
--- a/res/drawable-hdpi/icon.png
+++ b/res/drawable-hdpi/icon.png
Binary files differ
diff --git a/res/drawable-hdpi/trash.png b/res/drawable-hdpi/trash.png
index e5deef6..b5d4055 100644
--- a/res/drawable-hdpi/trash.png
+++ b/res/drawable-hdpi/trash.png
Binary files differ
diff --git a/res/drawable-mdpi/trash.png b/res/drawable-mdpi/trash.png
index 5e423c4..7824cf2 100644
--- a/res/drawable-mdpi/trash.png
+++ b/res/drawable-mdpi/trash.png
Binary files differ
diff --git a/res/drawable/preview.png b/res/drawable/preview.png
new file mode 100644
index 0000000..312bea2
--- /dev/null
+++ b/res/drawable/preview.png
Binary files differ
diff --git a/res/xml/widget_build.xml b/res/xml/widget_build.xml
index c402aac..22303a7 100644
--- a/res/xml/widget_build.xml
+++ b/res/xml/widget_build.xml
@@ -18,4 +18,5 @@
android:minWidth="294dip"
android:minHeight="72dip"
android:updatePeriodMillis="0"
+ android:previewImage="@drawable/preview"
android:initialLayout="@layout/widget" />
diff --git a/src/com/android/protips/ProtipWidget.java b/src/com/android/protips/ProtipWidget.java
index ddc0b42..82d8ecf 100644
--- a/src/com/android/protips/ProtipWidget.java
+++ b/src/com/android/protips/ProtipWidget.java
@@ -16,36 +16,22 @@
package com.android.protips;
-import android.app.AlarmManager;
import android.app.PendingIntent;
-import android.app.Service;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
-import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.Intent;
import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
-import android.os.IBinder;
-import android.os.Looper;
-import android.os.Message;
-import android.os.SystemClock;
-import android.text.format.Time;
-import android.text.Spannable;
import android.util.Log;
import android.view.View;
import android.widget.RemoteViews;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.util.Random;
/** Mister Widget appears on your home screen to provide helpful tips. */
public class ProtipWidget extends AppWidgetProvider {
@@ -58,11 +44,16 @@
public static final String PREFS_TIP_NUMBER = "widget_tip";
public static final String PREFS_TIP_SET = "widget_tip_set";
- private static Random sRNG = new Random();
-
private static final Pattern sNewlineRegex = Pattern.compile(" *\\n *");
private static final Pattern sDrawableRegex = Pattern.compile(" *@(drawable/[a-z0-9_]+) *");
+ private static Handler mAsyncHandler;
+ static {
+ HandlerThread thr = new HandlerThread("ProtipWidget async");
+ thr.start();
+ mAsyncHandler = new Handler(thr.getLooper());
+ }
+
// initial appearance: eyes closed, no bubble
private int mIconRes = R.drawable.droidman_open;
private int mMessage = 0;
@@ -111,7 +102,19 @@
}
@Override
- public void onReceive(Context context, Intent intent) {
+ public void onReceive(final Context context, final Intent intent) {
+ final PendingResult result = goAsync();
+ Runnable worker = new Runnable() {
+ @Override
+ public void run() {
+ onReceiveAsync(context, intent);
+ result.finish();
+ }
+ };
+ mAsyncHandler.post(worker);
+ }
+
+ void onReceiveAsync(Context context, Intent intent) {
setup(context);
Resources res = mContext.getResources();
@@ -121,7 +124,7 @@
mMessage = getNextMessageIndex();
SharedPreferences.Editor pref = context.getSharedPreferences(PREFS_NAME, 0).edit();
pref.putInt(PREFS_TIP_NUMBER, mMessage);
- pref.commit();
+ pref.apply();
refresh();
} else if (intent.getAction().equals(ACTION_POKE)) {
blink(intent.getIntExtra(EXTRA_TIMES, 1));
@@ -135,7 +138,7 @@
SharedPreferences.Editor pref = context.getSharedPreferences(PREFS_NAME, 0).edit();
pref.putInt(PREFS_TIP_NUMBER, mMessage);
pref.putInt(PREFS_TIP_SET, mTipSet);
- pref.commit();
+ pref.apply();
mContext.startActivity(
new Intent(Intent.ACTION_MAIN)