Added rat type in gui
This commit is contained in:
parent
7ca05039b5
commit
e020204ce5
5 changed files with 93 additions and 35 deletions
|
|
@ -31,11 +31,9 @@ import de.mindpipe.android.logging.log4j.LogConfigurator;
|
||||||
|
|
||||||
public class MainActivity extends FragmentActivity implements OnSharedPreferenceChangeListener{
|
public class MainActivity extends FragmentActivity implements OnSharedPreferenceChangeListener{
|
||||||
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/";
|
||||||
|
|
||||||
/**
|
/** Fragments **/
|
||||||
* Fragment managing the behaviors, interactions and presentation of the navigation drawer.
|
|
||||||
*/
|
|
||||||
private NavigationDrawerFragment navigationDrawerFragment;
|
|
||||||
private StatusFragment statusFragment;
|
private StatusFragment statusFragment;
|
||||||
private boolean backButtonPressed = false;
|
private boolean backButtonPressed = false;
|
||||||
|
|
||||||
|
|
@ -52,17 +50,11 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
|
|
||||||
// Setup Main GUI
|
// Setup Main GUI
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
//navigationDrawerFragment = (NavigationDrawerFragment)
|
|
||||||
// getFragmentManager().findFragmentById(R.id.navigation_drawer);
|
|
||||||
statusFragment = (StatusFragment)
|
statusFragment = (StatusFragment)
|
||||||
getFragmentManager().findFragmentById(R.id.status_fragment);
|
getFragmentManager().findFragmentById(R.id.status_fragment);
|
||||||
getFragmentManager().beginTransaction()
|
getFragmentManager().beginTransaction()
|
||||||
.replace(R.id.container, BehaviourListFragment.newInstance()).commit();
|
.replace(R.id.container, BehaviourListFragment.newInstance()).commit();
|
||||||
|
|
||||||
// Set up the drawer.
|
|
||||||
//navigationDrawerFragment.setUp(
|
|
||||||
// R.id.navigation_drawer,
|
|
||||||
// (DrawerLayout) findViewById(R.id.drawer_layout));
|
|
||||||
|
|
||||||
currentExecutor = new UeControlExecutor();
|
currentExecutor = new UeControlExecutor();
|
||||||
currentExecutor.addBehaviour(new UeBehaviourSleep());
|
currentExecutor.addBehaviour(new UeBehaviourSleep());
|
||||||
|
|
@ -73,7 +65,7 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
|
|
||||||
public void setupDebugLogging(){
|
public void setupDebugLogging(){
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
String path = prefs.getString("logging_path", "/sdcard/uecontrol/");
|
String path = prefs.getString("logging_path", DEFAULT_LOG_PATH);
|
||||||
if(!path.endsWith("/")) path += File.separator;
|
if(!path.endsWith("/")) path += File.separator;
|
||||||
|
|
||||||
LogConfigurator logConfigurator = new LogConfigurator();
|
LogConfigurator logConfigurator = new LogConfigurator();
|
||||||
|
|
@ -105,7 +97,6 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
if (navigationDrawerFragment == null || !navigationDrawerFragment.isDrawerOpen()) {
|
|
||||||
// Only show items in the action bar relevant to this screen
|
// Only show items in the action bar relevant to this screen
|
||||||
// if the drawer is not showing. Otherwise, let the drawer
|
// if the drawer is not showing. Otherwise, let the drawer
|
||||||
// decide what to show in the action bar.
|
// decide what to show in the action bar.
|
||||||
|
|
@ -117,8 +108,6 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import com.jjoe64.graphview.LineGraphView;
|
||||||
public class StatusFragment extends Fragment {
|
public class StatusFragment extends Fragment {
|
||||||
private TextView down_speed;
|
private TextView down_speed;
|
||||||
private TextView up_speed;
|
private TextView up_speed;
|
||||||
|
private TextView rat_type;
|
||||||
private GraphViewSeries downGraph;
|
private GraphViewSeries downGraph;
|
||||||
private GraphViewSeries upGraph;
|
private GraphViewSeries upGraph;
|
||||||
private int x = 0;
|
private int x = 0;
|
||||||
|
|
@ -46,6 +47,7 @@ public class StatusFragment extends Fragment {
|
||||||
|
|
||||||
down_speed = (TextView) view.findViewById(R.id.down_speed);
|
down_speed = (TextView) view.findViewById(R.id.down_speed);
|
||||||
up_speed = (TextView) view.findViewById(R.id.up_speed);
|
up_speed = (TextView) view.findViewById(R.id.up_speed);
|
||||||
|
rat_type = (TextView) view.findViewById(R.id.rat_type);
|
||||||
|
|
||||||
// Init the graph
|
// Init the graph
|
||||||
GraphViewData[] zeroPoint = new GraphViewData[]{new GraphViewData(0, 0)};
|
GraphViewData[] zeroPoint = new GraphViewData[]{new GraphViewData(0, 0)};
|
||||||
|
|
@ -77,6 +79,7 @@ public class StatusFragment extends Fragment {
|
||||||
public void run() {
|
public void run() {
|
||||||
down_speed.setText(ThroughputCalculator.getBitThroughputString(downThroughput));
|
down_speed.setText(ThroughputCalculator.getBitThroughputString(downThroughput));
|
||||||
up_speed.setText(ThroughputCalculator.getBitThroughputString(upThroughput));
|
up_speed.setText(ThroughputCalculator.getBitThroughputString(upThroughput));
|
||||||
|
rat_type.setText(CSVWriter.getRat(getActivity()));
|
||||||
downGraph.appendData(new GraphViewData(x, downThroughput), true, 120);
|
downGraph.appendData(new GraphViewData(x, downThroughput), true, 120);
|
||||||
upGraph.appendData(new GraphViewData(x, upThroughput), true, 120);
|
upGraph.appendData(new GraphViewData(x, upThroughput), true, 120);
|
||||||
x++;
|
x++;
|
||||||
|
|
@ -89,4 +92,5 @@ public class StatusFragment extends Fragment {
|
||||||
public UeControlExecutor.ThroughputListener getThroughputListener(){
|
public UeControlExecutor.ThroughputListener getThroughputListener(){
|
||||||
return throughputListener;
|
return throughputListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -31,12 +31,10 @@ public class CSVWriter {
|
||||||
|
|
||||||
|
|
||||||
private File file;
|
private File file;
|
||||||
|
private Context context;
|
||||||
private NetworkInfo netInfo;
|
|
||||||
private WifiInfo wifiInfo;
|
|
||||||
private TelephonyManager telMan;
|
|
||||||
|
|
||||||
public CSVWriter(Context context){
|
public CSVWriter(Context context){
|
||||||
|
this.context = context;
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
String path = prefs.getString("logging_path", "/sdcard/uecontrol/");
|
String path = prefs.getString("logging_path", "/sdcard/uecontrol/");
|
||||||
if(!path.endsWith(File.separator)) path += File.separator;
|
if(!path.endsWith(File.separator)) path += File.separator;
|
||||||
|
|
@ -44,13 +42,6 @@ public class CSVWriter {
|
||||||
path,
|
path,
|
||||||
"log_"+fileDateFormater.format(System.currentTimeMillis())+".csv");
|
"log_"+fileDateFormater.format(System.currentTimeMillis())+".csv");
|
||||||
|
|
||||||
ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
||||||
netInfo = cm.getActiveNetworkInfo();
|
|
||||||
|
|
||||||
WifiManager wm = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
|
|
||||||
wifiInfo = wm.getConnectionInfo();
|
|
||||||
|
|
||||||
telMan = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
||||||
|
|
||||||
// Write Headings
|
// Write Headings
|
||||||
StringBuilder line = new StringBuilder();
|
StringBuilder line = new StringBuilder();
|
||||||
|
|
@ -70,7 +61,7 @@ public class CSVWriter {
|
||||||
line.append(behaviour).append(DELIMITER);
|
line.append(behaviour).append(DELIMITER);
|
||||||
line.append(down).append(DELIMITER);
|
line.append(down).append(DELIMITER);
|
||||||
line.append(up).append(DELIMITER);
|
line.append(up).append(DELIMITER);
|
||||||
line.append(getRat()).append(DELIMITER);
|
line.append(getRat(context)).append(DELIMITER);
|
||||||
writeLine(line.toString());
|
writeLine(line.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,8 +75,15 @@ public class CSVWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getRat(){
|
public static String getRat(Context context){
|
||||||
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
NetworkInfo netInfo = cm.getActiveNetworkInfo();
|
||||||
|
|
||||||
|
//WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||||
|
//WifiInfo wifiInfo = wm.getConnectionInfo();
|
||||||
|
|
||||||
if(netInfo.getType() == ConnectivityManager.TYPE_MOBILE){
|
if(netInfo.getType() == ConnectivityManager.TYPE_MOBILE){
|
||||||
|
TelephonyManager telMan = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
switch(telMan.getNetworkType()){
|
switch(telMan.getNetworkType()){
|
||||||
case TelephonyManager.NETWORK_TYPE_GPRS: return "GPRS";
|
case TelephonyManager.NETWORK_TYPE_GPRS: return "GPRS";
|
||||||
case TelephonyManager.NETWORK_TYPE_EDGE: return "EDGE";
|
case TelephonyManager.NETWORK_TYPE_EDGE: return "EDGE";
|
||||||
|
|
|
||||||
57
app/src/main/java/com/ericsson/uecontrol/gui/util/VerticalTextView.java
Executable file
57
app/src/main/java/com/ericsson/uecontrol/gui/util/VerticalTextView.java
Executable file
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.ericsson.uecontrol.gui.util;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.text.TextPaint;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class VerticalTextView extends TextView {
|
||||||
|
|
||||||
|
private int _width, _height;
|
||||||
|
private final Rect _bounds = new Rect();
|
||||||
|
|
||||||
|
public VerticalTextView(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VerticalTextView(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VerticalTextView(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
// vise versa
|
||||||
|
_height = getMeasuredWidth();
|
||||||
|
_width = getMeasuredHeight();
|
||||||
|
setMeasuredDimension(_width, _height);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
canvas.save();
|
||||||
|
|
||||||
|
canvas.translate(_width, _height);
|
||||||
|
canvas.rotate(-90);
|
||||||
|
|
||||||
|
TextPaint paint = getPaint();
|
||||||
|
paint.setColor(getTextColors().getDefaultColor());
|
||||||
|
|
||||||
|
String text = text();
|
||||||
|
|
||||||
|
paint.getTextBounds(text, 0, text.length(), _bounds);
|
||||||
|
canvas.drawText(text, getCompoundPaddingLeft(), (_bounds.height() - _width) / 2, paint);
|
||||||
|
|
||||||
|
canvas.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String text() {
|
||||||
|
return super.getText().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -57,11 +57,21 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/graph"
|
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" >
|
||||||
|
|
||||||
|
<com.ericsson.uecontrol.gui.util.VerticalTextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="left|center_vertical"
|
||||||
|
android:textColor="#ffffffff"
|
||||||
|
android:text="n/a"
|
||||||
|
android:id="@+id/rat_type" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue