package treehou.se.habit.tasker.boundle;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;

import treehou.se.habit.core.db.ItemDB;
import treehou.se.habit.tasker.reciever.CommandReciever;
import treehou.se.habit.tasker.reciever.IFireReciever;

public class CommandBoundleManager {

    public static final String TAG = "CommandBoundleManager";

    public static final int TYPE_COMMAND = 1;

    /**
     * @param context Application context.
     * @param command The toast message to be displayed by the plug-in. Cannot be null.
     * @return A plug-in bundle.
     */
    public static Bundle generateCommandBundle(final Context context, final ItemDB item, final String command) {

        Log.d(TAG, "Item " + item + " Command " + command);

        final Bundle result = new Bundle();
        result.putInt(IFireReciever.BUNDLE_EXTRA_TYPE, TYPE_COMMAND);
        result.putString(CommandReciever.BUNDLE_EXTRA_COMMAND, command);
        result.putLong(CommandReciever.BUNDLE_EXTRA_ITEM, item.getId());

        return result;
    }

    /**
     * Private constructor prevents instantiation
     *
     * @throws UnsupportedOperationException because this class cannot be instantiated.
     */
    private CommandBoundleManager() {
        throw new UnsupportedOperationException("This class is non-instantiable"); //$NON-NLS-1$
    }
}

@@ -420,16 +420,148 @@
 D = 1;%0A%0A
+    private static final String BUNDLE_KEY_VARIABLE_REPLACE_STRINGS = %22net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS%22;%0A%0A
     /**%0A
@@ -1094,16 +1094,193 @@
 mmand);%0A
+        // Instruct tasker to perform variable substitutions in the command%0A        result.putString(BUNDLE_KEY_VARIABLE_REPLACE_STRINGS, CommandReciever.BUNDLE_EXTRA_COMMAND);%0A
         

allow variable replacement in command