mirror of https://github.com/M66B/NetGuard.git
Display roaming
This commit is contained in:
parent
31e6a812b6
commit
5495cd7cd5
|
@ -196,7 +196,10 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
Log.i(TAG, "Received " + intent);
|
||||
Util.logExtras(TAG, intent);
|
||||
if (menuNetwork != null)
|
||||
menuNetwork.setIcon(Util.isWifiActive(ActivityMain.this) ? R.drawable.ic_network_wifi_white_24dp : R.drawable.ic_network_cell_white_24dp);
|
||||
menuNetwork.setIcon(
|
||||
Util.isWifiActive(context) ? R.drawable.ic_network_wifi_white_24dp :
|
||||
Util.isRoaming(context) ? R.drawable.ic_network_cell_white_24px_roaming :
|
||||
R.drawable.ic_network_cell_white_24dp);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -316,7 +319,10 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
menu.findItem(R.id.menu_network).setIcon(Util.isWifiActive(this) ? R.drawable.ic_network_wifi_white_24dp : R.drawable.ic_network_cell_white_24dp);
|
||||
menu.findItem(R.id.menu_network).setIcon(
|
||||
Util.isWifiActive(this) ? R.drawable.ic_network_wifi_white_24dp :
|
||||
Util.isRoaming(this) ? R.drawable.ic_network_cell_white_24px_roaming :
|
||||
R.drawable.ic_network_cell_white_24dp);
|
||||
|
||||
menu.findItem(R.id.menu_whitelist_wifi).setChecked(prefs.getBoolean("whitelist_wifi", true));
|
||||
menu.findItem(R.id.menu_whitelist_other).setChecked(prefs.getBoolean("whitelist_other", true));
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.PowerManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -34,6 +35,11 @@ public class Util {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isRoaming(Context context) {
|
||||
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
return tm.isNetworkRoaming();
|
||||
}
|
||||
|
||||
public static boolean isWifiActive(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo ni = cm.getActiveNetworkInfo();
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 387 B |
Binary file not shown.
After Width: | Height: | Size: 289 B |
Binary file not shown.
After Width: | Height: | Size: 474 B |
Binary file not shown.
After Width: | Height: | Size: 653 B |
Loading…
Reference in New Issue