Initial implementation of a history view, no parsing of csv file yet
This commit is contained in:
parent
5172a268ad
commit
b3d75b9ad9
15 changed files with 281 additions and 118 deletions
|
|
@ -7,6 +7,7 @@
|
|||
android:icon="@drawable/icon"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
|
||||
<activity
|
||||
android:name=".gui.MainActivity"
|
||||
android:label="@string/app_name" >
|
||||
|
|
@ -15,6 +16,17 @@
|
|||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".gui.EditActivity"
|
||||
android:label="@string/title_activity_edit" >
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".gui.HistoryActivity"
|
||||
android:label="@string/title_activity_history" >
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".gui.SettingsActivity"
|
||||
android:label="@string/app_name" >
|
||||
|
|
@ -22,14 +34,12 @@
|
|||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".gui.MainActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".gui.EditActivity"
|
||||
android:label="@string/title_activity_edit" >
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".gui.AboutActivity"
|
||||
android:label="@string/title_activity_about" >
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
<uses-sdk android:minSdkVersion="15"
|
||||
|
|
|
|||
100
app/src/main/java/com/ericsson/uecontrol/gui/HistoryActivity.java
Executable file
100
app/src/main/java/com/ericsson/uecontrol/gui/HistoryActivity.java
Executable file
|
|
@ -0,0 +1,100 @@
|
|||
package com.ericsson.uecontrol.gui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ListActivity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
import com.ericsson.uecontrol.R;
|
||||
import com.jjoe64.graphview.GraphView;
|
||||
import com.jjoe64.graphview.GraphViewSeries;
|
||||
import com.jjoe64.graphview.GraphViewStyle;
|
||||
import com.jjoe64.graphview.LineGraphView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class HistoryActivity extends ListActivity {
|
||||
private static final Logger log = Logger.getLogger(HistoryActivity.class);
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_history);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
TextView warning = (TextView)this.findViewById(R.id.warning);
|
||||
if(!prefs.getBoolean("logging", false))
|
||||
warning.setVisibility(View.VISIBLE);
|
||||
else
|
||||
warning.setVisibility(View.GONE);
|
||||
|
||||
String strPath = prefs.getString("logging_path", MainActivity.DEFAULT_LOG_PATH);
|
||||
File logPath = new File(strPath);
|
||||
List<File> fileList = new ArrayList<File>();
|
||||
for(File file : logPath.listFiles()){
|
||||
if(file.getName().endsWith(".csv"))
|
||||
fileList.add(file);
|
||||
}
|
||||
Collections.sort(fileList, Collections.reverseOrder());
|
||||
|
||||
HistoryListAdapter adapter = new HistoryListAdapter(this, fileList);
|
||||
// Set the adapter
|
||||
ListView listView = (ListView) this.findViewById(android.R.id.list);
|
||||
listView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Created by ezivkoc on 2014-07-15.
|
||||
*/
|
||||
public class HistoryListAdapter extends ArrayAdapter<File> {
|
||||
private static final int VIEW_RESOURCE = R.layout.list_history_item;
|
||||
|
||||
|
||||
public HistoryListAdapter(Activity a, List<File> fileList) {
|
||||
super(a, VIEW_RESOURCE, fileList);
|
||||
}
|
||||
|
||||
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = convertView;
|
||||
if(convertView==null) {
|
||||
LayoutInflater inflater = (LayoutInflater) HistoryActivity.this
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = inflater.inflate(VIEW_RESOURCE, parent, false);
|
||||
}
|
||||
File csvFile = super.getItem(position);
|
||||
|
||||
TextView fileNameView = (TextView)view.findViewById(R.id.file_name);
|
||||
fileNameView.setText(csvFile.getName());
|
||||
|
||||
LineGraphView graphView = new LineGraphView(this.getContext(), "HistoryView");
|
||||
graphView.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT));
|
||||
graphView.getGraphViewStyle().setGridStyle(GraphViewStyle.GridStyle.BOTH);
|
||||
graphView.addSeries(new GraphViewSeries("Download Throughput", new GraphViewSeries.GraphViewSeriesStyle(Color.GREEN, 3),
|
||||
new GraphView.GraphViewData[]{new GraphView.GraphViewData(0, 0)}));
|
||||
graphView.addSeries(new GraphViewSeries("Upload Throughput", new GraphViewSeries.GraphViewSeriesStyle(Color.RED, 3),
|
||||
new GraphView.GraphViewData[]{new GraphView.GraphViewData(0, 0)}));
|
||||
graphView.setShowVerticalLabels(false);
|
||||
graphView.setShowHorizontalLabels(false);
|
||||
graphView.setDisableTouch(true);
|
||||
LinearLayout graphLayout = (LinearLayout)view.findViewById(R.id.graph);
|
||||
graphLayout.addView(graphView);
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -188,8 +188,7 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
|||
else {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if(prefs.getBoolean("logging", false))
|
||||
executor.setLogPath(prefs.getString("logging_path",
|
||||
Environment.getExternalStorageDirectory().getAbsolutePath()+"/uecontrol/"));
|
||||
executor.setLogPath(prefs.getString("logging_path", DEFAULT_LOG_PATH));
|
||||
else
|
||||
executor.setLogPath(null);
|
||||
executor.execute();
|
||||
|
|
@ -233,6 +232,10 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
|||
"/sdcard", FileBrowserDialog.BrowserMode.NEW_FILE);
|
||||
browser.show(this.getFragmentManager(), "export");
|
||||
}
|
||||
else if (id == R.id.action_history) {
|
||||
startActivity(new Intent(this, HistoryActivity.class));
|
||||
return true;
|
||||
}
|
||||
else if (id == R.id.action_settings) {
|
||||
startActivity(new Intent(this, SettingsActivity.class));
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class BehaviourListFragment extends Fragment {
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_item, container, false);
|
||||
View view = inflater.inflate(R.layout.fragment_list, container, false);
|
||||
|
||||
// Set the adapter
|
||||
listView = (AdapterView) view.findViewById(android.R.id.list);
|
||||
|
|
|
|||
|
|
@ -69,12 +69,11 @@ public class StatusFragment extends Fragment {
|
|||
new GraphViewData[]{new GraphViewData(0, 0)});
|
||||
|
||||
graphView = new LineGraphView(this.getActivity(), "GraphView");
|
||||
graphView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
||||
graphView.addSeries(downGraph);
|
||||
graphView.addSeries(upGraph);
|
||||
graphView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
||||
graphView.getGraphViewStyle().setGridStyle(GraphViewStyle.GridStyle.BOTH);
|
||||
graphView.setShowVerticalLabels(false);
|
||||
//graphView.setDrawDataPoints(true);
|
||||
updateGraphLength();
|
||||
graphView.setViewPort(0, length);
|
||||
graphView.setScrollable(true);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import java.util.List;
|
|||
* Created by ezivkoc on 2014-07-15.
|
||||
*/
|
||||
public class BehaviourListAdapter extends StableArrayAdapter<UeBehaviour>{
|
||||
private static final int VIEW_RESOURCE = R.layout.behaviour_list_item;
|
||||
private static final int VIEW_RESOURCE = R.layout.list_behaviour_item;
|
||||
|
||||
private static LayoutInflater inflater = null;
|
||||
|
||||
|
|
|
|||
25
app/src/main/res/layout/activity_history.xml
Executable file
25
app/src/main/res/layout/activity_history.xml
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context="com.ericsson.uecontrol.gui.HistoryActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/warning"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="CSV Logging is not enabled"
|
||||
android:background="#ff0000"
|
||||
android:gravity="center"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp" />
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:listitem="@layout/list_history_item" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:name="com.ericsson.uecontrol.gui.fragments.BehaviourListFragment"
|
||||
tools:layout="@layout/fragment_item" />
|
||||
tools:layout="@layout/fragment_list" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent"
|
||||
tools:listitem="@layout/list_behaviour_item" />
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/empty"
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@
|
|||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/graph"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal" >
|
||||
|
|
@ -72,6 +71,11 @@
|
|||
android:text="n/a"
|
||||
android:id="@+id/rat_type" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/graph"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,93 +1,93 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingRight="5dp">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/draggable"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:src="@drawable/draggable"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- Behaviour name-->
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Title"
|
||||
android:textColor="#040404"
|
||||
android:typeface="sans"
|
||||
android:textSize="17dip"
|
||||
android:textStyle="bold"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toRightOf="@+id/draggable" />
|
||||
|
||||
<!-- Behaviour description -->
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#343434"
|
||||
android:textSize="12dip"
|
||||
android:text="Description"
|
||||
android:layout_below="@+id/title"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:layout_toRightOf="@+id/draggable"
|
||||
android:layout_toLeftOf="@+id/warning"/>
|
||||
|
||||
|
||||
<!-- Rightend -->
|
||||
<ProgressBar
|
||||
android:id="@+id/active"
|
||||
style="?android:attr/progressBarStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="10dp"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/warning"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:src="@drawable/warning"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="invisible"
|
||||
android:layout_toLeftOf="@+id/active" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/description"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="2m 30s"
|
||||
android:id="@+id/time"
|
||||
android:singleLine="true"
|
||||
android:textColor="#46000000"
|
||||
android:textSize="12dp"
|
||||
android:layout_alignBottom="@+id/title"
|
||||
android:layout_alignRight="@+id/progress"
|
||||
android:visibility="invisible" />
|
||||
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingRight="5dp">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/draggable"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:src="@drawable/draggable"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- Behaviour name-->
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Title"
|
||||
android:textColor="#040404"
|
||||
android:typeface="sans"
|
||||
android:textSize="17dip"
|
||||
android:textStyle="bold"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toRightOf="@+id/draggable" />
|
||||
|
||||
<!-- Behaviour description -->
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#343434"
|
||||
android:textSize="12dip"
|
||||
android:text="Description"
|
||||
android:layout_below="@+id/title"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:layout_toRightOf="@+id/draggable"
|
||||
android:layout_toLeftOf="@+id/warning"/>
|
||||
|
||||
|
||||
<!-- Rightend -->
|
||||
<ProgressBar
|
||||
android:id="@+id/active"
|
||||
style="?android:attr/progressBarStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="10dp"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/warning"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:src="@drawable/warning"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="invisible"
|
||||
android:layout_toLeftOf="@+id/active" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/description"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="2m 30s"
|
||||
android:id="@+id/time"
|
||||
android:singleLine="true"
|
||||
android:textColor="#46000000"
|
||||
android:textSize="12dp"
|
||||
android:layout_alignBottom="@+id/title"
|
||||
android:layout_alignRight="@+id/progress"
|
||||
android:visibility="invisible" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
25
app/src/main/res/layout/list_history_item.xml
Executable file
25
app/src/main/res/layout/list_history_item.xml
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="100dp"
|
||||
android:background="#ff000000">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/graph"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:id="@+id/file_name"
|
||||
android:padding="5dp"
|
||||
android:textColor="#ffffffff"
|
||||
android:text="filename.csv"/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
@ -30,8 +30,14 @@
|
|||
android:showAsAction="never"
|
||||
android:enabled="true" />
|
||||
|
||||
<item android:id="@+id/action_history"
|
||||
android:title="@string/action_history"
|
||||
android:orderInCategory="200"
|
||||
android:showAsAction="never"
|
||||
android:enabled="true" />
|
||||
|
||||
<item android:id="@+id/action_settings"
|
||||
android:title="@string/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:orderInCategory="300"
|
||||
android:showAsAction="never" />
|
||||
</menu>
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
<resources>
|
||||
|
||||
<!--
|
||||
Layout alias to replace the single-pane version of the layout with a
|
||||
two-pane version on Large screens.
|
||||
|
||||
For more on layout aliases, see:
|
||||
http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters
|
||||
-->
|
||||
<item name="fragment_item" type="layout">@layout/fragment_list</item>
|
||||
|
||||
</resources>
|
||||
|
|
@ -40,6 +40,8 @@
|
|||
<string name="pref_join_beta_summ">Join the Google+ group to get access to the beta releases of the app.</string>
|
||||
<string name="pref_throughput_average_freq">Throughput Averaging 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="title_activity_history">Execution History</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue