Remove AddOnActivity and AddOnService

Alex Baker 13 years ago
parent 7e73c12c53
commit 41f736a6a6

@ -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;
}
}

@ -174,9 +174,6 @@
</intent-filter>
</activity>
<!-- Activity that selects and installs add-ons -->
<activity
android:name="com.todoroo.astrid.activity.AddOnActivity"
android:windowSoftInputMode="stateHidden"/>
<!-- Activity for preferences -->
<activity
android:name="com.todoroo.astrid.activity.EditPreferences"

@ -31,7 +31,6 @@ import com.todoroo.astrid.dao.WaitingOnMeDao;
import com.todoroo.astrid.dao.WaitingOnMeOutstandingDao;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.service.AddOnService;
import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.TagDataService;
@ -62,9 +61,6 @@ public final class PluginServices {
@Autowired
TagMetadataDao tagMetadataDao;
@Autowired
AddOnService addOnService;
@Autowired
TagDataService tagDataService;
@ -188,10 +184,6 @@ public final class PluginServices {
return getInstance().metadataService;
}
public static AddOnService getAddOnService() {
return getInstance().addOnService;
}
public static StoreObjectDao getStoreObjectDao() {
return getInstance().storeObjectDao;
}

@ -21,7 +21,6 @@ import android.widget.Spinner;
import com.timsu.astrid.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;
@ -194,18 +193,6 @@ public final class LocaleEditAlerts extends ListActivity {
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

@ -53,10 +53,6 @@ public class LocaleReceiver extends BroadcastReceiver {
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);

@ -1,184 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.activity;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ListView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.Tab;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.astrid.adapter.AddOnAdapter;
import com.todoroo.astrid.data.AddOn;
import com.todoroo.astrid.service.AddOnService;
import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.utility.Constants;
import java.util.ArrayList;
/**
* TODO: fix deprecation or get rid of me
*
* @author Tim Su <tim@todoroo.com>
*/
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<AddOn> installed = new ArrayList<AddOn>();
ArrayList<AddOn> available = new ArrayList<AddOn>();
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();
}
}
};
}
}

@ -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() {

@ -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;

@ -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 <tim@todoroo.com>
*/
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<AddOn> list = new ArrayList<AddOn>(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()]);
}
}

@ -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

@ -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) {

@ -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$

@ -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

Loading…
Cancel
Save