Commit 566e1feaa1ac0298f12a9a8becc48c52ba77ddef
1 parent
f5d0062e
修改bar图标
Showing
10 changed files
with
92 additions
and
3 deletions
C5/app/src/main/AndroidManifest.xml
@@ -81,6 +81,17 @@ | @@ -81,6 +81,17 @@ | ||
81 | </receiver> | 81 | </receiver> |
82 | 82 | ||
83 | <receiver | 83 | <receiver |
84 | + android:name=".server.NetWorkStateReceiver" | ||
85 | + android:enabled="true" | ||
86 | + android:permission="android.permission.RECEIVE_BOOT_COMPLETED" > | ||
87 | + <intent-filter> | ||
88 | + <action android:name="android.intent.action.BOOT_COMPLETED" /> | ||
89 | + <category android:name="android.intent.category.DEFAULT" /> | ||
90 | + </intent-filter> | ||
91 | + </receiver> | ||
92 | + | ||
93 | + | ||
94 | + <receiver | ||
84 | android:name=".BootBroadcastReceiver" | 95 | android:name=".BootBroadcastReceiver" |
85 | android:enabled="true" | 96 | android:enabled="true" |
86 | android:permission="android.permission.RECEIVE_BOOT_COMPLETED"> | 97 | android:permission="android.permission.RECEIVE_BOOT_COMPLETED"> |
C5/app/src/main/java/com/sunvote/xpadapp/MainActivity.java
@@ -6,12 +6,14 @@ import android.app.Fragment; | @@ -6,12 +6,14 @@ import android.app.Fragment; | ||
6 | import android.app.FragmentManager; | 6 | import android.app.FragmentManager; |
7 | import android.app.FragmentTransaction; | 7 | import android.app.FragmentTransaction; |
8 | import android.app.ProgressDialog; | 8 | import android.app.ProgressDialog; |
9 | +import android.app.usage.NetworkStats; | ||
9 | import android.content.BroadcastReceiver; | 10 | import android.content.BroadcastReceiver; |
10 | import android.content.DialogInterface; | 11 | import android.content.DialogInterface; |
11 | import android.content.Intent; | 12 | import android.content.Intent; |
12 | import android.content.IntentFilter; | 13 | import android.content.IntentFilter; |
13 | import android.content.pm.PackageManager; | 14 | import android.content.pm.PackageManager; |
14 | import android.graphics.Color; | 15 | import android.graphics.Color; |
16 | +import android.net.ConnectivityManager; | ||
15 | import android.net.Uri; | 17 | import android.net.Uri; |
16 | import android.os.Build; | 18 | import android.os.Build; |
17 | import android.os.Bundle; | 19 | import android.os.Bundle; |
@@ -75,6 +77,7 @@ import com.sunvote.xpadapp.presenter.ServicePresent; | @@ -75,6 +77,7 @@ import com.sunvote.xpadapp.presenter.ServicePresent; | ||
75 | import com.sunvote.xpadapp.presenter.XPadPresenter; | 77 | import com.sunvote.xpadapp.presenter.XPadPresenter; |
76 | import com.sunvote.xpadapp.server.BatteryReceiver; | 78 | import com.sunvote.xpadapp.server.BatteryReceiver; |
77 | import com.sunvote.xpadapp.server.MoniService; | 79 | import com.sunvote.xpadapp.server.MoniService; |
80 | +import com.sunvote.xpadapp.server.NetWorkStateReceiver; | ||
78 | import com.sunvote.xpadapp.utils.FileUtil; | 81 | import com.sunvote.xpadapp.utils.FileUtil; |
79 | import com.sunvote.xpadapp.utils.SharedPreferencesUtil; | 82 | import com.sunvote.xpadapp.utils.SharedPreferencesUtil; |
80 | import com.sunvote.xpadapp.widget.StatusBarView; | 83 | import com.sunvote.xpadapp.widget.StatusBarView; |
@@ -217,6 +220,7 @@ public class MainActivity extends BaseActivity implements ComListener { | @@ -217,6 +220,7 @@ public class MainActivity extends BaseActivity implements ComListener { | ||
217 | private ImageView service; | 220 | private ImageView service; |
218 | 221 | ||
219 | BatteryReceiver m_receiver; | 222 | BatteryReceiver m_receiver; |
223 | + NetWorkStateReceiver netWork_receiver; | ||
220 | StatusBarView statusBarView; | 224 | StatusBarView statusBarView; |
221 | @Override | 225 | @Override |
222 | protected void onCreate(Bundle savedInstanceState) { | 226 | protected void onCreate(Bundle savedInstanceState) { |
@@ -254,6 +258,10 @@ public class MainActivity extends BaseActivity implements ComListener { | @@ -254,6 +258,10 @@ public class MainActivity extends BaseActivity implements ComListener { | ||
254 | IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); | 258 | IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); |
255 | m_receiver = new BatteryReceiver(); | 259 | m_receiver = new BatteryReceiver(); |
256 | registerReceiver(m_receiver, intentFilter); | 260 | registerReceiver(m_receiver, intentFilter); |
261 | + | ||
262 | + IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); | ||
263 | + netWork_receiver = new NetWorkStateReceiver(); | ||
264 | + registerReceiver(netWork_receiver, filter); | ||
257 | setTiltleStatus(); | 265 | setTiltleStatus(); |
258 | 266 | ||
259 | clearApkFile(); | 267 | clearApkFile(); |
@@ -293,6 +301,19 @@ public class MainActivity extends BaseActivity implements ComListener { | @@ -293,6 +301,19 @@ public class MainActivity extends BaseActivity implements ComListener { | ||
293 | } | 301 | } |
294 | }); | 302 | }); |
295 | 303 | ||
304 | + netWork_receiver.setOnReceiveResultData(new NetWorkStateReceiver.IReceiveData() { | ||
305 | + @Override | ||
306 | + public void onReceiveData() { | ||
307 | + runOnUiThread(new Runnable() { | ||
308 | + @Override | ||
309 | + public void run() { | ||
310 | + statusBarView.setStatusSignal(netWork_receiver.getRssiLevel()); | ||
311 | + } | ||
312 | + }); | ||
313 | + } | ||
314 | + }); | ||
315 | + | ||
316 | + | ||
296 | //显示时间的控件 | 317 | //显示时间的控件 |
297 | TimeThread timeThread = new TimeThread(statusBarView.getTimeCtl()); | 318 | TimeThread timeThread = new TimeThread(statusBarView.getTimeCtl()); |
298 | timeThread.start();//启动线程 | 319 | timeThread.start();//启动线程 |
@@ -370,7 +391,12 @@ public class MainActivity extends BaseActivity implements ComListener { | @@ -370,7 +391,12 @@ public class MainActivity extends BaseActivity implements ComListener { | ||
370 | if (batteryLevelRcvr != null) { | 391 | if (batteryLevelRcvr != null) { |
371 | unregisterReceiver(batteryLevelRcvr); | 392 | unregisterReceiver(batteryLevelRcvr); |
372 | } | 393 | } |
373 | - | 394 | + if (m_receiver != null) { |
395 | + unregisterReceiver(m_receiver); | ||
396 | + } | ||
397 | + if (netWork_receiver != null) { | ||
398 | + unregisterReceiver(netWork_receiver); | ||
399 | + } | ||
374 | System.exit(0); | 400 | System.exit(0); |
375 | } | 401 | } |
376 | 402 |
C5/app/src/main/java/com/sunvote/xpadapp/server/NetWorkStateReceiver.java
0 → 100644
1 | +package com.sunvote.xpadapp.server; | ||
2 | + | ||
3 | +import android.content.BroadcastReceiver; | ||
4 | +import android.content.Context; | ||
5 | +import android.content.Intent; | ||
6 | +import android.net.wifi.WifiInfo; | ||
7 | +import android.net.wifi.WifiManager; | ||
8 | + | ||
9 | +public class NetWorkStateReceiver extends BroadcastReceiver { | ||
10 | + | ||
11 | + int wifiLevel = -101; | ||
12 | + | ||
13 | + @Override | ||
14 | + public void onReceive(Context context, Intent intent) { | ||
15 | + WifiManager mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); | ||
16 | + WifiInfo mWifiInfo = mWifiManager.getConnectionInfo(); | ||
17 | + int wifi = mWifiInfo.getRssi();//获取wifi信号强度 | ||
18 | + if (wifi > -50 && wifi < 0) {//最强 | ||
19 | + | ||
20 | + } else if (wifi > -70 && wifi < -50) {//较强 | ||
21 | + | ||
22 | + } else if (wifi > -80 && wifi < -70) {//较弱 | ||
23 | + | ||
24 | + } else if (wifi > -100 && wifi < -80) {//微弱 | ||
25 | + | ||
26 | + } else { | ||
27 | + | ||
28 | + } | ||
29 | + wifiLevel = wifi; | ||
30 | + iReceiveData.onReceiveData(); | ||
31 | + } | ||
32 | + | ||
33 | + public int getRssiLevel() { | ||
34 | + return wifiLevel; | ||
35 | + } | ||
36 | + | ||
37 | + private IReceiveData iReceiveData; | ||
38 | + public void setOnReceiveResultData(IReceiveData receiveData){ | ||
39 | + iReceiveData = receiveData; | ||
40 | + } | ||
41 | + | ||
42 | + public interface IReceiveData{ | ||
43 | + void onReceiveData(); | ||
44 | + } | ||
45 | +} |
C5/app/src/main/java/com/sunvote/xpadapp/widget/StatusBarView.java
@@ -57,7 +57,7 @@ public class StatusBarView extends LinearLayout { | @@ -57,7 +57,7 @@ public class StatusBarView extends LinearLayout { | ||
57 | * @param rssi | 57 | * @param rssi |
58 | */ | 58 | */ |
59 | public void setStatusSignal(int rssi){ | 59 | public void setStatusSignal(int rssi){ |
60 | - barSignal.setIcon(R.mipmap.signal); | 60 | + /* barSignal.setIcon(R.mipmap.signal); |
61 | if (rssi < 95){ | 61 | if (rssi < 95){ |
62 | barSignal.setIcon(R.mipmap.signal_1); | 62 | barSignal.setIcon(R.mipmap.signal_1); |
63 | } | 63 | } |
@@ -72,7 +72,14 @@ public class StatusBarView extends LinearLayout { | @@ -72,7 +72,14 @@ public class StatusBarView extends LinearLayout { | ||
72 | } | 72 | } |
73 | if (rssi < 55) { | 73 | if (rssi < 55) { |
74 | barSignal.setIcon(R.mipmap.signal_5); | 74 | barSignal.setIcon(R.mipmap.signal_5); |
75 | - } | 75 | + }*/ |
76 | + | ||
77 | + if(rssi > -100) { | ||
78 | + barSignal.setVisibility(VISIBLE); | ||
79 | + barSignal.setIcon(R.mipmap.wifi); | ||
80 | + }else { | ||
81 | + barSignal.setVisibility(INVISIBLE); | ||
82 | + } | ||
76 | } | 83 | } |
77 | 84 | ||
78 | /** | 85 | /** |
C5/app/src/main/res/mipmap-hdpi/battery.png
C5/app/src/main/res/mipmap-hdpi/battery_1.png
C5/app/src/main/res/mipmap-hdpi/battery_2.png
C5/app/src/main/res/mipmap-hdpi/battery_3.png
C5/app/src/main/res/mipmap-hdpi/battery_4.png
C5/app/src/main/res/mipmap-hdpi/wifi.png
0 → 100644
1.53 KB