mirror of https://github.com/M66B/NetGuard.git
parent
859caa6536
commit
5ab87cdca8
|
@ -298,32 +298,6 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
|||
pref_technical_network.setOnPreferenceClickListener(listener);
|
||||
pref_technical_subscription.setOnPreferenceClickListener(listener);
|
||||
updateTechnicalInfo();
|
||||
|
||||
// Handle devices without wifi
|
||||
if (!Util.hasWifi(this)) {
|
||||
PreferenceCategory defaults = (PreferenceCategory) screen.findPreference("category_defaults");
|
||||
defaults.removePreference(screen.findPreference("whitelist_wifi"));
|
||||
defaults.removePreference(screen.findPreference("screen_wifi"));
|
||||
|
||||
PreferenceCategory options = (PreferenceCategory) screen.findPreference("category_options");
|
||||
options.removePreference(screen.findPreference("wifi_homes"));
|
||||
options.removePreference(screen.findPreference("use_metered"));
|
||||
}
|
||||
|
||||
// Handle devices without telephony
|
||||
if (!Util.hasTelephony(this)) {
|
||||
PreferenceCategory defaults = (PreferenceCategory) screen.findPreference("category_defaults");
|
||||
defaults.removePreference(screen.findPreference("whitelist_other"));
|
||||
defaults.removePreference(screen.findPreference("screen_other"));
|
||||
defaults.removePreference(screen.findPreference("whitelist_roaming"));
|
||||
|
||||
PreferenceCategory options = (PreferenceCategory) screen.findPreference("category_options");
|
||||
options.removePreference(screen.findPreference("use_metered"));
|
||||
options.removePreference(screen.findPreference("unmetered_2g"));
|
||||
options.removePreference(screen.findPreference("unmetered_3g"));
|
||||
options.removePreference(screen.findPreference("unmetered_4g"));
|
||||
options.removePreference(screen.findPreference("national_roaming"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -68,8 +68,6 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
private Activity context;
|
||||
private DatabaseHelper dh;
|
||||
private RecyclerView rv;
|
||||
private boolean wifi;
|
||||
private boolean telephony;
|
||||
private boolean filter;
|
||||
private boolean debuggable;
|
||||
private int colorText;
|
||||
|
@ -92,11 +90,9 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
|
||||
public TextView tvHosts;
|
||||
|
||||
public LinearLayout llWifi;
|
||||
public CheckBox cbWifi;
|
||||
public ImageView ivScreenWifi;
|
||||
|
||||
public LinearLayout llOther;
|
||||
public CheckBox cbOther;
|
||||
public ImageView ivScreenOther;
|
||||
public TextView tvRoaming;
|
||||
|
@ -108,11 +104,9 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
public TextView tvDisabled;
|
||||
public TextView tvInternet;
|
||||
|
||||
public LinearLayout llWifiAttr;
|
||||
public ImageView ivWifiLegend;
|
||||
public CheckBox cbScreenWifi;
|
||||
|
||||
public LinearLayout llOtherAttr;
|
||||
public ImageView ivOtherLegend;
|
||||
public CheckBox cbScreenOther;
|
||||
public CheckBox cbRoaming;
|
||||
|
@ -138,11 +132,9 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
|
||||
tvHosts = (TextView) itemView.findViewById(R.id.tvHosts);
|
||||
|
||||
llWifi = (LinearLayout) itemView.findViewById(R.id.llWifi);
|
||||
cbWifi = (CheckBox) itemView.findViewById(R.id.cbWifi);
|
||||
ivScreenWifi = (ImageView) itemView.findViewById(R.id.ivScreenWifi);
|
||||
|
||||
llOther = (LinearLayout) itemView.findViewById(R.id.llOther);
|
||||
cbOther = (CheckBox) itemView.findViewById(R.id.cbOther);
|
||||
ivScreenOther = (ImageView) itemView.findViewById(R.id.ivScreenOther);
|
||||
tvRoaming = (TextView) itemView.findViewById(R.id.tvRoaming);
|
||||
|
@ -154,11 +146,9 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
tvDisabled = (TextView) itemView.findViewById(R.id.tvDisabled);
|
||||
tvInternet = (TextView) itemView.findViewById(R.id.tvInternet);
|
||||
|
||||
llWifiAttr = (LinearLayout) itemView.findViewById(R.id.llWifiAttr);
|
||||
ivWifiLegend = (ImageView) itemView.findViewById(R.id.ivWifiLegend);
|
||||
cbScreenWifi = (CheckBox) itemView.findViewById(R.id.cbScreenWifi);
|
||||
|
||||
llOtherAttr = (LinearLayout) itemView.findViewById(R.id.llOtherAttr);
|
||||
ivOtherLegend = (ImageView) itemView.findViewById(R.id.ivOtherLegend);
|
||||
cbScreenOther = (CheckBox) itemView.findViewById(R.id.cbScreenOther);
|
||||
cbRoaming = (CheckBox) itemView.findViewById(R.id.cbRoaming);
|
||||
|
@ -206,8 +196,6 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
|
||||
this.context = context;
|
||||
this.dh = dh;
|
||||
this.wifi = Util.hasWifi(context);
|
||||
this.telephony = Util.hasTelephony(context);
|
||||
this.filter = prefs.getBoolean("filter", false);
|
||||
this.debuggable = Util.isDebuggable(context);
|
||||
|
||||
|
@ -344,8 +332,6 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
holder.tvHosts.setText(Long.toString(rules));
|
||||
|
||||
// Wi-Fi settings
|
||||
holder.llWifi.setVisibility(wifi ? View.VISIBLE : View.GONE);
|
||||
|
||||
holder.cbWifi.setAlpha(wifiActive ? 1 : 0.5f);
|
||||
holder.cbWifi.setOnCheckedChangeListener(null);
|
||||
holder.cbWifi.setChecked(rule.wifi_blocked);
|
||||
|
@ -363,8 +349,6 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
}
|
||||
|
||||
// Mobile settings
|
||||
holder.llOther.setVisibility(telephony ? View.VISIBLE : View.GONE);
|
||||
|
||||
holder.cbOther.setAlpha(otherActive ? 1 : 0.5f);
|
||||
holder.cbOther.setOnCheckedChangeListener(null);
|
||||
holder.cbOther.setChecked(rule.other_blocked);
|
||||
|
@ -386,8 +370,6 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
|
||||
// Expanded configuration section
|
||||
holder.llConfiguration.setVisibility(rule.expanded ? View.VISIBLE : View.GONE);
|
||||
holder.llWifiAttr.setVisibility(wifi ? View.VISIBLE : View.GONE);
|
||||
holder.llOtherAttr.setVisibility(telephony ? View.VISIBLE : View.GONE);
|
||||
|
||||
// Show application details
|
||||
holder.tvUid.setText(rule.info.applicationInfo == null ? "?" : Integer.toString(rule.info.applicationInfo.uid));
|
||||
|
|
|
@ -967,7 +967,6 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
|
|||
boolean unmetered_4g = prefs.getBoolean("unmetered_4g", false);
|
||||
boolean roaming = Util.isRoaming(SinkholeService.this);
|
||||
boolean national = prefs.getBoolean("national_roaming", false);
|
||||
boolean telephony = Util.hasTelephony(this);
|
||||
boolean tethering = prefs.getBoolean("tethering", false);
|
||||
boolean filter = prefs.getBoolean("filter", false);
|
||||
|
||||
|
@ -975,7 +974,7 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
|
|||
last_connected = Util.isConnected(SinkholeService.this);
|
||||
|
||||
// Update metered state
|
||||
if (wifi && (!useMetered || !telephony))
|
||||
if (wifi && !useMetered)
|
||||
metered = false;
|
||||
if (wifi && ssidHomes.size() > 0 && !ssidHomes.contains(ssidNetwork)) {
|
||||
metered = true;
|
||||
|
@ -999,7 +998,6 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
|
|||
" home=" + TextUtils.join(",", ssidHomes) +
|
||||
" network=" + ssidNetwork +
|
||||
" metered=" + metered +
|
||||
" telephony=" + telephony +
|
||||
" generation=" + generation +
|
||||
" roaming=" + roaming +
|
||||
" interactive=" + last_interactive +
|
||||
|
|
|
@ -99,20 +99,6 @@ public class Util {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean hasTelephony(Context context) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
if (pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY))
|
||||
return true;
|
||||
// Workaround
|
||||
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
return (tm != null && tm.getNetworkType() != TelephonyManager.NETWORK_TYPE_UNKNOWN);
|
||||
}
|
||||
|
||||
public static boolean hasWifi(Context context) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
return pm.hasSystemFeature(PackageManager.FEATURE_WIFI);
|
||||
}
|
||||
|
||||
public static boolean isConnected(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo ni = (cm == null ? null : cm.getActiveNetworkInfo());
|
||||
|
@ -516,7 +502,6 @@ public class Util {
|
|||
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
|
||||
sb.append(String.format("Interactive %B\r\n", isInteractive(context)));
|
||||
sb.append(String.format("Telephony %B\r\n", hasTelephony(context)));
|
||||
sb.append(String.format("Connected %B\r\n", isConnected(context)));
|
||||
sb.append(String.format("WiFi %B\r\n", isWifiActive(context)));
|
||||
sb.append(String.format("Metered %B\r\n", isMeteredNetwork(context)));
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
android:textSize="12sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llWifi"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
@ -93,7 +92,6 @@
|
|||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llOther"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
@ -200,7 +198,6 @@
|
|||
android:textAppearance="@style/TextTitle" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llWifiAttr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
|
@ -222,7 +219,6 @@
|
|||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llOtherAttr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
|
Loading…
Reference in New Issue