Skip to content

Commit

Permalink
Added: 优化浮窗界面
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewleo committed Dec 17, 2013
1 parent 09028b5 commit 2133743
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 30 deletions.
39 changes: 18 additions & 21 deletions res/layout/floating.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,41 +42,38 @@
android:id="@+id/memtotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_weight="0.4"
android:gravity="right"
android:paddingRight="10.0dip"
android:textColor="#FFFFFF" />

<TextView
android:id="@+id/batt"
android:id="@+id/traffic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_weight="0.4"
android:gravity="right"
android:paddingRight="10.0dip"
android:textColor="#FFFFFF" />
<TextView
android:id="@+id/traffic"

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_weight="0.4"
android:gravity="right"
android:paddingRight="10.0dip"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/wifi"
android:layout_width="50dp"
android:layout_height="25dp" />

<Button
android:id="@+id/stop"
android:layout_width="50dp"
android:layout_height="25dp" />
android:orientation="horizontal"
android:layout_weight="0.4">

<Button
android:id="@+id/wifi"
android:textSize = "12dp"
android:layout_width="80dp"
android:layout_height="40dp" />
<Button
android:id="@+id/stop"
android:text="停止测试"
android:textSize = "12dp"
android:layout_width="80dp"
android:layout_height="40dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>

Expand Down
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
<string name="ok">保存</string>
<string name="openwifi">开启wifi</string>
<string name="closewifi">关闭wifi</string>
<string name="stopTest">停止测试</string>

</resources>
15 changes: 6 additions & 9 deletions src/com/netease/qa/emmagee/service/EmmageeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public class EmmageeService extends Service {
private TextView txtTotalMem;
private TextView txtUnusedMem;
private TextView txtTraffic;
private TextView txtBatt;
private ImageView imgViIcon;
private Button btnWifi;
private int delaytime;
Expand Down Expand Up @@ -181,7 +180,6 @@ public void onStart(Intent intent, int startId) {
viFloatingWindow = LayoutInflater.from(this).inflate(R.layout.floating, null);
txtUnusedMem = (TextView) viFloatingWindow.findViewById(R.id.memunused);
txtTotalMem = (TextView) viFloatingWindow.findViewById(R.id.memtotal);
txtBatt = (TextView) viFloatingWindow.findViewById(R.id.batt);
txtTraffic = (TextView) viFloatingWindow.findViewById(R.id.traffic);
btnWifi = (Button) viFloatingWindow.findViewById(R.id.wifi);

Expand All @@ -195,7 +193,6 @@ public void onStart(Intent intent, int startId) {
txtUnusedMem.setTextColor(android.graphics.Color.RED);
txtTotalMem.setTextColor(android.graphics.Color.RED);
txtTraffic.setTextColor(android.graphics.Color.RED);
txtBatt.setTextColor(android.graphics.Color.RED);
imgViIcon = (ImageView) viFloatingWindow.findViewById(R.id.img2);
imgViIcon.setVisibility(View.GONE);
imgViIcon.setOnClickListener(new OnClickListener() {
Expand Down Expand Up @@ -412,15 +409,15 @@ private void dataRefresh() {
}
// 如果cpu使用率存在且都不小于0,则输出
if (processCpuRatio != null && totalCpuRatio != null) {
txtUnusedMem.setText("占用内存:" + processMemory + "MB" + ",机器剩余:" + freeMemoryKb + "MB");
txtTotalMem.setText("占用CPU:" + processCpuRatio + "%" + ",总体CPU:" + totalCpuRatio + "%");
txtBatt.setText("电量:" + totalBatt + ",电流:" + currentBatt + "mA");
txtUnusedMem.setText("应用/剩余内存:" + processMemory + "/" + freeMemoryKb + "MB");
txtTotalMem.setText("应用/总体CPU:" + processCpuRatio + "%/" + totalCpuRatio + "%");
String batt = "电流:" + currentBatt + "mA,";
if ("-1".equals(trafficSize)) {
txtTraffic.setText("本程序或本设备不支持流量统计");
txtTraffic.setText(batt + "本程序或本设备不支持流量统计");
} else if (isMb)
txtTraffic.setText("流量:" + fomart.format(trafficMb) + "MB");
txtTraffic.setText(batt + "流量:" + fomart.format(trafficMb) + "MB");
else
txtTraffic.setText("流量:" + trafficSize + "KB");
txtTraffic.setText(batt + "流量:" + trafficSize + "KB");
}
// 当内存为0切cpu使用率为0时则是被测应用退出
if ("0".equals(processMemory) && "0.00".equals(processCpuRatio)) {
Expand Down

0 comments on commit 2133743

Please sign in to comment.