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{
|
||||
private static final Logger log = Logger.getLogger(MainActivity.class);
|
||||
public static final String DEFAULT_LOG_PATH = "/sdcard/uecontrol/";
|
||||
|
||||
/**
|
||||
* Fragment managing the behaviors, interactions and presentation of the navigation drawer.
|
||||
*/
|
||||
private NavigationDrawerFragment navigationDrawerFragment;
|
||||
/** Fragments **/
|
||||
private StatusFragment statusFragment;
|
||||
private boolean backButtonPressed = false;
|
||||
|
||||
|
|
@ -52,17 +50,11 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
|||
|
||||
// Setup Main GUI
|
||||
setContentView(R.layout.activity_main);
|
||||
//navigationDrawerFragment = (NavigationDrawerFragment)
|
||||
// getFragmentManager().findFragmentById(R.id.navigation_drawer);
|
||||
statusFragment = (StatusFragment)
|
||||
getFragmentManager().findFragmentById(R.id.status_fragment);
|
||||
getFragmentManager().beginTransaction()
|
||||
.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.addBehaviour(new UeBehaviourSleep());
|
||||
|
|
@ -73,7 +65,7 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
|||
|
||||
public void setupDebugLogging(){
|
||||
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;
|
||||
|
||||
LogConfigurator logConfigurator = new LogConfigurator();
|
||||
|
|
@ -105,19 +97,16 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
|||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
if (navigationDrawerFragment == null || !navigationDrawerFragment.isDrawerOpen()) {
|
||||
// Only show items in the action bar relevant to this screen
|
||||
// if the drawer is not showing. Otherwise, let the drawer
|
||||
// decide what to show in the action bar.
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
// Only show items in the action bar relevant to this screen
|
||||
// if the drawer is not showing. Otherwise, let the drawer
|
||||
// decide what to show in the action bar.
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
|
||||
ActionBar actionBar = getActionBar();
|
||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
ActionBar actionBar = getActionBar();
|
||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import com.jjoe64.graphview.LineGraphView;
|
|||
public class StatusFragment extends Fragment {
|
||||
private TextView down_speed;
|
||||
private TextView up_speed;
|
||||
private TextView rat_type;
|
||||
private GraphViewSeries downGraph;
|
||||
private GraphViewSeries upGraph;
|
||||
private int x = 0;
|
||||
|
|
@ -46,6 +47,7 @@ public class StatusFragment extends Fragment {
|
|||
|
||||
down_speed = (TextView) view.findViewById(R.id.down_speed);
|
||||
up_speed = (TextView) view.findViewById(R.id.up_speed);
|
||||
rat_type = (TextView) view.findViewById(R.id.rat_type);
|
||||
|
||||
// Init the graph
|
||||
GraphViewData[] zeroPoint = new GraphViewData[]{new GraphViewData(0, 0)};
|
||||
|
|
@ -77,6 +79,7 @@ public class StatusFragment extends Fragment {
|
|||
public void run() {
|
||||
down_speed.setText(ThroughputCalculator.getBitThroughputString(downThroughput));
|
||||
up_speed.setText(ThroughputCalculator.getBitThroughputString(upThroughput));
|
||||
rat_type.setText(CSVWriter.getRat(getActivity()));
|
||||
downGraph.appendData(new GraphViewData(x, downThroughput), true, 120);
|
||||
upGraph.appendData(new GraphViewData(x, upThroughput), true, 120);
|
||||
x++;
|
||||
|
|
@ -89,4 +92,5 @@ public class StatusFragment extends Fragment {
|
|||
public UeControlExecutor.ThroughputListener getThroughputListener(){
|
||||
return throughputListener;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -31,12 +31,10 @@ public class CSVWriter {
|
|||
|
||||
|
||||
private File file;
|
||||
|
||||
private NetworkInfo netInfo;
|
||||
private WifiInfo wifiInfo;
|
||||
private TelephonyManager telMan;
|
||||
private Context context;
|
||||
|
||||
public CSVWriter(Context context){
|
||||
this.context = context;
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String path = prefs.getString("logging_path", "/sdcard/uecontrol/");
|
||||
if(!path.endsWith(File.separator)) path += File.separator;
|
||||
|
|
@ -44,13 +42,6 @@ public class CSVWriter {
|
|||
path,
|
||||
"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
|
||||
StringBuilder line = new StringBuilder();
|
||||
|
|
@ -70,7 +61,7 @@ public class CSVWriter {
|
|||
line.append(behaviour).append(DELIMITER);
|
||||
line.append(down).append(DELIMITER);
|
||||
line.append(up).append(DELIMITER);
|
||||
line.append(getRat()).append(DELIMITER);
|
||||
line.append(getRat(context)).append(DELIMITER);
|
||||
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){
|
||||
TelephonyManager telMan = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
switch(telMan.getNetworkType()){
|
||||
case TelephonyManager.NETWORK_TYPE_GPRS: return "GPRS";
|
||||
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
|
||||
android:id="@+id/graph"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
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>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue