Fixed up the little bugs in Locale. It works awesomely!

pull/14/head
Tim Su 14 years ago
parent e99e52b64f
commit 861bc9a4c9

@ -199,7 +199,7 @@
</activity> </activity>
<receiver android:name="com.todoroo.astrid.locale.LocaleReceiver"> <receiver android:name="com.todoroo.astrid.locale.LocaleReceiver">
<intent-filter> <intent-filter>
<action android:name="com.todoroo.astrid.action.LOCALE_ALERT" /> <action android:name="com.twofortyfouram.locale.intent.action.FIRE_SETTING" />
</intent-filter> </intent-filter>
</receiver> </receiver>

@ -31,10 +31,6 @@ public final class LocaleEditAlerts extends ExpandableListActivity {
// --- locale constants // --- locale constants
/** value for action type for tag alert */
@SuppressWarnings("nls")
public static final String ACTION_LOCALE_ALERT = "com.todoroo.astrid.action.LOCALE_ALERT";
/** key name for filter title in bundle */ /** key name for filter title in bundle */
@SuppressWarnings("nls") @SuppressWarnings("nls")
public static final String KEY_FILTER_TITLE = "title"; public static final String KEY_FILTER_TITLE = "title";
@ -216,7 +212,7 @@ public final class LocaleEditAlerts extends ExpandableListActivity {
/* /*
* This is the return Intent, into which we'll put all the required extras * This is the return Intent, into which we'll put all the required extras
*/ */
final Intent returnIntent = new Intent(ACTION_LOCALE_ALERT); final Intent returnIntent = new Intent();
/* /*
* This extra is the data to ourselves: either for the Activity or the BroadcastReceiver. Note that anything * This extra is the data to ourselves: either for the Activity or the BroadcastReceiver. Note that anything

@ -6,6 +6,7 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.timsu.astrid.R; import com.timsu.astrid.R;
@ -48,11 +49,15 @@ public class LocaleReceiver extends BroadcastReceiver {
/** Called when the system is started up */ /** Called when the system is started up */
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
try { try {
if (LocaleEditAlerts.ACTION_LOCALE_ALERT.equals(intent.getAction())) { if (com.twofortyfouram.Intent.ACTION_FIRE_SETTING.equals(intent.getAction())) {
final String title = intent.getStringExtra(LocaleEditAlerts.KEY_FILTER_TITLE); final String title = intent.getStringExtra(LocaleEditAlerts.KEY_FILTER_TITLE);
final String sql = intent.getStringExtra(LocaleEditAlerts.KEY_SQL); final String sql = intent.getStringExtra(LocaleEditAlerts.KEY_SQL);
final int interval = intent.getIntExtra(LocaleEditAlerts.KEY_INTERVAL, 24*3600); final int interval = intent.getIntExtra(LocaleEditAlerts.KEY_INTERVAL, 24*3600);
if(TextUtils.isEmpty(title) || TextUtils.isEmpty(sql) ||
sql.contains("--") || sql.contains(";") || interval == 0)
return;
// check if we've already made a notification recently // check if we've already made a notification recently
String preferenceKey = makePreferenceKey(title, interval); String preferenceKey = makePreferenceKey(title, interval);
long lastNotifyTime = Preferences.getLong(preferenceKey, 0); long lastNotifyTime = Preferences.getLong(preferenceKey, 0);
@ -82,7 +87,7 @@ public class LocaleReceiver extends BroadcastReceiver {
PendingIntent pendingIntent = PendingIntent.getActivity(context, PendingIntent pendingIntent = PendingIntent.getActivity(context,
Constants.NOTIFICATION_TIMER, notifyIntent, 0); Constants.NOTIFICATION_TIMER, notifyIntent, 0);
Notification notification = new Notification( Notification notification = new Notification(
R.drawable.timers_notification, reminder, System.currentTimeMillis()); R.drawable.notif_astrid, reminder, System.currentTimeMillis());
notification.setLatestEventInfo(context, r.getString(R.string.locale_edit_alerts_title), notification.setLatestEventInfo(context, r.getString(R.string.locale_edit_alerts_title),
reminder, pendingIntent); reminder, pendingIntent);
@ -94,7 +99,8 @@ public class LocaleReceiver extends BroadcastReceiver {
} }
} }
} catch (Exception e) { } catch (Exception e) {
Log.e("astrid-locale-rx", "Error receiving intent", e); if(Constants.DEBUG)
Log.i("astrid-locale-rx", "Error receiving intent", e);
} }
} }

@ -28,7 +28,7 @@
</string-array> </string-array>
<!-- Notification --> <!-- Notification -->
<string name="locale_notification">You have $NUM tasks in $FILTER</string> <string name="locale_notification">You have $NUM in $FILTER</string>
<!-- Locale style --> <!-- Locale style -->
<style name="TextAppearance.Locale_Label"> <style name="TextAppearance.Locale_Label">

Loading…
Cancel
Save