Initial implementation of a history view, no parsing of csv file yet

This commit is contained in:
Ziver Koc 2015-02-27 17:10:29 +01:00
parent 5172a268ad
commit b3d75b9ad9
15 changed files with 281 additions and 118 deletions

View file

@ -7,6 +7,7 @@
android:icon="@drawable/icon" android:icon="@drawable/icon"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/AppTheme" > android:theme="@style/AppTheme" >
<activity <activity
android:name=".gui.MainActivity" android:name=".gui.MainActivity"
android:label="@string/app_name" > android:label="@string/app_name" >
@ -15,6 +16,17 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </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 <activity
android:name=".gui.SettingsActivity" android:name=".gui.SettingsActivity"
android:label="@string/app_name" > android:label="@string/app_name" >
@ -22,14 +34,12 @@
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".gui.MainActivity" /> android:value=".gui.MainActivity" />
</activity> </activity>
<activity
android:name=".gui.EditActivity"
android:label="@string/title_activity_edit" >
</activity>
<activity <activity
android:name=".gui.AboutActivity" android:name=".gui.AboutActivity"
android:label="@string/title_activity_about" > android:label="@string/title_activity_about" >
</activity> </activity>
</application> </application>
<uses-sdk android:minSdkVersion="15" <uses-sdk android:minSdkVersion="15"

View 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;
}
}
}

View file

@ -188,8 +188,7 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
else { else {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if(prefs.getBoolean("logging", false)) if(prefs.getBoolean("logging", false))
executor.setLogPath(prefs.getString("logging_path", executor.setLogPath(prefs.getString("logging_path", DEFAULT_LOG_PATH));
Environment.getExternalStorageDirectory().getAbsolutePath()+"/uecontrol/"));
else else
executor.setLogPath(null); executor.setLogPath(null);
executor.execute(); executor.execute();
@ -233,6 +232,10 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
"/sdcard", FileBrowserDialog.BrowserMode.NEW_FILE); "/sdcard", FileBrowserDialog.BrowserMode.NEW_FILE);
browser.show(this.getFragmentManager(), "export"); 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) { else if (id == R.id.action_settings) {
startActivity(new Intent(this, SettingsActivity.class)); startActivity(new Intent(this, SettingsActivity.class));
return true; return true;

View file

@ -48,7 +48,7 @@ public class BehaviourListFragment extends Fragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { 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 // Set the adapter
listView = (AdapterView) view.findViewById(android.R.id.list); listView = (AdapterView) view.findViewById(android.R.id.list);

View file

@ -69,12 +69,11 @@ public class StatusFragment extends Fragment {
new GraphViewData[]{new GraphViewData(0, 0)}); new GraphViewData[]{new GraphViewData(0, 0)});
graphView = new LineGraphView(this.getActivity(), "GraphView"); graphView = new LineGraphView(this.getActivity(), "GraphView");
graphView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
graphView.addSeries(downGraph); graphView.addSeries(downGraph);
graphView.addSeries(upGraph); graphView.addSeries(upGraph);
graphView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
graphView.getGraphViewStyle().setGridStyle(GraphViewStyle.GridStyle.BOTH); graphView.getGraphViewStyle().setGridStyle(GraphViewStyle.GridStyle.BOTH);
graphView.setShowVerticalLabels(false); graphView.setShowVerticalLabels(false);
//graphView.setDrawDataPoints(true);
updateGraphLength(); updateGraphLength();
graphView.setViewPort(0, length); graphView.setViewPort(0, length);
graphView.setScrollable(true); graphView.setScrollable(true);

View file

@ -19,7 +19,7 @@ import java.util.List;
* Created by ezivkoc on 2014-07-15. * Created by ezivkoc on 2014-07-15.
*/ */
public class BehaviourListAdapter extends StableArrayAdapter<UeBehaviour>{ 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; private static LayoutInflater inflater = null;

View 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>

View file

@ -25,7 +25,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:name="com.ericsson.uecontrol.gui.fragments.BehaviourListFragment" android:name="com.ericsson.uecontrol.gui.fragments.BehaviourListFragment"
tools:layout="@layout/fragment_item" /> tools:layout="@layout/fragment_list" />
</LinearLayout> </LinearLayout>

View file

@ -8,7 +8,8 @@
<ListView <ListView
android:id="@android:id/list" android:id="@android:id/list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent"
tools:listitem="@layout/list_behaviour_item" />
<TextView <TextView
android:id="@android:id/empty" android:id="@android:id/empty"

View file

@ -59,7 +59,6 @@
<LinearLayout <LinearLayout
android:id="@+id/graph"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" > android:orientation="horizontal" >
@ -72,6 +71,11 @@
android:text="n/a" android:text="n/a"
android:id="@+id/rat_type" /> android:id="@+id/rat_type" />
<LinearLayout
android:id="@+id/graph"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" />
</LinearLayout> </LinearLayout>

View file

@ -1,93 +1,93 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="5dp" android:paddingLeft="5dp"
android:paddingTop="5dp" android:paddingTop="5dp"
android:paddingRight="5dp"> android:paddingRight="5dp">
<ImageView <ImageView
android:id="@+id/draggable" android:id="@+id/draggable"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:src="@drawable/draggable" android:src="@drawable/draggable"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:visibility="gone" /> android:visibility="gone" />
<!-- Behaviour name--> <!-- Behaviour name-->
<TextView <TextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Title" android:text="Title"
android:textColor="#040404" android:textColor="#040404"
android:typeface="sans" android:typeface="sans"
android:textSize="17dip" android:textSize="17dip"
android:textStyle="bold" android:textStyle="bold"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/draggable" /> android:layout_toRightOf="@+id/draggable" />
<!-- Behaviour description --> <!-- Behaviour description -->
<TextView <TextView
android:id="@+id/description" android:id="@+id/description"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="#343434" android:textColor="#343434"
android:textSize="12dip" android:textSize="12dip"
android:text="Description" android:text="Description"
android:layout_below="@+id/title" android:layout_below="@+id/title"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true" android:singleLine="true"
android:layout_toRightOf="@+id/draggable" android:layout_toRightOf="@+id/draggable"
android:layout_toLeftOf="@+id/warning"/> android:layout_toLeftOf="@+id/warning"/>
<!-- Rightend --> <!-- Rightend -->
<ProgressBar <ProgressBar
android:id="@+id/active" android:id="@+id/active"
style="?android:attr/progressBarStyleSmall" style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:visibility="invisible" /> android:visibility="invisible" />
<ImageView <ImageView
android:id="@+id/warning" android:id="@+id/warning"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:src="@drawable/warning" android:src="@drawable/warning"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:visibility="invisible" android:visibility="invisible"
android:layout_toLeftOf="@+id/active" /> android:layout_toLeftOf="@+id/active" />
<ProgressBar <ProgressBar
android:id="@+id/progress" android:id="@+id/progress"
style="?android:attr/progressBarStyleHorizontal" style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/description" android:layout_below="@+id/description"
android:visibility="invisible" /> android:visibility="invisible" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:text="2m 30s" android:text="2m 30s"
android:id="@+id/time" android:id="@+id/time"
android:singleLine="true" android:singleLine="true"
android:textColor="#46000000" android:textColor="#46000000"
android:textSize="12dp" android:textSize="12dp"
android:layout_alignBottom="@+id/title" android:layout_alignBottom="@+id/title"
android:layout_alignRight="@+id/progress" android:layout_alignRight="@+id/progress"
android:visibility="invisible" /> android:visibility="invisible" />
</RelativeLayout> </RelativeLayout>

View 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>

View file

@ -30,8 +30,14 @@
android:showAsAction="never" android:showAsAction="never"
android:enabled="true" /> 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" <item android:id="@+id/action_settings"
android:title="@string/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" android:orderInCategory="300"
android:showAsAction="never" /> android:showAsAction="never" />
</menu> </menu>

View file

@ -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>

View file

@ -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_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">Throughput Averaging Frequency</string>
<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="title_activity_history">Execution History</string>
</resources> </resources>