Added new logic behaviours (Iterator, Stop)

[artf473055]
This commit is contained in:
Ziver Koc 2015-01-19 17:52:09 +01:00
parent b07ac93e35
commit fef55a5dd4
9 changed files with 203 additions and 56 deletions

View file

@ -17,6 +17,7 @@ import android.widget.Toast;
import com.ericsson.uecontrol.R;
import com.ericsson.uecontrol.core.UeControlExecutor;
import com.ericsson.uecontrol.core.UeControlExecutor.ExecutionListener;
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSleep;
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSurfing;
import com.ericsson.uecontrol.gui.fragments.BehaviourListFragment;
@ -34,7 +35,7 @@ import de.mindpipe.android.logging.log4j.LogConfigurator;
public class MainActivity extends FragmentActivity implements OnSharedPreferenceChangeListener,
OnFileSelectionListener {
OnFileSelectionListener, ExecutionListener {
private static final Logger log = Logger.getLogger(MainActivity.class);
public static final String DEFAULT_LOG_PATH = "/sdcard/uecontrol/";
public static final String BEHAVIOUR_SAVE_FILE = "behaviour_list.json";
@ -103,6 +104,7 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
executor.setThroughputListener(statusFragment.getThroughputListener());
executor.setExecutionListener(this);
updateExecutionState();
}
@ -241,25 +243,42 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
}
}
private void updateExecutionState(){
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if(action_execute != null) {
if (executor.isRunning()) {
if (executor.isRunning())
executionStarted();
else
executionStopped();
}
}
public void executionStarted(){
if(action_execute == null)
return;
this.runOnUiThread(new Runnable() {
@Override
public void run() {
action_execute.setTitle(R.string.action_stop);
ExecNotification.create();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
if(action_mark != null && prefs.getBoolean("logging", false))
action_mark.setEnabled(true);
if(prefs.getBoolean("screen_on", false))
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
else {
});
}
public void executionStopped(){
if(action_execute == null)
return;
this.runOnUiThread(new Runnable() {
@Override
public void run() {
action_execute.setTitle(R.string.action_run);
ExecNotification.dismiss();
action_mark.setEnabled(false);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
});
}