Added rat type in gui

This commit is contained in:
Ziver Koc 2014-08-04 14:21:27 +02:00
parent 7ca05039b5
commit e020204ce5
5 changed files with 93 additions and 35 deletions

View file

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

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