diff --git a/astrid/libs/locale_platform.jar b/astrid/libs/locale_platform.jar deleted file mode 100644 index cd7183aa0..000000000 Binary files a/astrid/libs/locale_platform.jar and /dev/null differ diff --git a/astrid/src/main/AndroidManifest.xml b/astrid/src/main/AndroidManifest.xml index 2a2fe9e83..4cc45c7b4 100644 --- a/astrid/src/main/AndroidManifest.xml +++ b/astrid/src/main/AndroidManifest.xml @@ -517,21 +517,6 @@ - - - - - - - - - - - - diff --git a/astrid/src/main/java/com/todoroo/astrid/locale/LocaleEditAlerts.java b/astrid/src/main/java/com/todoroo/astrid/locale/LocaleEditAlerts.java deleted file mode 100644 index 7a37fbbf7..000000000 --- a/astrid/src/main/java/com/todoroo/astrid/locale/LocaleEditAlerts.java +++ /dev/null @@ -1,341 +0,0 @@ -/** - * Copyright (c) 2012 Todoroo Inc - * - * See the file "LICENSE" for the full license governing this code. - */ -package com.todoroo.astrid.locale; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.ListActivity; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.os.Bundle; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.ListView; -import android.widget.Spinner; - -import org.tasks.R; -import com.todoroo.andlib.service.ContextManager; -import com.todoroo.andlib.utility.AndroidUtilities; -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.service.StatisticsConstants; -import com.twofortyfouram.SharedResources; - -/** - * Activity to edit alerts from Locale - * - * @author Tim Su - * - */ -public final class LocaleEditAlerts extends ListActivity { - - // --- locale constants - - /** key name for filter title in bundle */ - public static final String KEY_FILTER_TITLE = "title"; - - /** key name for filter SQL in bundle */ - public static final String KEY_SQL = "sql"; - - /** key name for filter content-values in bundle */ - public static final String KEY_VALUES = "val"; - - /** key name for interval (integer, # of seconds) */ - public static final String KEY_INTERVAL = "interval"; - - // --- activity constants - - /** - * Indices for interval setting - */ - public static final int INTERVAL_ONE_HOUR = 0; - public static final int INTERVAL_SIX_HOURS = 1; - public static final int INTERVAL_TWELVE_HOURS = 2; - public static final int INTERVAL_ONE_DAY = 3; - public static final int INTERVAL_THREE_DAYS = 4; - public static final int INTERVAL_ONE_WEEK = 5; - - /** - * Intervals in seconds - */ - public static final int[] INTERVALS = new int[] { - 3600, 6 * 3600, 12 * 3600, 24 * 3600, 3 * 24 * 3600, 7 * 24 * 3600 - }; - - /** - * Menu ID of the save item. - */ - private static final int MENU_SAVE = 1; - - /** - * Menu ID of the don't save item. - */ - private static final int MENU_DONT_SAVE = 2; - - // --- implementation - - FilterAdapter adapter = null; - Spinner interval = null; - - /** - * Flag boolean that can only be set to true via the "Don't Save" menu item in {@link #onMenuItemSelected(int, MenuItem)}. If - * true, then this {@code Activity} should return {@link Activity#RESULT_CANCELED} in {@link #finish()}. - *

- * 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 - public void onCreate(Bundle savedInstanceState) { - setTheme(R.style.Theme); - super.onCreate(savedInstanceState); - setContentView(R.layout.locale_edit_alerts); - - ContextManager.setContext(this); - - /* - * Locale guarantees that the breadcrumb string will be present, but checking for null anyway makes your Activity more - * robust and re-usable - */ - final String breadcrumbString = getIntent().getStringExtra(com.twofortyfouram.Intent.EXTRA_STRING_BREADCRUMB); - if (breadcrumbString != null) { - setTitle(String.format("%s%s%s", breadcrumbString, com.twofortyfouram.Intent.BREADCRUMB_SEPARATOR, //$NON-NLS-1$ - getString(R.string.locale_edit_alerts_title))); - } - - /* - * Load the Locale background frame from Locale - */ -// ((LinearLayout) findViewById(R.id.frame)).setBackgroundDrawable( -// SharedResources.getDrawableResource(getPackageManager(), -// SharedResources.DRAWABLE_LOCALE_BORDER)); - - // set up UI components - interval = (Spinner) findViewById(R.id.intervalSpinner); - interval.setSelection(INTERVAL_ONE_DAY); - String selectionToMatch = null; - - try { - /* - * if savedInstanceState == null, then we are entering the Activity directly from Locale and we need to check whether the - * Intent has forwarded a Bundle extra (e.g. whether we editing an old setting or creating a new one) - */ - if (savedInstanceState == null) - { - final Bundle forwardedBundle = getIntent().getBundleExtra(com.twofortyfouram.Intent.EXTRA_BUNDLE); - - /* - * the forwardedBundle would be null if this was a new setting - */ - if (forwardedBundle != null) - { - final int intervalValue = forwardedBundle.getInt(KEY_INTERVAL, INTERVALS[interval.getSelectedItemPosition()]); - for(int i = 0; i < INTERVALS.length; i++) { - if(intervalValue == INTERVALS[i]) { - interval.setSelection(i); - break; - } - } - selectionToMatch = forwardedBundle.getString(KEY_SQL); - } - } - } catch (Exception e) { - selectionToMatch = null; - Log.e("astrid-locale", "Error loading bundle", e); //$NON-NLS-1$ //$NON-NLS-2$ - } - - // if we match a selection, make it selected - final String finalSelection = selectionToMatch; - adapter = new FilterAdapter(this, getListView(), R.layout.filter_adapter_row, true) { - @Override - public void onReceiveFilter(FilterListItem item) { - if(adapter.getSelection() != null || finalSelection == null) { - return; - } - if(item instanceof Filter) { - if(finalSelection.equals(((Filter)item).getSqlQuery())) { - adapter.setSelection(item); - } - } else if(item instanceof FilterCategory) { - Filter[] filters = ((FilterCategory)item).children; - if(filters == null) { - return; - } - for(Filter filter : filters) { - if (finalSelection.equals(filter.getSqlQuery())) { - adapter.setSelection(filter); - break; - } - } - } - } - }; - adapter.filterStyle = R.style.TextAppearance_LEA_Filter; - adapter.headerStyle = R.style.TextAppearance_LEA_Header; - 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 - public void onListItemClick(ListView parent, View v, int position, long id) { - Filter item = adapter.getItem(position); - adapter.setSelection(item); - } - - /** - * Called when the {@code Activity} is being terminated. This method determines the state of the {@code Activity} and what - * sort of result should be returned to Locale. - */ - @Override - public void finish() - { - if(isRemoved) { - setResult(com.twofortyfouram.Intent.RESULT_REMOVE); - } else if (isCancelled) { - setResult(RESULT_CANCELED); - } else - { - final FilterListItem selected = adapter.getSelection(); - final int intervalIndex = interval.getSelectedItemPosition(); - - if (selected == null) - { - /* - * If nothing is selected, return as if user had canceled - */ - setResult(RESULT_CANCELED); - } - else - { - /* - * This is the return Intent, into which we'll put all the required extras - */ - final Intent returnIntent = new Intent(); - - /* - * This extra is the data to ourselves: either for the Activity or the BroadcastReceiver. Note that anything - * placed in this bundle must be available to Locale's class loader. So storing String, int, and other basic - * objects will work just fine. You cannot store an object that only exists in your project, as Locale will be - * unable to serialize it. - */ - final Bundle storeAndForwardExtras = new Bundle(); - - Filter filterItem = (Filter) selected; - storeAndForwardExtras.putString(KEY_FILTER_TITLE, filterItem.title); - storeAndForwardExtras.putString(KEY_SQL, filterItem.getSqlQuery()); - if(filterItem.valuesForNewTasks != null) { - storeAndForwardExtras.putString(KEY_VALUES, AndroidUtilities.contentValuesToSerializedString(filterItem.valuesForNewTasks)); - } - storeAndForwardExtras.putInt(KEY_INTERVAL, INTERVALS[intervalIndex]); - - returnIntent.putExtra(com.twofortyfouram.Intent.EXTRA_BUNDLE, storeAndForwardExtras); - - /* - * This is the blurb concisely describing what your setting's state is. This is simply used for display in the UI. - */ - if (filterItem.title != null && filterItem.title.length() > com.twofortyfouram.Intent.MAXIMUM_BLURB_LENGTH) { - returnIntent.putExtra(com.twofortyfouram.Intent.EXTRA_STRING_BLURB, filterItem.title.substring(0, com.twofortyfouram.Intent.MAXIMUM_BLURB_LENGTH)); - } else { - returnIntent.putExtra(com.twofortyfouram.Intent.EXTRA_STRING_BLURB, filterItem.title); - } - - setResult(RESULT_OK, returnIntent); - } - } - - super.finish(); - } - - // --- boring stuff - - @Override - protected void onResume() { - super.onResume(); - adapter.registerRecevier(); - } - - @Override - protected void onPause() { - super.onPause(); - adapter.unregisterRecevier(); - } - - @Override - protected void onStart() { - super.onStart(); - } - - @Override - protected void onStop() { - super.onStop(); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean onCreateOptionsMenu(final Menu menu) - { - super.onCreateOptionsMenu(menu); - - final PackageManager manager = getPackageManager(); - - /* - * We are dynamically loading resources from Locale's APK. This will only work if Locale is actually installed - */ - menu.add(0, MENU_DONT_SAVE, 0, SharedResources.getTextResource(manager, SharedResources.STRING_MENU_DONTSAVE)) - .setIcon(SharedResources.getDrawableResource(manager, SharedResources.DRAWABLE_MENU_DONTSAVE)).getItemId(); - - menu.add(0, MENU_SAVE, 0, SharedResources.getTextResource(manager, SharedResources.STRING_MENU_SAVE)) - .setIcon(SharedResources.getDrawableResource(manager, SharedResources.DRAWABLE_MENU_SAVE)).getItemId(); - - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean onMenuItemSelected(final int featureId, final MenuItem item) - { - switch (item.getItemId()) - { - case MENU_SAVE: - { - finish(); - return true; - } - case MENU_DONT_SAVE: - { - isCancelled = true; - finish(); - return true; - } - } - - return super.onOptionsItemSelected(item); - } - -} diff --git a/astrid/src/main/java/com/todoroo/astrid/locale/LocaleReceiver.java b/astrid/src/main/java/com/todoroo/astrid/locale/LocaleReceiver.java deleted file mode 100644 index 1c8d270f7..000000000 --- a/astrid/src/main/java/com/todoroo/astrid/locale/LocaleReceiver.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright (c) 2012 Todoroo Inc - * - * See the file "LICENSE" for the full license governing this code. - */ -package com.todoroo.astrid.locale; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.res.Resources; -import android.os.Bundle; -import android.text.TextUtils; -import android.util.Log; - -import org.tasks.R; -import com.todoroo.andlib.data.TodorooCursor; -import com.todoroo.andlib.service.ContextManager; -import com.todoroo.andlib.service.DependencyInjectionService; -import com.todoroo.andlib.utility.AndroidUtilities; -import com.todoroo.andlib.utility.DateUtilities; -import com.todoroo.andlib.utility.Preferences; -import com.todoroo.astrid.activity.ShortcutActivity; -import com.todoroo.astrid.api.Filter; -import com.todoroo.astrid.core.PluginServices; -import com.todoroo.astrid.data.Task; -import com.todoroo.astrid.reminders.Notifications; -import com.todoroo.astrid.utility.Constants; - -/** - * Receiver is activated when Locale conditions are triggered - * - * @author timsu - * - */ -public class LocaleReceiver extends BroadcastReceiver { - - /** - * Create a preference key for storing / retrieving last interval time - * @param filterTitle - * @param interval - * @return - */ - private String makePreferenceKey(String filterTitle, int interval) { - return "LOCALE:" + filterTitle + interval; //$NON-NLS-1$ - } - - @Override - /** Called when the system is started up */ - public void onReceive(Context context, Intent intent) { - ContextManager.setContext(context); - - try { - if (com.twofortyfouram.Intent.ACTION_FIRE_SETTING.equals(intent.getAction())) { - if(!PluginServices.getAddOnService().hasLocalePlugin()) { - return; - } - - final Bundle forwardedBundle = intent.getBundleExtra(com.twofortyfouram.Intent.EXTRA_BUNDLE); - - final String title = forwardedBundle.getString(LocaleEditAlerts.KEY_FILTER_TITLE); - final String sql = forwardedBundle.getString(LocaleEditAlerts.KEY_SQL); - final String values = forwardedBundle.getString(LocaleEditAlerts.KEY_VALUES); - final int interval = forwardedBundle.getInt(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 - String preferenceKey = makePreferenceKey(title, interval); - long lastNotifyTime = Preferences.getLong(preferenceKey, 0); - if(DateUtilities.now() - lastNotifyTime < interval * 1000L) { - Log.i("astrid-locale-rx", title + ": Too soon, need " + (interval - - (DateUtilities.now() - lastNotifyTime)/1000) + " more seconds"); - return; - } - - // find out if we have active tasks with this tag - DependencyInjectionService.getInstance().inject(this); - Filter filter = new Filter(title, title, sql, null); - TodorooCursor cursor = PluginServices.getTaskService().fetchFiltered( - sql, null, Task.ID); - try { - if(cursor.getCount() == 0) { - return; - } - - if(values != null) { - filter.valuesForNewTasks = AndroidUtilities.contentValuesFromSerializedString(values); - } - - Resources r = context.getResources(); - String reminder = r.getString(R.string.locale_notification). - replace("$NUM", r.getQuantityString(R.plurals.Ntasks, - cursor.getCount(), cursor.getCount())). - replace("$FILTER", title); - - // show a reminder - String notificationTitle = r.getString(R.string.locale_edit_alerts_title); - Intent notifyIntent = ShortcutActivity.createIntent(filter); - notifyIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - Notifications.showNotification(Constants.NOTIFICATION_LOCALE, - notifyIntent, 0, notificationTitle, reminder, 1); - - Preferences.setLong(preferenceKey, DateUtilities.now()); - } finally { - cursor.close(); - } - } - } catch (Exception e) { - Log.i("astrid-locale-rx", "Error receiving intent", e); - } - } - -} diff --git a/astrid/src/main/java/com/todoroo/astrid/service/AddOnService.java b/astrid/src/main/java/com/todoroo/astrid/service/AddOnService.java index ca089e4ac..af0056ceb 100644 --- a/astrid/src/main/java/com/todoroo/astrid/service/AddOnService.java +++ b/astrid/src/main/java/com/todoroo/astrid/service/AddOnService.java @@ -5,13 +5,8 @@ */ package com.todoroo.astrid.service; -import java.util.ArrayList; - import android.content.Context; -import android.content.res.Resources; -import android.graphics.drawable.BitmapDrawable; -import org.tasks.R; import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.Preferences; @@ -32,24 +27,11 @@ public class AddOnService { /** Astrid Power Pack package */ public static final String POWER_PACK_PACKAGE = "com.todoroo.astrid.ppack"; - /** Astrid Locale package */ - public static final String LOCALE_PACKAGE = "com.todoroo.astrid.locale"; - /** Checks whether power pack should be enabled */ public boolean hasPowerPack() { return true; } - /** Checks whether locale plugin should be enabled */ - public boolean hasLocalePlugin() { - if (Preferences.getBoolean(PREF_OEM, false)) { - return true; - } else if(isInstalled(LOCALE_PACKAGE, true)) { - return true; - } - return false; - } - /** * Record that a version was an OEM install */ @@ -132,19 +114,7 @@ public class AddOnService { * @return available add-ons */ public AddOn[] getAddOns() { - Resources r = ContextManager.getContext().getResources(); - - // temporary temporary - ArrayList list = new ArrayList(3); - - if(Constants.MARKET_STRATEGY.includesLocalePlugin()) { - list.add(new AddOn(false, true, r.getString(R.string.AOA_locale_title), null, - r.getString(R.string.AOA_locale_description), - LOCALE_PACKAGE, - ((BitmapDrawable) r.getDrawable(R.drawable.icon_locale)).getBitmap())); - } - - return list.toArray(new AddOn[list.size()]); + return new AddOn[0]; } } diff --git a/astrid/src/main/java/com/todoroo/astrid/service/MarketStrategy.java b/astrid/src/main/java/com/todoroo/astrid/service/MarketStrategy.java index e72c1ba84..1d5f3104e 100644 --- a/astrid/src/main/java/com/todoroo/astrid/service/MarketStrategy.java +++ b/astrid/src/main/java/com/todoroo/astrid/service/MarketStrategy.java @@ -20,13 +20,6 @@ public abstract class MarketStrategy { abstract public String strategyId(); - /** - * @return if this market has locale plugin - */ - public boolean includesLocalePlugin() { - return true; - } - public int[] excludedSettings() { return null; } @@ -98,11 +91,6 @@ public abstract class MarketStrategy { packageName)); } - @Override - public boolean includesLocalePlugin() { - return false; - } - /** * @return true if the device is a kindle fire and needs special treatment */ @@ -136,11 +124,6 @@ public abstract class MarketStrategy { packageName)); } - @Override - public boolean includesLocalePlugin() { - return false; - } - @Override public boolean allowIdeasTab() { return false; diff --git a/astrid/src/main/res/drawable/icon_32.png b/astrid/src/main/res/drawable/icon_32.png deleted file mode 100644 index 8da7133d7..000000000 Binary files a/astrid/src/main/res/drawable/icon_32.png and /dev/null differ diff --git a/astrid/src/main/res/drawable/icon_locale.png b/astrid/src/main/res/drawable/icon_locale.png deleted file mode 100644 index 1d120188e..000000000 Binary files a/astrid/src/main/res/drawable/icon_locale.png and /dev/null differ diff --git a/astrid/src/main/res/drawable/locale_border.9.png b/astrid/src/main/res/drawable/locale_border.9.png deleted file mode 100644 index 0024c8fbb..000000000 Binary files a/astrid/src/main/res/drawable/locale_border.9.png and /dev/null differ diff --git a/astrid/src/main/res/layout/locale_edit_alerts.xml b/astrid/src/main/res/layout/locale_edit_alerts.xml deleted file mode 100644 index 96057f20e..000000000 --- a/astrid/src/main/res/layout/locale_edit_alerts.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/astrid/src/main/res/values/strings-core.xml b/astrid/src/main/res/values/strings-core.xml index 5394d3dab..85b5dd15b 100644 --- a/astrid/src/main/res/values/strings-core.xml +++ b/astrid/src/main/res/values/strings-core.xml @@ -663,9 +663,6 @@ Empty List! - Tasks Locale Plugin - Allows Tasks to make use of the Locale application to send you notifications based on filter conditions. Requires Locale. - diff --git a/astrid/src/main/res/values/strings-locale.xml b/astrid/src/main/res/values/strings-locale.xml index b9d1d2630..bc1b988a0 100644 --- a/astrid/src/main/res/values/strings-locale.xml +++ b/astrid/src/main/res/values/strings-locale.xml @@ -1,34 +1,7 @@ - - - - Tasks Filter Alert - - - Tasks will send you a reminder - when you have any tasks in the following filter: - - - - - Limit notifications to: - - - - once an hour - once every six hours - once every twelve hours - once a day - once every three days - once a week - - - + You have $NUM matching: $FILTER - - Please install the Tasks Locale plugin! - diff --git a/astrid/src/main/res/values/styles-locale.xml b/astrid/src/main/res/values/styles-locale.xml deleted file mode 100644 index 6a71b49f3..000000000 --- a/astrid/src/main/res/values/styles-locale.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - -