// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
//     public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
//         generator.generateActon(sb, this, subject);
//     }
// }
// 
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
//     private String group = null;
//     private Subject subject;
//     private Action action;
//     private String description;
//     private long time;
// 
//     public RecordingEvent(String group, Subject subject, Action action) {
//         this.group = group;
//         this.subject = subject;
//         this.action = action;
//     }
// 
//     public RecordingEvent(Subject subject, Action action, String description) {
//         this.subject = subject;
//         this.action = action;
//         this.description = description;
//     }
// 
//     public Subject getSubject() {
//         return subject;
//     }
// 
//     public Action getAction() {
//         return action;
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public void setDescription(String description) {
//         this.description = description;
//     }
// 
//     public String getGroup() {
//         return group;
//     }
// 
//     public void setGroup(String group) {
//         this.group = group;
//     }
// 
//     public long getTime() {
//         return time;
//     }
// 
//     public void setTime(long time) {
//         this.time = time;
//     }
// 
//     public void accept(StringBuilder sb, TestGenerator generator){
//         generator.generateEvent(sb, this);
//     }
// 
//     @Override
//     public String toString() {
//         return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
//                 (description==null?"":description)+"]";
//     }
// 
//     public static RecordingEvent fromString(String str) {
//         String tmp = str.substring(7, str.length()-1);
//         String arr[] = tmp.split("[,]");
// 
//         String timeStr = arr[0];
//         String group = arr[1];
//         String subjectStr = arr[2];
//         String actionStr = arr[3];
//         String description = arr.length == 5 ? arr[4] : null;
//         RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
// 
//         event.setTime(Long.parseLong(timeStr));
// 
//         if (group.length() > 0) {
//             event.setGroup(group);
//         }
// 
//         return event;
//     }
// }


import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.lang.reflect.Field;
package com.vpedak.testsrecorder.core;




public class CheckableProcessor {
    private ActivityProcessor activityProcessor;

    public CheckableProcessor(ActivityProcessor activityProcessor) {
        this.activityProcessor = activityProcessor;
    }

    public void processClick(final CompoundButton checkable) {
        CompoundButton.OnCheckedChangeListener listener = null;
        try {
            Field f = CompoundButton.class.getDeclaredField("mOnCheckedChangeListener");
            f.setAccessible(true);
            listener = (CompoundButton.OnCheckedChangeListener) f.get(checkable);
        } catch (IllegalAccessException e) {
            Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "IllegalAccessException", e);
        } catch (NoSuchFieldException e) {
            Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "NoSuchFieldException", e);
        }

        final CompoundButton.OnCheckedChangeListener finalListener = listener;
        checkable.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                String id = activityProcessor.resolveId(buttonView.getId());
                if (id != null) {
                    String descr = (isChecked ? "Check " : "Uncheck ") + activityProcessor.getWidgetName(buttonView) + " with id "+id;
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
//     public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
//         generator.generateActon(sb, this, subject);
//     }
// }
// 
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
//     private String group = null;
//     private Subject subject;
//     private Action action;
//     private String description;
//     private long time;
// 
//     public RecordingEvent(String group, Subject subject, Action action) {
//         this.group = group;
//         this.subject = subject;
//         this.action = action;
//     }
// 
//     public RecordingEvent(Subject subject, Action action, String description) {
//         this.subject = subject;
//         this.action = action;
//         this.description = description;
//     }
// 
//     public Subject getSubject() {
//         return subject;
//     }
// 
//     public Action getAction() {
//         return action;
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public void setDescription(String description) {
//         this.description = description;
//     }
// 
//     public String getGroup() {
//         return group;
//     }
// 
//     public void setGroup(String group) {
//         this.group = group;
//     }
// 
//     public long getTime() {
//         return time;
//     }
// 
//     public void setTime(long time) {
//         this.time = time;
//     }
// 
//     public void accept(StringBuilder sb, TestGenerator generator){
//         generator.generateEvent(sb, this);
//     }
// 
//     @Override
//     public String toString() {
//         return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
//                 (description==null?"":description)+"]";
//     }
// 
//     public static RecordingEvent fromString(String str) {
//         String tmp = str.substring(7, str.length()-1);
//         String arr[] = tmp.split("[,]");
// 
//         String timeStr = arr[0];
//         String group = arr[1];
//         String subjectStr = arr[2];
//         String actionStr = arr[3];
//         String description = arr.length == 5 ? arr[4] : null;
//         RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
// 
//         event.setTime(Long.parseLong(timeStr));
// 
//         if (group.length() > 0) {
//             event.setGroup(group);
//         }
// 
//         return event;
//     }
// }


// Path: RecordingLib/src/com/vpedak/testsrecorder/core/CheckableProcessor.java
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.lang.reflect.Field;

package com.vpedak.testsrecorder.core;




public class CheckableProcessor {
    private ActivityProcessor activityProcessor;

    public CheckableProcessor(ActivityProcessor activityProcessor) {
        this.activityProcessor = activityProcessor;
    }

    public void processClick(final CompoundButton checkable) {
        CompoundButton.OnCheckedChangeListener listener = null;
        try {
            Field f = CompoundButton.class.getDeclaredField("mOnCheckedChangeListener");
            f.setAccessible(true);
            listener = (CompoundButton.OnCheckedChangeListener) f.get(checkable);
        } catch (IllegalAccessException e) {
            Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "IllegalAccessException", e);
        } catch (NoSuchFieldException e) {
            Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "NoSuchFieldException", e);
        }

        final CompoundButton.OnCheckedChangeListener finalListener = listener;
        checkable.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                String id = activityProcessor.resolveId(buttonView.getId());
                if (id != null) {
                    String descr = (isChecked ? "Check " : "Uncheck ") + activityProcessor.getWidgetName(buttonView) + " with id "+id;
                    activityProcessor.getEventWriter().writeEvent(new RecordingEvent(new com.vpedak.testsrecorder.core.events.View(id), new ClickAction(), descr));