diff --git a/api/src/com/todoroo/andlib/utility/AndroidUtilities.java b/api/src/com/todoroo/andlib/utility/AndroidUtilities.java index 76ec43b79..31afee9f3 100644 --- a/api/src/com/todoroo/andlib/utility/AndroidUtilities.java +++ b/api/src/com/todoroo/andlib/utility/AndroidUtilities.java @@ -836,6 +836,7 @@ public class AndroidUtilities { PackageManager.GET_SIGNATURES); return packageInfo.signatures[0].toCharsString(); } catch (Exception e) { + Log.e("AndroidUtilities", packageName + " is not installed"); return null; } } diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml index bc2eaf10f..02418aa89 100644 --- a/astrid/AndroidManifest.xml +++ b/astrid/AndroidManifest.xml @@ -174,9 +174,6 @@ - - */ -public class AddOnActivity extends SherlockFragmentActivity { - - /** - * boolean: whether to start on available page - */ - public static final String TOKEN_START_WITH_AVAILABLE = "av"; //$NON-NLS-1$ - - private View installedView; - private View availableView; - - @Autowired - AddOnService addOnService; - - static { - AstridDependencyInjector.initialize(); - } - - public AddOnActivity() { - DependencyInjectionService.getInstance().inject(this); - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - ThemeService.applyTheme(this); - super.onCreate(savedInstanceState); - - LayoutInflater inflater = LayoutInflater.from(this); - installedView = inflater.inflate(R.layout.addon_list_container, null); - availableView = inflater.inflate(R.layout.addon_list_container, null); - - ActionBar ab = getSupportActionBar(); - ab.setDisplayHomeAsUpEnabled(true); - ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); - ActionBar.Tab installedTab = ab.newTab().setText(" " + getString(R.string.AOA_tab_installed)) //$NON-NLS-1$ - .setIcon(R.drawable.gl_pencil) - .setTabListener(new AddOnTabListener(installedView)); - - ActionBar.Tab availableTab = ab.newTab().setText(" " + getString(R.string.AOA_tab_available)) //$NON-NLS-1$ - .setIcon(R.drawable.gl_more) - .setTabListener(new AddOnTabListener(availableView)); - - ab.addTab(availableTab); - ab.addTab(installedTab); - - setTitle(R.string.AOA_title); - - populate(); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - if (item.getItemId() == android.R.id.home) { - finish(); - return true; - } - return super.onOptionsItemSelected(item); - } - - private class AddOnTabListener implements ActionBar.TabListener { - - private final View mView; - - public AddOnTabListener(View v) { - this.mView = v; - } - - @Override - public void onTabReselected(Tab tab, FragmentTransaction ft) { - // - } - - @Override - public void onTabSelected(Tab tab, FragmentTransaction ft) { - setContentView(mView); - } - - @Override - public void onTabUnselected(Tab tab, FragmentTransaction ft) { - // - } - - } - - private void populate() { - AddOn[] list = addOnService.getAddOns(); - if (list == null) { - return; - } - - ArrayList installed = new ArrayList(); - ArrayList available = new ArrayList(); - - for (AddOn addOn : list) { - if (AddOnService.POWER_PACK_PACKAGE.equals(addOn.getPackageName())) { - if (addOnService.hasPowerPack()) { - installed.add(addOn); - } else if (Constants.MARKET_STRATEGY.generateMarketLink(addOn.getPackageName()) != null) { - available.add(addOn); - } - } else { - if (addOnService.isInstalled(addOn)) { - installed.add(addOn); - } else if (Constants.MARKET_STRATEGY.generateMarketLink(addOn.getPackageName()) != null) { - available.add(addOn); - } - - } - } - - ListView installedList = (ListView) installedView.findViewById(R.id.list); - installedList.setAdapter(new AddOnAdapter(this, true, installed)); - if (installed.size() > 0) { - installedView.findViewById(R.id.empty).setVisibility(View.GONE); - } - - ListView availableList = (ListView) availableView.findViewById(R.id.list); - availableList.setAdapter(new AddOnAdapter(this, false, available)); - if (available.size() > 0) { - availableView.findViewById(R.id.empty).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/activity/EditPreferences.java b/astrid/src/com/todoroo/astrid/activity/EditPreferences.java index 3ac7a87c4..1a37fe8b3 100644 --- a/astrid/src/com/todoroo/astrid/activity/EditPreferences.java +++ b/astrid/src/com/todoroo/astrid/activity/EditPreferences.java @@ -41,7 +41,6 @@ import com.todoroo.astrid.files.FileExplore; import com.todoroo.astrid.gcal.CalendarStartupReceiver; import com.todoroo.astrid.gtasks.GtasksPreferences; import com.todoroo.astrid.helper.MetadataHelper; -import com.todoroo.astrid.service.AddOnService; import com.todoroo.astrid.service.MarketStrategy.AmazonMarketStrategy; import com.todoroo.astrid.service.StartupService; import com.todoroo.astrid.service.TaskService; @@ -84,8 +83,6 @@ public class EditPreferences extends TodorooPreferenceActivity { @Autowired private TaskService taskService; @Autowired - private AddOnService addOnService; - @Autowired private ActFmPreferenceService actFmPreferenceService; @Autowired @@ -230,9 +227,8 @@ public class EditPreferences extends TodorooPreferenceActivity { } private void disablePremiumPrefs() { - boolean hasPowerPack = addOnService.hasPowerPack(); - findPreference(getString(R.string.p_files_dir)).setEnabled(ActFmPreferenceService.isPremiumUser()); - findPreference(getString(R.string.p_voiceRemindersEnabled)).setEnabled(hasPowerPack); + findPreference(getString(R.string.p_files_dir)).setEnabled(true); + findPreference(getString(R.string.p_voiceRemindersEnabled)).setEnabled(true); } private void showBeastMode() { diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java index 86711d2c2..23f793367 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java @@ -86,7 +86,6 @@ import com.todoroo.astrid.helper.SyncActionHelper; import com.todoroo.astrid.helper.TaskListContextMenuExtensionLoader; import com.todoroo.astrid.helper.TaskListContextMenuExtensionLoader.ContextMenuItem; import com.todoroo.astrid.reminders.ReminderDebugContextActions; -import com.todoroo.astrid.service.AddOnService; import com.todoroo.astrid.service.AstridDependencyInjector; import com.todoroo.astrid.service.MetadataService; import com.todoroo.astrid.service.TagDataService; @@ -176,9 +175,6 @@ public class TaskListFragment extends SherlockListFragment implements OnSortSele @Autowired Database database; - @Autowired - AddOnService addOnService; - @Autowired UpgradeService upgradeService; diff --git a/astrid/src/com/todoroo/astrid/service/AddOnService.java b/astrid/src/com/todoroo/astrid/service/AddOnService.java deleted file mode 100644 index a4d2dc293..000000000 --- a/astrid/src/com/todoroo/astrid/service/AddOnService.java +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Copyright (c) 2012 Todoroo Inc - * - * See the file "LICENSE" for the full license governing this code. - */ -package com.todoroo.astrid.service; - -import android.content.Context; -import android.content.res.Resources; -import android.graphics.drawable.BitmapDrawable; - -import com.timsu.astrid.R; -import com.todoroo.andlib.service.ContextManager; -import com.todoroo.andlib.utility.AndroidUtilities; -import com.todoroo.andlib.utility.Preferences; -import com.todoroo.astrid.data.AddOn; -import com.todoroo.astrid.utility.Constants; - -import java.util.ArrayList; - -/** - * Astrid Service for managing add-ons - * - * @author Tim Su - */ - -public class AddOnService { - - /** - * OEM preference key - */ - private static final String PREF_OEM = "poem"; - - /** - * 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"; - - /** - * Astrid Power Pack label - */ - public static final String POWER_PACK_LABEL = "Astrid Power Pack"; - - /** - * Checks whether power pack should be enabled - */ - public boolean hasPowerPack() { - if (Preferences.getBoolean(PREF_OEM, false)) { - return true; - } else if (isInstalled(POWER_PACK_PACKAGE, true)) { - return true; - } - return false; - } - - /** - * 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 - */ - public static void recordOem() { - Preferences.setBoolean(PREF_OEM, true); - } - - /** - * Check whether a given add-on is installed - * - * @param addOn - * @return - */ - public boolean isInstalled(AddOn addOn) { - // it isnt installed if it is null... - if (addOn == null) { - return false; - } - return isInstalled(addOn.getPackageName(), addOn.isInternal()); - } - - /** - * Check whether an external add-on is installed - * - * @param packageName - * @return - */ - public boolean isInstalled(String packageName) { - return isInstalled(packageName, false); - } - - /** - * Check whether a given add-on is installed - * - * @param addOn - * @param internal whether to do api sig check - * @return - */ - private boolean isInstalled(String packageName, boolean internal) { - if (Constants.PACKAGE.equals(packageName)) { - return true; - } - - Context context = ContextManager.getContext(); - - String packageSignature = AndroidUtilities.getSignature(context, packageName); - if (packageSignature == null) { - return false; - } - if (!internal) { - return true; - } - - String astridSignature = AndroidUtilities.getSignature(context, Constants.PACKAGE); - return packageSignature.equals(astridSignature); - } - - /** - * Get one AddOn-descriptor by packageName and title. - * - * @param packageName could be Constants.PACKAGE or one of AddOnService-constants - * @param title the descriptive title, as in "Astrid Power Pack" - * @return the addon-descriptor, if it is available (registered here in getAddOns), otherwise null - */ - public AddOn getAddOn(String packageName, String title) { - if (title == null || packageName == null) { - return null; - } - - AddOn addon = null; - AddOn[] addons = getAddOns(); - for (AddOn addon1 : addons) { - if (packageName.equals(addon1.getPackageName()) && title.equals(addon1.getTitle())) { - addon = addon1; - } - } - return addon; - } - - /** - * Get a list of add-ons - * - * @return available add-ons - */ - public AddOn[] getAddOns() { - Resources r = ContextManager.getContext().getResources(); - - // temporary temporary - ArrayList list = new ArrayList(3); - if (Constants.MARKET_STRATEGY.includesPowerPack()) { - list.add(new AddOn(false, true, r.getString(R.string.AOA_ppack_title), null, - r.getString(R.string.AOA_ppack_description), - POWER_PACK_PACKAGE, - ((BitmapDrawable) r.getDrawable(R.drawable.icon_pp)).getBitmap())); - } - - 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()]); - } - -} diff --git a/astrid/src/com/todoroo/astrid/service/AstridDependencyInjector.java b/astrid/src/com/todoroo/astrid/service/AstridDependencyInjector.java index 8addfb694..1ce47af4e 100644 --- a/astrid/src/com/todoroo/astrid/service/AstridDependencyInjector.java +++ b/astrid/src/com/todoroo/astrid/service/AstridDependencyInjector.java @@ -95,7 +95,6 @@ public class AstridDependencyInjector extends AbstractDependencyInjector { injectables.put("metadataService", MetadataService.class); injectables.put("tagDataService", TagDataService.class); injectables.put("upgradeService", UpgradeService.class); - injectables.put("addOnService", AddOnService.class); injectables.put("syncService", SyncV2Service.class); // com.timsu.astrid.data diff --git a/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java b/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java index a4bb41206..8bc0e38b0 100644 --- a/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java +++ b/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java @@ -68,8 +68,6 @@ public class UpdateMessageService { @Autowired private ActFmPreferenceService actFmPreferenceService; @Autowired - private AddOnService addOnService; - @Autowired private StoreObjectDao storeObjectDao; private final Activity activity; @@ -321,9 +319,8 @@ public class UpdateMessageService { // handle internal plugin specially if (PLUGIN_GTASKS.equals(plugin)) { return gtasksPreferenceService.isLoggedIn(); - } else { - return addOnService.isInstalled(plugin); } + return true; } private boolean messageAlreadySeen(String date, String message) { diff --git a/astrid/src/com/todoroo/astrid/service/UpgradeService.java b/astrid/src/com/todoroo/astrid/service/UpgradeService.java index d5dd4e919..81fc57f2d 100644 --- a/astrid/src/com/todoroo/astrid/service/UpgradeService.java +++ b/astrid/src/com/todoroo/astrid/service/UpgradeService.java @@ -152,9 +152,6 @@ public final class UpgradeService { @Autowired GtasksPreferenceService gtasksPreferenceService; - @Autowired - AddOnService addOnService; - @Autowired ActFmPreferenceService actFmPreferenceService; @@ -171,10 +168,6 @@ public final class UpgradeService { * @param to */ public void performUpgrade(final Activity context, final int from) { - if (from == 135) { - AddOnService.recordOem(); - } - if (from > 0 && from < V3_8_2) { if (Preferences.getBoolean(R.string.p_transparent_deprecated, false)) { Preferences.setString(R.string.p_theme, "transparent"); //$NON-NLS-1$ diff --git a/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java b/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java index dd4bcc35b..bade786de 100644 --- a/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java +++ b/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java @@ -37,7 +37,6 @@ import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.activity.AstridActivity; import com.todoroo.astrid.activity.TaskEditFragment; -import com.todoroo.astrid.activity.TaskListActivity; import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.activity.TaskListFragment.OnTaskListItemClickedListener; import com.todoroo.astrid.core.PluginServices; @@ -51,7 +50,6 @@ import com.todoroo.astrid.files.FileUtilities; import com.todoroo.astrid.gcal.GCalControlSet; import com.todoroo.astrid.gcal.GCalHelper; import com.todoroo.astrid.repeats.RepeatControlSet; -import com.todoroo.astrid.service.AddOnService; import com.todoroo.astrid.service.MetadataService; import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.utility.Flags; @@ -79,8 +77,6 @@ public class QuickAddBar extends LinearLayout { private String currentVoiceFile = null; - @Autowired - AddOnService addOnService; @Autowired ExceptionService exceptionService; @Autowired