/*
 * Copyright 2013 Andrew Okin
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.forkk.andcron.data.action;

import android.preference.PreferenceFragment;

import net.forkk.andcron.R;
import net.forkk.andcron.data.Automation;
import net.forkk.andcron.data.AutomationComponentBase;
import net.forkk.andcron.data.AutomationService;


/**
 * Abstract base class for actions that implements common functionality.
 */
public abstract class ActionBase extends AutomationComponentBase implements Action
{
    public ActionBase(Automation parent, AutomationService service, int id)
    {
        super(parent, service, id);
    }

    @Override
    protected String getSharedPreferencesName(int id)
    {
        return "action_" + id;
    }

    protected static String getSharedPreferencesNameForId(int id)
    {
        return "action_" + id;
    }

    @Override
    public void addPreferencesToFragment(PreferenceFragment fragment)
    {
        super.addPreferencesToFragment(fragment);
        fragment.addPreferencesFromResource(R.xml.prefs_action);
    }
}

@@ -1132,32 +1132,290 @@
 ce, id);%0A    %7D%0A%0A
+    @Override%0A    public void setEnabled(boolean enabled)%0A    %7B%0A        super.setEnabled(enabled);%0A        if (enabled)%0A        %7B%0A            if (getParent().isActive()) onActivate(getService());%0A            else onDeactivate(getService());%0A        %7D%0A    %7D%0A%0A
     @Override%0A  

Call onActivate or onDeactivate for an action when it becomes enabled.