Added new logic behaviours (Iterator, Stop)
[artf473055]
This commit is contained in:
parent
b07ac93e35
commit
fef55a5dd4
9 changed files with 203 additions and 56 deletions
11
.idea/libraries/support_v4_19_1_0.xml
generated
11
.idea/libraries/support_v4_19_1_0.xml
generated
|
|
@ -1,11 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="support-v4-19.1.0">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://C:/Program Files (x86)/Android/android-sdk/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES>
|
|
||||||
<root url="jar://C:/Program Files (x86)/Android/android-sdk/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0-sources.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
|
|
@ -11,33 +11,36 @@ import java.io.Serializable;
|
||||||
*/
|
*/
|
||||||
public abstract class UeBehaviour implements Serializable{
|
public abstract class UeBehaviour implements Serializable{
|
||||||
private static final Logger log = Logger.getLogger(UeBehaviour.class);
|
private static final Logger log = Logger.getLogger(UeBehaviour.class);
|
||||||
|
/** A sleep period for visual queue, mainly for behaviours that instantly finnish **/
|
||||||
|
public static final int VISUAL_SLEEP_PERIOD = 200;
|
||||||
|
|
||||||
private transient boolean running;
|
|
||||||
private transient long execTime = -1;
|
private transient long execTime = -1;
|
||||||
private transient BehaviourExecutionListener execListener;
|
private transient BehaviourExecutionListener execListener;
|
||||||
|
private transient UeControlExecutor executor;
|
||||||
|
|
||||||
|
|
||||||
public synchronized void preRun() {
|
public synchronized void preRun() { }
|
||||||
running = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts to run the behaviour, this method will block until the execution is done
|
* Starts to run the behaviour, this method will block until the execution is done
|
||||||
*/
|
*/
|
||||||
public void run(){
|
public synchronized void run(UeControlExecutor exec){
|
||||||
execTime = -1;
|
execTime = -1;
|
||||||
long startTime = System.currentTimeMillis();
|
this.executor = exec;
|
||||||
if(execListener != null)
|
if(execListener != null)
|
||||||
execListener.executionStarted();
|
execListener.executionStarted();
|
||||||
|
setProgress(0);
|
||||||
|
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
setProgress(0);
|
|
||||||
execute();
|
execute();
|
||||||
} catch(Exception e){
|
} catch(Exception e){
|
||||||
if(execListener != null) execListener.exception(e);
|
if(execListener != null) execListener.exception(e);
|
||||||
log.warn(null, e);
|
log.warn(null, e);
|
||||||
}
|
}
|
||||||
running = false;
|
|
||||||
execTime = System.currentTimeMillis() - startTime;
|
execTime = System.currentTimeMillis() - startTime;
|
||||||
|
|
||||||
|
executor = null;
|
||||||
if(execListener != null)
|
if(execListener != null)
|
||||||
execListener.executionStopped(execTime);
|
execListener.executionStopped(execTime);
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +49,7 @@ public abstract class UeBehaviour implements Serializable{
|
||||||
* Will stop the currently running behaviour
|
* Will stop the currently running behaviour
|
||||||
*/
|
*/
|
||||||
public void terminate(){
|
public void terminate(){
|
||||||
running = false;
|
executor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(){
|
public void reset(){
|
||||||
|
|
@ -62,14 +65,18 @@ public abstract class UeBehaviour implements Serializable{
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRunning(){
|
public boolean isRunning(){
|
||||||
return running;
|
return executor != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return if currently running behaviour should be terminated
|
* @return if currently running behaviour should be terminated
|
||||||
*/
|
*/
|
||||||
protected boolean stopExecution(){
|
protected boolean stopExecution(){
|
||||||
return !running;
|
return !isRunning();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected UeControlExecutor getExecutor(){
|
||||||
|
return executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ public class UeControlExecutor implements Runnable{
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
private ThroughputUpdateRunnable throughputUpdateRunnable;
|
private ThroughputUpdateRunnable throughputUpdateRunnable;
|
||||||
private ThroughputListener throughputListener;
|
private ThroughputListener throughputListener;
|
||||||
|
private ExecutionListener execListener;
|
||||||
|
|
||||||
|
|
||||||
public UeControlExecutor(){
|
public UeControlExecutor(){
|
||||||
|
|
@ -90,7 +91,7 @@ public class UeControlExecutor implements Runnable{
|
||||||
try{ Thread.sleep(20); }catch(Exception e){log.error(null,e);}
|
try{ Thread.sleep(20); }catch(Exception e){log.error(null,e);}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void terminateNonBlock(){
|
public void terminateNonBlock(){
|
||||||
terminate = true;
|
terminate = true;
|
||||||
handler.removeCallbacks(throughputUpdateRunnable);
|
handler.removeCallbacks(throughputUpdateRunnable);
|
||||||
if(currentlyActive != null)
|
if(currentlyActive != null)
|
||||||
|
|
@ -105,14 +106,14 @@ public class UeControlExecutor implements Runnable{
|
||||||
try {
|
try {
|
||||||
thread.wait();
|
thread.wait();
|
||||||
while(isRunning()) // Just to make sure it has stopped
|
while(isRunning()) // Just to make sure it has stopped
|
||||||
Thread.sleep(10);
|
Thread.sleep(100);
|
||||||
}catch(InterruptedException e) {log.error(null,e);}
|
}catch(InterruptedException e) {log.error(null,e);}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void reset(){
|
public synchronized void reset(){
|
||||||
terminate();
|
terminateNonBlock();
|
||||||
currentlyActive = null;
|
currentlyActive = null;
|
||||||
for(int i=0; i<behaviours.size(); i++){
|
for(int i=0; i<behaviours.size(); i++){
|
||||||
behaviours.get(i).reset();
|
behaviours.get(i).reset();
|
||||||
|
|
@ -127,6 +128,8 @@ public class UeControlExecutor implements Runnable{
|
||||||
|
|
||||||
public void run(){
|
public void run(){
|
||||||
log.info("Starting execution");
|
log.info("Starting execution");
|
||||||
|
if(execListener != null)
|
||||||
|
execListener.executionStarted();
|
||||||
if(csvPath != null)
|
if(csvPath != null)
|
||||||
csvLogger = new CSVWriter(csvPath);
|
csvLogger = new CSVWriter(csvPath);
|
||||||
while(!terminate) {
|
while(!terminate) {
|
||||||
|
|
@ -144,11 +147,15 @@ public class UeControlExecutor implements Runnable{
|
||||||
currentlyActive.preRun();
|
currentlyActive.preRun();
|
||||||
thread.notifyAll();
|
thread.notifyAll();
|
||||||
}
|
}
|
||||||
// Run behaviour
|
|
||||||
log.info("Running behaviour: " + currentlyActive.getName());
|
|
||||||
currentlyActive.run();
|
|
||||||
|
|
||||||
if(!terminate) {
|
// Run behaviour
|
||||||
|
UeBehaviour execBehaviour = currentlyActive;
|
||||||
|
log.info("Running behaviour: " + currentlyActive.getName());
|
||||||
|
execBehaviour.run(this);
|
||||||
|
|
||||||
|
// Before deciding on the next behaviour check if currentlyActive
|
||||||
|
// has been changed by the previous behaviour
|
||||||
|
if(!terminate && execBehaviour == currentlyActive) {
|
||||||
int index = behaviours.indexOf(currentlyActive) + 1;
|
int index = behaviours.indexOf(currentlyActive) + 1;
|
||||||
if (index < behaviours.size())
|
if (index < behaviours.size())
|
||||||
currentlyActive = behaviours.get(index);
|
currentlyActive = behaviours.get(index);
|
||||||
|
|
@ -161,9 +168,16 @@ public class UeControlExecutor implements Runnable{
|
||||||
csvLogger = null;
|
csvLogger = null;
|
||||||
}
|
}
|
||||||
log.info("Execution completed");
|
log.info("Execution completed");
|
||||||
|
if(execListener != null)
|
||||||
|
execListener.executionStopped();
|
||||||
synchronized (thread){thread.notifyAll();}
|
synchronized (thread){thread.notifyAll();}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setNextBehaviour(int i) {
|
||||||
|
if(0 <= i && i < behaviours.size())
|
||||||
|
currentlyActive = behaviours.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the log path or null to disable logging
|
* Set the log path or null to disable logging
|
||||||
*/
|
*/
|
||||||
|
|
@ -173,6 +187,9 @@ public class UeControlExecutor implements Runnable{
|
||||||
public void setThroughputListener(ThroughputListener listener){
|
public void setThroughputListener(ThroughputListener listener){
|
||||||
throughputListener = listener;
|
throughputListener = listener;
|
||||||
}
|
}
|
||||||
|
public void setExecutionListener(ExecutionListener listener){
|
||||||
|
execListener = listener;
|
||||||
|
}
|
||||||
public void setDeviceBasedThroughput(boolean enable){
|
public void setDeviceBasedThroughput(boolean enable){
|
||||||
throughputUpdateRunnable.deviceBasedThroughput = enable;
|
throughputUpdateRunnable.deviceBasedThroughput = enable;
|
||||||
}
|
}
|
||||||
|
|
@ -188,11 +205,16 @@ public class UeControlExecutor implements Runnable{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static interface ThroughputListener{
|
|
||||||
public void throughputUpdate(double downThroughput, double upThroughput);
|
public static interface ExecutionListener {
|
||||||
|
public void executionStarted();
|
||||||
|
public void executionStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static interface ThroughputListener{
|
||||||
|
public void throughputUpdate(double downThroughput, double upThroughput);
|
||||||
|
}
|
||||||
|
|
||||||
private class ThroughputUpdateRunnable implements Runnable{
|
private class ThroughputUpdateRunnable implements Runnable{
|
||||||
protected boolean deviceBasedThroughput;
|
protected boolean deviceBasedThroughput;
|
||||||
|
|
|
||||||
49
app/src/main/java/com/ericsson/uecontrol/core/logic/UeBehaviourIterator.java
Executable file
49
app/src/main/java/com/ericsson/uecontrol/core/logic/UeBehaviourIterator.java
Executable file
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.ericsson.uecontrol.core.logic;
|
||||||
|
|
||||||
|
import com.ericsson.uecontrol.core.UeBehaviour;
|
||||||
|
import com.ericsson.uecontrol.core.util.Configurator.Configurable;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ezivkoc on 2015-01-19.
|
||||||
|
*/
|
||||||
|
public class UeBehaviourIterator extends UeBehaviour {
|
||||||
|
private static final Logger log = Logger.getLogger(UeBehaviourIterator.class);
|
||||||
|
|
||||||
|
@Configurable(order=1, value="Iterations")
|
||||||
|
private int iterations = 5;
|
||||||
|
|
||||||
|
|
||||||
|
private transient int iterationCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() throws Exception {
|
||||||
|
iterationCount++;
|
||||||
|
if(iterationCount < iterations){
|
||||||
|
log.debug("Iteration: "+ iterationCount);
|
||||||
|
super.getExecutor().setNextBehaviour(0);
|
||||||
|
Thread.sleep(VISUAL_SLEEP_PERIOD); // Sleep as a visual queue
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
log.debug("Iteration done, skipping");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
iterationCount = 0;
|
||||||
|
super.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Iterator";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Will iterate " +iterations+ " times";
|
||||||
|
}
|
||||||
|
}
|
||||||
34
app/src/main/java/com/ericsson/uecontrol/core/logic/UeBehaviourStop.java
Executable file
34
app/src/main/java/com/ericsson/uecontrol/core/logic/UeBehaviourStop.java
Executable file
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.ericsson.uecontrol.core.logic;
|
||||||
|
|
||||||
|
import com.ericsson.uecontrol.core.UeBehaviour;
|
||||||
|
import com.ericsson.uecontrol.core.util.Configurator.Configurable;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ezivkoc on 2015-01-19.
|
||||||
|
*/
|
||||||
|
public class UeBehaviourStop extends UeBehaviour {
|
||||||
|
private static final Logger log = Logger.getLogger(UeBehaviourStop.class);
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() throws Exception {
|
||||||
|
log.debug("Terminating execution");
|
||||||
|
super.getExecutor().setNextBehaviour(0);
|
||||||
|
log.debug("Resetting executor");
|
||||||
|
super.getExecutor().reset();
|
||||||
|
Thread.sleep(VISUAL_SLEEP_PERIOD); // Sleep as a visual queue
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Stop";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Will stop execution";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ public class Configurator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum ConfigType{
|
public static enum ConfigType{
|
||||||
STRING, INT
|
STRING, INT, BOOLEAN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -96,6 +96,7 @@ public class Configurator {
|
||||||
|
|
||||||
if (f.getType() == String.class) type = ConfigType.STRING;
|
if (f.getType() == String.class) type = ConfigType.STRING;
|
||||||
else if(f.getType() == int.class) type = ConfigType.INT;
|
else if(f.getType() == int.class) type = ConfigType.INT;
|
||||||
|
else if(f.getType() == boolean.class)type = ConfigType.BOOLEAN;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,6 +115,8 @@ public class Configurator {
|
||||||
value = v; break;
|
value = v; break;
|
||||||
case INT:
|
case INT:
|
||||||
value = Integer.parseInt(v); break;
|
value = Integer.parseInt(v); break;
|
||||||
|
case BOOLEAN:
|
||||||
|
value = Boolean.parseBoolean(v); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import com.ericsson.uecontrol.R;
|
import com.ericsson.uecontrol.R;
|
||||||
import com.ericsson.uecontrol.core.UeControlExecutor;
|
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.UeBehaviourSleep;
|
||||||
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSurfing;
|
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSurfing;
|
||||||
import com.ericsson.uecontrol.gui.fragments.BehaviourListFragment;
|
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,
|
public class MainActivity extends FragmentActivity implements OnSharedPreferenceChangeListener,
|
||||||
OnFileSelectionListener {
|
OnFileSelectionListener, ExecutionListener {
|
||||||
private static final Logger log = Logger.getLogger(MainActivity.class);
|
private static final Logger log = Logger.getLogger(MainActivity.class);
|
||||||
public static final String DEFAULT_LOG_PATH = "/sdcard/uecontrol/";
|
public static final String DEFAULT_LOG_PATH = "/sdcard/uecontrol/";
|
||||||
public static final String BEHAVIOUR_SAVE_FILE = "behaviour_list.json";
|
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.setThroughputListener(statusFragment.getThroughputListener());
|
||||||
|
executor.setExecutionListener(this);
|
||||||
updateExecutionState();
|
updateExecutionState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,25 +243,42 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void updateExecutionState(){
|
private void updateExecutionState(){
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
if(action_execute != null) {
|
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);
|
action_execute.setTitle(R.string.action_stop);
|
||||||
ExecNotification.create();
|
ExecNotification.create();
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
|
||||||
if(action_mark != null && prefs.getBoolean("logging", false))
|
if(action_mark != null && prefs.getBoolean("logging", false))
|
||||||
action_mark.setEnabled(true);
|
action_mark.setEnabled(true);
|
||||||
if(prefs.getBoolean("screen_on", false))
|
if(prefs.getBoolean("screen_on", false))
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
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);
|
action_execute.setTitle(R.string.action_run);
|
||||||
ExecNotification.dismiss();
|
ExecNotification.dismiss();
|
||||||
action_mark.setEnabled(false);
|
action_mark.setEnabled(false);
|
||||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
@ -16,6 +17,7 @@ import com.ericsson.uecontrol.R;
|
||||||
import com.ericsson.uecontrol.core.UeBehaviour;
|
import com.ericsson.uecontrol.core.UeBehaviour;
|
||||||
import com.ericsson.uecontrol.gui.MainActivity;
|
import com.ericsson.uecontrol.gui.MainActivity;
|
||||||
import com.ericsson.uecontrol.core.util.Configurator;
|
import com.ericsson.uecontrol.core.util.Configurator;
|
||||||
|
import com.ericsson.uecontrol.core.util.Configurator.ConfigType;
|
||||||
import com.ericsson.uecontrol.core.util.Configurator.ConfigurationParam;
|
import com.ericsson.uecontrol.core.util.Configurator.ConfigurationParam;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -24,12 +26,12 @@ import java.util.HashMap;
|
||||||
* Created by ezivkoc on 2014-07-24.
|
* Created by ezivkoc on 2014-07-24.
|
||||||
*/
|
*/
|
||||||
public class ConfigureDialog extends DialogFragment {
|
public class ConfigureDialog extends DialogFragment {
|
||||||
private HashMap<String, EditText> inputs;
|
private HashMap<String, Object> inputs;
|
||||||
private Configurator confer;
|
private Configurator confer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
inputs = new HashMap<String, EditText>();
|
inputs = new HashMap<String, Object>();
|
||||||
|
|
||||||
// Fix for CopyPaste bar not visible
|
// Fix for CopyPaste bar not visible
|
||||||
Context context = new ContextThemeWrapper(getActivity(), android.R.style.Theme_Holo_Light);
|
Context context = new ContextThemeWrapper(getActivity(), android.R.style.Theme_Holo_Light);
|
||||||
|
|
@ -62,20 +64,33 @@ public class ConfigureDialog extends DialogFragment {
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT));
|
LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||||
layout.addView(label);
|
layout.addView(label);
|
||||||
|
if(confParam.getType() == ConfigType.STRING || confParam.getType() == ConfigType.INT) {
|
||||||
|
EditText input = new EditText(context);
|
||||||
|
input.setLayoutParams(new LinearLayout.LayoutParams(
|
||||||
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||||
|
LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||||
|
// Set previous value
|
||||||
|
if (savedInstanceState != null && savedInstanceState.containsKey(confParam.getName()))
|
||||||
|
input.setText(savedInstanceState.getString(confParam.getName()), TextView.BufferType.EDITABLE);
|
||||||
|
else
|
||||||
|
input.setText(confParam.getString(), TextView.BufferType.EDITABLE);
|
||||||
|
|
||||||
EditText input = new EditText(context);
|
// store inputs for later use
|
||||||
input.setLayoutParams(new LinearLayout.LayoutParams(
|
inputs.put(confParam.getName(), input);
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
layout.addView(input);
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT));
|
}
|
||||||
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
else if(confParam.getType() == ConfigType.BOOLEAN) {
|
||||||
// Set previous value
|
CheckBox input = new CheckBox(context);
|
||||||
if(savedInstanceState != null && savedInstanceState.containsKey(confParam.getName()))
|
// Set previous value
|
||||||
input.setText(savedInstanceState.getString(confParam.getName()), TextView.BufferType.EDITABLE);
|
if (savedInstanceState != null && savedInstanceState.containsKey(confParam.getName()))
|
||||||
else
|
input.setChecked(Boolean.parseBoolean(savedInstanceState.getString(confParam.getName())));
|
||||||
input.setText(confParam.getString(), TextView.BufferType.EDITABLE);
|
else
|
||||||
// store inputs for later use
|
input.setChecked(Boolean.parseBoolean(confParam.getString()));
|
||||||
inputs.put(confParam.getName(), input);
|
// store inputs for later use
|
||||||
layout.addView(input);
|
inputs.put(confParam.getName(), input);
|
||||||
|
layout.addView(input);
|
||||||
|
}
|
||||||
|
|
||||||
root.addView(layout);
|
root.addView(layout);
|
||||||
}
|
}
|
||||||
|
|
@ -83,8 +98,11 @@ public class ConfigureDialog extends DialogFragment {
|
||||||
|
|
||||||
builder.setPositiveButton(R.string.action_save, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.action_save, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
for(ConfigurationParam confParam : confer.getConfiguration()){
|
for (ConfigurationParam confParam : confer.getConfiguration()) {
|
||||||
confParam.setString(inputs.get(confParam.getName()).getText().toString());
|
if(inputs.get(confParam.getName()) instanceof EditText)
|
||||||
|
confParam.setString(((EditText)inputs.get(confParam.getName())).getText().toString());
|
||||||
|
else if(inputs.get(confParam.getName()) instanceof CheckBox)
|
||||||
|
confParam.setString(""+ ((CheckBox)inputs.get(confParam.getName())).isChecked());
|
||||||
}
|
}
|
||||||
confer.setConfiguration();
|
confer.setConfiguration();
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +121,10 @@ public class ConfigureDialog extends DialogFragment {
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
for(String key : inputs.keySet()){
|
for(String key : inputs.keySet()){
|
||||||
outState.putString(key, inputs.get(key).getText().toString());
|
if(inputs.get(key) instanceof EditText)
|
||||||
|
outState.putString(key, ((EditText)inputs.get(key)).getText().toString());
|
||||||
|
else if(inputs.get(key) instanceof CheckBox)
|
||||||
|
outState.putString(key, ""+ ((CheckBox)inputs.get(key)).isChecked());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@
|
||||||
<item>com.ericsson.uecontrol.core.behaviour.UeBehaviourSpeechCall</item>
|
<item>com.ericsson.uecontrol.core.behaviour.UeBehaviourSpeechCall</item>
|
||||||
<item>com.ericsson.uecontrol.core.behaviour.UeBehaviourSurfing</item>
|
<item>com.ericsson.uecontrol.core.behaviour.UeBehaviourSurfing</item>
|
||||||
<item>com.ericsson.uecontrol.core.behaviour.UeBehaviourVideoStreaming</item>
|
<item>com.ericsson.uecontrol.core.behaviour.UeBehaviourVideoStreaming</item>
|
||||||
|
|
||||||
|
<item>com.ericsson.uecontrol.core.logic.UeBehaviourIterator</item>
|
||||||
|
<item>com.ericsson.uecontrol.core.logic.UeBehaviourStop</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="throughput_types">
|
<string-array name="throughput_types">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue