diff --git a/astrid/.classpath b/astrid/.classpath
index a24e70588..09b2318ba 100644
--- a/astrid/.classpath
+++ b/astrid/.classpath
@@ -7,20 +7,11 @@
-
-
-
-
-
-
-
-
-
-
+
diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml
index 8a94d522f..7635cab91 100644
--- a/astrid/AndroidManifest.xml
+++ b/astrid/AndroidManifest.xml
@@ -226,7 +226,7 @@
+ android:exported="true">
diff --git a/astrid/libs/locale_platform.jar b/astrid/libs/locale_platform.jar
new file mode 100644
index 000000000..cd7183aa0
Binary files /dev/null and b/astrid/libs/locale_platform.jar differ
diff --git a/astrid/plugin-src/com/todoroo/astrid/backup/BackupPreferences.java b/astrid/plugin-src/com/todoroo/astrid/backup/BackupPreferences.java
index 9aea2e7ca..f5777dd0a 100644
--- a/astrid/plugin-src/com/todoroo/astrid/backup/BackupPreferences.java
+++ b/astrid/plugin-src/com/todoroo/astrid/backup/BackupPreferences.java
@@ -2,8 +2,6 @@ package com.todoroo.astrid.backup;
import java.util.Date;
-import android.content.DialogInterface;
-import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
@@ -71,15 +69,7 @@ public class BackupPreferences extends TodorooPreferences {
dialogUtilities.okCancelDialog(BackupPreferences.this,
getString(R.string.DLG_information_title),
getString(R.string.backup_BPr_how_to_restore_dialog),
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- Intent intent = new Intent(BackupPreferences.this,
- AddOnActivity.class);
- intent.putExtra(AddOnActivity.TOKEN_START_WITH_AVAILABLE, true);
- startActivity(intent);
- }
- }, null);
+ AddOnActivity.createAddOnClicker(BackupPreferences.this, false), null);
return false;
}
});
diff --git a/astrid/plugin-src/com/todoroo/astrid/core/PluginServices.java b/astrid/plugin-src/com/todoroo/astrid/core/PluginServices.java
index b2001a228..f5a1b0499 100644
--- a/astrid/plugin-src/com/todoroo/astrid/core/PluginServices.java
+++ b/astrid/plugin-src/com/todoroo/astrid/core/PluginServices.java
@@ -3,6 +3,7 @@ package com.todoroo.astrid.core;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
+import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.service.AddOnService;
import com.todoroo.astrid.service.MetadataService;
@@ -28,6 +29,9 @@ public final class PluginServices {
@Autowired
MetadataService metadataService;
+ @Autowired
+ DialogUtilities dialogUtilities;
+
@Autowired
AddOnService addOnService;
@@ -60,4 +64,8 @@ public final class PluginServices {
public static AddOnService getAddOnService() {
return getInstance().addOnService;
}
+
+ public static DialogUtilities getDialogUtilities() {
+ return getInstance().dialogUtilities;
+ }
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/locale/LocaleEditAlerts.java b/astrid/plugin-src/com/todoroo/astrid/locale/LocaleEditAlerts.java
index 220628589..d8bdfeddf 100644
--- a/astrid/plugin-src/com/todoroo/astrid/locale/LocaleEditAlerts.java
+++ b/astrid/plugin-src/com/todoroo/astrid/locale/LocaleEditAlerts.java
@@ -1,6 +1,7 @@
package com.todoroo.astrid.locale;
import android.app.Activity;
+import android.app.AlertDialog;
import android.app.ExpandableListActivity;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -15,10 +16,12 @@ import android.widget.Spinner;
import com.flurry.android.FlurryAgent;
import com.timsu.astrid.R;
+import com.todoroo.astrid.activity.AddOnActivity;
import com.todoroo.astrid.adapter.FilterAdapter;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterCategory;
import com.todoroo.astrid.api.FilterListItem;
+import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.utility.Constants;
import com.twofortyfouram.SharedResources;
@@ -85,6 +88,7 @@ public final class LocaleEditAlerts extends ExpandableListActivity {
* There is no need to save/restore this field's state when the {@code Activity} is paused.
*/
private boolean isCancelled = false;
+ private boolean isRemoved = false;
/** Called when the activity is first created. */
@Override
@@ -168,6 +172,18 @@ public final class LocaleEditAlerts extends ExpandableListActivity {
adapter.headerStyle = R.style.TextAppearance_LEA_Header;
adapter.categoryStyle = R.style.TextAppearance_LEA_Category;
setListAdapter(adapter);
+
+ // check for plugin
+ if(!PluginServices.getAddOnService().hasLocalePlugin()) {
+ isRemoved = true;
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.DLG_information_title)
+ .setMessage(R.string.locale_plugin_required)
+ .setCancelable(false)
+ .setPositiveButton(android.R.string.ok,
+ AddOnActivity.createAddOnClicker(LocaleEditAlerts.this, true))
+ .show();
+ }
}
@Override
@@ -206,7 +222,9 @@ public final class LocaleEditAlerts extends ExpandableListActivity {
@Override
public void finish()
{
- if (isCancelled)
+ if(isRemoved)
+ setResult(com.twofortyfouram.Intent.RESULT_REMOVE);
+ else if (isCancelled)
setResult(RESULT_CANCELED);
else
{
diff --git a/astrid/plugin-src/com/todoroo/astrid/locale/LocaleReceiver.java b/astrid/plugin-src/com/todoroo/astrid/locale/LocaleReceiver.java
index 253fa19a3..bdfc6b87f 100644
--- a/astrid/plugin-src/com/todoroo/astrid/locale/LocaleReceiver.java
+++ b/astrid/plugin-src/com/todoroo/astrid/locale/LocaleReceiver.java
@@ -14,6 +14,7 @@ import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.activity.ShortcutActivity;
import com.todoroo.astrid.api.Filter;
+import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.model.Task;
import com.todoroo.astrid.reminders.Notifications;
import com.todoroo.astrid.service.TaskService;
@@ -47,6 +48,9 @@ public class LocaleReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
try {
if (com.twofortyfouram.Intent.ACTION_FIRE_SETTING.equals(intent.getAction())) {
+ if(!PluginServices.getAddOnService().hasLocalePlugin())
+ return;
+
final String title = intent.getStringExtra(LocaleEditAlerts.KEY_FILTER_TITLE);
final String sql = intent.getStringExtra(LocaleEditAlerts.KEY_SQL);
final int interval = intent.getIntExtra(LocaleEditAlerts.KEY_INTERVAL, 24*3600);
diff --git a/astrid/res/values/strings-locale.xml b/astrid/res/values/strings-locale.xml
index a3dc40368..9b3c1e682 100644
--- a/astrid/res/values/strings-locale.xml
+++ b/astrid/res/values/strings-locale.xml
@@ -29,5 +29,8 @@
You have $NUM matching: $FILTER
+
+
+ Please install the Astrid Locale plugin!
diff --git a/astrid/src/com/todoroo/astrid/activity/AddOnActivity.java b/astrid/src/com/todoroo/astrid/activity/AddOnActivity.java
index 59efa93cf..73e3d219a 100644
--- a/astrid/src/com/todoroo/astrid/activity/AddOnActivity.java
+++ b/astrid/src/com/todoroo/astrid/activity/AddOnActivity.java
@@ -3,7 +3,10 @@ package com.todoroo.astrid.activity;
import java.util.ArrayList;
+import android.app.Activity;
import android.app.TabActivity;
+import android.content.DialogInterface;
+import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -87,6 +90,25 @@ public class AddOnActivity extends TabActivity {
findViewById(R.id.empty_available).setVisibility(View.GONE);
}
-
+ /**
+ * Creates an on click listener
+ * @param activity
+ * @param finish whether to finish activity
+ * @return
+ */
+ public static DialogInterface.OnClickListener createAddOnClicker(final Activity activity,
+ final boolean finish) {
+ return new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(activity,
+ AddOnActivity.class);
+ intent.putExtra(AddOnActivity.TOKEN_START_WITH_AVAILABLE, true);
+ activity.startActivity(intent);
+ if(finish)
+ activity.finish();
+ }
+ };
+ }
}
diff --git a/astrid/src/com/todoroo/astrid/service/AddOnService.java b/astrid/src/com/todoroo/astrid/service/AddOnService.java
index 8aa81da1a..edb26fd7d 100644
--- a/astrid/src/com/todoroo/astrid/service/AddOnService.java
+++ b/astrid/src/com/todoroo/astrid/service/AddOnService.java
@@ -59,6 +59,19 @@ public class AddOnService {
return isPowerPack;
}
+ /** Checks whether locale plugin should be enabled */
+ public boolean hasLocalePlugin() {
+ if (isPowerPack == null) {
+ isPowerPack = false;
+ if (Preferences.getBoolean(PREF_OEM, false))
+ isPowerPack = true;
+ else if(isInstalled(LOCALE_PACKAGE, true))
+ isPowerPack = true;
+ }
+
+ return isPowerPack;
+ }
+
/**
* Takes users to the market
*