Added custom marks
[artf403916]
This commit is contained in:
parent
9727b88327
commit
ffd5dcc7cc
5 changed files with 92 additions and 22 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
<facet type="android" name="Android">
|
<facet type="android" name="Android">
|
||||||
<configuration>
|
<configuration>
|
||||||
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||||
|
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
|
||||||
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
||||||
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
|
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
|
||||||
|
|
@ -24,6 +25,7 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||||
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
|
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,10 @@
|
||||||
package com.ericsson.uecontrol.gui;
|
package com.ericsson.uecontrol.gui;
|
||||||
|
|
||||||
import android.app.ActionBar;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
|
@ -15,7 +12,6 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
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.UeControlExecutor.ExecutionListener;
|
||||||
|
|
@ -27,14 +23,12 @@ import com.ericsson.uecontrol.gui.fragments.ExecNotification;
|
||||||
import com.ericsson.uecontrol.gui.fragments.FileBrowserDialog;
|
import com.ericsson.uecontrol.gui.fragments.FileBrowserDialog;
|
||||||
import com.ericsson.uecontrol.gui.fragments.FileBrowserDialog.OnFileSelectionListener;
|
import com.ericsson.uecontrol.gui.fragments.FileBrowserDialog.OnFileSelectionListener;
|
||||||
import com.ericsson.uecontrol.gui.fragments.StatusFragment;
|
import com.ericsson.uecontrol.gui.fragments.StatusFragment;
|
||||||
|
import de.mindpipe.android.logging.log4j.LogConfigurator;
|
||||||
import org.apache.log4j.Level;
|
import org.apache.log4j.Level;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import de.mindpipe.android.logging.log4j.LogConfigurator;
|
|
||||||
|
|
||||||
|
|
||||||
public class MainActivity extends FragmentActivity implements OnSharedPreferenceChangeListener,
|
public class MainActivity extends FragmentActivity implements OnSharedPreferenceChangeListener,
|
||||||
OnFileSelectionListener, ExecutionListener {
|
OnFileSelectionListener, ExecutionListener {
|
||||||
|
|
@ -46,9 +40,12 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
/* Fragments */
|
/* Fragments */
|
||||||
private StatusFragment statusFragment;
|
private StatusFragment statusFragment;
|
||||||
private BehaviourListFragment behaviourListFragment;
|
private BehaviourListFragment behaviourListFragment;
|
||||||
|
|
||||||
|
/* Internal variables */
|
||||||
private MenuItem action_execute;
|
private MenuItem action_execute;
|
||||||
private MenuItem action_mark;
|
private MenuItem action_mark;
|
||||||
private boolean backButtonPressed = false;
|
private boolean backButtonPressed = false;
|
||||||
|
private boolean defaultMark = false; // Add default mark if all other marks are disabled
|
||||||
|
|
||||||
/* Static Data */
|
/* Static Data */
|
||||||
private static UeControlExecutor executor;
|
private static UeControlExecutor executor;
|
||||||
|
|
@ -129,7 +126,7 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
log.debug("Preference changed: "+key);
|
log.debug("Preference changed: " + key);
|
||||||
if(key.equals("debug")) {
|
if(key.equals("debug")) {
|
||||||
if (sharedPreferences.getBoolean("debug", false)) {
|
if (sharedPreferences.getBoolean("debug", false)) {
|
||||||
Logger.getRootLogger().setLevel(Level.DEBUG);
|
Logger.getRootLogger().setLevel(Level.DEBUG);
|
||||||
|
|
@ -154,6 +151,10 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
statusFragment.updateGraphLength();
|
statusFragment.updateGraphLength();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(key.startsWith("mark_")){
|
||||||
|
log.info("Marks has changed, invalidating menu");
|
||||||
|
invalidateOptionsMenu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -164,15 +165,33 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
// decide what to show in the action bar.
|
// decide what to show in the action bar.
|
||||||
getMenuInflater().inflate(R.menu.main, menu);
|
getMenuInflater().inflate(R.menu.main, menu);
|
||||||
|
|
||||||
ActionBar actionBar = getActionBar();
|
|
||||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
action_execute = (MenuItem) menu.findItem(R.id.action_execute);
|
action_execute = (MenuItem) menu.findItem(R.id.action_execute);
|
||||||
action_mark = (MenuItem) menu.findItem(R.id.action_mark);
|
action_mark = (MenuItem) menu.findItem(R.id.action_mark);
|
||||||
updateExecutionState();
|
updateExecutionState();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public boolean onPrepareOptionsMenu (Menu menu){
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
|
MenuItem mark01 = menu.findItem(R.id.action_mark_01);
|
||||||
|
mark01.setVisible(!prefs.getString("mark_01", "").trim().isEmpty());
|
||||||
|
MenuItem mark02 = menu.findItem(R.id.action_mark_02);
|
||||||
|
mark02.setVisible(!prefs.getString("mark_02", "").trim().isEmpty());
|
||||||
|
MenuItem mark03 = menu.findItem(R.id.action_mark_03);
|
||||||
|
mark03.setVisible(!prefs.getString("mark_03", "").trim().isEmpty());
|
||||||
|
MenuItem mark04 = menu.findItem(R.id.action_mark_04);
|
||||||
|
mark04.setVisible(!prefs.getString("mark_04", "").trim().isEmpty());
|
||||||
|
MenuItem mark05 = menu.findItem(R.id.action_mark_05);
|
||||||
|
mark05.setVisible(!prefs.getString("mark_05", "").trim().isEmpty());
|
||||||
|
|
||||||
|
defaultMark = !mark01.isVisible() && !mark02.isVisible() &&
|
||||||
|
!mark03.isVisible() && !mark04.isVisible() &&
|
||||||
|
!mark05.isVisible();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -196,12 +215,12 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
updateExecutionState();
|
updateExecutionState();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (id == R.id.action_mark) {
|
else if (id == R.id.action_mark_01) addMark(01);
|
||||||
if (executor.getCsvLogger() != null) {
|
else if (id == R.id.action_mark_02) addMark(02);
|
||||||
executor.getCsvLogger().addComment("--- Mark ---");
|
else if (id == R.id.action_mark_03) addMark(03);
|
||||||
Toast.makeText(this, "Mark added to log", Toast.LENGTH_SHORT).show();
|
else if (id == R.id.action_mark_04) addMark(04);
|
||||||
}
|
else if (id == R.id.action_mark_05) addMark(05);
|
||||||
}
|
else if (id == R.id.action_mark && defaultMark) addMark(00); // Add default mark if all other marks are disabled
|
||||||
else if (id == R.id.action_reset) {
|
else if (id == R.id.action_reset) {
|
||||||
if(executor != null) {
|
if(executor != null) {
|
||||||
executor.terminate();
|
executor.terminate();
|
||||||
|
|
@ -242,6 +261,17 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
private void addMark(int mark_id){
|
||||||
|
if (executor.getCsvLogger() != null) {
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
String comment = "--- Mark 0"+mark_id+" --- "+prefs.getString("mark_0"+mark_id, "");
|
||||||
|
|
||||||
|
log.info(comment);
|
||||||
|
executor.getCsvLogger().addComment(comment);
|
||||||
|
Toast.makeText(this, "Mark 0" + mark_id + " added to log", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onFileSelection(String tag, File file){
|
public void onFileSelection(String tag, File file){
|
||||||
try {
|
try {
|
||||||
if(tag.equals("import")) {
|
if(tag.equals("import")) {
|
||||||
|
|
@ -291,9 +321,11 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
this.runOnUiThread(new Runnable() {
|
this.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
action_execute.setTitle(R.string.action_run);
|
if(action_execute != null)
|
||||||
|
action_execute.setTitle(R.string.action_run);
|
||||||
ExecNotification.dismiss();
|
ExecNotification.dismiss();
|
||||||
action_mark.setEnabled(false);
|
if(action_mark != null)
|
||||||
|
action_mark.setEnabled(false);
|
||||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,20 @@
|
||||||
android:title="@string/action_mark"
|
android:title="@string/action_mark"
|
||||||
android:orderInCategory="0"
|
android:orderInCategory="0"
|
||||||
android:showAsAction="withText|ifRoom"
|
android:showAsAction="withText|ifRoom"
|
||||||
android:enabled="false" />
|
android:enabled="false" >
|
||||||
|
<menu>
|
||||||
|
<item android:id="@+id/action_mark_01"
|
||||||
|
android:title="Mark 01"/>
|
||||||
|
<item android:id="@+id/action_mark_02"
|
||||||
|
android:title="Mark 02"/>
|
||||||
|
<item android:id="@+id/action_mark_03"
|
||||||
|
android:title="Mark 03"/>
|
||||||
|
<item android:id="@+id/action_mark_04"
|
||||||
|
android:title="Mark 04"/>
|
||||||
|
<item android:id="@+id/action_mark_05"
|
||||||
|
android:title="Mark 05"/>
|
||||||
|
</menu>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item android:id="@+id/action_reset"
|
<item android:id="@+id/action_reset"
|
||||||
android:title="@string/action_reset"
|
android:title="@string/action_reset"
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@
|
||||||
<string name="pref_throughput_average_freq_summ">Frequency per second(Will also impact csv logging frequency)</string>
|
<string name="pref_throughput_average_freq_summ">Frequency per second(Will also impact csv logging frequency)</string>
|
||||||
<string name="action_history">History</string>
|
<string name="action_history">History</string>
|
||||||
<string name="title_activity_history">Execution History</string>
|
<string name="title_activity_history">Execution History</string>
|
||||||
|
<string name="pref_custom_marks">Custom Marks</string>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/pref_exec_title"
|
android:title="@string/pref_exec_title"
|
||||||
android:key="pref_key_storage_settings">
|
android:key="pref_key_execution_settings">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="logging"
|
android:key="logging"
|
||||||
|
|
@ -35,11 +35,33 @@
|
||||||
android:title="@string/pref_screen_on"
|
android:title="@string/pref_screen_on"
|
||||||
android:summary="@string/pref_screen_on_summ"
|
android:summary="@string/pref_screen_on_summ"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="false" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="custom_marks"
|
||||||
|
android:title="@string/pref_custom_marks"
|
||||||
|
android:persistent="false">
|
||||||
|
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="mark_01"
|
||||||
|
android:title="Mark 01" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="mark_02"
|
||||||
|
android:title="Mark 02" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="mark_03"
|
||||||
|
android:title="Mark 03" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="mark_04"
|
||||||
|
android:title="Mark 04" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="mark_05"
|
||||||
|
android:title="Mark 05" />
|
||||||
|
</PreferenceScreen>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/pref_other_title"
|
android:title="@string/pref_other_title"
|
||||||
android:key="pref_key_storage_settings">
|
android:key="pref_key_other_settings">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="debug"
|
android:key="debug"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue