package com.todoroo.astrid.tags;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.todoroo.astrid.actfm.TagViewActivity;
import com.todoroo.astrid.api.Addon;
import com.todoroo.astrid.api.AstridApiConstants;

public class TagsPlugin extends BroadcastReceiver {

    static final String IDENTIFIER = "tags"; //$NON-NLS-1$

    @SuppressWarnings("nls")
    @Override
    public void onReceive(Context context, Intent intent) {
        Addon plugin = new Addon(IDENTIFIER, "Tags", "Todoroo",
                "Provides tagging support for tasks.");

        Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_ADDONS);
        broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, plugin);
        context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
    }


    /**
     * Create new tag data
     * @param activity
     */
    public void showNewTagDialog(final Activity activity) {
        Intent intent = new Intent(activity, TagViewActivity.class);
        intent.putExtra(TagViewActivity.EXTRA_NEW_TAG, true);
        intent.putExtra(TagViewActivity.EXTRA_START_TAB, "settings"); //$NON-NLS-1$
        activity.startActivity(intent);
    }

}
